info(); if ($auth['company']) { return $auth['company']; } return false; } # 设置公司权限 public function set($company_id) { $company_id = $company_id ? $company_id : Dever::input('company_id'); $auth = $this->getAuth(); if ($auth) { $auth = explode(',', $auth); if (in_array($company_id, $auth)) { return $this->_add('company', $company_id, 3600 * 24 * 365); } } return false; } # 获取公司权限 public function get() { $company_id = $this->_get('company'); /* if ($company_id) { $auth = $this->getAuth(); if ($auth) { $auth = explode(',', $auth); if (!in_array($company_id, $auth)) { $company_id = false; } } }*/ if (!$company_id) { $company = $this->getData(); if ($company) { $company_id = $company['id']; $this->set($company_id); } } return $company_id; } # 获取公司列表 public function getList() { $company_id = $this->get(); $data = $this->getData(); $result = array(); if ($data && count($data) > 1) { foreach ($data as $k => $v) { if ($company_id && $company_id != $v['id']) { $result[] = $v; } else { $this->company = $v; } } } return $result; } # 获取当前公司 public function getCur() { //print_r($this->company);die; if ($this->company) { return $this->company['name']; } return false; } private function getData() { $auth = $this->getAuth(); $where = array(); if ($auth) { $where['ids'] = $auth; return Dever::db('manage/company')->getOld($where); } else { return array(); } } }