Пример #1
0
 function getMailings($listId, $listType, $start = -1, $limit = -1, $emailsearch, &$total, $order, $showOnlyPublished = true, $viewArchive = false)
 {
     if (ACA_CMSTYPE) {
         // joomla 15
         $my =& JFactory::getUser();
         $database =& JFactory::getDBO();
     } else {
         //joomla 1x
         global $my, $database;
     }
     //endif
     $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
     $where = array();
     $flag = false;
     $sortList = false;
     $query = 'SELECT * FROM `#__acajoom_mailings`';
     if ($listType > 0) {
         $where[] = '  `list_type` = ' . $listType . ' ';
     } elseif ($listId > 0) {
         $where[] = '  `list_id` = ' . $listId . ' ';
         $sortList = true;
     }
     if ($showOnlyPublished) {
         $where[] = ' `published` =1 ';
         $where[] = ' `visible`=1 ';
     } else {
         $where[] = ' `published`<>-1 ';
     }
     if (class_exists('pro') && $sortList) {
     } elseif (!acajoom::checkPermissions('admin') && !$viewArchive) {
         $where[] = ' `author_id` = ' . $my->id;
     }
     if (!empty($emailsearch)) {
         $where[] = ' (subject LIKE \'%' . $emailsearch . '%\' OR fromname LIKE \'%' . $emailsearch . '%\') ';
     }
     $query .= count($where) ? " WHERE " . implode(' AND ', $where) : "";
     if (empty($order)) {
         $order = 'idD';
     }
     $query .= acajoom::orderBy($order);
     if ($start != -1 && $limit != -1) {
         $query .= ' LIMIT ' . $start . ', ' . $limit;
     }
     $database->setQuery($query);
     $mailing = $database->loadObjectList();
     $erro->err = $database->getErrorMsg();
     if (!$erro->E(__LINE__, '8400', $database)) {
         return '';
     } else {
         foreach ($mailing as $key => $mail) {
             $mailing[$key]->htmlcontent = stripslashes($mailing[$key]->htmlcontent);
             $mailing[$key]->subject = stripslashes($mailing[$key]->subject);
             $mailing[$key]->attachments = stripslashes($mailing[$key]->attachments);
             $mailing[$key]->images = stripslashes($mailing[$key]->images);
             $mailing[$key]->textonly = stripslashes($mailing[$key]->textonly);
             $mailing[$key]->send_date = stripslashes($mailing[$key]->send_date);
         }
         return $mailing;
     }
 }
Пример #2
0
 function getSubscriberLists($userId)
 {
     global $database;
     if ($userId > 0) {
         $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
         $query = 'SELECT * FROM `#__acajoom_queue` WHERE `subscriber_id`=' . $userId;
         $query .= acajoom::orderBy('list_idA');
         $database->setQuery($query);
         $queue = $database->loadObjectList();
         $erro->err = $database->getErrorMsg();
         return $erro->Ertrn(__LINE__, '8500', $database, $queue);
     } else {
         return '';
     }
 }
Пример #3
0
 function getLists($listId, $listType, $author = null, $order = 'listnameA', $autoAdd = false, $onlyPublished = true, $onlyName = false, $notification = false)
 {
     global $database, $my, $acl;
     $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
     if ($onlyName) {
         $query = 'SELECT `id` AS id, `list_name` AS list_name, `list_desc` AS list_desc, `list_type` AS list_type FROM `#__acajoom_lists`';
     } else {
         $query = 'SELECT * FROM `#__acajoom_lists` ';
     }
     $where = array();
     if ($listId > 0) {
         $where[] = ' `id`=' . intval($listId);
     }
     if ($listType > 0) {
         $where[] = ' `list_type`=' . intval($listType);
     }
     if ($autoAdd) {
         $where[] = ' `auto_add`=1 ';
     }
     if ($onlyPublished == true) {
         $where[] = ' `published`=1 AND `hidden`=1 ';
     }
     if (class_exists('pro') && isset($author)) {
         $aro_id = isset($my->id) && $my->id > 0 ? $acl->get_object_id('users', $my->id, 'ARO') : 1;
         $qacl = "SELECT `group_id` FROM `#__core_acl_groups_aro_map` WHERE `aro_id` =" . $aro_id;
         $database->setQuery($qacl);
         $gidd = $database->loadResult();
         $gidFront = $acl->get_group_id('Public Frontend', 'ARO');
         $gid = $gidd > 0 ? $gidd : $gidFront;
         $ex_groups = $acl->get_group_parents($gid, 'ARO', 'RECURSE');
         $gidAdmin = $acl->get_group_id('Public Backend', 'ARO');
         if (in_array($gidAdmin, $ex_groups)) {
             $ex_groups2 = $acl->get_group_children($gidFront, 'ARO', 'RECURSE');
             $ex_groups2[] = $gidFront;
             $ex_groups = array_merge($ex_groups, $ex_groups2);
         }
         $ex_groups[] = $gid;
         $ex_groups[] = 0;
         $accIds = implode(',', $ex_groups);
         $where[] = " `acc_id` IN ( {$accIds} ) ";
     }
     if (!$notification) {
         $where[] = ' `notification`=0 ';
     }
     $wheretag = count($where) ? ' WHERE ' . implode(' AND ', $where) : '';
     $query .= $wheretag;
     $query .= class_exists('acajoom') ? acajoom::orderBy($order) : '';
     $database->setQuery($query);
     $lists = $database->loadObjectList();
     $erro->err = $database->getErrorMsg();
     if (!empty($lists)) {
         foreach ($lists as $key => $list) {
             $lists[$key]->list_name = stripslashes($lists[$key]->list_name);
             $lists[$key]->list_desc = stripslashes($lists[$key]->list_desc);
         }
     }
     if (!$erro->E(__LINE__, '8300')) {
         return false;
     } else {
         return $lists;
     }
 }
