Example #1
0
 function convertQuery($as, $column, $operator, $value, $type = '')
 {
     $operator = str_replace(array('&lt;', '&gt;'), array('<', '>'), $operator);
     if ($operator == 'CONTAINS') {
         $operator = 'LIKE';
         $value = '%' . $value . '%';
     } elseif ($operator == 'BEGINS') {
         $operator = 'LIKE';
         $value = $value . '%';
     } elseif ($operator == 'END') {
         $operator = 'LIKE';
         $value = '%' . $value;
     } elseif ($operator == 'NOTCONTAINS') {
         $operator = 'NOT LIKE';
         $value = '%' . $value . '%';
     } elseif (!in_array($operator, array('REGEXP', 'NOT REGEXP', 'IS NULL', 'IS NOT NULL', 'NOT LIKE', 'LIKE', '=', '!=', '>', '<', '>=', '<='))) {
         die('Operator not safe : ' . $operator);
     }
     if (strpos($value, '{time}') !== false) {
         $value = acymailing_replaceDate($value);
         $value = strftime('%Y-%m-%d %H:%M:%S', $value);
     }
     $replace = array('{year}', '{month}', '{weekday}', '{day}');
     $replaceBy = array(date('Y'), date('m'), date('N'), date('d'));
     $value = str_replace($replace, $replaceBy, $value);
     if (!is_numeric($value) or in_array($operator, array('REGEXP', 'NOT REGEXP', 'NOT LIKE', 'LIKE', '=', '!='))) {
         $value = $this->db->Quote($value);
     }
     if (in_array($operator, array('IS NULL', 'IS NOT NULL'))) {
         $value = '';
     }
     if ($type == 'datetime' && in_array($operator, array('=', '!='))) {
         return 'DATE_FORMAT(' . $as . '.`' . acymailing_secureField($column) . '`, "%Y-%m-%d") ' . $operator . ' ' . 'DATE_FORMAT(' . $value . ', "%Y-%m-%d")';
     }
     if ($type == 'timestamp' && in_array($operator, array('=', '!='))) {
         return 'FROM_UNIXTIME(' . $as . '.`' . acymailing_secureField($column) . '`, "%Y-%m-%d") ' . $operator . ' ' . 'FROM_UNIXTIME(' . $value . ', "%Y-%m-%d")';
     }
     return $as . '.`' . acymailing_secureField($column) . '` ' . $operator . ' ' . $value;
 }
Example #2
0
 function onAcyProcessAction_addqueue($cquery, $action, $num)
 {
     $action['mailid'] = intval($action['mailid']);
     if (empty($action['mailid'])) {
         return 'mailid not valid';
     }
     $action['senddate'] = acymailing_replaceDate($action['senddate']);
     if (!is_numeric($action['senddate'])) {
         $action['senddate'] = acymailing_getTime($action['senddate']);
     }
     if (empty($action['senddate'])) {
         return 'send date not valid';
     }
     $query = 'INSERT IGNORE INTO `#__acymailing_queue` (`mailid`,`subid`,`senddate`,`priority`) ' . $cquery->getQuery(array($action['mailid'], 'sub.`subid`', $action['senddate'], '2'));
     $db = JFactory::getDBO();
     $db->setQuery($query);
     $db->query();
     return JText::sprintf('ADDED_QUEUE', $db->getAffectedRows());
 }
Example #3
0
 function onAcyProcessFilter_list(&$query, $filter, $num)
 {
     $otherconditions = '';
     $field = empty($filter['dates']) ? 'subdate' : 'unsubdate';
     if (!empty($filter['subdateinf'])) {
         $filter['subdateinf'] = acymailing_replaceDate($filter['subdateinf']);
         if (!is_numeric($filter['subdateinf'])) {
             $filter['subdateinf'] = strtotime($filter['subdateinf']);
         }
         if (!empty($filter['subdateinf'])) {
             $otherconditions .= ' AND list' . $num . '.' . $field . ' > ' . $filter['subdateinf'];
         }
     }
     if (!empty($filter['subdatesup'])) {
         $filter['subdatesup'] = acymailing_replaceDate($filter['subdatesup']);
         if (!is_numeric($filter['subdatesup'])) {
             $filter['subdatesup'] = strtotime($filter['subdatesup']);
         }
         if (!empty($filter['subdatesup'])) {
             $otherconditions .= ' AND list' . $num . '.' . $field . ' < ' . $filter['subdatesup'];
         }
     }
     $query->leftjoin['list' . $num] = '#__acymailing_listsub AS list' . $num . ' ON sub.subid = list' . $num . '.subid AND list' . $num . '.listid = ' . intval($filter['selectedlist']) . $otherconditions;
     if ($filter['status'] == -2) {
         $query->where[] = 'list' . $num . '.listid IS NULL';
     } else {
         $query->where[] = 'list' . $num . '.status = ' . intval($filter['status']);
     }
 }
