/** * вернет поcледние $limit постов * * результат в $this->_actions_data['posts'] */ public function action_list($limit = null) { if ($limit === null) { $limit = !empty($_REQUEST['posts_list_limit']) && is_numeric($_REQUEST['posts_list_limit']) ? $_REQUEST['posts_list_limit'] : 10; } $sql = 'SELECT a.id,a.uid,a.text,a.create_on,b.email,b.name as username,b.public_email FROM posts a, users b WHERE b.uid = a.uid AND a.status = \'active\' ORDER BY id DESC LIMIT ' . $limit; foreach (posts::find_by_sql($sql) as $post) { $attr = $post->attributes(); if (is_object($attr['create_on'])) { $attr['create_on'] = $attr['create_on']->format('d M Y H:i:s'); } $attr['like_already'] = $this->is_already_like($attr['id']) ? 1 : 0; // $this->action_like_members_count($attr['id']); $attr['like_members_count'] = $this->_actions_data['like_members_count']; unset($this->_actions_data['like_members_count']); // $this->action_like_members($attr['id']); $attr['like_members'] =& $this->_actions_data['like_members']; unset($this->_actions_data['like_members']); // $this->action_attachments($attr['id']); $attr['attachments'] =& $this->_actions_data['attachments']; unset($this->_actions_data['attachments']); $this->_actions_data['posts'][] = $attr; } }