function setPermissionsRoleUser($role_id, $user_id) { $CI = _ci(); $CI->load->model('permissions_role_m'); $permissions = $CI->permissions_role_m->get(array('role_id' => $role_id), 'permission_id'); if (count($permissions) > 0) { $dataPermissionsUser = array(); foreach ($permissions as $p) { $dataPermissionsUser[] = array('user_id' => $user_id, 'permission_id' => $p->permission_id); } $this->load->model('permissions_user_m'); $this->permissions_user_m->save_batch($dataPermissionsUser); } return TRUE; }
function permissionsUser($user_id = FALSE) { $CI = _ci(); if ($user_id === FALSE) { if (!$CI->session->userdata('logged')) { return FALSE; } $user_id = $CI->session->userdata('user_id'); } $permissions = array(); $CI->load->model('permissions_user_m'); $getPermissions = $CI->permissions_user_m->get(array('user_id' => $user_id)); foreach ($getPermissions as $get) { $permissions[] = $get->permission_id; } return $permissions; }
/** * Get a single phrase by name and index * * @access public * @param string * @param string * @param array * @return string */ function line($name, $args = null, $default = false) { $line = _ci()->lang->line($name); $line or $line = !$default ? $name : $default; return $args !== null ? vsprintf($line, (array) $args) : $line; }
/** * Using $this->load->view() * * @access public * @param string * @param array * @param boolean * @return void */ function render($view, $data = array(), $return = false) { return _ci()->load->view($view, $data, $return); }
/** * Generates an html img tag * * @access public * @param string * @param mixed * @return string */ function img($file = null, $attr = null) { // Load functions_helper if not loaded if (!function_exists('img_url')) { _ci()->load->helper('functions'); } if (strlen($file) > 0) { $tag = '<img src="' . img_url($file) . '"' . ($attr ? _stringify_attributes($attr) : '') . ' />'; return $tag; } return null; }