/**
  * Tags list (tags in topic, search results)
  */
 public function _tag_list()
 {
     $sm = vivvo_lite_site::get_instance();
     $um = $sm->get_url_manager();
     $list_template = $this->load_template($this->_template_root . 'tag_list.xml');
     $params = Tags_list::get_search_params_from_url($sm);
     $params['search_advanced_mode'] = 1;
     if ($um->isset_param('topic_id')) {
         $topic = TagsGroups_list::factory()->get_group_by_id($um->get_param('topic_id'));
         $params['search_topic_id'] = $topic->get_id();
         $list_template->assign('topic', $topic);
     }
     $list_template->assign('tag_list_params', $params);
     $search_sort_by = $params['search_sort_by'] . '.' . $params['search_order'];
     $list_template->assign('search_sort_by', $search_sort_by);
     $list_template->assign('search_limit', $params['search_limit']);
     return $list_template;
 }
Example #2
0
 /**
  * Delete tag
  *
  * @param	integer	$tag_id
  * @return	boolean	true on success or false on fail
  */
 function delete_tag($tag_id, $all_matching = 0)
 {
     if (!$this->check_token()) {
         return false;
     }
     if (!vivvo_hooks_manager::call('tag_delete', array(&$tag_id))) {
         return vivvo_hooks_manager::get_status();
     }
     if ($tag_id <= 100) {
         $this->set_error_code(2421);
         // system tag can't be deleted.
         return false;
     }
     $sm = vivvo_lite_site::get_instance();
     $user = $sm->user;
     if ($sm->user && $sm->user->can('ARTICLE_TAG')) {
         if ($sm->user->is_admin() || $sm->user->is('EDITOR')) {
             $tag_list = new Tags_list();
             if ($all_matching) {
                 $params = Tags_list::get_search_params_from_url($sm);
                 $tag_list->search($params['search_options'], '', 'ascending', 0, 0);
                 if ($tag_list->sql_delete_list($this->_post_master, null, true)) {
                     admin_log($user->get_username(), 'Deleted tags like ' . $params['search_options']);
                     return true;
                 }
             } else {
                 $tag_list->get_tags_by_ids($tag_id, false);
                 if ($tag_list->sql_delete_list($this->_post_master)) {
                     admin_log($user->get_username(), 'Deleted tag #' . $tag_id);
                     return true;
                 }
             }
             $this->set_error_code(2404);
             return false;
         } else {
             $this->set_error_code(2405);
             return false;
         }
     } else {
         $this->set_error_code(2406);
         return false;
     }
 }