Example #1
0
 public function action_latest($route_id, &$data, $args)
 {
     $topic_guid = $this->configuration->get('news_topic');
     if (!$topic_guid) {
         throw new midcom_exception_notfound("No news topic defined");
     }
     $data['topic'] = new midgard_topic($topic_guid);
     $_MIDCOM->componentloader->load('org_openpsa_qbpager');
     $qb = new org_openpsa_qbpager_pager('midgard_article');
     $qb->add_constraint('topic', '=', $data['topic']->id);
     $qb->add_order('metadata.published', 'DESC');
     if ($route_id == 'latest') {
         if (!is_numeric($args['number'])) {
             throw new midcom_exception_notfound("Number expected as argument");
         }
         $qb->results_per_page = (int) $args['number'];
     } else {
         $qb->results_per_page = (int) $this->configuration->get('index_show_articles');
     }
     $articles = $qb->execute();
     foreach ($articles as $article) {
         if (!$article->url || !$this->configuration->get('link_articles_to_external_url')) {
             $article->url = $_MIDCOM->dispatcher->generate_url('show', array('name' => $article->name));
         }
         $data['news'][] = $article;
     }
     $data['previousnext'] = $qb->get_previousnext();
 }
Example #2
0
 public function action_index($route_id, &$data, $args)
 {
     // $notifier = new net_nemein_notifications_notifier('e857294ea89a11dbb67e7f95d175e24ee24e');
     // $notifier->send_mail(array(
     //     'title' => 'Testing 2....'
     // ));
     $qb = new org_openpsa_qbpager_pager('net_nemein_notifications_notification');
     $qb->add_constraint('recipient', '=', 2);
     $qb->add_order('metadata.published', 'DESC');
     $qb->results_per_page = 10;
     $data['notifications'] = $qb->execute();
     $data['previousnext'] = $qb->get_previousnext();
 }