Ejemplo n.º 1
0
 /**
  *
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  * @return boolean Indicating success.
  */
 function _handler_moderate($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_valid_user();
     if (!$this->_topic->can_do('net.nehmer.comments:moderation')) {
         return new midcom_response_relocate('/');
     }
     // This might exit.
     $this->_process_admintoolbar();
     $view_status = array();
     $this->_request_data['handler'] = $args[0];
     switch ($args[0]) {
         case 'reported_abuse':
             $this->_request_data['status_to_show'] = 'reported abuse';
             $view_status[] = net_nehmer_comments_comment::REPORTED_ABUSE;
             break;
         case 'abuse':
             $this->_request_data['status_to_show'] = 'abuse';
             $view_status[] = net_nehmer_comments_comment::ABUSE;
             break;
         case 'junk':
             $this->_request_data['status_to_show'] = 'junk';
             $view_status[] = net_nehmer_comments_comment::JUNK;
             break;
         case 'latest':
             $this->_request_data['status_to_show'] = 'latest comments';
             $view_status[] = net_nehmer_comments_comment::NEW_ANONYMOUS;
             $view_status[] = net_nehmer_comments_comment::NEW_USER;
             $view_status[] = net_nehmer_comments_comment::MODERATED;
             if ($this->_config->get('show_reported_abuse_as_normal')) {
                 $view_status[] = net_nehmer_comments_comment::REPORTED_ABUSE;
             }
             break;
         case 'latest_new':
             $this->_request_data['status_to_show'] = 'latest comments, only new';
             $view_status[] = net_nehmer_comments_comment::NEW_ANONYMOUS;
             $view_status[] = net_nehmer_comments_comment::NEW_USER;
             if ($this->_config->get('show_reported_abuse_as_normal')) {
                 $view_status[] = net_nehmer_comments_comment::REPORTED_ABUSE;
             }
             break;
         case 'latest_approved':
             $this->_request_data['status_to_show'] = 'latest comments, only approved';
             $view_status[] = net_nehmer_comments_comment::MODERATED;
             break;
     }
     $qb = new org_openpsa_qbpager('net_nehmer_comments_comment', 'net_nehmer_comments_comments');
     $qb->results_per_page = $this->_config->get('items_to_show');
     $qb->display_pages = $this->_config->get('paging');
     $qb->add_constraint('status', 'IN', $view_status);
     $qb->add_order('metadata.revised', 'DESC');
     $this->_comments = $qb->execute();
     if ($this->_comments) {
         $this->_init_display_datamanager();
     }
     net_nehmer_comments_viewer::add_head_elements();
     $this->_prepare_request_data();
     $this->add_breadcrumb('', $this->_l10n->get($data['status_to_show']));
 }
Ejemplo n.º 2
0
 /**
  * Handle actual article display
  *
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  */
 public function _handler_view($handler_id, array $args, array &$data)
 {
     if ($handler_id == 'view-raw') {
         midcom::get()->skip_page_style = true;
     }
     $this->_load_datamanager();
     if ($this->_config->get('enable_ajax_editing')) {
         $this->_request_data['controller'] = midcom_helper_datamanager2_controller::create('ajax');
         $this->_request_data['controller']->schemadb =& $this->_request_data['schemadb'];
         $this->_request_data['controller']->set_storage($this->_article);
         $this->_request_data['controller']->process_ajax();
     }
     if ($this->_config->get('comments_enable')) {
         $comments_node = $this->_seek_comments();
         if ($comments_node) {
             $this->_request_data['comments_url'] = $comments_node[MIDCOM_NAV_RELATIVEURL] . "comment/{$this->_article->guid}";
             if ($this->_topic->can_do('midgard:update') && $this->_topic->can_do('net.nehmer.comments:moderation')) {
                 net_nehmer_comments_viewer::add_head_elements();
             }
         }
         // TODO: Should we tell admin to create a net.nehmer.comments folder?
     }
     $tmp = array();
     $arg = $this->_article->name ? $this->_article->name : $this->_article->guid;
     if ($this->_config->get('view_in_url')) {
         $view_url = "view/{$arg}/";
     } else {
         $view_url = "{$arg}/";
     }
     $this->add_breadcrumb($view_url, $this->_article->title);
     $this->_prepare_request_data();
     if ($this->_config->get('enable_article_links') && $this->_content_topic->can_do('midgard:create')) {
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n_midcom->get('create %s'), $this->_l10n->get('article link')), MIDCOM_TOOLBAR_URL => "create/link/?article={$this->_article->id}", MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/attach.png'));
     }
     $this->bind_view_to_object($this->_article, $this->_datamanager->schema->name);
     midcom::get('metadata')->set_request_metadata($this->_article->metadata->revised, $this->_article->guid);
     midcom::get('head')->set_pagetitle("{$this->_topic->extra}: {$this->_article->title}");
 }