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 editTab($tid = '0', $option = 'com_comprofiler', $task = 'editTab') { global $_CB_database, $_CB_framework, $_PLUGINS; $this->_importNeeded(); $canEditState = CBuser::getMyInstance()->authoriseAction('core.edit.state'); $row = new moscomprofilerTabs($_CB_database); if ($tid) { // load the row from the db table $row->load((int) $tid); // Check if user is a super user: if (!$_CB_framework->acl->amIaSuperAdmin()) { // Check if user belongs to useraccessgroupid: if (!in_array($row->useraccessgroupid, $_CB_framework->acl->get_groups_below_me(null, true))) { echo "<script type=\"text/javascript\"> alert('" . addslashes(CBTxt::T('Unauthorized Access')) . "'); window.history.go(-1);</script>\n"; exit; } // Check if user belongs to viewaccesslevel: if (!in_array($row->viewaccesslevel, CBuser::getMyInstance()->getAuthorisedViewLevelsIds(false))) { echo "<script type=\"text/javascript\"> alert('" . addslashes(CBTxt::T('Unauthorized Access')) . "'); window.history.go(-1);</script>\n"; exit; } } } $lists = array(); if ($row->sys == '2') { $lists['enabled'] = "Yes"; } else { $lists['enabled'] = moscomprofilerHTML::yesnoSelectList('enabled', 'class="inputbox" size="1"' . ($canEditState ? '' : ' disabled="disabled"'), $row->enabled !== null ? $row->enabled : 1); } /* ------------------------- ! head ! !-----------------------! ! ! ! ! ! left ! middle ! right ! ! ! ! ! !-----------------------! ! ! ! tabmain ! ! ! !-----------------------! ! underall ! ------------------------- ! ! ! ! ! L1C1 ! L1C2 ! L1C3 ! L1C1...C9 ! ! ! ! !-----------------------! ! ! ! ! ! L2C1 ! L2C4 ! L2C8 ! ... ! ! ! ! !-----------------------! ! ! ! L4C7 ! ! ! !-----------------------! ! ! ! ! L8C3 ! L8C4 ! ...L9C9 ! ! ! !-----------------------! ! + not_on_profile_1..9 */ $position = array(); $position[] = moscomprofilerHTML::makeOption('cb_head', _UE_POS_CB_HEAD); $position[] = moscomprofilerHTML::makeOption('cb_left', _UE_POS_CB_LEFT); $position[] = moscomprofilerHTML::makeOption('cb_middle', _UE_POS_CB_MIDDLE); $position[] = moscomprofilerHTML::makeOption('cb_right', _UE_POS_CB_RIGHT); $position[] = moscomprofilerHTML::makeOption('cb_tabmain', _UE_POS_CB_MAIN); $position[] = moscomprofilerHTML::makeOption('cb_underall', _UE_POS_CB_BOTTOM); for ($i = 1; $i <= 9; $i++) { for ($j = 1; $j <= 9; $j++) { $position[] = moscomprofilerHTML::makeOption('L' . $i . 'C' . $j, CBTxt::T('Line') . ' ' . $i . ' ' . CBTxt::T('Column') . ' ' . $j); } } for ($i = 1; $i <= 9; $i++) { $position[] = moscomprofilerHTML::makeOption('not_on_profile_' . $i, CBTxt::T('Not displayed on profile') . ' ' . $i); } if (!$row->position) { $row->position = 'cb_tabmain'; } $lists['position'] = moscomprofilerHTML::selectList($position, 'position', 'class="inputbox" size="1"', 'value', 'text', $row->position, 2); $displaytype = array(); $displaytype[] = moscomprofilerHTML::makeOption('tab', _UE_DISPLAY_TAB); $displaytype[] = moscomprofilerHTML::makeOption('div', _UE_DISPLAY_DIV); $displaytype[] = moscomprofilerHTML::makeOption('rounddiv', _UE_DISPLAY_ROUNDED_DIV); $displaytype[] = moscomprofilerHTML::makeOption('html', _UE_DISPLAY_HTML); $displaytype[] = moscomprofilerHTML::makeOption('overlib', _UE_DISPLAY_OVERLIB); $displaytype[] = moscomprofilerHTML::makeOption('overlibfix', _UE_DISPLAY_OVERLIBFIX); $displaytype[] = moscomprofilerHTML::makeOption('overlibsticky', _UE_DISPLAY_OVERLIBSTICKY); if (!$row->displaytype) { $row->displaytype = 'tab'; } $lists['displaytype'] = moscomprofilerHTML::selectList($displaytype, 'displaytype', 'class="inputbox" size="1"', 'value', 'text', $row->displaytype, 2); if ($tid) { if ($row->ordering > -10000 && $row->ordering < 10000) { // build the html select list for ordering $query = "SELECT ordering AS value, title AS text" . "\n FROM #__comprofiler_tabs" . "\n WHERE position='" . $_CB_database->getEscaped($row->position) . "'" . "\n AND enabled > 0" . "\n AND ordering > -10000" . "\n AND ordering < 10000" . "\n ORDER BY ordering"; $order = $this->_cbGetOrderingList($query); $lists['ordering'] = moscomprofilerHTML::selectList($order, 'ordering', 'class="inputbox" size="1"' . ($canEditState ? '' : ' disabled="disabled"'), 'value', 'text', intval($row->ordering), 2); } else { $lists['ordering'] = '<input type="hidden" name="ordering" value="' . $row->ordering . '" />' . CBTxt::T('This plugin cannot be reordered'); } } else { $row->ordering = 999; $row->ordering_register = 10; $row->published = 1; $row->description = ''; $row->useraccessgroupid = -2; $row->viewaccesslevel = 1; $lists['ordering'] = '<input type="hidden" name="ordering" value="' . $row->ordering . '" />' . CBTxt::T('New items default to the last place. Ordering can be changed after this item is saved.'); } $lists['ordering_register'] = '<input type="text" name="ordering_register" class="inputbox"' . ($canEditState ? '' : ' disabled="disabled"') . ' size="40" value="' . $row->ordering_register . '" />'; // build the html select list for the view level access (filtered by View Access Levels visible by the admin if not super user: $accessTree = $_CB_framework->acl->get_access_children_tree(true, false, !$_CB_framework->acl->amIaSuperAdmin()); $lists['viewaccesslevel'] = moscomprofilerHTML::selectList($accessTree, 'viewaccesslevel', 'class="inputbox"' . ($canEditState ? '' : ' disabled="disabled"'), 'value', 'text', intval($row->viewaccesslevel), 2); // We want to use View Access Levels in Joomla 1.6, and hide old method if unused: if (isStillUsingGroupsForViewAccess($row->_tbl)) { $gtree3 = array(); $gtree3[] = moscomprofilerHTML::makeOption(-2, '- ' . CBtxt::T('Everybody') . ' -'); $gtree3[] = moscomprofilerHTML::makeOption(-1, '- ' . CBtxt::T('All Registered Users') . ' -'); if (!$_CB_framework->acl->amIaSuperAdmin() && in_array((int) $row->useraccessgroupid, $_CB_framework->acl->get_groups_below_me(null, true))) { // This should always be the case: // ensure user can't add group higher than themselves: $gtree3 = array_merge($gtree3, $_CB_framework->acl->get_groups_below_me()); // vs $_CB_framework->acl->get_groups_below_me( null, true ) in tab lists } else { // Just in case we missed one, and as super-admin we should see everything: $gtree3 = array_merge($gtree3, $_CB_framework->acl->get_group_children_tree(null, 'USERS', false)); } $lists['useraccessgroup'] = moscomprofilerHTML::selectList($gtree3, 'useraccessgroupid', 'size="4"' . ($canEditState ? '' : ' disabled="disabled"'), 'value', 'text', $row->useraccessgroupid, 2, false); } else { $lists['useraccessgroup'] = null; } // params: $paramsEditorHtml = array(); $options = array('option' => $option, 'task' => $task, 'cid' => $row->tabid); // additional non-specific other parameters: $_PLUGINS->loadPluginGroup('user'); $fieldsParamsPlugins = $_PLUGINS->getUserTabParamsPluginIds(); foreach ($fieldsParamsPlugins as $pluginId => $fieldParamHandlerClassName) { $fieldParamHandler = new $fieldParamHandlerClassName($pluginId, $row); // cbFieldParamsHandler(); $addParamsHtml = $fieldParamHandler->drawParamsEditor($options); if ($addParamsHtml) { $addParamsTitle = $fieldParamHandler->getFieldsParamsLabel(); $paramsEditorHtml[] = array('title' => $addParamsTitle, 'content' => $addParamsHtml); } } $pluginView = _CBloadView('tab'); $pluginView->edittab($row, $option, $lists, $tid, $paramsEditorHtml); }