function get_list($page = 1) { // Nb and Minimum $nb = $this->input->post('nb') ? $this->input->post('nb') : '50'; if ($nb < 25) { $nb = 25; } $page = $page - 1; $offset = $page * $nb; // Send the filter elements to the view $this->template['filter'] = array(); // Like conditions $like = array(); foreach (array('username', 'screen_name', 'email') as $key) { if ($this->input->post($key)) { $like[$key] = $this->input->post($key); $this->template['filter'][$key] = $like[$key]; } } // Where $where = array(); if ($this->input->post('id_role')) { $this->template['filter']['id_role'] = $this->input->post('id_role'); $where['user.id_role'] = $this->input->post('id_role'); } // Order by last registered if ($this->input->post('registered')) { $where['order_by'] = 'join_date DESC'; } $where = array_merge($where, array('limit' => $nb, 'offset' => $offset, 'like' => $like, 'role_level <= ' => $this->current_role['role_level'])); // Get user list filtered on levels <= current_user level $this->template['users'] = $this->user_model->get_list_with_role($where); // Pagination $this->template['current_page'] = $page + 1; $this->template['nb'] = $nb; $this->template['users_count'] = $this->user_model->count($where); $this->template['users_pages'] = ceil($this->template['users_count'] / $nb); // XHR answer $this->output('user/list'); }
function index() { // Articles $articles = $this->article_model->get_lang_list(array('order_by' => 'updated DESC'), Settings::get_lang('default')); // Last 10 articles $last_articles = array(); $max = count($articles) > 9 ? 10 : count($articles); $count = 0; if (!empty($articles)) { foreach ($articles as $article) { if (Authority::can('access', 'backend/menu/' . $article['id_menu'], NULL, TRUE) && Authority::can('access', 'backend/page/' . $article['id_page'], NULL, TRUE) && Authority::can('access', 'backend/article/' . $article['id_article'], NULL, TRUE)) { $last_articles[] = $article; $count++; if ($count == $max) { break; } } } } // Orphan articles $orphan_articles = array(); foreach ($articles as $article) { if (!$article['id_page']) { $orphan_articles[] = $article; } } // Orphan pages $orphan_pages = $this->page_model->get_lang_list(array('id_menu' => '0', 'order_by' => 'name ASC'), Settings::get_lang('default')); // Last connected /registered users $logged_user_role = User()->get_role(); $users = $this->user_model->get_list_with_role(array('limit' => '10', 'order_by' => 'last_visit DESC', 'last_visit <>' => '')); $last_registered_users = $this->user_model->get_list_with_role(array('limit' => '10', 'order_by' => 'join_date DESC')); // Updates on last articles foreach ($last_articles as &$article) { // User name update foreach ($users as $user) { if ($user['username'] == $article['updater']) { $article['updater'] = $user['screen_name']; } if ($user['username'] == $article['author']) { $article['author'] = $user['screen_name']; } } $pages = $this->page_model->get_parent_array($article['id_page'], array(), Settings::get_lang('default')); $breadcrumb = array(); foreach ($pages as $page) { $breadcrumb[] = !empty($page['title']) ? $page['title'] : $page['name']; } $article['breadcrumb'] = implode(' > ', $breadcrumb); } // Updates on orphan pages foreach ($orphan_pages as &$page) { // User name update foreach ($users as $user) { if ($user['username'] == $page['updater']) { $page['updater'] = $user['screen_name']; } if ($user['username'] == $page['author']) { $page['author'] = $user['screen_name']; } } } // Updates on orphan articles foreach ($orphan_articles as &$article) { // User name update foreach ($users as $user) { if ($user['username'] == $article['updater']) { $article['updater'] = $user['screen_name']; } if ($user['username'] == $article['author']) { $article['author'] = $user['screen_name']; } } } // Flags $settings = Settings::get_settings(); $flags = array(); foreach ($settings as $key => $setting) { if (strpos($key, 'flag') !== FALSE && $setting != '') { $flags[substr($key, -1)] = $setting; } } // Put installed module list to template $installed_modules = Modules()->get_installed_modules(); $modules = array(); foreach ($installed_modules as $module) { if ($module['has_admin'] && Authority::can('access', 'module/' . $module['key'])) { $modules[] = $module; } } $this->template['modules'] = $modules; $this->template['flags'] = $flags; $this->template['last_articles'] = $last_articles; $this->template['orphan_pages'] = $orphan_pages; $this->template['orphan_articles'] = $orphan_articles; $this->template['users'] = $users; $this->template['last_registered_users'] = $last_registered_users; $this->output('desktop/dashboard'); }