function render() { if (empty(PA::$login_user)) { return __("Login required"); } $this->title = 'Reviews'; $this->subject_type = $this->params['subject_type']; $this->subject_id = $this->params['subject_id']; switch ($this->view) { case 'default': if (empty($this->subject_type) || empty($this->subject_id)) { return "subject_type and subject_id are required"; } $this->reviews = Review::get_recent_by_subject($this->subject_type, $this->subject_id, 10); break; case 'recent_short': if (empty($this->subject_type)) { return "subject_type is required"; } $this->reviews = Review::get_recent_by_subject_type($this->subject_type, 10); break; } // find unique author user_id values $user_ids = array(); foreach ($this->reviews as $rev) { $user_ids[$rev->author_id] = 1; } if (!empty($user_ids)) { // load all users $u = new User(); $users = $u->load_users(array_keys($user_ids)); // map ids to user info $user_map = array(); foreach ($users as $u) { $user_map[$u['user_id']] = $u; } // and finally put them all in the review objects foreach ($this->reviews as $rev) { $rev->author = $user_map[$rev->author_id]; } } $this->inner_HTML = $this->generate_inner_html(); $content = parent::render(); return $content; }
function manage_links($contents_list) { global $base_url; $cnt = count($contents_list); $link_array = array(); if ($cnt > 0) { // Loading all users for ($i = 0; $i < $cnt; $i++) { $user_listing[$i] = $contents_list[$i]['user_id']; } $usr = new User(); $user_info = $usr->load_users($user_listing, 'user_id'); $cnt_no = count($user_info); for ($j = 0; $j < $cnt_no; $j++) { $user_array[$user_info[$j]['user_id']] = $user_info[$j]['login_name']; } for ($i = 0; $i < $cnt; $i++) { $link_array[$i]['time'] = $contents_list[$i]['created']; $link_array[$i]['comment'] = $contents_list[$i]['comment']; $link_array[$i]['comment_title'] = $contents_list[$i]['comment_title']; $link_array[$i]['type'] = 'comment'; $link_array[$i]['author_id'] = $contents_list[$i]['user_id']; if ($link_array[$i]['author_id'] == ANONYMOUS_USER_ID) { $link_array[$i]['author_name'] = 'Anonymous'; } else { $login = User::get_login_name_from_id($link_array[$i]['author_id']); $current_url = $base_url . '/' . FILE_USER_BLOG . '?uid=' . $link_array[$i]['author_id']; $url_perms = array('current_url' => $current_url, 'login' => $login); $url = get_url(FILE_USER_BLOG, $url_perms); $link_array[$i]['author_name'] = '<a href="' . $url . '">' . $user_array[$contents_list[$i]['user_id']] . '</a>'; } $link_array[$i]['comment_id'] = $contents_list[$i]['comment_id']; $link_array[$i]['delete_url'] = $base_url . '/deletecomment.php?comment&comment_id=' . $link_array[$i]['comment_id']; $link_array[$i]['hyper_link'] = $base_url . '/content.php?cid=' . $contents_list[$i]['content_id']; // Here we calcuting the number of total abuse on comment $link_array[$i]['abuses'] = total_abuse($contents_list[$i]['comment_id'], TYPE_COMMENT); } } // End of If condition return $link_array; }
function render() { $this->title = __('Reviews'); $this->subject_type = @$this->params['subject_type']; $this->subject_id = @$this->params['subject_id']; $this->page = (int) @$this->params['page'] ? (int) $this->params['page'] : 1; switch ($this->view) { case 'item': // reviews on an item if (empty($this->subject_type) || empty($this->subject_id)) { return "subject_type and subject_id are required"; } $this->item = Item::find_by_subject($this->subject_type, $this->subject_id); if (empty($this->item)) { return "Item {$this->subject_type}:{$this->subject_id} not found. Is the frontend server sending it correctly?"; } list($this->reviews, $this->n_reviews, $this->n_pages, $this->page, $this->per_page) = Review::get_recent_by_subject($this->subject_type, $this->subject_id, 5, $this->page); // get tags $this->tags = ItemTags::get_tags_for_item($this->subject_type, $this->subject_id); break; case 'recent_single': // most recent review of an item (a chosen new release) if (empty($this->subject_type) || empty($this->subject_id)) { return "subject_type and subject_id are required"; } $this->item = Item::find_by_subject($this->subject_type, $this->subject_id); if (empty($this->item)) { return "Item {$this->subject_type}:{$this->subject_id} not found. Is the frontend server sending it correctly?"; } list($this->reviews, , , , ) = Review::get_recent_by_subject($this->subject_type, $this->subject_id, 1, 1); break; case 'recent': // recent reviews if (empty($this->subject_type)) { return "subject_type is required"; } $this->reviews = Review::get_recent_by_subject_type($this->subject_type, 3); foreach ($this->reviews as &$review) { $review->item = Item::find_by_subject($review->subject_type, $review->subject_id); if (empty($review->item)) { return "Item {$this->subject_type}:{$this->subject_id} not found. Is the frontend server sending it correctly?"; } } break; case 'top': // top reviewers $this->reviewers = User::get_top_reviewers(8); foreach ($this->reviewers as &$u) { foreach ($u->get_profile_fields("videoplay", array("display_login_name", "url", "thumbnail_url")) as $k => $v) { $u->{$k} = $v; } } break; case 'recent_by_user': if (empty($this->uid)) { return "user_id parameter is required"; } // recent reviews from a user list($this->reviews, $this->n_reviews, $this->n_pages, $this->page, $this->per_page) = Review::get_recent_by_user($this->uid, 5, $this->page); break; default: return "Unknown ReviewModule view: {$this->view}"; } // find unique author user_id values $user_ids = array(); foreach ($this->reviews as $rev) { $user_ids[$rev->author_id] = 1; } if (!empty($user_ids)) { // load all users $us = new User(); $users = $us->load_users(array_keys($user_ids)); // add in videoplay-specific profile data foreach ($users as &$u) { $us->user_id = $u['user_id']; foreach ($us->get_profile_fields("videoplay", array("display_login_name", "url", "thumbnail_url")) as $k => $v) { $u[$k] = $v; } } unset($u); // map ids to user info $user_map = array(); foreach ($users as $u) { $user_map[$u['user_id']] = $u; } // and finally put them all in the review objects foreach ($this->reviews as $rev) { $rev->author = $user_map[$rev->author_id]; } } $tpl =& new Template(dirname(__FILE__) . "/" . $this->skin . "_" . $this->view . ".tpl", $this); $this->inner_HTML = $tpl->fetch(); if (preg_match($this->skin, "/_inner\$/")) { $content = parent::render(); } else { $content = $this->inner_HTML; } return $content; }
function render() { // if (empty(PA::$login_user)) return __("Login required"); $this->title = __('Comments'); $this->subject_type = @$this->params['subject_type']; $this->page = (int) @$this->params['page'] ? (int) $this->params['page'] : 1; switch ($this->view) { case 'item': $this->subject_id = $this->params['subject_id']; $this->item = Item::find_by_subject($this->subject_type, $this->subject_id); if (empty($this->item)) { return "Item {$this->subject_type}:{$this->subject_id} not found. Is the frontend server sending it correctly?"; } if (empty($this->subject_type) || empty($this->subject_id)) { return "subject_type and subject_id are required"; } list($this->comments, $this->n_comments, $this->n_pages, $this->page, $this->per_page) = Comment2::get_recent_by_subject($this->subject_type, $this->subject_id, 5, $this->page); break; case 'most_commented': if (empty($this->subject_type)) { return "subject_type is required"; } $this->items = Item::get_most_commented_by_subject_type($this->subject_type, 3); break; case 'recent_by_user': if (empty($this->uid)) { return "user_id is required"; } //TODO list($this->comments, $this->n_comments, $this->n_pages, $this->page, $this->per_page) = Comment2::get_recent_by_user($this->uid, 5, $this->page); break; default: return "Unknown CommentModule view: {$this->view}"; } // find unique author user_id values $user_ids = array(); foreach ($this->comments as $c) { $user_ids[$c->author_id] = 1; } if (!empty($user_ids)) { // load all users $us = new User(); $users = $us->load_users(array_keys($user_ids)); // add in videoplay-specific profile data foreach ($users as &$u) { $us->user_id = $u['user_id']; foreach ($us->get_profile_fields("videoplay", array("display_login_name", "url", "thumbnail_url")) as $k => $v) { $u[$k] = $v; } } unset($u); // free the reference so we don't break stuff down below by assigning $u // map ids to user info $user_map = array(); foreach ($users as $u) { $user_map[$u['user_id']] = $u; } // and finally put them all in the comment objects foreach ($this->comments as $rev) { $rev->author = $user_map[$rev->author_id]; } } $this->inner_HTML = $this->generate_inner_html(); if (preg_match($this->skin, "/_inner\$/")) { $content = parent::render(); } else { $content = $this->inner_HTML; } return $content; }