/** * 按状态和分页获取任务列表 * @param int $status * @param string $limit */ public function GetList($status, $limit = NULL) { $cond = array('status' => $status); if (!Passport::IsAdmin()) { $user = new User(); $perms = $user->getPerms(Passport::GetLoginUid()); if (count($perms) > 0) { $cond['pid'] = array_keys($perms); } else { $cond['uid'] = Passport::GetLoginUid(); } } $list = $this->findBy($cond, $this->primary_key, $limit, null, 'send_time desc, id desc'); // 查询 username 字段 $uids = array(); foreach ($list as $item) { $uids[] = $item['uid']; } $uids = array_unique($uids); $user = new User(); $user_list = $user->gets($uids); foreach ($list as &$item) { $item['username'] = if_null($user_list[$item['uid']]['username'], 'uid: ' . $item['uid']); unset($item); } return $list; }
/** * 按平台和权限获取博客列表 * @param int $pid * @param bool $perm */ public function getBlogList($pid = 0, $perm = TRUE) { if ($pid == 0) { return array(); } if ($perm) { $user = new User(); $perms = $user->getPerms(Passport::GetLoginUid()); if (!array_key_exists($pid, $perms)) { return array(); } } $list = Config::blog_list(); if ($pid > 0) { $set_list = $this->findBy(array('status' => 1, 'pid' => $pid), 'name'); $new_list = array(); foreach ($list as $key => $value) { if (array_key_exists($key, $set_list) || array_key_exists($key, Config::simula_list())) { $new_list[$key] = $list[$key]; } } $list = $new_list; } else { foreach ($list as $key => $value) { if ($key == 'qzone_simula') { // 只要设定任何一个 qzone APPKEY,qzone模拟登录就关闭 if ($this->fetchOne(array('status' => 1, 'name' => 'qzone'))) { unset($list[$key]); continue; } } if (array_key_exists($key, Config::open_list())) { unset($list[$key]); } } } return $list; }