Example #4
0
 public function acymailing_generateautonews(&$email)
 {
     $time = time();
     $tags = $this->acypluginsHelper->extractTags($email, 'autocontent');
     $return = new stdClass();
     $return->status = true;
     $return->message = '';
     $this->tags = array();
     if (empty($tags)) {
         return $return;
     }
     foreach ($tags as $oneTag => $parameter) {
         if (isset($this->tags[$oneTag])) {
             continue;
         }
         $allcats = explode('-', $parameter->id);
         $selectedArea = array();
         foreach ($allcats as $oneCat) {
             if (!ACYMAILING_J16) {
                 $sectype = substr($oneCat, 0, 3);
                 $num = substr($oneCat, 3);
                 if (empty($num)) {
                     continue;
                 }
                 if ($sectype == 'cat') {
                     $selectedArea[] = 'catid = ' . (int) $num;
                 } elseif ($sectype == 'sec') {
                     $selectedArea[] = 'sectionid = ' . (int) $num;
                 }
             } else {
                 if (empty($oneCat)) {
                     continue;
                 }
                 $selectedArea[] = intval($oneCat);
             }
         }
         $query = 'SELECT a.id FROM `#__content` as a ';
         $where = array();
         if (!empty($parameter->tags) && version_compare(JVERSION, '3.1.0', '>=')) {
             $tagsArray = explode(',', $parameter->tags);
             JArrayHelper::toInteger($tagsArray);
             if (!empty($tagsArray)) {
                 foreach ($tagsArray as $oneTagId) {
                     $query .= 'JOIN #__contentitem_tag_map AS tagsmap' . $oneTagId . ' ON (a.id = tagsmap' . $oneTagId . '.content_item_id AND tagsmap' . $oneTagId . '.type_alias LIKE "com_content.article" AND tagsmap' . $oneTagId . '.tag_id = ' . $oneTagId . ') ';
                 }
             }
         }
         if (!empty($parameter->featured)) {
             if (ACYMAILING_J16) {
                 $where[] = 'a.featured = 1';
             } else {
                 $query .= 'JOIN `#__content_frontpage` as b ON a.id = b.content_id ';
                 $where[] = 'b.content_id IS NOT NULL';
             }
         }
         if (!empty($parameter->nofeatured)) {
             if (ACYMAILING_J16) {
                 $where[] = 'a.featured = 0';
             } else {
                 $query .= 'LEFT JOIN `#__content_frontpage` as b ON a.id = b.content_id ';
                 $where[] = 'b.content_id IS NULL';
             }
         }
         if (ACYMAILING_J16 && !empty($parameter->subcats) && !empty($selectedArea)) {
             $this->db->setQuery('SELECT lft,rgt FROM #__categories WHERE id IN (' . implode(',', $selectedArea) . ')');
             $catinfos = $this->db->loadObjectList();
             if (!empty($catinfos)) {
                 $whereCats = array();
                 foreach ($catinfos as $onecat) {
                     $whereCats[] = 'lft > ' . $onecat->lft . ' AND rgt < ' . $onecat->rgt;
                 }
                 $this->db->setQuery('SELECT id FROM #__categories WHERE (' . implode(') OR (', $whereCats) . ')');
                 $othercats = acymailing_loadResultArray($this->db);
                 $selectedArea = array_merge($selectedArea, $othercats);
             }
         }
         if (!empty($selectedArea)) {
             if (!ACYMAILING_J16) {
                 $where[] = implode(' OR ', $selectedArea);
             } else {
                 $filter_cat = '`catid` IN (' . implode(',', $selectedArea) . ')';
                 if (file_exists(JPATH_SITE . DS . 'components' . DS . 'com_multicats')) {
                     $filter_cat = '`catid` REGEXP "^([0-9]+,)*' . implode('(,[0-9]+)*$" OR `catid` REGEXP "^([0-9]+,)*', $selectedArea) . '(,[0-9]+)*$"';
                 }
                 $where[] = $filter_cat;
             }
         }
         if (!empty($parameter->excludedcats)) {
             $excludedCats = explode('-', $parameter->excludedcats);
             JArrayHelper::toInteger($excludedCats);
             $filter_cat = '`catid` NOT IN ("' . implode('","', $excludedCats) . '")';
             if (file_exists(JPATH_SITE . DS . 'components' . DS . 'com_multicats')) {
                 $filter_cat = '`catid` NOT REGEXP "^([0-9]+,)*' . implode('(,[0-9]+)*$" AND `catid` NOT REGEXP "^([0-9]+,)*', $excludedCats) . '(,[0-9]+)*$"';
             }
             $where[] = $filter_cat;
         }
         if (!empty($parameter->filter) && !empty($email->params['lastgenerateddate'])) {
             $condition = '(`publish_up` > \'' . date('Y-m-d H:i:s', $email->params['lastgenerateddate'] - date('Z')) . '\' AND `publish_up` < \'' . date('Y-m-d H:i:s', $time - date('Z')) . '\')';
             $condition .= ' OR (`created` > \'' . date('Y-m-d H:i:s', $email->params['lastgenerateddate'] - date('Z')) . '\' AND `created` < \'' . date('Y-m-d H:i:s', $time - date('Z')) . '\')';
             if ($parameter->filter == 'modify') {
                 $modify = '(`modified` > \'' . date('Y-m-d H:i:s', $email->params['lastgenerateddate'] - date('Z')) . '\' AND `modified` < \'' . date('Y-m-d H:i:s', $time - date('Z')) . '\')';
                 if (!empty($parameter->maxpublished)) {
                     $modify = '(' . $modify . ' AND `publish_up` > \'' . date('Y-m-d H:i:s', time() - date('Z') - (int) $parameter->maxpublished * 60 * 60 * 24) . '\')';
                 }
                 $condition .= ' OR ' . $modify;
             }
             $where[] = $condition;
         }
         if (!empty($parameter->maxcreated)) {
             $date = $parameter->maxcreated;
             if (strpos($parameter->maxcreated, '[time]') !== false) {
                 $date = acymailing_replaceDate(str_replace('[time]', '{time}', $parameter->maxcreated));
             }
             if (!is_numeric($date)) {
                 $date = strtotime($parameter->maxcreated);
             }
             if (empty($date)) {
                 acymailing_display('Wrong date format (' . $parameter->maxcreated . ' in ' . $oneTag . '), please use YYYY-MM-DD', 'warning');
             }
             $where[] = '`created` < ' . $this->db->Quote(date('Y-m-d H:i:s', $date)) . ' OR `publish_up` < ' . $this->db->Quote(date('Y-m-d H:i:s', $date));
         } else {
             $where[] = '`publish_up` < \'' . date('Y-m-d H:i:s', $time - date('Z')) . '\'';
         }
         if (!empty($parameter->mincreated)) {
             $date = $parameter->mincreated;
             if (strpos($parameter->mincreated, '[time]') !== false) {
                 $date = acymailing_replaceDate(str_replace('[time]', '{time}', $parameter->mincreated));
             }
             if (!is_numeric($date)) {
                 $date = strtotime($parameter->mincreated);
             }
             if (empty($date)) {
                 acymailing_display('Wrong date format (' . $parameter->mincreated . ' in ' . $oneTag . '), please use YYYY-MM-DD', 'warning');
             }
             $where[] = '`created` > ' . $this->db->Quote(date('Y-m-d H:i:s', $date)) . ' OR `publish_up` > ' . $this->db->Quote(date('Y-m-d H:i:s', $date));
         }
         if (!empty($parameter->meta)) {
             $allMetaTags = explode(',', $parameter->meta);
             $metaWhere = array();
             foreach ($allMetaTags as $oneMeta) {
                 if (empty($oneMeta)) {
                     continue;
                 }
                 $metaWhere[] = "`metakey` LIKE '%" . acymailing_getEscaped($oneMeta, true) . "%'";
             }
             if (!empty($metaWhere)) {
                 $where[] = implode(' OR ', $metaWhere);
             }
         }
         $where[] = '`publish_down` > \'' . date('Y-m-d H:i:s', $time - date('Z')) . '\' OR `publish_down` = 0';
         if (empty($parameter->unpublished)) {
             $where[] = 'state = 1';
         } else {
             $where[] = 'state = 0';
         }
         if (!ACYMAILING_J16) {
             if (isset($parameter->access)) {
                 $where[] = 'access <= ' . intval($parameter->access);
             } else {
                 if ($this->params->get('contentaccess', 'registered') == 'registered') {
                     $where[] = 'access <= 1';
                 } elseif ($this->params->get('contentaccess', 'registered') == 'public') {
                     $where[] = 'access = 0';
                 }
             }
         } elseif (isset($parameter->access)) {
             if (strpos($parameter->access, ',')) {
                 $allAccess = explode(',', $parameter->access);
                 JArrayHelper::toInteger($allAccess);
                 $where[] = 'access IN (' . implode(',', $allAccess) . ')';
             } else {
                 $where[] = 'access = ' . intval($parameter->access);
             }
         }
         if (ACYMAILING_J16 && !empty($parameter->language)) {
             $allLanguages = explode(',', $parameter->language);
             $langWhere = 'language IN (';
             foreach ($allLanguages as $oneLanguage) {
                 $langWhere .= $this->db->Quote(trim($oneLanguage)) . ',';
             }
             $where[] = trim($langWhere, ',') . ')';
         }
         $query .= ' WHERE (' . implode(') AND (', $where) . ')';
         if (!empty($parameter->order)) {
             $ordering = explode(',', $parameter->order);
             if ($ordering[0] == 'rand') {
                 $query .= ' ORDER BY rand()';
             } else {
                 $query .= ' ORDER BY `' . acymailing_secureField($ordering[0]) . '` ' . acymailing_secureField($ordering[1]) . ' , a.`id` DESC';
             }
         }
         $start = '';
         if (!empty($parameter->start)) {
             $start = intval($parameter->start) . ',';
         }
         if (empty($parameter->max)) {
             $parameter->max = 100;
         }
         $query .= ' LIMIT ' . $start . (int) $parameter->max;
         $this->db->setQuery($query);
         $allArticles = acymailing_loadResultArray($this->db);
         if (!empty($parameter->min) && count($allArticles) < $parameter->min) {
             $return->status = false;
             $return->message = 'Not enough articles for the tag ' . $oneTag . ' : ' . count($allArticles) . ' / ' . $parameter->min . ' between ' . acymailing_getDate($email->params['lastgenerateddate']) . ' and ' . acymailing_getDate($time);
         }
         $stringTag = empty($parameter->noentrytext) ? '' : $parameter->noentrytext;
         if (!empty($allArticles)) {
             if (file_exists(ACYMAILING_MEDIA . 'plugins' . DS . 'autocontent.php')) {
                 ob_start();
                 require ACYMAILING_MEDIA . 'plugins' . DS . 'autocontent.php';
                 $stringTag = ob_get_clean();
             } else {
                 $arrayElements = array();
                 $numArticle = 1;
                 foreach ($allArticles as $oneArticleId) {
                     $args = array();
                     $args[] = 'joomlacontent:' . $oneArticleId;
                     $args[] = 'num:' . $numArticle++;
                     if (!empty($parameter->invert) && $numArticle % 2 == 1) {
                         $args[] = 'invert';
                     }
                     if (!empty($parameter->type)) {
                         $args[] = 'type:' . $parameter->type;
                     }
                     if (!empty($parameter->format)) {
                         $args[] = 'format:' . $parameter->format;
                     }
                     if (!empty($parameter->template)) {
                         $args[] = 'template:' . $parameter->template;
                     }
                     if (!empty($parameter->jtags)) {
                         $args[] = 'jtags';
                     }
                     if (!empty($parameter->link)) {
                         $args[] = 'link';
                     }
                     if (!empty($parameter->author)) {
                         $args[] = 'author';
                     }
                     if (!empty($parameter->autologin)) {
                         $args[] = 'autologin';
                     }
                     if (!empty($parameter->cattitle)) {
                         $args[] = 'cattitle';
                     }
                     if (!empty($parameter->cattitlelink)) {
                         $args[] = 'cattitlelink';
                     }
                     if (!empty($parameter->lang)) {
                         $args[] = 'lang:' . $parameter->lang;
                     }
                     if (!empty($parameter->theme)) {
                         $args[] = 'theme';
                     }
                     if (!empty($parameter->clean)) {
                         $args[] = 'clean';
                     }
                     if (!empty($parameter->notitle)) {
                         $args[] = 'notitle';
                     }
                     if (!empty($parameter->nopictstyle)) {
                         $args[] = 'nopictstyle';
                     }
                     if (!empty($parameter->nopictlink)) {
                         $args[] = 'nopictlink';
                     }
                     if (!empty($parameter->created)) {
                         $args[] = 'created';
                     }
                     if (!empty($parameter->noattach)) {
                         $args[] = 'noattach';
                     }
                     if (!empty($parameter->itemid)) {
                         $args[] = 'itemid:' . $parameter->itemid;
                     }
                     if (!empty($parameter->noreadmore)) {
                         $args[] = 'noreadmore';
                     }
                     if (isset($parameter->pict)) {
                         $args[] = 'pict:' . $parameter->pict;
                     }
                     if (!empty($parameter->wrap)) {
                         $args[] = 'wrap:' . $parameter->wrap;
                     }
                     if (!empty($parameter->maxwidth)) {
                         $args[] = 'maxwidth:' . $parameter->maxwidth;
                     }
                     if (!empty($parameter->maxheight)) {
                         $args[] = 'maxheight:' . $parameter->maxheight;
                     }
                     if (!empty($parameter->readmore)) {
                         $args[] = 'readmore:' . $parameter->readmore;
                     }
                     if (!empty($parameter->dateformat)) {
                         $args[] = 'dateformat:' . $parameter->dateformat;
                     }
                     if (!empty($parameter->textafter)) {
                         $args[] = 'textafter:' . $parameter->textafter;
                     }
                     if (!empty($parameter->maxchar)) {
                         $args[] = 'maxchar:' . $parameter->maxchar;
                     }
                     if (!empty($parameter->share)) {
                         $args[] = 'share:' . $parameter->share;
                     }
                     if (!empty($parameter->sharetxt)) {
                         $args[] = 'sharetxt:' . $parameter->sharetxt;
                     }
                     if (!empty($parameter->catpict)) {
                         $args[] = 'catpict';
                     }
                     if (!empty($parameter->catmaxwidth)) {
                         $args[] = 'catmaxwidth:' . $parameter->catmaxwidth;
                     }
                     if (!empty($parameter->catmaxheight)) {
                         $args[] = 'catmaxheight:' . $parameter->catmaxheight;
                     }
                     $arrayElements[] = '{' . implode('|', $args) . '}';
                 }
                 $stringTag = $this->acypluginsHelper->getFormattedResult($arrayElements, $parameter);
             }
         }
         $this->tags[$oneTag] = $stringTag;
     }
     return $return;
 }
