/** * Get notice list * * @access public * @return Response (json) * @throws Exception in Controller_Base::controller_common_api * @see Controller_Base::controller_common_api */ public function get_list() { $this->controller_common_api(function () { list($limit, $page) = $this->common_get_pager_list_params(\Config::get('notice.articles.limit'), \Config::get('notice.articles.limit_max')); $data = Model_NoticeStatus::get_pager_list4member_id($this->u->id, $limit, $page); $list_array = array(); foreach ($data['list'] as $key => $obj) { $row = $obj->to_array(); $row['members_count'] = Model_NoticeMemberFrom::get_count4notice_id($row['notice_id'], $this->u->id); $row['members'] = array(); $notice_member_froms = Model_NoticeMemberFrom::get4notice_id($row['notice_id'], \Config::get('notice.noticeMemberFrom.limit'), $this->u->id); foreach ($notice_member_froms as $notice_member_from) { $row['members'][] = \Model_Member::get_one_basic4id($notice_member_from->member_id); } $row['is_read'] = (int) $row['is_read']; $list_array[] = $row; } // json response $data['list'] = $list_array; $data['is_detail'] = (bool) \Input::get('is_detail', 0); $this->set_response_body_api($data); }); }
public static function get_unread_count_cache($member_id, $is_make_cache = false) { $cache_key = self::get_unread_count_cache_key($member_id); $cache_expir = \Config::get('notice.cache.unreadCount.expir'); try { $unread_count = \Cache::get($cache_key, $cache_expir); } catch (\CacheNotFoundException $e) { $unread_count = null; if ($is_make_cache) { $unread_count = Model_NoticeStatus::get_unread_count4member_id($member_id); \Cache::set($cache_key, $unread_count, $cache_expir); } } return $unread_count; }