function _default_assignments()
 {
     $sm = vivvo_lite_site::get_instance();
     $template = $sm->get_template();
     $um = $sm->get_url_manager();
     require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Comments.class.php';
     $params = Comments_list::get_search_params_from_url($sm);
     $template->assign('comments_params', $params);
     $template->assign('search_limit', $um->get_param('search_limit'));
     $template->assign('search_sort_by', strval($params['search_sort_by'] . '.' . $params['search_order']));
     $template->assign('user_filters_section', strval('comment'));
 }
Beispiel #2
0
 /**
  * Generate box output
  *
  * @param array $params Parameters
  */
 function generate_output($params)
 {
     $this->set_template($params);
     $params += array('pg' => 1, 'fields' => '');
     // defaults
     require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Comments.class.php';
     $comments = new Comments_list(null, $params['fields']);
     $search_params = Comments_list::get_search_params(null, $params);
     if (isset($search_params['search_options']['search_article_id'])) {
         $this->_template->assign('article_id', $search_params['search_options']['search_article_id']);
     }
     $comments->search($search_params['search_options'], $search_params['search_sort_by'], $search_params['search_order'], $search_params['search_limit'], $search_params['offset']);
     if (!empty($comments->list)) {
         $comments->set_pagination($params['pg']);
         $this->_template->assign('comment_list', $comments->list);
     }
     $sm = vivvo_lite_site::get_instance();
     if (!$sm->user && $sm->guest_group) {
         $this->_template->assign('guest_group_wait_comment_for_approval', $sm->guest_group->group_privileges['ARTICLE_COMMENT']);
     }
     $this->_template->assign('comment_list_object', $comments);
 }
Beispiel #3
0
 /**
  * Sets {@link $number_of_comments}
  *
  * @param	integer	$num
  */
 function set_number_of_comments($num = false)
 {
     if ($num === false || !is_numeric($num)) {
         require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Comments.class.php';
         $cl = new Comments_list();
         $params = array('search_article_id' => $this->id);
         defined('VIVVO_ADMIN_MODE') or $params['search_status'] = 1;
         $cl->search($params, '', '', 0, 0, false);
         $this->number_of_comments = $cl->get_total_count();
     } elseif (is_numeric($num)) {
         $this->number_of_comments = $num;
     } else {
         $this->number_of_comments = false;
     }
     return true;
 }
Beispiel #4
0
 function get_search_params_from_url(&$sm)
 {
     $um =& $sm->get_url_manager();
     $params = Comments_list::get_search_params($sm, $um->list);
     return $params;
 }
 /**
  * Edit comment
  *
  * @param	integer		$comment_id
  * @param	array		$data
  * @return	boolean		true on succes, or false on fail
  */
 function vote($comment_id, $vote)
 {
     if (!vivvo_hooks_manager::call('comment_vote', array(&$comment_id, &$vote))) {
         return vivvo_hooks_manager::get_status();
     }
     $sm = vivvo_lite_site::get_instance();
     $dm = $sm->get_dump_manager();
     if (!$sm->user && $sm->guest_group && $sm->guest_group->group_privileges['ARTICLE_COMMENT'] > 0 || $sm->user && $sm->user->privileges['ARTICLE_COMMENT'] > 0) {
         if (!isset($_SESSION['vivvo']['comment'])) {
             $_SESSION['vivvo']['comment'] = array();
         }
         if (in_array($comment_id, $_SESSION['vivvo']['comment'])) {
             $this->set_error_code(2222);
             return false;
         } else {
             if ($vote != 1 and $vote != -1) {
                 $this->set_error_code(2223);
                 return false;
             }
             $comment_list = new Comments_list();
             $comment = $comment_list->get_comments_by_id($comment_id);
             if ($comment !== false) {
                 $vote += $comment->get_vote();
                 $comment->set_vote($vote);
                 $this->_post_master->set_data_object($comment);
                 if ($this->_post_master->sql_update()) {
                     $_SESSION['vivvo']['comment'][] = $comment->id;
                     $dm->add_dump('info', 0, $vote);
                     return true;
                 } else {
                     $this->set_error_code(2224);
                     return false;
                 }
             } else {
                 $this->set_error_code(2225);
                 return false;
             }
         }
     } else {
         $this->set_error_code(2226);
         return false;
     }
 }
 function web_statistics()
 {
     $content_template = $this->load_template($this->_template_root . 'web_statistics.xml');
     $sm = vivvo_lite_site::get_instance();
     $db =& $sm->get_db();
     require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Categories.class.php';
     $cat_list = new Categories_list();
     $content_template->assign('website_categories', strval($cat_list->get_count()));
     require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Tags.class.php';
     $tag_list = new Tags_list();
     $content_template->assign('website_tags', strval($tag_list->get_count()));
     require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
     $articles_list = new Articles_list();
     $content_template->assign('website_articles', strval($articles_list->get_count()));
     $content_template->assign('website_articles_active', strval($articles_list->get_count(array('search_status' => 1))));
     $res = $db->query('SELECT sum(times_read) as times_view FROM ' . VIVVO_DB_PREFIX . 'articles_stats');
     if (!PEAR::isError($res)) {
         if ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
             $times_view = $row['times_view'];
         }
     }
     $content_template->assign('website_articles_view', intval($times_view));
     require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Comments.class.php';
     $comments_list = new Comments_list();
     $content_template->assign('website_comments', strval($comments_list->get_count()));
     $user_mng = $sm->get_user_manager();
     $user_list = $user_mng->get_user_list();
     $content_template->assign('system_staff', strval($user_list->get_count(array('search_user_type' => 'staff'))));
     return $content_template->get_output();
 }