public function render() { // group recent posts if ($this->type == 'group') { $group = new Group(); $group->collection_id = $this->gid; $this->links = $group->get_contents_for_collection('all', FALSE, $this->limit, 1, 'created', 'DESC', TRUE); // user recent posts } else { if ($this->type == 'user') { $this->links = CNContent::get_user_content($this->uid); // network recent posts } else { $this->links = CNContent::load_content_id_array($user_id = 0, $type = NULL, $cnt = FALSE, $show = $this->limit, $page = 1, $sort_by = 'created', $direction = 'DESC', $only_homepage = false); } } $this->view_all_url = count($this->links) > 0 ? $this->view_all_url : ''; $this->inner_HTML = $this->generate_inner_html($this->links); $content = parent::render(); return $content; }
/** * deletes all content related with an user_id * @param int user_id */ public static function delete_all_content_of_user($user_id) { Logger::log("Enter: CNContent::delete_all_content_of_user()"); $res = false; // searching for all content related with user id $user_content_data = CNContent::get_user_content($user_id); if (0 < count($user_content_data)) { for ($i = 0; $i < count($user_content_data); $i++) { $content_id[$i] = $user_content_data[$i]['content_id']; } // soft deleting $sql = "UPDATE {contents} SET is_active = 0 WHERE author_id = ?"; $data = array($user_id); $res = Dal::query($sql, $data); // delete tags of related user_id's content $id = $content_id[0]; $sql = "DELETE FROM {tags_contents} WHERE content_id = {$id}"; for ($i = 1; $i < count($content_id); $i++) { $id = $content_id[$i]; $sql .= " OR content_id = {$id}"; } $res = Dal::query($sql); // Delete comment of related user_id's content Logger::log("Deleting the all comments related to this object"); $id = $content_id[0]; $sql = "UPDATE {comments} SET is_active = 0 WHERE content_id = {$id}"; for ($i = 0; $i < count($content_id); $i++) { $id = $content_id[$i]; $sql .= " OR content_id = {$id}"; } $res = Dal::query($sql); } Logger::log("Exit: CNContent::delete_all_content_of_user()"); return $res; }