Example #5
0
 static function replaceDate($mydate)
 {
     return acymailing_replaceDate($mydate);
 }
 function onAcyProcessFilter_acymailingfield(&$query, $filter, $num)
 {
     if (empty($filter['map'])) {
         return;
     }
     $type = '';
     $value = acymailing_replaceDate($filter['value']);
     if (strpos($filter['value'], '{time}') !== false && !in_array($filter['map'], array('created', 'confirmed_date', 'lastclick_date', 'lastopen_date', 'lastsent_date'))) {
         $value = strftime('%Y-%m-%d', $value);
     }
     if (in_array($filter['map'], array('created', 'confirmed_date', 'lastclick_date', 'lastopen_date', 'lastsent_date'))) {
         if (!is_numeric($value)) {
             $value = strtotime($value);
         }
         $type = 'timestamp';
     }
     $query->where[] = $query->convertQuery('sub', $filter['map'], $filter['operator'], $value, $type);
 }
Example #7
0
 function onAcyProcessFilter_joomlafield(&$query, $filter, $num)
 {
     if (strpos($filter['map'], 'customfield_') !== false) {
         $query->leftjoin['joomlauserprofiles' . $num] = '#__user_profiles AS joomlauserprofiles' . $num . ' ON joomlauserprofiles' . $num . '.user_id = sub.userid AND joomlauserprofiles' . $num . '.profile_key = ' . $query->db->Quote(str_replace('customfield_', '', $filter['map']));
         $val = trim($filter['value'], '"');
         if (in_array($filter['operator'], array('=', '!=', '<', '>', '<=', '>=', 'BEGINS', 'LIKE', 'NOT LIKE'))) {
             $val = '"' . $val;
         }
         if (in_array($filter['operator'], array('=', '!=', '<', '>', '<=', '>=', 'END', 'LIKE', 'NOT LIKE'))) {
             $val = $val . '"';
         }
         $query->where[] = $query->convertQuery('joomlauserprofiles' . $num, 'profile_value', $filter['operator'], $val);
     } else {
         $query->leftjoin['joomlauser'] = '******';
         if (in_array($filter['map'], array('registerDate', 'lastvisitDate'))) {
             $filter['value'] = acymailing_replaceDate($filter['value']);
             if (!is_numeric($filter['value'])) {
                 $filter['value'] = strtotime($filter['value']);
             }
             $filter['value'] = strftime('%Y-%m-%d %H:%M:%S', $filter['value']);
         }
         $query->where[] = $query->convertQuery('joomlauser', $filter['map'], $filter['operator'], $filter['value']);
     }
 }
