function showTab($option) { global $_CB_database, $_CB_framework; $limit = (int) $_CB_framework->getCfg('list_limit'); if ($limit == 0) { $limit = 10; } $limit = $_CB_framework->getUserStateFromRequest("viewlistlimit", 'limit', $limit); $lastCBlist = $_CB_framework->getUserState("view{$option}lastCBlist", null); if ($lastCBlist == 'showtab') { $limitstart = $_CB_framework->getUserStateFromRequest("view{$option}limitstart", 'limitstart', 0); $lastSearch = $_CB_framework->getUserState("search{$option}", null); $search = $_CB_framework->getUserStateFromRequest("search{$option}", 'search', ''); if ($lastSearch != $search) { $limitstart = 0; $_CB_framework->setUserState("view{$option}limitstart", $limitstart); } $search = trim(strtolower($search)); } else { clearSearchBox(); $search = ""; $limitstart = 0; $_CB_framework->setUserState("view{$option}limitstart", $limitstart); $_CB_framework->setUserState("view{$option}lastCBlist", "showtab"); } $where = array(); if (isset($search) && $search != "") { $search = cbEscapeSQLsearch(trim(strtolower(cbGetEscaped($search)))); $where[] = "(a.title LIKE '%{$search}%')"; } if (!$_CB_framework->acl->amIaSuperAdmin()) { $viewAccessLevelsInts = CBuser::getMyInstance()->getAuthorisedViewLevelsIds(false); $where[] = 'a.viewaccesslevel IN (' . implode(',', $viewAccessLevelsInts) . ')'; $where[] = "a.useraccessgroupid IN (" . implode(',', $_CB_framework->acl->get_groups_below_me(null, true)) . ")"; } $_CB_database->setQuery("SELECT COUNT(*)" . "\nFROM #__comprofiler_tabs AS a" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "")); $total = $_CB_database->loadResult(); echo $_CB_database->getErrorMsg(); if ($total <= $limitstart) { $limitstart = 0; } cbimport('cb.pagination'); $pageNav = new cbPageNav($total, $limitstart, $limit); if (checkJversion() >= 2) { $title = 'title'; } else { $title = 'name'; } $query = "SELECT a.*, p.name AS pluginname, p.published AS pluginpublished, al.{$title} AS viewaccesslevelname" . "\n FROM #__comprofiler_tabs AS a" . "\n LEFT JOIN #__comprofiler_plugin AS p ON p.id = a.pluginid"; if (checkJversion() >= 2) { $query .= "\n LEFT JOIN #__viewlevels AS al ON al.id = a.viewaccesslevel"; } else { $query .= "\n LEFT JOIN #__groups AS al ON al.id + 1 = a.viewaccesslevel"; // fix J1.5-'s wrong access levels, same as g.id = IF( m.access = 0, 1, IF( m.access = 1, 2, IF( m.access = 2, 3, m.access ) ) ) } $query .= (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\n ORDER BY position, ordering"; $_CB_database->setQuery($query, (int) $pageNav->limitstart, (int) $pageNav->limit); $rows = $_CB_database->loadObjectList(); if ($_CB_database->getErrorNum()) { echo $_CB_database->stderr(); return false; } $canEdit = CBuser::getMyInstance()->authoriseAction('core.edit'); $canEditState = CBuser::getMyInstance()->authoriseAction('core.edit.state'); $showUserAccessGroupId = isStillUsingGroupsForViewAccess('#__comprofiler_tabs'); HTML_comprofiler::showTabs($rows, $pageNav, $search, $option, $canEdit, $canEditState, $showUserAccessGroupId); return true; }
function showTab( $option ) { global $_CB_database, $_CB_framework; $limit = (int) $_CB_framework->getCfg( 'list_limit' ); if ( $limit == 0 ) { $limit = 10; } $limit = $_CB_framework->getUserStateFromRequest( "viewlistlimit", 'limit', $limit ); $lastCBlist = $_CB_framework->getUserState( "view{$option}lastCBlist", null ); if($lastCBlist=='showtab') { $limitstart = $_CB_framework->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ); $lastSearch = $_CB_framework->getUserState( "search{$option}", null ); $search = $_CB_framework->getUserStateFromRequest( "search{$option}", 'search', '' ); if ($lastSearch != $search) { $limitstart = 0; $_CB_framework->setUserState( "view{$option}limitstart", $limitstart ); } $search = trim( strtolower( $search ) ); } else { clearSearchBox(); $search=""; $limitstart = 0; $_CB_framework->setUserState( "view{$option}limitstart", $limitstart ); $_CB_framework->setUserState( "view{$option}lastCBlist", "showtab" ); } $where = array(); if (isset( $search ) && $search!= "") { $search = cbEscapeSQLsearch( trim( strtolower( cbGetEscaped($search)))); $where[] = "(a.title LIKE '%$search%')"; } $where[] = "a.useraccessgroupid IN (".implode(',',getChildGIDS(userGID( $_CB_framework->myId() ))).")"; $_CB_database->setQuery( "SELECT COUNT(*)" . "\nFROM #__comprofiler_tabs AS a" . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") ); $total = $_CB_database->loadResult(); echo $_CB_database->getErrorMsg(); if ($total <= $limitstart) $limitstart = 0; cbimport( 'cb.pagination' ); $pageNav = new cbPageNav( $total, $limitstart, $limit ); $_CB_database->setQuery( "SELECT a.*, p.name AS pluginname, p.published AS pluginpublished " . "\nFROM #__comprofiler_tabs AS a" . "\n LEFT JOIN #__comprofiler_plugin AS p ON p.id = a.pluginid" . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") . "\n ORDER BY position, ordering", (int) $pageNav->limitstart, (int) $pageNav->limit ); $rows = $_CB_database->loadObjectList(); if ($_CB_database->getErrorNum()) { echo $_CB_database->stderr(); return false; } HTML_comprofiler::showTabs( $rows, $pageNav, $search, $option ); return true; }