public function insert($post_id, $channel_id) { parent::insert($channel_id, array('id' => $post_id), false); $this->truncate($channel_id, 100); parent::insert(0, array('id' => $post_id), false); $this->truncate(0, 100); $users = channel_user_peer::instance()->get_list($channel_id); foreach ($users as $data) { $user_id = $data['id']; user_post_peer::instance()->insert($user_id, $post_id); } }
<?php $channel = channel_peer::instance()->get_by_id((int) $_GET['id']); $posts = channel_post_peer::instance()->get_list($channel['id'], null, 20); $is_mine = user_channel_peer::instance()->is_my_channel($_SESSION['user_id'], $channel['id']); $user_count = channel_user_peer::instance()->length($channel['id']);
/** * @return channel_user_peer */ public static function instance() { return self::$instance ? self::$instance : (self::$instance = new self()); }
public function delete($user_id, $channel_id) { parent::delete($user_id, array('id' => $channel_id)); channel_user_peer::instance()->delete($channel_id, $user_id); }