Пример #1
0
 /**
  * Generates the HTML to display the user profile tab
  *
  * @param  TabTable        $tab   The tab database entry
  * @param  UserTable       $user  The user being displayed
  * @param  int             $ui    1 for front-end, 2 for back-end
  * @return string|boolean         Either string HTML for tab content, or false if ErrorMSG generated
  */
 public function getDisplayTab($tab, $user, $ui)
 {
     global $_CB_framework;
     $model = cbforumsClass::getModel();
     if (!$model->file) {
         return CBTxt::T('No supported forum model found!');
     }
     outputCbJs(1);
     outputCbTemplate(1);
     $plugin = cbforumsClass::getPlugin();
     $viewer =& CBuser::getUserDataInstance($_CB_framework->myId());
     $message = null;
     cbforumsClass::getTemplate('tab');
     if ($user->get('id') == $_CB_framework->myId()) {
         $profileUrl = cbSef('index.php?option=com_comprofiler&tab=' . (int) $tab->tabid, false);
         if ($this->params->get('tab_favs_display', 1)) {
             $unfavorite = cbGetParam($_REQUEST, 'forums_unfav', null);
             if ($unfavorite) {
                 if (cbforumsModel::unFavorite($unfavorite, $user, $plugin)) {
                     cbRedirect($profileUrl, CBTxt::T('Favorite deleted successfully!'));
                 } else {
                     cbRedirect($profileUrl, CBTxt::T('Favorite failed to delete.'), 'error');
                 }
             }
         }
         if ($this->params->get('tab_subs_display', 1)) {
             $unsubscribePost = cbGetParam($_REQUEST, 'forums_unsub', null);
             if ($unsubscribePost) {
                 if (cbforumsModel::unSubscribe($unsubscribePost, $user, $plugin)) {
                     cbRedirect($profileUrl, CBTxt::T('Subscription deleted successfully!'));
                 } else {
                     cbRedirect($profileUrl, CBTxt::T('Subscription failed to delete.'), 'error');
                 }
             }
             $unsubscribeCat = cbGetParam($_REQUEST, 'forums_unsubcat', null);
             if ($unsubscribeCat) {
                 if (cbforumsModel::unSubscribeCategory($unsubscribeCat, $user, $plugin)) {
                     cbRedirect($profileUrl, CBTxt::T('Category subscription deleted successfully!'));
                 } else {
                     cbRedirect($profileUrl, CBTxt::T('Category subscription failed to delete.'), 'error');
                 }
             }
         }
     }
     $tab->params = $this->params;
     $class = $plugin->params->get('general_class', null);
     $return = '<div id="cbForums" class="cbForums' . ($class ? ' ' . htmlspecialchars($class) : null) . '">' . '<div id="cbForumsInner" class="cbForumsInner">' . HTML_cbforumsTab::showTab($viewer, $user, $tab, $plugin) . '</div>' . '</div>';
     return $return;
 }
Пример #2
0
 /**
  * View Forum Category Subscriptions
  *
  * @param  UserTable    $viewer  Viewing User
  * @param  UserTable    $user    Viewed at User
  * @param  TabTable     $tab     Current Tab
  * @param  PluginTable  $plugin  Current Plugin
  * @return string|boolean        HTML or FALSE
  */
 public static function getCategorySubscriptions($viewer, $user, $tab, $plugin)
 {
     global $_CB_framework, $_CB_database;
     if (!class_exists('KunenaForumCategoryHelper')) {
         return CBTxt::T('Kunena not installed, enabled, or failed to load.');
     }
     cbimport('cb.pagination');
     cbforumsClass::getTemplate('tab_subs_cats');
     $limit = (int) $tab->params->get('tab_subs_limit', 15);
     $limitstart = $_CB_framework->getUserStateFromRequest('tab_subs_cats_limitstart{com_comprofiler}', 'tab_subs_cats_limitstart');
     $filterSearch = $_CB_framework->getUserStateFromRequest('tab_subs_cats_search{com_comprofiler}', 'tab_subs_cats_search');
     $where = array();
     if (isset($filterSearch) && $filterSearch != '') {
         $where[] = '( c.' . $_CB_database->NameQuote('name') . ' LIKE ' . $_CB_database->Quote('%' . $_CB_database->getEscaped($filterSearch, true) . '%', false) . ' )';
     }
     $searching = count($where) ? true : false;
     $params = array('where' => count($where) ? ' AND ' . implode(' AND ', $where) : null);
     $categories = KunenaForumCategoryHelper::getLatestSubscriptions((int) $user->id, 0, 0, $params);
     $total = array_shift($categories);
     if ($total <= $limitstart) {
         $limitstart = 0;
     }
     $pageNav = new cbPageNav($total, $limitstart, $limit);
     $pageNav->setInputNamePrefix('tab_subs_cats_');
     if ($tab->params->get('tab_subs_paging', 1)) {
         $categories = KunenaForumCategoryHelper::getLatestSubscriptions((int) $user->id, (int) $pageNav->limitstart, (int) $pageNav->limit, $params);
         $categories = array_pop($categories);
     } else {
         $categories = array_pop($categories);
     }
     $rows = array();
     /** @var KunenaForumCategory[] $categories */
     if ($categories) {
         foreach ($categories as $category) {
             $row = new stdClass();
             $row->id = $category->id;
             $row->category_id = $category->id;
             $row->category_name = $category->name;
             $row->category_url = $category->getUrl();
             $rows[] = $row;
         }
     }
     $input = array();
     $input['search'] = '<input type="text" name="tab_subs_cats_search" value="' . htmlspecialchars($filterSearch) . '" onchange="document.forumCatSubsForm.submit();" placeholder="' . htmlspecialchars(CBTxt::T('Search Category Subscriptions...')) . '" class="form-control" />';
     if (!$rows && !$searching) {
         return false;
     } else {
         return HTML_cbforumsTabCatSubs::showCategorySubscriptions($rows, $pageNav, $searching, $input, $viewer, $user, $tab, $plugin);
     }
 }