protected function get_available_records($filter) { if (has_capability('block/curr_admin:cluster:role_assign_cluster_users', $this->get_context(), NULL, false)) { global $CURMAN, $CFG; $context = $this->get_context(); $roleid = required_param('role', PARAM_INT); $pagenum = optional_param('page', 0, PARAM_INT); $perpage = 30; $sort = optional_param('sort', 'name', PARAM_ACTION); $order = optional_param('dir', 'ASC', PARAM_ACTION); if ($order != 'DESC') { $order = 'ASC'; } static $sortfields = array('name' => array('lastname', 'firstname'), 'idnumber' => 'idnumber'); if (!array_key_exists($sort, $sortfields)) { $sort = key($sortfields); } if (is_array($sortfields[$sort])) { $sortclause = implode(', ', array_map(create_function('$x', "return \"\$x {$order}\";"), $sortfields[$sort])); } else { $sortclause = "{$sortfields[$sort]} {$order}"; } $where = "idnumber NOT IN (SELECT mu.idnumber\n FROM {$CURMAN->db->prefix_table('user')} mu\n LEFT JOIN {$CURMAN->db->prefix_table('role_assignments')} ra\n ON ra.userid = mu.id\n WHERE ra.contextid = {$context->id}\n AND ra.roleid = {$roleid}\n AND mu.mnethostid = {$CFG->mnet_localhost_id})\n AND id IN (SELECT userid\n FROM {$CURMAN->db->prefix_table('crlm_usercluster')} uc\n WHERE uc.clusterid = {$context->instanceid})"; $extrasql = $filter->get_sql_filter(); if ($extrasql) { $where .= " AND {$extrasql}"; } $count = $CURMAN->db->count_records_select('crlm_user usr', $where); $users = $CURMAN->db->get_records_select('crlm_user usr', $where, $sortclause, '*', $pagenum * $perpage, $perpage); return array($users, $count); } else { return parent::get_available_records($filter); } }
/** * Class constructor * * @param rolepage $page The page being used to display the list of roles */ function __construct(&$page) { //copy the page instance for safety reasons $this->page = $page->get_new_page(); }