public function find($criteria = array(), $n = NULL, $offset = NULL) { $where = $this->_get_where($criteria); $orderby = parent::_get_orderby($criteria, 'nombre'); $order = parent::_get_order($criteria, 'ASC'); return parent::find('personas', $where, $orderby, $order, $n, $offset); }
public function find($id=null) { $role = parent::find($id); if (!$role) { return false; } // Grab our permissions for the role. $permissions = $this->permission_model->find_for_role($id); $role->permissions = $permissions[0]; return $role; }
public function login($uname, $str) { //取出随机数列 $login_key = $this->session->userdata('key'); $this->session->unset_userdata('key'); /*获得用户信息*/ if (parent::count(array('uname' => $uname)) == 1) { //$q=$this->db->get_where('user',array('uname'=>$uname))->row_array(); $q = end(parent::find(array('uname' => $uname))); //检查用户是否已经过期 if (isset($q['expire_time']) && $q['expire_time'] < time()) { //验证待激活用户是否过期,过期则删除,并返回登陆失败 if (parent::deleteByPk($q['id'])) { return $this->set_err(101, 'Expired User!'); } else { return FALSE; } } /*检验用户是否已经激活*/ if (!$q['active']) { return $this->set_err(102, 'Please activate the user first'); } /*产生服务器端的hash数据*/ $ser = sha1($q['pword'] . $login_key); /*验证*/ if ($str == $ser) { /*更新最后登陆时间以及登陆状态*/ /* $this->db->where('id',$q['id']); $this->db->update('hfi_user',array('latest_login'=>time())); */ parent::updateByPk(array('latest_login' => time()), $q['id']); //更新session $s_data = array('rsc_login' => TRUE, 'uid' => $q['id']); $this->session->set_userdata($s_data); //set security session $this->session->set_userdata('security', TRUE); $this->session->set_userdata('sec_time', time() + 60); //设置登陆数据 $this->uid = $q['id']; return TRUE; /*登陆成功*/ } else { return $this->set_err(104, 'Wrong user name and password combination.'); } } else { return $this->set_err(104, 'Wrong user name and password combination.'); } }
public function find($id=null) { $this->db->join('roles', 'roles.role_id = users.role_id', 'left'); return parent::find($id); }
/** * Find posts with linked text and author's profile * * @param type $id * @param type $limit * @param type $from * @return type */ public function find($id = NULL, $limit = NULL, $from = NULL) { $this->db->select('t.*, u.id AS user_id, u.login, u.email, u.avatar, u.banned, u.role')->join($this->users_table . ' AS u', 't.user_id = u.id', 'LEFT'); return parent::find($id, $limit, $from); }
/** * Check whether the resources is shared with current user * @param $rsc_type * @param $rsc_id * @return boolean whether the information is shared by the current user */ public function is_shared($rsc_type, $rsc_id) { if ($this->identity->is_researcher()) { $uid = $this->identity->get_uid(); } else { return FALSE; } if (!$this->_check_rsc($rsc_type, $rsc_id)) { $this->err_code = 400; $this->err_msg = "Wrong Input as Experiment Resource Identifier:[" . $rsc_type . "," . $rsc_id . "]"; return FALSE; } // fetch the data $record = end(parent::find(array("rsc_type" => $rsc_type, "rsc_id" => $rsc_id))); if (!$record) { return FALSE; } //the error codes should be set up already switch ($record["share"]) { case "private": return $this->is_owner($rsc_type, $rsc_id); // since we have already checked, and the targeted user is not the owner break; case "limited": // then we need to find the list // TODO will the owner be in the list? return in_array($uid, $record["share_list"]) || $this->is_owner($rsc_type, $rsc_id); break; case "protected": return $this->identity->is_researcher(); break; case "public": return TRUE; break; default: return FALSE; //sorry, I just cannot break; } }
public function getPackageByGID($gid) { return end(parent::find(['gid' => $gid])); }