Example #1
0
 public function get_newest_log($pid, $limit)
 {
     $list = Model_OperateLog::data_access()->filter(Model_OperateLog::PID, intval($pid))->limit(intval($limit))->sort(Model_OperateLog::ID)->find();
     if (empty($list)) {
         return $list;
     }
     $ids = array();
     $uids = array();
     foreach ($list as $row) {
         $ids[] = $row->id;
         if (!in_array($row->user_id, $uids)) {
             $uids[] = $row->user_id;
         }
     }
     $users = Biz_User::get_instance()->get_users_map($uids);
     foreach ($list as $key => $row) {
         if (array_key_exists($row->user_id, $users)) {
             $list[$key]->user = $users[$row->user_id];
         }
     }
     $cmds = Biz_Command::get_instance()->get_cmds_map($ids);
     foreach ($list as $key => $row) {
         if (array_key_exists($row->id, $cmds)) {
             $list[$key]->cmd = $cmds[$row->id];
         }
     }
     return $list;
 }
Example #2
0
 public static function get_instance()
 {
     if (!self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Example #3
0
 private function _login()
 {
     $oauth_url = APF::get_instance()->get_config('oauth_url');
     $oauth_cid = APF::get_instance()->get_config('oauth_cid');
     $oauth_secret = APF::get_instance()->get_config('oauth_secret');
     if (isset($_REQUEST['code']) && $_REQUEST['code']) {
         $data = array("client_id" => $oauth_cid, "client_secret" => $oauth_secret, "grant_type" => 'authorization_code', "code" => $_REQUEST['code']);
         header("HTTP/1.1 302 Found");
         header("Location: " . $oauth_url . '/token.php?' . http_build_query($data));
         exit;
     }
     if (isset($_REQUEST['access_token']) && $_REQUEST['access_token']) {
         $access_token = $_REQUEST['access_token'];
         $data = array("oauth_token" => $access_token);
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $oauth_url . "/resource.php");
         curl_setopt($ch, CURLOPT_POST, TRUE);
         curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
         $info = curl_exec($ch);
         if ($info) {
             $info = json_decode($info);
             $access_token = $info->access_token;
             $d = $detail = json_decode($this->_get_info_from_ldap($access_token, $oauth_url));
             $user_id = Biz_User::get_instance()->check_user($d->chinese_name, $d->english_name, $d->email);
             setcookie(APF::get_instance()->get_config('cookie_name'), $user_id, time() + 60 * 60 * 24 * 30, '/');
             $this->_response->redirect(PageHelper::get_domain() . '/project/list');
         } else {
             exit;
         }
     }
     exit;
 }
Example #4
0
 public function handle_request()
 {
     $this->_param = APF::get_instance()->get_request()->get_parameters();
     $this->_match = APF::get_instance()->get_request()->get_router_matches();
     $this->_page = max(1, isset($this->_param['page']) ? intval($this->_param['page']) : 1);
     $this->_request = APF::get_instance()->get_request();
     $this->_response = APF::get_instance()->get_response();
     $this->_domain = APF::get_instance()->get_config('domain');
     $cookie_name = APF::get_instance()->get_config('cookie_name');
     if (isset($_COOKIE[$cookie_name])) {
         $uid = $_COOKIE[$cookie_name];
         $this->_user = Biz_User::get_instance()->get_user($uid);
         $this->_request->set_attribute('user', $this->_user);
     }
     return $this->handle_request_internel();
 }