Example #8
0
 function onAcyProcessFilter_acymailingfield(&$query, $filter, $num)
 {
     $value = acymailing_replaceDate($filter['value']);
     if (strpos($filter['value'], '{time}') !== false && $filter['map'] != 'created') {
         $value = strftime('%Y-%m-%d', $value);
     }
     if (!is_numeric($value) && $filter['map'] == 'created') {
         $value = strtotime($value);
     }
     $query->where[] = $query->convertQuery('sub', $filter['map'], $filter['operator'], $value);
 }
Example #9
0
 function onAcyProcessFilter_joomlafield(&$query, $filter, $num)
 {
     $query->leftjoin['joomlauser'] = '******';
     if (in_array($filter['map'], array('registerDate', 'lastvisitDate'))) {
         $filter['value'] = acymailing_replaceDate($filter['value']);
         if (!is_numeric($filter['value'])) {
             $filter['value'] = strtotime($filter['value']);
         }
         $filter['value'] = strftime('%Y-%m-%d %H:%M:%S', $filter['value']);
     }
     $query->where[] = $query->convertQuery('joomlauser', $filter['map'], $filter['operator'], $filter['value']);
 }
Example #10
0
 function onAcyProcessFilter_hikaorder(&$query, $filter, $num)
 {
     if (!$this->loadAcymailing()) {
         return;
     }
     $config =& hikashop_config();
     $statuses = explode(',', $config->get('invoice_order_statuses', 'confirmed,shipped'));
     $condition = array();
     foreach ($statuses as $status) {
         $condition[] = $query->db->Quote($status);
     }
     $myquery = "SELECT DISTINCT b.user_email\r\n\t\t\t\t\tFROM #__hikashop_order_product AS a\r\n\t\t\t\t\tLEFT JOIN #__hikashop_order AS c ON a.order_id = c.order_id\r\n\t\t\t\t\tLEFT JOIN #__hikashop_user AS b on c.order_user_id = b.user_id\r\n\t\t\t\t\tWHERE c.order_status IN (" . implode(',', $condition) . ")";
     if (!empty($filter['product']) and is_numeric($filter['product'])) {
         $myquery .= " AND a.product_id = " . (int) $filter['product'];
     } elseif (!empty($filter['cat']) and is_numeric($filter['cat'])) {
         $myquery .= " AND a.product_id IN (SELECT product_id FROM #__hikashop_product_category WHERE category_id = " . $filter['cat'] . ")";
     }
     $datesVar = array('creationdatesup', 'creationdateinf');
     foreach ($datesVar as $oneDate) {
         if (empty($filter[$oneDate])) {
             continue;
         }
         $filter[$oneDate] = acymailing_replaceDate($filter[$oneDate]);
         if (!is_numeric($filter[$oneDate])) {
             $filter[$oneDate] = strtotime($filter[$oneDate]);
         }
     }
     if (empty($filter['datefield'])) {
         $filter['datefield'] = 'order_created';
     }
     if (!empty($filter['creationdateinf'])) {
         $myquery .= ' AND c.`' . $filter['datefield'] . '` > ' . $filter['creationdateinf'];
     }
     if (!empty($filter['creationdatesup'])) {
         $myquery .= ' AND c.`' . $filter['datefield'] . '` < ' . $filter['creationdatesup'];
     }
     $query->db->setQuery($myquery);
     $allEmails = acymailing_loadResultArray($query->db);
     if (empty($allEmails)) {
         $allEmails[] = 'none';
     }
     if (empty($filter['type'])) {
         $query->where[] = "sub.email NOT IN ('" . implode("','", $allEmails) . "')";
     } else {
         $query->where[] = "sub.email IN ('" . implode("','", $allEmails) . "')";
     }
 }
