Example #1
0
 function getCategoryTree(&$xmap, &$parent, &$params, $listid)
 {
     $db =& JFactory::getDBO();
     if (!$listid) {
         // view=lists
         $query = ' SELECT a.listid,a.name' . ' ,CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS("-", a.listid, a.alias) ELSE a.listid END as slug' . ' FROM #__acymailing_list AS a ' . ' WHERE a.published=1 AND  a.visible=1' . ' ORDER by a.ordering ';
         $db->setQuery($query);
         $cats = $db->loadObjectList();
         $xmap->changeLevel(1);
         foreach ($cats as $cat) {
             $node = new stdclass();
             $node->id = $parent->id;
             $node->uid = 'com_acymailingl' . $cat->listid;
             $node->name = $cat->name;
             $node->link = 'index.php?option=com_acymailing&ctrl=archive&listid=' . $cat->slug;
             $node->priority = $params['cat_priority'];
             $node->changefreq = $params['cat_changefreq'];
             $node->expandible = true;
             if ($xmap->printNode($node) !== FALSE) {
                 xmap_com_acymailing::getCategoryTree($xmap, $parent, $params, $cat->listid, '&ctrl=archive');
             }
         }
         $xmap->changeLevel(-1);
     } elseif ($params['include_mails']) {
         //view=archive || //ctrl=archive&listid=...
         $query = ' SELECT a.mailid,a.subject,a.created' . ' ,CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS("-", a.mailid, a.alias) ELSE a.mailid END as slug' . ' ,CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS("-", c.listid, c.alias) ELSE c.listid END as catslug' . ' FROM #__acymailing_mail AS a,#__acymailing_listmail AS ac,#__acymailing_list AS c ' . ' WHERE ac.mailid = a.mailid AND a.published=1 and a.visible=1 ' . ' AND ac.listid=' . $listid . ' AND c.listid=ac.listid ' . ' ORDER by a.created ' . $params['limit'];
         $db->setQuery($query);
         $mails = $db->loadObjectList();
         $xmap->changeLevel(1);
         foreach ($mails as $mail) {
             $node = new stdclass();
             $node->id = $parent->id;
             $node->uid = 'com_acymailingm' . $mail->mailid;
             $node->name = $mail->subject;
             $node->created = $mail->created;
             $node->link = 'index.php?option=com_acymailing&ctrl=archive&task=view&listid=' . $mail->catslug . '&mailid=' . $mail->slug;
             $node->priority = $params['mail_priority'];
             $node->changefreq = $params['mail_changefreq'];
             $node->expandible = false;
             $xmap->printNode($node);
         }
         $xmap->changeLevel(-1);
     }
 }
 public function __construct()
 {
     self::$enabled = JComponentHelper::isEnabled('com_acymailing');
 }