Пример #4
0
 function getSubscribers($start = -1, $limit = -1, $emailsearch, &$total, $listId, $mailingId, $blackList = 0, $confirmed = 0, $order = '')
 {
     global $database, $my;
     $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
     $flag = false;
     $limitFlag = false;
     if ($listId == 0) {
         $query = 'SELECT M.* FROM `#__acajoom_subscribers` AS M  ';
     } else {
         $query = 'SELECT M.* FROM `#__acajoom_subscribers` AS M LEFT JOIN `#__acajoom_queue` AS N' . ' ON  M.id = N.subscriber_id  WHERE  N.list_id =' . $listId . ' AND  N.published<>2 ';
         $flag = true;
     }
     if ($mailingId > 0 and $flag) {
         $query .= ' AND N.mailing_id = ' . $mailingId;
     }
     if ($listId == 0) {
         if ($blackList == 1) {
             if ($confirmed == 1) {
                 $query .= ' WHERE M.blacklist = 0 AND M.confirmed = 1  ';
                 $flag = true;
             } else {
                 $query .= ' WHERE M.blacklist = 0 ';
                 $flag = true;
             }
         }
     } else {
         if ($blackList == 1) {
             if ($confirmed == 1) {
                 $query .= ' AND M.blacklist = 0 AND M.confirmed = 1  ';
                 $flag = true;
             } else {
                 $query .= ' AND M.blacklist = 0 ';
                 $flag = true;
             }
         }
     }
     if (!empty($emailsearch)) {
         if ($flag) {
             $query .= ' AND (M.email LIKE \'%' . $emailsearch . '%\' OR M.name LIKE \'%' . $emailsearch . '%\') ';
         } else {
             $query .= ' WHERE M.email LIKE \'%' . $emailsearch . '%\' OR M.name LIKE \'%' . $emailsearch . '%\' ';
         }
     }
     if ($listId != 0) {
         $query .= ' GROUP BY M.id ';
     }
     if (!empty($order)) {
         $query .= acajoom::orderBy($order);
     }
     if ($start != -1 && $limit != -1) {
         $query .= ' LIMIT ' . $start . ', ' . $limit;
         $limitFlag = true;
     }
     $database->setQuery($query);
     $subscribers = $database->loadObjectList();
     $erro->err = $database->getErrorMsg();
     if ($erro->E(__LINE__, '8611', $database)) {
         if ($limitFlag) {
             $flag = false;
             $query = 'SELECT COUNT(M.id) FROM #__acajoom_subscribers AS M';
             if ($mailingId > 0) {
                 $query .= ' LEFT JOIN `#__acajoom_queue` AS N  ON  M.id = N.subscriber_id  WHERE  N.mailing_id = ' . $mailingId;
                 $flag = true;
             } elseif ($listId > 0) {
                 $query .= ' LEFT JOIN `#__acajoom_queue` AS N  ON  M.id = N.subscriber_id  WHERE  N.list_id = ' . $listId;
                 $flag = true;
             }
             if (!empty($emailsearch)) {
                 if ($flag) {
                     $query .= ' AND (M.email LIKE \'%' . $emailsearch . '%\' OR M.name LIKE \'%' . $emailsearch . '%\') ';
                 } else {
                     $query .= ' WHERE M.email LIKE \'%' . $emailsearch . '%\' OR M.name LIKE \'%' . $emailsearch . '%\' ';
                 }
             }
             if ($listId > 0) {
                 $query .= ' GROUP BY M.id ';
             }
             $database->setQuery($query);
             $total = $database->loadResult();
         } else {
             $total = count($subscribers);
         }
     }
     return $subscribers;
 }