Example #11
0
 function convertQuery($as, $column, $operator, $value)
 {
     if ($operator == 'CONTAINS') {
         $operator = 'LIKE';
         $value = '%' . $value . '%';
     } elseif ($operator == 'BEGINS') {
         $operator = 'LIKE';
         $value = $value . '%';
     } elseif ($operator == 'END') {
         $operator = 'LIKE';
         $value = '%' . $value;
     } elseif (!in_array($operator, array('REGEXP', 'NOT REGEXP', 'IS NULL', 'IS NOT NULL', 'NOT LIKE', 'LIKE', '=', '!=', '>', '<', '>=', '<='))) {
         die('Operator not safe : ' . $operator);
     }
     if (strpos($value, '{time}') !== false) {
         $value = acymailing_replaceDate($value);
         $value = strftime('%Y-%m-%d %H:%M:%S', $value);
     }
     if (!is_numeric($value) or in_array($operator, array('REGEXP', 'NOT REGEXP', 'NOT LIKE', 'LIKE'))) {
         $value = $this->db->Quote($value);
     }
     if (in_array($operator, array('IS NULL', 'IS NOT NULL'))) {
         $value = '';
     }
     return $as . '.`' . acymailing_secureField($column) . '` ' . $operator . ' ' . $value;
 }
 function onAcyProcessFilterCount_list(&$query, $filter, $num)
 {
     $otherconditions = '';
     if (!empty($filter['subdateinf'])) {
         $filter['subdateinf'] = acymailing_replaceDate($filter['subdateinf']);
         if (!is_numeric($filter['subdateinf'])) {
             $filter['subdateinf'] = strtotime($filter['subdateinf']);
         }
         if (!empty($filter['subdateinf'])) {
             $otherconditions .= ' AND list' . $num . '.subdate > ' . $filter['subdateinf'];
         }
     }
     if (!empty($filter['subdatesup'])) {
         $filter['subdatesup'] = acymailing_replaceDate($filter['subdatesup']);
         if (!is_numeric($filter['subdatesup'])) {
             $filter['subdatesup'] = strtotime($filter['subdatesup']);
         }
         if (!empty($filter['subdatesup'])) {
             $otherconditions .= ' AND list' . $num . '.subdate < ' . $filter['subdatesup'];
         }
     }
     if ($filter['status'] == -2) {
         $myquery = 'SELECT COUNT(sub.subid) FROM #__acymailing_subscriber as sub LEFT JOIN #__acymailing_listsub AS list' . $num . ' ON sub.subid = list' . $num . '.subid AND list' . $num . '.listid = ' . intval($filter['selectedlist']) . $otherconditions . ' WHERE list' . $num . '.listid IS NULL';
     } else {
         $myquery = 'SELECT COUNT(list' . $num . '.subid) FROM #__acymailing_listsub as list' . $num . ' WHERE list' . $num . '.listid = ' . intval($filter['selectedlist']) . $otherconditions . ' AND list' . $num . '.status = ' . intval($filter['status']);
     }
     $db =& JFactory::getDBO();
     $db->setQuery($myquery);
     $nbSubscribers = $db->loadResult();
     return JText::sprintf('SELECTED_USERS', $nbSubscribers);
 }