static function array_sort_by_subkey(&$arr_data, $subkey, $asc = true) { $arr_res = Func::array_transparent($arr_data, $subkey); if ($asc) { ksort($arr_res); } else { krsort($arr_res); } $arr_data = array(); foreach ($arr_res as $key => $value) { $arr_data = array_merge($arr_data, $value); } }
function getGroupPermissions($nGroupID, $sItemType = 'module') { $nGroupID = intval($nGroupID); $sQuery = "SELECT M.*, (P.item_id IS NOT NULL) as permissed\n FROM " . TABLE_MODULE_METHODS . " M\n LEFT JOIN " . TABLE_USERS_GROUPS_PERMISSIONS . " P\n ON P.unit_type='group'\n AND P.unit_id = {$nGroupID}\n AND P.item_type = " . $this->db->str2sql($sItemType) . ' AND P.item_id = M.id WHERE M.module=M.method ORDER BY M.number, M.id '; $aData = $this->db->select($sQuery); $sQuery = "SELECT M.*, (P.item_id IS NOT NULL) as permissed\n FROM " . TABLE_MODULE_METHODS . " M\n LEFT JOIN " . TABLE_USERS_GROUPS_PERMISSIONS . " P\n ON P.unit_type='group'\n AND P.unit_id = {$nGroupID}\n AND P.item_type = " . $this->db->str2sql($sItemType) . ' AND P.item_id = M.id WHERE M.module!=M.method ORDER BY M.number, M.id '; $aSubData = $this->db->select($sQuery); $aSubData = Func::array_transparent($aSubData, 'module'); for ($i = 0; $i < count($aData); $i++) { $aData[$i]['subitems'] = array(); if (isset($aSubData[$aData[$i]['module']])) { $aData[$i]['subitems'] = $aSubData[$aData[$i]['module']]; } } return $aData; }
function admin_listing() { if (!$this->haveAccessTo('admins-listing')) { return $this->showAccessDenied(); } $bShowDeleted = true; //prepare order $this->prepareOrder($orderBy, $orderDirection, 'login,asc'); //get users $this->generatePagenationPrevNext('SELECT U.user_id, U.login, U.email, U.password, U.blocked, U.deleted, U.activated , U.social, U.vk_id FROM ' . TABLE_USERS . ' U WHERE U.admin = 1 ' . (!FORDEV ? ' AND U.user_id!=1 ' : '') . ' ORDER BY U.' . $orderBy . ' ' . $orderDirection, $aData, 'users', 15); //get 'all admins groups' $aUsersGroups = $this->db->select(' SELECT G.*, U.user_id FROM ' . TABLE_USERS . ' U, ' . TABLE_USER_IN_GROUPS . ' UIG, ' . TABLE_USERS_GROUPS . ' G WHERE G.adminpanel=1 AND UIG.group_id = G.group_id AND U.user_id = UIG.user_id ORDER BY G.group_id '); $aUsersGroups = Func::array_transparent($aUsersGroups, 'user_id'); foreach ($aData['users'] as &$v) { $v = func::array_2_htmlspecialchars($v); $v['tuid'] = $this->makeTUID($v['user_id']); $v['groups'] = ''; if (isset($aUsersGroups[$v['user_id']])) { $v['groups'] = $aUsersGroups[$v['user_id']]; } } $this->tplAssign('aData', $aData); return $this->tplFetch('admin.admin.listing.tpl'); }
private function getBannersByPosition($mPosition = null) { $sWhere = ''; if (!empty($mPosition)) { if (is_array($mPosition)) { $sWhere = ' AND ' . $this->db->prepareIN('position', $mPosition, false, true, false); } else { $sWhere = ' AND position = ' . $this->db->str2sql($mPosition); } } $aData = $this->db->select('SELECT * FROM ' . TABLE_BANNERS . ' WHERE enabled = 1 ' . $sWhere . ' AND show_start <= DATE_FORMAT(NOW(),"%Y-%m-%d 00:00") ORDER BY position'); for ($i = 0; $i < count($aData); $i++) { $aData[$i]['positioninfo'] = $this->positions[$aData[$i]['position']]; $aData[$i]['img'] = BANNERS_PATH . $aData[$i]['id'] . '_thumb_' . $aData[$i]['banner']; $aData[$i]['img_work'] = SITEURL . '/bn/show/' . $aData[$i]['id'] . '/'; $aData[$i]['flash'] = unserialize($aData[$i]['flash']); if ($aData[$i]['clickurl']) { $aData[$i]['clickurl'] = SITEURL . '/bn/click/' . $aData[$i]['id']; } else { $aData[$i]['clickurl'] = ''; } } $aData = Func::array_transparent($aData, 'position'); return $aData; }
function mm_listing() { if (!FORDEV || !$this->security->isSuperAdmin()) { return $this->showAccessDenied(); } if (bff::$isAjax) { switch (func::GET('act')) { case 'rotate': $res = $this->db->rotateTablednd(TABLE_MODULE_METHODS, '', 'id', 'number'); $this->ajaxResponse($res ? Errors::SUCCESS : Errors::IMPOSSIBLE); break; case 'delete': if (!($nRecordID = $this->input->id('rec', 'p'))) { break; } $aResult = $this->db->one_array('SELECT * FROM ' . TABLE_MODULE_METHODS . ' WHERE id = ' . $nRecordID); if (empty($aResult)) { $this->ajaxResponse(Errors::IMPOSSIBLE); } if ($aResult['module'] == $aResult['method']) { //если модуль, получаем методы $aMethodsID = $this->db->select_one_column('SELECT id FROM ' . TABLE_MODULE_METHODS . ' WHERE module=' . $this->db->str2sql($aResult['module']) . ' AND module!=method ORDER BY number, id'); //удалить методы $this->db->execute('DELETE FROM ' . TABLE_MODULE_METHODS . ' WHERE id IN (' . implode(',', $aMethodsID) . ')'); $this->db->execute('DELETE FROM ' . TABLE_USERS_GROUPS_PERMISSIONS . ' WHERE item_type = ' . $this->db->str2sql('module') . ' and item_id IN (' . implode(',', $aMethodsID) . ')'); } //удалить модули и методы $this->db->execute('DELETE FROM ' . TABLE_MODULE_METHODS . ' WHERE id = ' . $nRecordID); $this->db->execute('DELETE FROM ' . TABLE_USERS_GROUPS_PERMISSIONS . ' WHERE unit_type=' . $this->db->str2sql('group') . ' AND item_type=' . $this->db->str2sql('module') . ' AND item_id=' . $nRecordID); $this->ajaxResponse(Errors::SUCCESS); break; } $this->ajaxResponse(Errors::IMPOSSIBLE); } $aData = $this->db->select(' SELECT M.*, 1 as numlevel FROM ' . TABLE_MODULE_METHODS . ' M WHERE M.module=M.method ORDER BY M.number, M.id'); $aSubData = $this->db->select('SELECT M.*, 2 as numlevel FROM ' . TABLE_MODULE_METHODS . ' M WHERE M.module!=M.method ORDER BY M.number, M.id'); $aSubData = Func::array_transparent($aSubData, 'module'); for ($i = 0; $i < count($aData); $i++) { $aData[$i]['subitems'] = array(); if (isset($aSubData[$aData[$i]['module']])) { $aData[$i]['subitems'] = $aSubData[$aData[$i]['module']]; } } $this->includeJS('tablednd'); $this->tplAssign('aData', $aData); return $this->tplFetch('admin.mm.tpl'); }