function remove() { if (!$this->isAllowed($this->aclCat, 'delete')) { return; } JRequest::checkToken() or die('Invalid Token'); $mailid = JRequest::getVar('filter_mail', 0, 'post', 'int'); $queueClass = acymailing_get('class.queue'); $search = JRequest::getString('search'); $filters = array(); if (!empty($search)) { $db = JFactory::getDBO(); $searchVal = '\'%' . acymailing_getEscaped($search, true) . '%\''; $searchFields = array('b.name', 'b.email', 'c.subject', 'a.mailid', 'a.subid'); $filters[] = implode(" LIKE {$searchVal} OR ", $searchFields) . " LIKE {$searchVal}"; } if (!empty($mailid)) { $filters[] = 'a.mailid = ' . intval($mailid); } $total = $queueClass->delete($filters); $app = JFactory::getApplication(); $app->enqueueMessage(JText::sprintf('SUCC_DELETE_ELEMENTS', $total), 'message'); JRequest::setVar('filter_mail', 0, 'post'); JRequest::setVar('search', '', 'post'); return $this->listing(); }
function trigger($triggerName) { if (!acymailing_level(3)) { return; } $config = acymailing_config(); if (!$config->get('triggerfilter_' . $triggerName)) { return; } $this->database->setQuery("SELECT * FROM `#__acymailing_filter` WHERE `trigger` LIKE '%" . acymailing_getEscaped($triggerName, true) . "%' ORDER BY filid ASC"); $filters = $this->database->loadObjectList(); if (empty($filters)) { $newconfig = new stdClass(); $name = 'triggerfilter_' . $triggerName; $newconfig->{$name} = 0; $config->save($newconfig); return; } foreach ($filters as $oneFilter) { if (empty($oneFilter->published)) { continue; } if (!empty($oneFilter->filter)) { $oneFilter->filter = unserialize($oneFilter->filter); } if (!empty($oneFilter->action)) { $oneFilter->action = unserialize($oneFilter->action); } $this->execute($oneFilter->filter, $oneFilter->action); } }
function delete($elements) { if (!is_array($elements)) { $elements = array($elements); } foreach ($elements as $key => $val) { $elements[$key] = acymailing_getEscaped($val); } if (empty($elements)) { return 0; } $this->database->setQuery('DELETE FROM #__acymailing_listcampaign WHERE `campaignid` IN (' . implode(',', $elements) . ')'); $this->database->query(); return parent::delete($elements); }
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; }
function listing() { JHTML::_('behavior.modal', 'a.modal'); $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->elements = new stdClass(); $config = acymailing_config(); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".filter_order", 'filter_order', 'a.mailid', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); if (strtolower($pageInfo->filter->order->dir) !== 'desc') { $pageInfo->filter->order->dir = 'asc'; } $pageInfo->search = $app->getUserStateFromRequest($paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $selectedList = $app->getUserStateFromRequest($paramBase . "filter_list", 'filter_list', 0, 'int'); $selectedCreator = $app->getUserStateFromRequest($paramBase . "filter_creator", 'filter_creator', 0, 'int'); $pageInfo->limit->value = $app->getUserStateFromRequest($paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($paramBase . '.limitstart', 'limitstart', 0, 'int'); $database = JFactory::getDBO(); $searchMap = array('a.mailid', 'a.alias', 'a.subject', 'a.fromname', 'a.fromemail', 'a.replyname', 'a.replyemail', 'a.userid', 'b.name', 'b.username', 'b.email'); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . acymailing_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $filters[] = 'a.type = \'' . $this->type . '\''; if (!empty($selectedList)) { $filters[] = 'c.listid = ' . $selectedList; } if (!empty($selectedCreator)) { $filters[] = 'a.userid = ' . $selectedCreator; } if ($this->type == 'news') { $selectedDate = $app->getUserStateFromRequest($paramBase . "filter_date", 'filter_date', 0, 'string'); if (!empty($selectedDate)) { if (strlen($selectedDate) > 4) { $filters[] = 'DATE_FORMAT(FROM_UNIXTIME(senddate),"%Y-%m") = ' . $database->Quote($selectedDate); } else { $filters[] = 'DATE_FORMAT(FROM_UNIXTIME(senddate),"%Y") = ' . $database->Quote($selectedDate); } } } $selection = array_merge($searchMap, array('a.created', 'a.frequency', 'a.senddate', 'a.published', 'a.type', 'a.visible', 'a.abtesting')); if (empty($selectedList)) { if ($app->isAdmin()) { $query = 'SELECT ' . implode(',', $selection) . ' FROM ' . acymailing_table('mail') . ' as a'; $queryCount = 'SELECT COUNT(a.mailid) FROM ' . acymailing_table('mail') . ' as a'; } else { $query = 'SELECT ' . implode(',', $selection) . ' FROM ' . acymailing_table('listmail') . ' as c'; $query .= ' JOIN ' . acymailing_table('mail') . ' as a on a.mailid = c.mailid '; $queryCount = 'SELECT COUNT(DISTINCT c.mailid) FROM ' . acymailing_table('listmail') . ' as c'; $queryCount .= ' JOIN ' . acymailing_table('mail') . ' as a on a.mailid = c.mailid '; } } else { $query = 'SELECT ' . implode(',', $selection) . ' FROM ' . acymailing_table('listmail') . ' as c'; $query .= ' JOIN ' . acymailing_table('mail') . ' as a on a.mailid = c.mailid '; $queryCount = 'SELECT COUNT(c.mailid) FROM ' . acymailing_table('listmail') . ' as c'; $queryCount .= ' JOIN ' . acymailing_table('mail') . ' as a on a.mailid = c.mailid '; } $query .= ' LEFT JOIN ' . acymailing_table('users', false) . ' as b on a.userid = b.id '; $query .= ' WHERE (' . implode(') AND (', $filters) . ')'; if (count($filters) > 1) { $queryCount .= ' LEFT JOIN ' . acymailing_table('users', false) . ' as b on a.userid = b.id '; } $queryCount .= ' WHERE (' . implode(') AND (', $filters) . ')'; if (!$app->isAdmin()) { $listClass = acymailing_get('class.list'); $lists = $listClass->getFrontendLists(); if (!empty($lists)) { $frontListsIds = array(); if (empty($selectedList)) { foreach ($lists as $oneList) { $frontListsIds[] = $oneList->listid; } $query .= ' AND c.listid IN (' . implode(',', $frontListsIds) . ')'; $queryCount .= ' AND c.listid IN (' . implode(',', $frontListsIds) . ')'; } } $query .= ' GROUP BY a.mailid '; } if (!empty($pageInfo->filter->order->value)) { $query .= ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } $database->setQuery($query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $database->loadObjectList('mailid'); if (!empty($rows)) { $database->setQuery('SELECT COUNT(*) AS countqueued, mailid FROM ' . acymailing_table('queue') . ' WHERE mailid IN (' . implode(',', array_keys($rows)) . ') GROUP BY mailid'); $queueCount = $database->loadObjectList(); if (!empty($queueCount)) { foreach ($queueCount as $oneQueueCount) { $rows[$oneQueueCount->mailid]->countqueued = $oneQueueCount->countqueued; } } } $database->setQuery($queryCount); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); jimport('joomla.html.pagination'); $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); if ($app->isAdmin()) { acymailing_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $bar = JToolBar::getInstance('toolbar'); $buttonPreview = JText::_('ACY_PREVIEW'); if ($this->type == 'autonews') { JToolBarHelper::custom('generate', 'process', '', JText::_('GENERATE'), false); } elseif ($this->type == 'news') { $buttonPreview .= ' / ' . JText::_('SEND'); } JToolBarHelper::custom('preview', 'acypreview', '', $buttonPreview, true); JToolBarHelper::divider(); JToolBarHelper::addNew(); JToolBarHelper::editList(); if (acymailing_isAllowed($config->get('acl_' . $this->aclCat . '_delete', 'all'))) { JToolBarHelper::deleteList(JText::_('ACY_VALIDDELETEITEMS')); } JToolBarHelper::spacer(); if (acymailing_level(3) && acymailing_isAllowed($config->get('acl_' . $this->aclCat . '_abtesting', 'all')) && $this->type == 'news') { $bar->appendButton('Acypopup', 'acyabtesting', JText::_('ABTESTING'), '', 800, 600); } if (acymailing_isAllowed($config->get('acl_' . $this->aclCat . '_copy', 'all'))) { JToolBarHelper::custom('copy', 'copy.png', 'copy.png', JText::_('ACY_COPY')); } if (acymailing_level(3)) { $bar->appendButton('Acypopup', 'upload', JText::_('IMPORT'), "index.php?option=com_acymailing&ctrl=newsletter&task=upload&tmpl=component"); } JToolBarHelper::divider(); $bar->appendButton('Pophelp', $this->doc); if (acymailing_isAllowed($config->get('acl_cpanel_manage', 'all'))) { $bar->appendButton('Link', 'acymailing', JText::_('ACY_CPANEL'), acymailing_completeLink('dashboard')); } } $filters = new stdClass(); if ($app->isAdmin()) { $listmailType = acymailing_get('type.listsmail'); $listmailType->type = $this->type; $filters->list = $listmailType->display('filter_list', $selectedList); } else { $accessibleLists = array(); $accessibleLists[] = JHTML::_('select.option', '0', JText::_('ALL_LISTS')); foreach ($lists as $oneList) { $accessibleLists[] = JHTML::_('select.option', $oneList->listid, $oneList->name); } $filters->list = JHTML::_('select.genericlist', $accessibleLists, 'filter_list', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', (int) $selectedList); } $mailcreatorType = acymailing_get('type.mailcreator'); $mailcreatorType->type = $this->type; $filters->creator = $mailcreatorType->display('filter_creator', $selectedCreator); if ($this->type == 'news') { $database->setQuery('SELECT DATE_FORMAT(FROM_UNIXTIME(senddate),"%Y-%m") AS date FROM #__acymailing_mail WHERE senddate IS NOT NULL AND senddate != 0 AND type = "news" GROUP BY date ORDER BY date DESC'); $senddates = acymailing_loadResultArray($database); $sendFilter = array(); $sendFilter[] = JHTML::_('select.option', '0', JText::_('SEND_DATE')); if (!empty($senddates)) { $currentYear = ''; foreach ($senddates as $oneSenddate) { list($year, $month) = explode('-', $oneSenddate); if ($year != $currentYear) { $sendFilter[] = JHTML::_('select.option', $year, '- ' . $year . ' -'); $currentYear = $year; } $sendFilter[] = JHTML::_('select.option', $oneSenddate, JHTML::_('date', strtotime($oneSenddate . '-15'), ACYMAILING_J16 ? 'F' : '%B', false)); } } $filters->date = JHTML::_('select.genericlist', $sendFilter, 'filter_date', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $selectedDate); } $this->assignRef('filters', $filters); $toggleClass = acymailing_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->assignRef('pagination', $pagination); $delay = acymailing_get('type.delaydisp'); $this->assignRef('delay', $delay); $this->assignRef('config', $config); $this->assign('app', $app); if ($this->type == 'autonews') { $frequency = acymailing_get('type.frequency'); $this->assignRef('frequencyType', $frequency); } }
function listing() { global $Itemid; $app = JFactory::getApplication(); $my = JFactory::getUser(); $pathway = $app->getPathway(); $values = new stdClass(); $jsite = JFactory::getApplication('site'); $menus = $jsite->getMenu(); $menu = $menus->getActive(); $config = acymailing_config(); if (empty($menu) and !empty($Itemid)) { $menus->setActive($Itemid); $menu = $menus->getItem($Itemid); } $myItem = empty($Itemid) ? '' : '&Itemid=' . $Itemid; $this->assignRef('item', $myItem); if (is_object($menu)) { jimport('joomla.html.parameter'); $menuparams = new acyParameter($menu->params); } $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->elements = new stdClass(); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".filter_order", 'filter_order', 'a.senddate', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->search = $app->getUserStateFromRequest($paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower($pageInfo->search); $pageInfo->limit->value = $app->getUserStateFromRequest($paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = JRequest::getInt('limitstart', 0); $listClass = acymailing_get('class.list'); $listid = acymailing_getCID('listid'); if (empty($listid) and !empty($menuparams)) { $listid = $menuparams->get('listid'); } if (empty($listid) and acymailing_level(3)) { $listClass = acymailing_get('class.list'); $allAllowedLists = $listClass->getFrontendLists(); if (!empty($allAllowedLists)) { $firstList = reset($allAllowedLists); $listid = $firstList->listid; JRequest::setVar('listid', $listid); } } if (empty($listid)) { return JError::raiseError(404, 'Mailing List not found'); } $oneList = $listClass->get($listid); if (empty($oneList->listid)) { return JError::raiseError(404, 'Mailing List not found : ' . $listid); } $access = new stdClass(); $access->frontEndManament = false; $access->frontEndAccess = true; if (!$access->frontEndManament and (!$oneList->published or !$oneList->visible or !$access->frontEndAccess)) { if (empty($my->id)) { $usercomp = !ACYMAILING_J16 ? 'com_user' : 'com_users'; $uri = JFactory::getURI(); $url = 'index.php?option=' . $usercomp . '&view=login&return=' . base64_encode($uri->toString()); $app->redirect($url, JText::_('ACY_NOTALLOWED')); return false; } else { $app->enqueueMessage(JText::_('ACY_NOTALLOWED'), 'error'); $app->redirect(acymailing_completeLink('lists', false, true)); return false; } } if ($config->get('open_popup', 1)) { JHTML::_('behavior.modal', 'a.modal'); } if (!empty($menuparams)) { $values->suffix = $menuparams->get('pageclass_sfx', ''); $values->page_title = $menuparams->get('page_title'); $values->page_heading = ACYMAILING_J16 ? $menuparams->get('page_heading') : $menuparams->get('page_title'); $values->show_page_heading = ACYMAILING_J16 ? $menuparams->get('show_page_heading', 1) : $menuparams->get('show_page_title', 1); } else { $values->suffix = ''; $values->show_page_heading = 1; } $values->show_description = $config->get('show_description', 1); $values->show_headings = $config->get('show_headings', 1); $values->show_senddate = $config->get('show_senddate', 1); $values->show_colnumber = $config->get('show_colnumber', 1); $values->show_receiveemail = $config->get('show_receiveemail', 0) && acymailing_level(1); $values->filter = $config->get('show_filter', 1); if (empty($values->page_title)) { $values->page_title = $oneList->name; } if (empty($values->page_heading)) { $values->page_heading = $oneList->name; } if (empty($menuparams)) { $pathway->addItem(JText::_('MAILING_LISTS'), acymailing_completeLink('lists')); $pathway->addItem($values->page_title); } elseif (!$menuparams->get('listid')) { $pathway->addItem($values->page_title); } $document = JFactory::getDocument(); $document->setTitle($values->page_title); $link = '&format=feed&limitstart='; if ($config->get('acyrss_format') == 'rss' || $config->get('acyrss_format') == 'both') { $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); } if ($config->get('acyrss_format') == 'atom' || $config->get('acyrss_format') == 'both') { $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); } $db = JFactory::getDBO(); $searchMap = array('a.mailid', 'a.subject', 'a.alias'); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . acymailing_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $filters[] = 'a.type = \'news\''; if (!$access->frontEndManament) { $filters[] = 'a.published = 1'; $filters[] = 'a.visible = 1'; } $filters[] = 'c.listid = ' . $oneList->listid; $selection = array_merge($searchMap, array('a.senddate', 'a.created', 'a.visible', 'a.published', 'a.fromname', 'a.fromemail', 'a.replyname', 'a.replyemail', 'a.userid')); $query = 'SELECT ' . implode(',', $selection); $query .= ' FROM ' . acymailing_table('listmail') . ' as c'; $query .= ' JOIN ' . acymailing_table('mail') . ' as a on a.mailid = c.mailid '; $query .= ' WHERE (' . implode(') AND (', $filters) . ')'; $query .= ' ORDER BY ' . acymailing_secureField($pageInfo->filter->order->value) . ' ' . acymailing_secureField($pageInfo->filter->order->dir) . ', c.mailid DESC'; $db->setQuery($query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $db->loadObjectList(); $pageInfo->elements->page = count($rows); if (!empty($pageInfo->search)) { $rows = acymailing_search($pageInfo->search, $rows); } if ($pageInfo->limit->value > $pageInfo->elements->page) { $pageInfo->elements->total = $pageInfo->limit->start + $pageInfo->elements->page; } else { $queryCount = 'SELECT COUNT(c.mailid) FROM ' . acymailing_table('listmail') . ' as c'; $queryCount .= ' JOIN ' . acymailing_table('mail') . ' as a on a.mailid = c.mailid '; $queryCount .= ' WHERE (' . implode(') AND (', $filters) . ')'; $db->setQuery($queryCount); $pageInfo->elements->total = $db->loadResult(); } jimport('joomla.html.pagination'); $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); $js = 'function tableOrdering( order, dir, task ){ var form = document.adminForm; form.filter_order.value = order; form.filter_order_Dir.value = dir; document.adminForm.submit( task ); } function changeReceiveEmail(checkedbox){ var form = document.adminForm; if(checkedbox){ form.nbreceiveemail.value++; }else{ form.nbreceiveemail.value--; } if(form.nbreceiveemail.value > 0 ){ document.getElementById(\'receiveemailbox\').className = \'receiveemailbox receiveemailbox_visible\'; }else{ document.getElementById(\'receiveemailbox\').className = \'receiveemailbox receiveemailbox_hidden\'; } } '; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); $this->assignRef('access', $access); $this->assignRef('rows', $rows); $this->assignRef('values', $values); $this->assignRef('list', $oneList); $this->assignRef('pagination', $pagination); $this->assignRef('pageInfo', $pageInfo); $this->assignRef('config', $config); $this->assignRef('my', $my); }
function choose() { $pageInfo = new stdClass(); $app = JFactory::getApplication(); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName() . '_' . $this->getLayout() . JRequest::getInt('onlyreg', 0); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->elements = new stdClass(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".filter_order", 'filter_order', 'a.name', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . ".filter_order_Dir", 'filter_order_Dir', 'asc', 'word'); $pageInfo->search = $app->getUserStateFromRequest($paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $pageInfo->limit->value = $app->getUserStateFromRequest($paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($paramBase . '.limitstart', 'limitstart', 0, 'int'); if (empty($pageInfo->limit->value)) { $pageInfo->limit->value = 100; } $db = JFactory::getDBO(); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . acymailing_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $this->searchFields) . " LIKE {$searchVal}"; } if (JRequest::getInt('onlyreg')) { $filters[] = 'a.userid > 0'; } $query = 'SELECT ' . implode(',', $this->selectedFields) . ' FROM #__acymailing_subscriber as a'; $query .= ' LEFT JOIN #__users as b on a.userid = b.id'; if (!empty($filters)) { $query .= ' WHERE (' . implode(') AND (', $filters) . ')'; } if (!empty($pageInfo->filter->order->value)) { $query .= ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } $db->setQuery($query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $db->loadObjectList(); $queryWhere = 'SELECT COUNT(a.subid) FROM #__acymailing_subscriber as a'; if (!empty($filters)) { $queryWhere .= ' LEFT JOIN #__users as b on a.userid = b.id'; $queryWhere .= ' WHERE (' . implode(') AND (', $filters) . ')'; } $db->setQuery($queryWhere); $pageInfo->elements->total = $db->loadResult(); $pageInfo->elements->page = count($rows); jimport('joomla.html.pagination'); $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->assignRef('pagination', $pagination); }
function listing() { $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->elements = new stdClass(); $config = acymailing_config(); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".filter_order", 'filter_order', 'a.mailid', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->search = $app->getUserStateFromRequest($paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower($pageInfo->search); $selectedList = $app->getUserStateFromRequest($paramBase . "filter_list", 'filter_list', 0, 'int'); $selectedCreator = $app->getUserStateFromRequest($paramBase . "filter_creator", 'filter_creator', 0, 'int'); $pageInfo->limit->value = $app->getUserStateFromRequest($paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($paramBase . '.limitstart', 'limitstart', 0, 'int'); $database = JFactory::getDBO(); $searchMap = array('a.mailid', 'a.alias', 'a.subject', 'a.fromname', 'a.fromemail', 'a.replyname', 'a.replyemail', 'a.userid', 'b.name', 'b.username', 'b.email'); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . acymailing_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $filters[] = 'a.type = \'' . $this->type . '\''; if (!empty($selectedList)) { $filters[] = 'c.listid = ' . $selectedList; } if (!empty($selectedCreator)) { $filters[] = 'a.userid = ' . $selectedCreator; } $selection = array_merge($searchMap, array('a.created', 'a.frequency', 'a.senddate', 'a.published', 'a.type', 'a.visible')); if (empty($selectedList)) { $query = 'SELECT ' . implode(',', $selection) . ' FROM ' . acymailing_table('mail') . ' as a'; $queryCount = 'SELECT COUNT(a.mailid) FROM ' . acymailing_table('mail') . ' as a'; } else { $query = 'SELECT ' . implode(',', $selection) . ' FROM ' . acymailing_table('listmail') . ' as c'; $query .= ' JOIN ' . acymailing_table('mail') . ' as a on a.mailid = c.mailid '; $queryCount = 'SELECT COUNT(c.mailid) FROM ' . acymailing_table('listmail') . ' as c'; $queryCount .= ' JOIN ' . acymailing_table('mail') . ' as a on a.mailid = c.mailid '; } $query .= ' LEFT JOIN ' . acymailing_table('users', false) . ' as b on a.userid = b.id '; $query .= ' WHERE (' . implode(') AND (', $filters) . ')'; if (!empty($pageInfo->filter->order->value)) { $query .= ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } if (count($filters) > 1) { $queryCount .= ' LEFT JOIN ' . acymailing_table('users', false) . ' as b on a.userid = b.id '; } $queryCount .= ' WHERE (' . implode(') AND (', $filters) . ')'; $database->setQuery($query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $database->loadObjectList(); if (!empty($pageInfo->search)) { $rows = acymailing_search($pageInfo->search, $rows); } $database->setQuery($queryCount); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); jimport('joomla.html.pagination'); $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); acymailing_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $bar = JToolBar::getInstance('toolbar'); $buttonPreview = JText::_('ACY_PREVIEW'); if ($this->type == 'autonews') { JToolBarHelper::custom('generate', 'process', '', JText::_('GENERATE'), false); } elseif ($this->type == 'news') { $buttonPreview .= ' / ' . JText::_('SEND'); } JToolBarHelper::custom('preview', 'acypreview', '', $buttonPreview, true); JToolBarHelper::divider(); JToolBarHelper::addNew(); JToolBarHelper::editList(); if (acymailing_isAllowed($config->get('acl_' . $this->aclCat . '_delete', 'all'))) { JToolBarHelper::deleteList(JText::_('ACY_VALIDDELETEITEMS')); } JToolBarHelper::spacer(); JToolBarHelper::custom('copy', 'copy.png', 'copy.png', JText::_('ACY_COPY')); JToolBarHelper::divider(); $bar->appendButton('Pophelp', $this->doc); if (acymailing_isAllowed($config->get('acl_cpanel_manage', 'all'))) { $bar->appendButton('Link', 'acymailing', JText::_('ACY_CPANEL'), acymailing_completeLink('dashboard')); } $filters = new stdClass(); $listmailType = acymailing_get('type.listsmail'); $listmailType->type = $this->type; $mailcreatorType = acymailing_get('type.mailcreator'); $mailcreatorType->type = $this->type; $filters->list = $listmailType->display('filter_list', $selectedList); $filters->creator = $mailcreatorType->display('filter_creator', $selectedCreator); $this->assignRef('filters', $filters); $toggleClass = acymailing_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->assignRef('pagination', $pagination); $delay = acymailing_get('type.delaydisp'); $this->assignRef('delay', $delay); $this->assignRef('config', $config); }
function listing(){ $app = JFactory::getApplication(); $config = acymailing_config(); JHTML::_('behavior.modal','a.modal'); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->elements = new stdClass(); $paramBase = ACYMAILING_COMPONENT.'.'.$this->getName().$this->getLayout(); $pageInfo->filter->order->value = $app->getUserStateFromRequest( $paramBase.".filter_order", 'filter_order', '','cmd' ); $pageInfo->filter->order->dir = $app->getUserStateFromRequest( $paramBase.".filter_order_Dir", 'filter_order_Dir', 'desc', 'word' ); if(strtolower($pageInfo->filter->order->dir) !== 'desc') $pageInfo->filter->order->dir = 'asc'; $pageInfo->search = $app->getUserStateFromRequest( $paramBase.".search", 'search', '', 'string' ); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $selectedMail = $app->getUserStateFromRequest( $paramBase."filter_mail",'filter_mail',0,'int'); $selectedUrl = $app->getUserStateFromRequest( $paramBase."filter_url",'filter_url',0,'int'); $pageInfo->limit->value = $app->getUserStateFromRequest( $paramBase.'.list_limit', 'limit', $app->getCfg('list_limit'), 'int' ); $pageInfo->limit->start = $app->getUserStateFromRequest( $paramBase.'.limitstart', 'limitstart', 0, 'int' ); $database = JFactory::getDBO(); $filters = array(); if(!empty($pageInfo->search)){ $searchVal = '\'%'.acymailing_getEscaped($pageInfo->search,true).'%\''; $filters[] = implode(" LIKE $searchVal OR ",$this->searchFields)." LIKE $searchVal"; } if(!empty($selectedMail)) $filters[] = 'a.mailid = '.$selectedMail; if(!empty($selectedUrl)) $filters[] = 'a.urlid = '.$selectedUrl; $query = 'SELECT SQL_CALC_FOUND_ROWS '.implode(' , ',$this->selectFields); $query .= ' FROM '.acymailing_table('urlclick').' as a'; $query .= ' JOIN '.acymailing_table('mail').' as b on a.mailid = b.mailid'; $query .= ' JOIN '.acymailing_table('url').' as c on a.urlid = c.urlid'; if(!empty($filters)) $query .= ' WHERE ('.implode(') AND (',$filters).')'; $query .= ' GROUP BY a.mailid,a.urlid'; if(!empty($pageInfo->filter->order->value)){ $query .= ' ORDER BY '.$pageInfo->filter->order->value.' '.$pageInfo->filter->order->dir; } $database->setQuery($query,$pageInfo->limit->start,$pageInfo->limit->value); $rows = $database->loadObjectList(); $database->setQuery('SELECT FOUND_ROWS()'); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); jimport('joomla.html.pagination'); $pagination = new JPagination( $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value ); $filtersType = new stdClass(); $mailType = acymailing_get('type.urlmail'); $urlType = acymailing_get('type.url'); $filtersType->mail = $mailType->display('filter_mail',$selectedMail); $filtersType->url = $urlType->display('filter_url',$selectedUrl); acymailing_setTitle(JText::_('CLICK_STATISTICS'),'stats','statsurl'); $bar = JToolBar::getInstance('toolbar'); $bar->appendButton( 'Link', 'cancel', JText::_('GLOBAL_STATISTICS'), acymailing_completeLink('stats') ); JToolBarHelper::divider(); $bar->appendButton( 'Pophelp','statsurl-listing'); if(acymailing_isAllowed($config->get('acl_cpanel_manage','all'))) $bar->appendButton( 'Link', 'acymailing', JText::_('ACY_CPANEL'), acymailing_completeLink('dashboard') ); $this->assignRef('filters',$filtersType); $this->assignRef('rows',$rows); $this->assignRef('pageInfo',$pageInfo); $this->assignRef('pagination',$pagination); }
function doexport() { if (!$this->isAllowed('subscriber', 'export')) { return; } JRequest::checkToken() or die('Invalid Token'); acymailing_increasePerf(); $filtersExport = JRequest::getVar('exportfilter', array(), '', 'array'); $listsToExport = JRequest::getVar('exportlists'); $fieldsToExport = JRequest::getVar('exportdata'); $fieldsToExportList = JRequest::getVar('exportdatalist'); $fieldsToExportOthers = JRequest::getVar('exportdataother'); $fieldsToExportGeoloc = JRequest::getVar('exportdatageoloc'); $inseparator = JRequest::getString('exportseparator'); $inseparator = str_replace(array('semicolon', 'colon', 'comma'), array(';', ',', ','), $inseparator); $exportFormat = JRequest::getString('exportformat'); if (!in_array($inseparator, array(',', ';'))) { $inseparator = ';'; } $exportUnsubLists = array(); $exportWaitLists = array(); $exportLists = array(); if (!empty($filtersExport['subscribed'])) { foreach ($listsToExport as $listid => $status) { if ($status == -1) { $exportUnsubLists[] = (int) $listid; } elseif ($status == 2) { $exportWaitLists[] = (int) $listid; } elseif (!empty($status)) { $exportLists[] = (int) $listid; } } } $app = JFactory::getApplication(); if (!$app->isAdmin() && (empty($filtersExport['subscribed']) || empty($exportLists) && empty($exportUnsubLists) && empty($exportWaitLists))) { $listClass = acymailing_get('class.list'); $frontLists = $listClass->getFrontendLists(); foreach ($frontLists as $frontList) { $exportLists[] = (int) $frontList->listid; } } $exportFields = array(); $exportFieldsList = array(); $exportFieldsOthers = array(); $exportFieldsGeoloc = array(); foreach ($fieldsToExport as $fieldName => $checked) { if (!empty($checked)) { $exportFields[] = acymailing_secureField($fieldName); } } foreach ($fieldsToExportList as $fieldName => $checked) { if (!empty($checked)) { $exportFieldsList[] = acymailing_secureField($fieldName); } } if (!empty($fieldsToExportOthers)) { foreach ($fieldsToExportOthers as $fieldName => $checked) { if (!empty($checked)) { $exportFieldsOthers[] = acymailing_secureField($fieldName); } } } if (!empty($fieldsToExportGeoloc)) { foreach ($fieldsToExportGeoloc as $fieldName => $checked) { if (!empty($checked)) { $exportFieldsGeoloc[] = acymailing_secureField($fieldName); } } } $selectFields = 's.`' . implode('`, s.`', $exportFields) . '`'; $config = acymailing_config(); $newConfig = new stdClass(); $newConfig->export_fields = implode(',', array_merge($exportFields, $exportFieldsOthers, $exportFieldsList, $exportFieldsGeoloc)); $newConfig->export_lists = implode(',', $exportLists); $newConfig->export_separator = JRequest::getString('exportseparator'); $newConfig->export_format = $exportFormat; $filterActive = array(); foreach ($filtersExport as $filterKey => $value) { if ($value == 1) { $filterActive[] = $filterKey; } } $newConfig->export_filters = implode(',', $filterActive); $config->save($newConfig); $where = array(); if (empty($exportLists) && empty($exportUnsubLists) && empty($exportWaitLists)) { $querySelect = 'SELECT s.`subid`, ' . $selectFields . ' FROM ' . acymailing_table('subscriber') . ' as s'; } else { $querySelect = 'SELECT DISTINCT s.`subid`, ' . $selectFields . ' FROM ' . acymailing_table('listsub') . ' as a JOIN ' . acymailing_table('subscriber') . ' as s on a.subid = s.subid'; if (!empty($exportLists)) { $conditions[] = 'a.status = 1 AND a.listid IN (' . implode(',', $exportLists) . ')'; } if (!empty($exportUnsubLists)) { $conditions[] = 'a.status = -1 AND a.listid IN (' . implode(',', $exportUnsubLists) . ')'; } if (!empty($exportWaitLists)) { $conditions[] = 'a.status = 2 AND a.listid IN (' . implode(',', $exportWaitLists) . ')'; } if (count($conditions) == 1) { $where[] = $conditions[0]; } else { $where[] = '(' . implode(') OR (', $conditions) . ')'; } } if (!empty($filtersExport['confirmed'])) { $where[] = 's.confirmed = 1'; } if (!empty($filtersExport['registered'])) { $where[] = 's.userid > 0'; } if (!empty($filtersExport['enabled'])) { $where[] = 's.enabled = 1'; } if (JRequest::getInt('sessionvalues') and !empty($_SESSION['acymailing']['exportusers'])) { $where[] = 's.subid IN (' . implode(',', $_SESSION['acymailing']['exportusers']) . ')'; } if (JRequest::getInt('fieldfilters')) { foreach ($_SESSION['acymailing']['fieldfilter'] as $field => $value) { $where[] = 's.' . acymailing_secureField($field) . ' LIKE "%' . acymailing_getEscaped($value, true) . '%"'; } } $query = $querySelect; if (!empty($where)) { $query .= ' WHERE (' . implode(') AND (', $where) . ')'; } if (JRequest::getInt('sessionquery')) { $currentSession = JFactory::getSession(); $selectOthers = ''; if (!empty($exportFieldsOthers)) { foreach ($exportFieldsOthers as $oneField) { $selectOthers .= ' , ' . $oneField . ' AS ' . str_replace('.', '_', $oneField); } } $query = 'SELECT DISTINCT s.`subid`, ' . $selectFields . $selectOthers . ' ' . $currentSession->get('acyexportquery'); } $query .= ' ORDER BY s.subid'; $db = JFactory::getDBO(); $encodingClass = acymailing_get('helper.encoding'); $exportHelper = acymailing_get('helper.export'); $fileName = 'export_' . date('Y-m-d'); if (!empty($exportLists)) { $fileName = ''; $db->setQuery('SELECT name FROM #__acymailing_list WHERE listid IN (' . implode(',', $exportLists) . ')'); $allExportedLists = $db->loadObjectList(); foreach ($allExportedLists as $oneList) { $fileName .= '__' . $oneList->name; } $fileName = trim($fileName, '__'); } $exportHelper->addHeaders($fileName); acymailing_displayErrors(); $eol = "\r\n"; $before = '"'; $separator = '"' . $inseparator . '"'; $after = '"'; $allFields = array_merge($exportFields, $exportFieldsOthers); if (!empty($exportFieldsList)) { $allFields = array_merge($allFields, $exportFieldsList); $selectFields = 'l.`' . implode('`, l.`', $exportFieldsList) . '`'; $selectFields = str_replace('listname', 'name', $selectFields); } if (!empty($exportFieldsGeoloc)) { $allFields = array_merge($allFields, $exportFieldsGeoloc); } $titleLine = $before . implode($separator, $allFields) . $after . $eol; $titleLine = str_replace('listid', 'listids', $titleLine); echo $titleLine; if (acymailing_bytes(ini_get('memory_limit')) > 150000000) { $nbExport = 50000; } elseif (acymailing_bytes(ini_get('memory_limit')) > 80000000) { $nbExport = 15000; } else { $nbExport = 5000; } if (!empty($exportFieldsList)) { $nbExport = 500; } $valDep = 0; $dateFields = array('created', 'confirmed_date', 'lastopen_date', 'lastclick_date', 'lastsent_date', 'userstats_opendate', 'userstats_senddate', 'urlclick_date', 'hist_date'); do { $db->setQuery($query . ' LIMIT ' . $valDep . ', ' . $nbExport); $valDep += $nbExport; $allData = $db->loadAssocList('subid'); if ($allData === false) { echo $eol . $eol . 'Error : ' . $db->getErrorMsg(); } if (empty($allData)) { break; } foreach ($allData as $subid => &$oneUser) { if (!in_array('subid', $exportFields)) { unset($allData[$subid]['subid']); } foreach ($dateFields as &$fieldName) { if (isset($allData[$subid][$fieldName])) { $allData[$subid][$fieldName] = acymailing_getDate($allData[$subid][$fieldName], '%Y-%m-%d %H:%M:%S'); } } } if (!empty($exportFieldsList) && !empty($allData)) { $queryList = 'SELECT ' . $selectFields . ', ls.subid FROM #__acymailing_listsub as ls JOIN #__acymailing_list as l ON ls.listid=l.listid JOIN #__acymailing_subscriber as s on ls.subid = s.subid WHERE (ls.status = 1) and ls.subid IN (' . implode(',', array_keys($allData)) . ')'; if (!empty($exportLists)) { $queryList .= ' AND ls.listid IN (' . implode(',', $exportLists) . ')'; } $db->setQuery($queryList); $resList = $db->loadObjectList(); foreach ($resList as &$listsub) { if (in_array('listid', $exportFieldsList)) { $allData[$listsub->subid]['listid'] = empty($allData[$listsub->subid]['listid']) ? $listsub->listid : $allData[$listsub->subid]['listid'] . ' - ' . $listsub->listid; } if (in_array('listname', $exportFieldsList)) { $allData[$listsub->subid]['listname'] = empty($allData[$listsub->subid]['listname']) ? $listsub->name : $allData[$listsub->subid]['listname'] . ' - ' . $listsub->name; } } unset($resList); } if (!empty($exportFieldsGeoloc) && !empty($allData)) { $orderGeoloc = JRequest::getCmd('exportgeolocorder'); if (strtolower($orderGeoloc) !== 'desc') { $orderGeoloc = 'asc'; } $db->setQuery('SELECT geolocation_subid,' . implode(', ', $exportFieldsGeoloc) . ' FROM (SELECT * FROM #__acymailing_geolocation WHERE geolocation_subid IN (' . implode(',', array_keys($allData)) . ') ORDER BY geolocation_id ' . $orderGeoloc . ') as geoloc GROUP BY geolocation_subid'); $resGeol = $db->loadObjectList(); foreach ($resGeol as $geolData) { foreach ($exportFieldsGeoloc as $geolField) { $allData[$geolData->geolocation_subid][$geolField] = $geolField == 'geolocation_created' ? acymailing_getDate($geolData->{$geolField}, '%Y-%m-%d %H:%M:%S') : $geolData->{$geolField}; } } unset($resGeol); } foreach ($allData as $subid => &$oneUser) { $dataexport = implode($separator, $oneUser); echo $before . $encodingClass->change($dataexport, 'UTF-8', $exportFormat) . $after . $eol; } unset($allData); } while (true); exit; }
$paramBase = ACYMAILING_COMPONENT . '.' . $this->getName() . $this->getLayout(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".filter_order", 'filter_order', '', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); if (strtolower($pageInfo->filter->order->dir) !== 'desc') { $pageInfo->filter->order->dir = 'asc'; } $pageInfo->search = $app->getUserStateFromRequest($paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $selectedMail = $app->getUserStateFromRequest($paramBase . "filter_mail", 'filter_mail', 0, 'int'); $selectedUrl = $app->getUserStateFromRequest($paramBase . "filter_url", 'filter_url', 0, 'int'); $pageInfo->limit->value = $app->getUserStateFromRequest($paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($paramBase . '.limitstart', 'limitstart', 0, 'int'); $database = JFactory::getDBO(); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . acymailing_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $this->detailSearchFields) . " LIKE {$searchVal}"; } if (!empty($selectedMail)) { $filters[] = 'a.mailid = ' . $selectedMail; } if (!empty($selectedUrl)) { $filters[] = 'a.urlid = ' . $selectedUrl; } $query = 'SELECT ' . implode(' , ', $this->detailSelectFields); $query .= ' FROM ' . acymailing_table('urlclick') . ' as a'; $query .= ' JOIN ' . acymailing_table('mail') . ' as b on a.mailid = b.mailid'; $query .= ' JOIN ' . acymailing_table('url') . ' as c on a.urlid = c.urlid'; $query .= ' JOIN ' . acymailing_table('subscriber') . ' as d on a.subid = d.subid'; if (!empty($filters)) { $query .= ' WHERE (' . implode(') AND (', $filters) . ')';
function listing() { $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->elements = new stdClass(); $config = acymailing_config(); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName() . $this->getLayout(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".filter_order", 'filter_order', 'a.ordering', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . ".filter_order_Dir", 'filter_order_Dir', 'asc', 'word'); if (strtolower($pageInfo->filter->order->dir) !== 'desc') { $pageInfo->filter->order->dir = 'asc'; } $pageInfo->search = $app->getUserStateFromRequest($paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $pageInfo->category = $app->getUserStateFromRequest($paramBase . ".category", 'category', '0', 'string'); $pageInfo->limit->value = $app->getUserStateFromRequest($paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($paramBase . '.limitstart', 'limitstart', 0, 'int'); $database = JFactory::getDBO(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . acymailing_getEscaped($pageInfo->search, true) . '%\''; $this->filters[] = "a.name LIKE {$searchVal} OR a.description LIKE {$searchVal} OR a.tempid LIKE {$searchVal}"; } if (!empty($pageInfo->category)) { $this->filters[] = 'a.category LIKE ' . $database->Quote($pageInfo->category); } $query = 'SELECT ' . implode(',', $this->selection) . ' FROM ' . acymailing_table('template') . ' as a'; if (!empty($this->filters)) { $query .= ' WHERE (' . implode(') AND (', $this->filters) . ')'; } if (!empty($pageInfo->filter->order->value)) { $query .= ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } $database->setQuery($query, $pageInfo->limit->start, $pageInfo->limit->value); try { $this->rows = $database->loadObjectList(); } catch (Exception $e) { $this->rows = null; } if ($this->rows === null) { acymailing_display(isset($e) ? $e->getMessage() : substr(strip_tags($database->getErrorMsg()), 0, 200) . '...', 'error'); if (file_exists(ACYMAILING_BACK . 'install.acymailing.php')) { include_once ACYMAILING_BACK . 'install.acymailing.php'; $installClass = new acymailingInstall(); $installClass->fromVersion = '4.1.0'; $installClass->update = true; $installClass->updateSQL(); } } $queryCount = 'SELECT COUNT(a.tempid) FROM ' . acymailing_table('template') . ' as a'; if (!empty($this->filters)) { $queryCount .= ' WHERE (' . implode(') AND (', $this->filters) . ')'; } $database->setQuery($queryCount); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($this->rows); jimport('joomla.html.pagination'); $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); if ($this->button) { acymailing_setTitle(JText::_('ACY_TEMPLATES'), 'acytemplate', 'template'); $bar = JToolBar::getInstance('toolbar'); $bar->appendButton('Acypopup', 'import', JText::_('IMPORT'), "index.php?option=com_acymailing&ctrl=template&task=upload&tmpl=component"); JToolBarHelper::custom('export', 'acyexport', 'acyexport', JText::_('ACY_EXPORT')); JToolBarHelper::divider(); JToolBarHelper::addNew(); JToolBarHelper::editList(); if (acymailing_isAllowed($config->get('acl_templates_delete', 'all'))) { JToolBarHelper::deleteList(JText::_('ACY_VALIDDELETEITEMS', true)); } if (acymailing_isAllowed($config->get('acl_templates_copy', 'all'))) { JToolBarHelper::spacer(); JToolBarHelper::custom('copy', 'copy.png', 'copy.png', JText::_('ACY_COPY')); } JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'template-listing'); if (acymailing_isAllowed($config->get('acl_cpanel_manage', 'all'))) { $bar->appendButton('Link', 'acymailing', JText::_('ACY_CPANEL'), acymailing_completeLink('dashboard')); } } $toggleClass = acymailing_get('helper.toggle'); $order = new stdClass(); $order->ordering = false; $order->orderUp = 'orderup'; $order->orderDown = 'orderdown'; $order->reverse = false; if ($pageInfo->filter->order->value == 'a.ordering') { $order->ordering = true; if ($pageInfo->filter->order->dir == 'desc') { $order->orderUp = 'orderdown'; $order->orderDown = 'orderup'; $order->reverse = true; } } $this->assignRef('order', $order); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('rows', $this->rows); $this->assignRef('pageInfo', $pageInfo); $this->assignRef('pagination', $pagination); }
function listing() { $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->elements = new stdClass(); $config = acymailing_config(); JHTML::_('behavior.modal', 'a.modal'); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName() . $this->getLayout(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".filter_order", 'filter_order', 'a.senddate', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); if (strtolower($pageInfo->filter->order->dir) !== 'desc') { $pageInfo->filter->order->dir = 'asc'; } $pageInfo->search = $app->getUserStateFromRequest($paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $pageInfo->limit->value = $app->getUserStateFromRequest($paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($paramBase . '.limitstart', 'limitstart', 0, 'int'); $database = JFactory::getDBO(); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . acymailing_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $this->searchFields) . " LIKE {$searchVal}"; } $listClass = acymailing_get('class.list'); $lists = $listClass->getLists(); $msgType = array(); $msgType[] = JHTML::_('select.option', '0', JText::_('ALL_EMAILS')); $msgType[] = JHTML::_('select.option', '<OPTGROUP>', JText::_('NEWSLETTER')); $msgType[] = JHTML::_('select.option', 'news', JText::_('ALL_LISTS')); foreach ($lists as $oneList) { $msgType[] = JHTML::_('select.option', 'list_' . $oneList->listid, $oneList->name); } $msgType[] = JHTML::_('select.option', '</OPTGROUP>'); $msgType[] = JHTML::_('select.option', 'notification', JText::_('NOTIFICATIONS')); if (acymailing_level(1)) { $msgType[] = JHTML::_('select.option', 'autonews', JText::_('AUTONEW')); $msgType[] = JHTML::_('select.option', 'joomlanotification', JText::_('JOOMLA_NOTIFICATIONS')); } if (acymailing_level(3)) { $listCampaign = acymailing_get('class.list'); $listCampaign->type = 'campaign'; $campaigns = $listCampaign->getLists(); $msgType[] = JHTML::_('select.option', '<OPTGROUP>', JText::_('FOLLOWUP')); $msgType[] = JHTML::_('select.option', 'followup', JText::_('ACY_ALL_CAMPAIGNS')); foreach ($campaigns as $oneCamp) { $msgType[] = JHTML::_('select.option', 'camp_' . $oneCamp->listid, $oneCamp->name); } $msgType[] = JHTML::_('select.option', '</OPTGROUP>'); } $msgType[] = JHTML::_('select.option', 'welcome', JText::_('MSG_WELCOME')); $msgType[] = JHTML::_('select.option', 'unsub', JText::_('MSG_UNSUB')); $selectedMsgType = $app->getUserStateFromRequest($paramBase . "filter_msg", 'filter_msg', 0, 'string'); $msgTypeChoice = JHTML::_('select.genericlist', $msgType, "filter_msg", 'class="inputbox" style="max-width: 200px;" onchange="document.adminForm.limitstart.value=0;document.adminForm.submit( );"', 'value', 'text', $selectedMsgType); $extraJoin = ''; if (!empty($selectedMsgType)) { $subfilter = substr($selectedMsgType, 0, 5); if ($subfilter == 'camp_' || $subfilter == 'list_') { $filters[] = " b.type = '" . ($subfilter == 'camp_' ? 'followup' : 'news') . "'"; $filters[] = " lm.listid = " . substr($selectedMsgType, 5); $extraJoin = " JOIN #__acymailing_listmail AS lm ON a.mailid = lm.mailid"; } else { $filters[] = " b.type = '" . $selectedMsgType . "'"; } } $query = 'SELECT ' . implode(' , ', $this->selectFields); $query .= ', CASE WHEN (a.senthtml+a.senttext) <= a.bounceunique THEN 0 ELSE (a.openunique/(a.senthtml+a.senttext-a.bounceunique)) END AS openprct'; $query .= ', CASE WHEN (a.senthtml+a.senttext) <= a.bounceunique THEN 0 ELSE (a.clickunique/(a.senthtml+a.senttext-a.bounceunique)) END AS clickprct'; $query .= ', CASE WHEN a.openunique = 0 THEN 0 ELSE (a.clickunique/a.openunique) END AS efficiencyprct'; $query .= ', CASE WHEN (a.senthtml+a.senttext) <= a.bounceunique THEN 0 ELSE (a.unsub/(a.senthtml+a.senttext-a.bounceunique)) END AS unsubprct'; $query .= ', (a.senthtml+a.senttext) as totalsent'; $query .= ', CASE WHEN (a.senthtml+a.senttext) = 0 THEN 0 ELSE (a.bounceunique/(a.senthtml+a.senttext)) END AS bounceprct'; $query .= ' FROM ' . acymailing_table('stats') . ' as a'; $query .= ' JOIN ' . acymailing_table('mail') . ' as b on a.mailid = b.mailid'; if (!empty($extraJoin)) { $query .= $extraJoin; } if (!empty($filters)) { $query .= ' WHERE (' . implode(') AND (', $filters) . ')'; } if (!empty($pageInfo->filter->order->value)) { $query .= ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } $database->setQuery($query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $database->loadObjectList(); if ($rows === null) { acymailing_display(substr(strip_tags($database->getErrorMsg()), 0, 200) . '...', 'error'); if (file_exists(ACYMAILING_BACK . 'install.acymailing.php')) { include_once ACYMAILING_BACK . 'install.acymailing.php'; $installClass = new acymailingInstall(); $installClass->fromVersion = '3.6.0'; $installClass->update = true; $installClass->updateSQL(); } } $queryCount = 'SELECT COUNT(a.mailid) FROM ' . acymailing_table('stats') . ' as a'; if (!empty($pageInfo->search) || !empty($filters)) { $queryCount .= ' JOIN ' . acymailing_table('mail') . ' as b on a.mailid = b.mailid'; if (!empty($extraJoin)) { $queryCount .= $extraJoin; } } if (!empty($filters)) { $queryCount .= ' WHERE (' . implode(') AND (', $filters) . ')'; } $database->setQuery($queryCount); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); jimport('joomla.html.pagination'); $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); $acyToolbar = acymailing::get('helper.toolbar'); $acyToolbar->custom('exportglobal', JText::_('ACY_EXPORT'), 'export', false); if (acymailing_isAllowed($config->get('acl_statistics_delete', 'all'))) { $acyToolbar->delete(); } $acyToolbar->divider(); $acyToolbar->help('statistics'); $acyToolbar->setTitle(JText::_('GLOBAL_STATISTICS'), 'stats'); $acyToolbar->display(); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->assignRef('pagination', $pagination); $this->assign('filterMsg', $msgTypeChoice); }
function acymailinghikashop_show() { $config = acymailing_config(); if ($config->get('version') < '4.9.4') { acymailing_display('Please download and install the latest AcyMailing version otherwise this plugin will NOT work', 'error'); return; } if (!$this->loadAcymailing()) { return 'Please install HikaShop before using the HikaShop tag plugin'; } $app = JFactory::getApplication(); $contentType = array(); $contentType[] = JHTML::_('select.option', "title", JText::_('TITLE_ONLY')); $contentType[] = JHTML::_('select.option', "intro", JText::_('INTRO_ONLY')); $contentType[] = JHTML::_('select.option', "full", JText::_('FULL_TEXT')); $priceDisplay = array(); $priceDisplay[] = JHTML::_('select.option', "full", JText::_('APPLY_DISCOUNTS')); $priceDisplay[] = JHTML::_('select.option', "no_discount", JText::_('NO_DISCOUNT')); $priceDisplay[] = JHTML::_('select.option', "none", JText::_('HIKASHOP_NO')); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $paramBase = ACYMAILING_COMPONENT . '.hikashop'; $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".filter_order", 'filter_order', 'a.product_id', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); if (strtolower($pageInfo->filter->order->dir) !== 'desc') { $pageInfo->filter->order->dir = 'asc'; } $pageInfo->search = $app->getUserStateFromRequest($paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $pageInfo->lang = $app->getUserStateFromRequest($paramBase . ".lang", 'lang', '', 'string'); $pageInfo->contenttype = $app->getUserStateFromRequest($paramBase . ".contenttype", 'contenttype', 'full', 'string'); $pageInfo->pricedisplay = $app->getUserStateFromRequest($paramBase . ".pricedisplay", 'pricedisplay', 'full', 'string'); $pageInfo->limit->value = $app->getUserStateFromRequest($paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($paramBase . '.limitstart', 'limitstart', 0, 'int'); if (!empty($pageInfo->search)) { $searchVal = '\'%' . acymailing_getEscaped($pageInfo->search) . '%\''; $filters[] = "a.product_id LIKE {$searchVal} OR a.product_description LIKE {$searchVal} OR a.product_name LIKE {$searchVal} OR a.product_code LIKE {$searchVal}"; } $whereQuery = ''; if (!empty($filters)) { $whereQuery = ' WHERE (' . implode(') AND (', $filters) . ')'; } $query = 'SELECT SQL_CALC_FOUND_ROWS a.* FROM ' . acymailing_table('hikashop_product', false) . ' as a'; if (!empty($whereQuery)) { $query .= $whereQuery; } if (!empty($pageInfo->filter->order->value)) { $query .= ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } $this->db->setQuery($query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $this->db->loadObjectList(); if (!empty($pageInfo->search)) { $rows = acymailing_search($pageInfo->search, $rows); } $this->db->setQuery('SELECT FOUND_ROWS()'); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $this->db->loadResult(); $pageInfo->elements->page = count($rows); jimport('joomla.html.pagination'); $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); $tabs = acymailing_get('helper.acytabs'); echo $tabs->startPane('hikashop_tab'); echo $tabs->startPanel(JText::_('PRODUCTS'), 'hikashop_product'); ?> <script language="javascript" type="text/javascript"> <!-- function updateTagProd(productid){ var tag = '{hikashop_product:'+productid; for(var i=0; i < document.adminForm.contenttype.length; i++){ if (document.adminForm.contenttype[i].checked){ tag += '|type:'+document.adminForm.contenttype[i].value; } } for(i=0; i < document.adminForm.pricedisplay.length; i++){ if (document.adminForm.pricedisplay[i].checked){ tag += '|price:'+document.adminForm.pricedisplay[i].value; } } if(window.document.getElementById('jflang') && window.document.getElementById('jflang').value != ''){ tag += '|lang:'; tag += window.document.getElementById('jflang').value; } tag += '}'; setTag(tag); insertTag(); } //--> </script> <table> <tr> <td width="100%"> <?php echo JText::_('JOOMEXT_FILTER'); ?> : <input type="text" name="search" id="acymailingsearch" value="<?php echo $pageInfo->search; ?> " class="text_area" onchange="document.adminForm.submit();" /> <button class="btn" onclick="this.form.submit();"><?php echo JText::_('JOOMEXT_GO'); ?> </button> <button class="btn" onclick="document.getElementById('acymailingsearch').value='';this.form.submit();"><?php echo JText::_('JOOMEXT_RESET'); ?> </button> </td> </tr> </table> <table width="100%" class="adminform"> <tr> <td> <?php echo JText::_('DISPLAY'); ?> </td> <td> <?php echo JHTML::_('acyselect.radiolist', $contentType, 'contenttype', 'size="1"', 'value', 'text', $pageInfo->contenttype); ?> </td> <td> <?php $jflanguages = acymailing_get('type.jflanguages'); echo $jflanguages->display('lang', $pageInfo->lang); ?> </td> </tr> <tr> <td> <?php echo JText::_('PRICE'); ?> </td> <td colspan="2"> <?php echo JHTML::_('acyselect.radiolist', $priceDisplay, 'pricedisplay', 'size="1"', 'value', 'text', $pageInfo->pricedisplay); ?> </td> </tr> </table> <table class="adminlist table table-striped" cellpadding="1" width="100%"> <thead> <tr> <th></th> <th class="title"> <?php echo JHTML::_('grid.sort', JText::_('HIKA_NAME'), 'a.product_name', $pageInfo->filter->order->dir, $pageInfo->filter->order->value); ?> </th> <th class="title"> <?php echo JHTML::_('grid.sort', JText::_('HIKA_DESCRIPTION'), 'a.product_description', $pageInfo->filter->order->dir, $pageInfo->filter->order->value); ?> </th> <th class="title titleid"> <?php echo JHTML::_('grid.sort', JText::_('ID'), 'a.product_id', $pageInfo->filter->order->dir, $pageInfo->filter->order->value); ?> </th> </tr> </thead> <tfoot> <tr> <td colspan="4"> <?php echo $pagination->getListFooter(); ?> <?php echo $pagination->getResultsCounter(); ?> </td> </tr> </tfoot> <tbody> <?php $k = 0; for ($i = 0, $a = count($rows); $i < $a; $i++) { $row =& $rows[$i]; ?> <tr id="content<?php echo $row->product_id; ?> " class="<?php echo "row{$k}"; ?> " onclick="updateTagProd(<?php echo $row->product_id; ?> );" style="cursor:pointer;"> <td class="acytdcheckbox"></td> <td> <?php echo acymailing_tooltip('CODE : ' . $row->product_code, $row->product_name, '', $row->product_name); ?> </td> <td> <?php echo $row->product_description; ?> </td> <td align="center"> <?php echo $row->product_id; ?> </td> </tr> <?php $k = 1 - $k; } ?> </tbody> </table> <input type="hidden" name="boxchecked" value="0" /> <input type="hidden" name="filter_order" value="<?php echo $pageInfo->filter->order->value; ?> " /> <input type="hidden" name="filter_order_Dir" value="<?php echo $pageInfo->filter->order->dir; ?> " /> <?php echo $tabs->endPanel(); echo $tabs->startPanel(JText::_('HIKA_CATEGORIES'), 'hikashop_auto'); $type = JRequest::getString('type'); $this->db->setQuery('SELECT * FROM ' . acymailing_table('hikashop_category', false) . ' WHERE category_type=\'product\' ORDER BY `category_ordering` ASC'); $categories = $this->db->loadObjectList('category_id'); $this->cats = array(); foreach ($categories as $oneCat) { $this->cats[$oneCat->category_parent_id][] = $oneCat; } $catClass = hikashop_get('class.category'); $root = $catClass->getRoot(); ?> <script language="javascript" type="text/javascript"> <!-- var selectedCat = new Array(); function applyAutoProduct(catid,rowClass){ if(catid == 'all'){ if(window.document.getElementById('product_cat'+catid).className == 'selectedrow'){ window.document.getElementById('product_catall').className = rowClass; }else{ window.document.getElementById('product_cat'+catid).className = 'selectedrow'; for(var key in selectedCat) { if(!isNaN(key)) { window.document.getElementById('product_cat'+key).className = rowClass; delete selectedCat[key]; } } } }else{ window.document.getElementById('product_catall').className = 'row0'; if(selectedCat[catid]){ window.document.getElementById('product_cat'+catid).className = rowClass; delete selectedCat[catid]; }else{ window.document.getElementById('product_cat'+catid).className = 'selectedrow'; selectedCat[catid] = 'product'; } } updateTagAuto(); } function updateTagAuto(){ var tag = '{hikashop_auto_product:'; for(var icat in selectedCat){ if(selectedCat[icat] == 'product'){ tag += icat+'-'; } } for(var i=0; i < document.adminForm.contenttypeauto.length; i++){ if (document.adminForm.contenttypeauto[i].checked){ tag += '| type:'+document.adminForm.contenttypeauto[i].value; } } if(document.adminForm.min_article && document.adminForm.min_article.value && document.adminForm.min_article.value!=0){ tag += '| min:'+document.adminForm.min_article.value; } if(document.adminForm.max_article.value && document.adminForm.max_article.value!=0){ tag += '| max:'+document.adminForm.max_article.value; } if(document.adminForm.contentorder.value){ tag += "| order:"+document.adminForm.contentorder.value+","+document.adminForm.contentorderdir.value; } if(document.adminForm.contentfilter && document.adminForm.contentfilter.value){ tag += '| filter:'+document.adminForm.contentfilter.value; } if(window.document.getElementById('jflang_auto') && window.document.getElementById('jflang_auto').value != ''){ tag += '| lang:'+window.document.getElementById('jflang_auto').value; } for(i=0; i < document.adminForm.pricedisplayauto.length; i++){ if (document.adminForm.pricedisplayauto[i].checked){ tag += '| price:'+document.adminForm.pricedisplayauto[i].value; } } tag += '}'; setTag(tag); } //--> </script> <table width="100%" class="adminform"> <tr> <td> <?php echo JText::_('DISPLAY'); ?> </td> <td colspan="2"> <?php echo JHTML::_('acyselect.radiolist', $contentType, 'contenttypeauto', 'size="1" onclick="updateTagAuto();"', 'value', 'text', 'full'); ?> </td> <td> <?php $jflanguages = acymailing_get('type.jflanguages'); if (!empty($jflanguages->values)) { $jflanguages->id = 'jflang_auto'; $jflanguages->onclick = 'onchange="updateTagAuto();"'; echo $jflanguages->display('language'); } ?> </td> </tr> <tr> <td> <?php echo JText::_('PRICE'); ?> </td> <td colspan="3"> <?php echo JHTML::_('acyselect.radiolist', $priceDisplay, 'pricedisplayauto', 'size="1" onclick="updateTagAuto();"', 'value', 'text', 'full'); ?> </td> </tr> <tr> <td> <label for="max_article"><?php echo JText::_('MAX_ARTICLE'); ?> </label> </td> <td> <input type="text" name="max_article" id="max_article" style="width:50px" value="" onchange="updateTagAuto();"/> </td> <td> <?php echo JText::_('ACY_ORDER'); ?> </td> <td> <?php $values = array('product_id' => 'ACY_ID', 'product_created' => 'CREATED_DATE', 'product_modified' => 'MODIFIED_DATE', 'product_name' => 'HIKA_TITLE'); echo $this->acypluginsHelper->getOrderingField($values, 'product_id', 'DESC'); ?> </td> </tr> <?php if ($type == 'autonews') { ?> <tr> <td> <label for="min_article"><?php echo JText::_('MIN_ARTICLE'); ?> </label> </td> <td> <input type="text" name="min_article" id="min_article" style="width:50px" value="1" onchange="updateTagAuto();"/> </td> <td> <?php echo JText::_('FILTER'); ?> </td> <td> <?php $filter = acymailing_get('type.contentfilter'); $filter->onclick = 'updateTagAuto();'; echo $filter->display('contentfilter', 'created', false); ?> </td> </tr> <?php } ?> </table> <table class="adminlist table table-striped" cellpadding="1" width="100%"> <tr id="product_catall" class="<?php echo "row0"; ?> " onclick="applyAutoProduct('all','<?php echo "row{$k}"; ?> ');" style="cursor:pointer;"> <td class="acytdcheckbox"></td> <td><?php echo JText::_('ACY_ALL'); ?> </td> </tr> <?php $k = 0; echo $this->displayChildren($root, $k); ?> </table> <?php echo $tabs->endPanel(); echo $tabs->startPanel(JText::_('COUPONS'), 'hikashop_coupon'); $currency = hikashop_get('type.currency'); $config =& hikashop_config(); ?> <script language="javascript" type="text/javascript"> <!-- function updateTag(){ var tagname = document.adminForm.minimum_order.value+'|'; tagname += document.adminForm.quota.value+'|'; tagname += document.adminForm.start.value+'|'; tagname += document.adminForm.end.value+'|'; tagname += document.adminForm.percent_amount.value+'|'; tagname += document.adminForm.flat_amount.value+'|'; tagname += document.adminForm.currency_id.value+'|'; tagname += document.adminForm.coupon_code.value+'|'; tagname += document.adminForm.product_id.value; setTag('{hikashop_coupon:'+tagname+'}'); } //--> </script> <table class="admintable" width="700px" style="margin:auto"> <tr> <td> <table class="admintable" style="margin:auto"> <tr> <td class="key"> <label for="coupon_code"> <?php echo JText::_('DISCOUNT_CODE'); ?> </label> </td> <td> <input type="text" id="coupon_code" onchange="updateTag();" value="[name][key][value]" /> </td> </tr> <tr> <td class="key"> <label for="flat_amount"> <?php echo JText::_('DISCOUNT_FLAT_AMOUNT'); ?> </label> </td> <td> <input style="width:50px;" type="text" id="flat_amount" onchange="updateTag();" value="0" /><?php echo $currency->display('currency_id', (int) $config->get('main_currency'), ' style="width:100px;" '); ?> </td> </tr> <tr> <td class="key"> <label for="percent_amount"> <?php echo JText::_('DISCOUNT_PERCENT_AMOUNT'); ?> </label> </td> <td> <input style="width:50px;" type="text" id="percent_amount" onchange="updateTag();" value="0" /> </td> </tr> </table> </td> <td> <table class="admintable" style="margin:auto"> <tr> <td class="key"> <label for="start"> <?php echo JText::_('DISCOUNT_START_DATE'); ?> </label> </td> <td> <?php echo JHTML::_('calendar', '', 'start', 'start', '%Y-%m-%d %H:%M', array('style' => 'width:100px', 'onchange' => 'updateTag();')); ?> </td> </tr> <tr> <td class="key"> <label for="end"> <?php echo JText::_('DISCOUNT_END_DATE'); ?> </label> </td> <td> <?php echo JHTML::_('calendar', '', 'end', 'end', '%Y-%m-%d %H:%M', array('style' => 'width:100px', 'onchange' => 'updateTag();')); ?> </td> </tr> <?php if (hikashop_level(1)) { ?> <tr> <td class="key"> <label for="minimum_order"> <?php echo JText::_('MINIMUM_ORDER_VALUE'); ?> </label> </td> <td> <input style="width:50px;" type="text" id="minimum_order" value="0" onchange="updateTag();" /> </td> </tr> <tr> <td class="key"> <label for="quota"> <?php echo JText::_('DISCOUNT_QUOTA'); ?> </label> </td> <td> <input style="width:50px;" type="text" id="quota" value="" onchange="updateTag();" /> </td> </tr> <tr> <td class="key"> <label for="product_id"> <?php echo JText::_('PRODUCT'); ?> </label> </td> <td> <?php $this->db->setQuery("SELECT `product_id`, CONCAT(product_name,' ( ',product_code,' )') as `title` FROM #__hikashop_product WHERE `product_type`='main' AND `product_published`=1 ORDER BY `product_code` ASC"); $results = $this->db->loadObjectList(); $obj = new stdClass(); $obj->product_id = ''; $obj->title = JText::_('HIKA_NONE'); array_unshift($results, $obj); echo JHTML::_('select.genericlist', $results, 'product_id', 'size="1" style="width:150px;" onchange="updateTag();"', 'product_id', 'title', ''); ?> </td> </tr> <?php } else { ?> <tr> <td> <input type="hidden" id="minimum_order" value="0" /> <input type="hidden" id="quota" value="" /> </td> </tr> <?php } ?> </table> </td> </tr> </table> <?php echo $tabs->endPanel(); echo $tabs->endPane(); }
function delete($elements) { if (!is_array($elements)) { $elements = array($elements); } if (empty($elements)) { return 0; } foreach ($elements as $key => $val) { $elements[$key] = acymailing_getEscaped($val); } $column = is_numeric(reset($elements)) ? $this->pkey : $this->namekey; if (empty($column) or empty($this->pkey) or empty($this->tables) or empty($elements)) { return false; } $whereIn = ' WHERE ' . $column . ' IN (' . implode(',', $elements) . ')'; $result = true; foreach ($this->tables as $oneTable) { $query = 'DELETE FROM ' . acymailing_table($oneTable) . $whereIn; $this->database->setQuery($query); $result = $this->database->query() && $result; } if (!$result) { return false; } return $this->database->getAffectedRows(); }
function listing() { $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->elements = new stdClass(); $config = acymailing_config(); JHTML::_('behavior.modal', 'a.modal'); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName() . $this->getLayout(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".filter_order", 'filter_order', 'a.senddate', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); if (strtolower($pageInfo->filter->order->dir) !== 'desc') { $pageInfo->filter->order->dir = 'asc'; } $pageInfo->search = $app->getUserStateFromRequest($paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $pageInfo->limit->value = $app->getUserStateFromRequest($paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($paramBase . '.limitstart', 'limitstart', 0, 'int'); $database = JFactory::getDBO(); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . acymailing_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $this->searchFields) . " LIKE {$searchVal}"; } $query = 'SELECT ' . implode(' , ', $this->selectFields); $query .= ', CASE WHEN (a.senthtml+a.senttext-a.bounceunique) = 0 THEN 0 ELSE (a.openunique/(a.senthtml+a.senttext-a.bounceunique)) END AS openprct'; $query .= ', CASE WHEN (a.senthtml+a.senttext-a.bounceunique) = 0 THEN 0 ELSE (a.clickunique/(a.senthtml+a.senttext-a.bounceunique)) END AS clickprct'; $query .= ', CASE WHEN a.openunique = 0 THEN 0 ELSE (a.clickunique/a.openunique) END AS efficiencyprct'; $query .= ', CASE WHEN (a.senthtml+a.senttext-a.bounceunique) = 0 THEN 0 ELSE (a.unsub/(a.senthtml+a.senttext-a.bounceunique)) END AS unsubprct'; $query .= ', (a.senthtml+a.senttext) as totalsent'; $query .= ', CASE WHEN (a.senthtml+a.senttext) = 0 THEN 0 ELSE (a.bounceunique/(a.senthtml+a.senttext)) END AS bounceprct'; $query .= ' FROM ' . acymailing_table('stats') . ' as a'; $query .= ' JOIN ' . acymailing_table('mail') . ' as b on a.mailid = b.mailid'; if (!empty($filters)) { $query .= ' WHERE (' . implode(') AND (', $filters) . ')'; } if (!empty($pageInfo->filter->order->value)) { $query .= ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } $database->setQuery($query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $database->loadObjectList(); if ($rows === null) { acymailing_display(substr(strip_tags($database->getErrorMsg()), 0, 200) . '...', 'error'); if (file_exists(ACYMAILING_BACK . 'install.acymailing.php')) { include_once ACYMAILING_BACK . 'install.acymailing.php'; $installClass = new acymailingInstall(); $installClass->fromVersion = '3.6.0'; $installClass->update = true; $installClass->updateSQL(); } } $queryCount = 'SELECT COUNT(a.mailid) FROM ' . acymailing_table('stats') . ' as a'; if (!empty($pageInfo->search)) { $queryCount .= ' JOIN ' . acymailing_table('mail') . ' as b on a.mailid = b.mailid'; } if (!empty($filters)) { $queryCount .= ' WHERE (' . implode(') AND (', $filters) . ')'; } $database->setQuery($queryCount); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); jimport('joomla.html.pagination'); $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); acymailing_setTitle(JText::_('GLOBAL_STATISTICS'), 'stats', 'stats'); $bar = JToolBar::getInstance('toolbar'); JToolBarHelper::custom('exportglobal', 'acyexport', '', JText::_('ACY_EXPORT'), false); JToolBarHelper::spacer(); if (acymailing_isAllowed($config->get('acl_statistics_delete', 'all'))) { JToolBarHelper::deleteList(JText::_('ACY_VALIDDELETEITEMS')); } JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'statistics'); if (acymailing_isAllowed($config->get('acl_cpanel_manage', 'all'))) { $bar->appendButton('Link', 'acymailing', JText::_('ACY_CPANEL'), acymailing_completeLink('dashboard')); } $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->assignRef('pagination', $pagination); }
function listing() { global $Itemid; $app = JFactory::getApplication(); $my = JFactory::getUser(); $values = new stdClass(); $jsite = JFactory::getApplication('site'); $menus = $jsite->getMenu(); $menu = $menus->getActive(); if (empty($menu) and !empty($Itemid)) { $menus->setActive($Itemid); $menu = $menus->getItem($Itemid); } $myItem = empty($Itemid) ? '' : '&Itemid=' . $Itemid; $this->assignRef('item', $myItem); if (is_object($menu)) { jimport('joomla.html.parameter'); $menuparams = new acyParameter($menu->params); } $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->elements = new stdClass(); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName(); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . ".ordering_dir", 'ordering_dir', 'DESC', 'word'); $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".ordering", 'ordering', 'senddate', 'cmd'); if (strtolower($pageInfo->filter->order->dir) !== 'desc') { $pageInfo->filter->order->dir = 'asc'; } $pageInfo->search = $app->getUserStateFromRequest($paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $pageInfo->limit->value = $app->getUserStateFromRequest($paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = JRequest::getInt('limitstart', 0); $listClass = acymailing_get('class.list'); $listid = acymailing_getCID('listid'); if (empty($listid) and !empty($menuparams)) { $listid = $menuparams->get('listid'); } if (empty($listid)) { $allLists = $listClass->getLists('listid'); } else { $oneList = $listClass->get($listid); if (empty($oneList->listid)) { return JError::raiseError(404, 'Mailing List not found : ' . $listid); } $allLists = array($oneList->listid => $oneList); if ($oneList->access_sub != 'all' && ($oneList->access_sub == 'none' || empty($my->id) || !acymailing_isAllowed($oneList->access_sub))) { $allLists = array(); } } if (empty($allLists)) { if (empty($my->id)) { $usercomp = ACYMAILING_J16 ? 'com_users' : 'com_user'; $uri = JFactory::getURI(); $app->redirect('index.php?option=' . $usercomp . '&view=login&return=' . base64_encode($uri->toString()), JText::_('ACY_NOTALLOWED')); } else { $app->enqueueMessage(JText::_('ACY_NOTALLOWED'), 'error'); $app->redirect(acymailing_completeLink('lists', false, true)); } return false; } $doc = JFactory::getDocument(); $db = JFactory::getDBO(); $pathway = $app->getPathway(); $config = acymailing_config(); if (!empty($menuparams)) { $values->suffix = $menuparams->get('pageclass_sfx', ''); $values->page_title = $menuparams->get('page_title'); $values->page_heading = ACYMAILING_J16 ? $menuparams->get('page_heading') : $menuparams->get('page_title'); $values->show_page_heading = ACYMAILING_J16 ? $menuparams->get('show_page_heading', 1) : $menuparams->get('show_page_title', 1); } else { $values->suffix = ''; $values->show_page_heading = 1; } $values->show_description = $config->get('show_description', 1); $values->show_senddate = $config->get('show_senddate', 1); $values->show_receiveemail = $config->get('show_receiveemail', 0) && acymailing_level(1); $values->filter = $config->get('show_filter', 1); if (empty($values->page_title)) { $values->page_title = count($allLists) > 1 || empty($listid) ? JText::_('NEWSLETTERS') : $allLists[$listid]->name; } if (empty($values->page_heading)) { $values->page_heading = count($allLists) > 1 || empty($listid) ? JText::_('NEWSLETTERS') : $allLists[$listid]->name; } if (empty($menuparams)) { $pathway->addItem(JText::_('MAILING_LISTS'), acymailing_completeLink('lists')); $pathway->addItem($values->page_title); } elseif (!$menuparams->get('listid')) { $pathway->addItem($values->page_title); } acymailing_setPageTitle($values->page_title); $this->addFeed(); $searchMap = array('a.mailid', 'a.subject', 'a.alias'); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . acymailing_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $filters[] = 'a.type = \'news\''; $noManageableLists = array(); foreach ($allLists as &$oneList) { if (empty($my->id)) { $noManageableLists[] = $oneList->listid; } if ((int) $my->id == (int) $oneList->userid) { continue; } if ($oneList->access_manage == 'all' || acymailing_isAllowed($oneList->access_manage)) { continue; } $noManageableLists[] = $oneList->listid; } $accessFilter = ''; $manageableLists = array_diff(array_keys($allLists), $noManageableLists); if (!empty($manageableLists)) { $accessFilter = 'c.listid IN (' . implode(',', $manageableLists) . ')'; } if (!empty($noManageableLists)) { if (empty($accessFilter)) { $accessFilter = 'c.listid IN (' . implode(',', $noManageableLists) . ') AND a.published = 1 AND a.visible = 1'; } else { $accessFilter .= ' OR (c.listid IN (' . implode(',', $noManageableLists) . ') AND a.published = 1 AND a.visible = 1)'; } } if (!empty($accessFilter)) { $filters[] = $accessFilter; } if ($config->get('open_popup', 1) || !empty($manageableLists)) { JHTML::_('behavior.modal', 'a.modal'); } $selection = array_merge($searchMap, array('a.senddate', 'a.created', 'a.visible', 'a.published', 'a.fromname', 'a.fromemail', 'a.replyname', 'a.replyemail', 'a.userid', 'a.summary', 'a.thumb', 'c.listid')); $query = 'SELECT "" AS body, "" AS altbody, html AS sendHTML, ' . implode(',', $selection); $query .= ' FROM ' . acymailing_table('listmail') . ' as c'; $query .= ' JOIN ' . acymailing_table('mail') . ' as a on a.mailid = c.mailid '; $query .= ' WHERE (' . implode(') AND (', $filters) . ')'; $query .= ' GROUP BY c.mailid'; $query .= ' ORDER BY a.' . acymailing_secureField($pageInfo->filter->order->value) . ' ' . acymailing_secureField($pageInfo->filter->order->dir) . ', c.mailid DESC'; $db->setQuery($query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $db->loadObjectList(); $pageInfo->elements->page = count($rows); if ($pageInfo->limit->value > $pageInfo->elements->page) { $pageInfo->elements->total = $pageInfo->limit->start + $pageInfo->elements->page; } else { $queryCount = 'SELECT COUNT(DISTINCT c.mailid) FROM ' . acymailing_table('listmail') . ' as c'; $queryCount .= ' JOIN ' . acymailing_table('mail') . ' as a on a.mailid = c.mailid '; $queryCount .= ' WHERE (' . implode(') AND (', $filters) . ')'; $db->setQuery($queryCount); $pageInfo->elements->total = $db->loadResult(); } if (!empty($my->email)) { $userClass = acymailing_get('class.subscriber'); $receiver = $userClass->get($my->email); } if (empty($receiver)) { $receiver = new stdClass(); $receiver->name = JText::_('VISITOR'); } JPluginHelper::importPlugin('acymailing'); $dispatcher = JDispatcher::getInstance(); foreach ($rows as $mail) { if (strpos($mail->subject, "{") !== false) { $dispatcher->trigger('acymailing_replacetags', array(&$mail, false)); $dispatcher->trigger('acymailing_replaceusertags', array(&$mail, &$receiver, false)); } } jimport('joomla.html.pagination'); $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); $js = 'function tableOrdering( order, dir, task ){ var form = document.adminForm; form.filter_order.value = order; form.filter_order_Dir.value = dir; document.adminForm.submit( task ); } function changeReceiveEmail(checkedbox){ var form = document.adminForm; if(checkedbox){ form.nbreceiveemail.value++; }else{ form.nbreceiveemail.value--; } if(form.nbreceiveemail.value > 0 ){ document.getElementById(\'receiveemailbox\').className = \'receiveemailbox receiveemailbox_visible\'; }else{ document.getElementById(\'receiveemailbox\').className = \'receiveemailbox receiveemailbox_hidden\'; } } '; $doc->addScriptDeclaration($js); $orderValues = array(); $orderValues[] = JHTML::_('select.option', 'senddate', JText::_('SEND_DATE')); $orderValues[] = JHTML::_('select.option', 'subject', JText::_('JOOMEXT_SUBJECT')); $orderValues[] = JHTML::_('select.option', 'created', JText::_('CREATED_DATE')); $orderValues[] = JHTML::_('select.option', 'mailid', JText::_('ACY_ID')); $ordering = '<span style="float:right;" id="orderingoption">'; $ordering .= JHTML::_('select.genericlist', $orderValues, 'ordering', 'size="1" style="width:100px;" onchange="this.form.submit();"', 'value', 'text', $pageInfo->filter->order->value); $orderDir = array(); $orderDir[] = JHTML::_('select.option', 'ASC', 'ASC'); $orderDir[] = JHTML::_('select.option', 'DESC', 'DESC'); $ordering .= ' ' . JHTML::_('select.genericlist', $orderDir, 'ordering_dir', 'size="1" style="width:75px;" onchange="this.form.submit();"', 'value', 'text', $pageInfo->filter->order->dir); $ordering .= '</span>'; $this->assignRef('ordering', $ordering); $this->assignRef('rows', $rows); $this->assignRef('values', $values); if (count($allLists) > 1) { $list = new stdClass(); $list->listid = 0; $list->description = ''; } else { $list = array_pop($allLists); } $this->assignRef('list', $list); $this->assignRef('manageableLists', $manageableLists); $this->assignRef('pagination', $pagination); $this->assignRef('pageInfo', $pageInfo); $this->assignRef('config', $config); $this->assignRef('my', $my); }
function delete($elements) { if (!is_array($elements)) { $elements = array($elements); } if (empty($elements)) { return 0; } foreach ($elements as $key => $val) { $elements[$key] = acymailing_getEscaped($val); } $column = is_numeric(reset($elements)) ? $this->pkey : $this->namekey; if (empty($column) or empty($this->pkey) or empty($this->tables) or empty($elements)) { return false; } $whereIn = ' WHERE ' . $column . ' IN (' . implode(',', $elements) . ')'; $result = true; JPluginHelper::importPlugin('acymailing'); $dispatcher = JDispatcher::getInstance(); foreach ($this->tables as $oneTable) { $dispatcher->trigger('onAcyBefore' . ucfirst($oneTable) . 'Delete', array(&$elements)); $query = 'DELETE FROM ' . acymailing_table($oneTable) . $whereIn; $this->database->setQuery($query); $result = $this->database->query() && $result; } if (!$result) { return false; } return $this->database->getAffectedRows(); }
function listing() { $app = JFactory::getApplication(); $config = acymailing_config(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->elements = new stdClass(); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".filter_order", 'filter_order', 'a.ordering', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . ".filter_order_Dir", 'filter_order_Dir', 'asc', 'word'); if (strtolower($pageInfo->filter->order->dir) !== 'desc') { $pageInfo->filter->order->dir = 'asc'; } $pageInfo->search = $app->getUserStateFromRequest($paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $selectedCreator = $app->getUserStateFromRequest($paramBase . "filter_creator", 'filter_creator', 0, 'int'); $selectedCategory = $app->getUserStateFromRequest($paramBase . "filter_category", 'filter_category', 0, 'string'); $pageInfo->limit->value = $app->getUserStateFromRequest($paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($paramBase . '.limitstart', 'limitstart', 0, 'int'); $database = JFactory::getDBO(); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . acymailing_getEscaped($pageInfo->search, true) . '%\''; $filters[] = "a.name LIKE {$searchVal} OR a.description LIKE {$searchVal} OR a.listid LIKE {$searchVal}"; } $filters[] = "a.type = 'list'"; if (!empty($selectedCreator)) { $filters[] = 'a.userid = ' . $selectedCreator; } if (!empty($selectedCategory)) { $filters[] = 'a.category = ' . $database->Quote($selectedCategory); } $query = 'SELECT a.*, d.name as creatorname, d.username, d.email'; $query .= ' FROM ' . acymailing_table('list') . ' as a'; $query .= ' LEFT JOIN ' . acymailing_table('users', false) . ' as d on a.userid = d.id'; $query .= ' WHERE (' . implode(') AND (', $filters) . ')'; if (!empty($pageInfo->filter->order->value)) { $query .= ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } $database->setQuery($query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $database->loadObjectList(); $queryCount = 'SELECT COUNT(a.listid) FROM ' . acymailing_table('list') . ' as a'; if (!empty($pageInfo->search)) { $queryCount .= ' LEFT JOIN ' . acymailing_table('users', false) . ' as d on a.userid = d.id'; } $queryCount .= ' WHERE (' . implode(') AND (', $filters) . ')'; $database->setQuery($queryCount); $pageInfo->elements->total = $database->loadResult(); $listids = array(); foreach ($rows as $oneRow) { $listids[] = $oneRow->listid; } $subscriptionresults = array(); if (!empty($listids)) { $querySubscription = 'SELECT count(subid) as total,listid,status FROM ' . acymailing_table('listsub') . ' WHERE listid IN (' . implode(',', $listids) . ') GROUP BY listid, status'; $database->setQuery($querySubscription); $countresults = $database->loadObjectList(); foreach ($countresults as $oneResult) { $subscriptionresults[$oneResult->listid][intval($oneResult->status)] = $oneResult->total; } } foreach ($rows as $i => $oneRow) { $rows[$i]->nbsub = intval(@$subscriptionresults[$oneRow->listid][1]); $rows[$i]->nbunsub = intval(@$subscriptionresults[$oneRow->listid][-1]); $rows[$i]->nbwait = intval(@$subscriptionresults[$oneRow->listid][2]); } $pageInfo->elements->page = count($rows); jimport('joomla.html.pagination'); $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); acymailing_setTitle(JText::_('LISTS'), 'acylist', 'list'); $bar = JToolBar::getInstance('toolbar'); if (acymailing_isAllowed($config->get('acl_lists_filter', 'all'))) { $bar->appendButton('Link', 'filter', JText::_('ACY_FILTERS'), acymailing_completeLink('filter')); JToolBarHelper::divider(); } if (acymailing_isAllowed($config->get('acl_lists_manage', 'all'))) { JToolBarHelper::addNew(); } if (acymailing_isAllowed($config->get('acl_lists_manage', 'all'))) { JToolBarHelper::editList(); } if (acymailing_isAllowed($config->get('acl_lists_delete', 'all'))) { JToolBarHelper::deleteList(JText::_('ACY_VALIDDELETEITEMS')); } JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'list-listing'); if (acymailing_isAllowed($config->get('acl_cpanel_manage', 'all'))) { $bar->appendButton('Link', 'acymailing', JText::_('ACY_CPANEL'), acymailing_completeLink('dashboard')); } $order = new stdClass(); $order->ordering = false; $order->orderUp = 'orderup'; $order->orderDown = 'orderdown'; $order->reverse = false; if ($pageInfo->filter->order->value == 'a.ordering') { $order->ordering = true; if ($pageInfo->filter->order->dir == 'desc') { $order->orderUp = 'orderdown'; $order->orderDown = 'orderup'; $order->reverse = true; } } $filters = new stdClass(); $listcreatorType = acymailing_get('type.listcreator'); $filters->creator = $listcreatorType->display('filter_creator', $selectedCreator); $listcategoryType = acymailing_get('type.categoryfield'); $filters->category = $listcategoryType->getFilter('list', 'filter_category', $selectedCategory, ' onchange="document.adminForm.submit();"'); $this->assignRef('filters', $filters); $this->assignRef('order', $order); $toggleClass = acymailing_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->assignRef('pagination', $pagination); }
function getSubscribersByEmail() { $app = JFactory::getApplication(); $NameSearched = JRequest::getString('search', ''); if (empty($NameSearched) || !$app->isAdmin() || !$this->isAllowed('subscriber', 'view')) { exit; } $db = JFactory::getDBO(); $NameSearched = '\'%' . acymailing_getEscaped($NameSearched, true) . '%\''; $db->setQuery('SELECT name, email FROM #__acymailing_subscriber WHERE email LIKE ' . $NameSearched . ' OR name LIKE ' . $NameSearched . ' ORDER BY email ASC LIMIT 30'); $users = $db->loadObjectList(); if (empty($users)) { exit; } echo '<table style="width:100%;">'; foreach ($users as $oneUser) { echo '<tr class="row_user" onclick="setUser(\'' . str_replace("'", "\\'", $oneUser->email) . '\');"><td>' . htmlspecialchars($oneUser->name, ENT_COMPAT, 'UTF-8') . '</td><td>' . htmlspecialchars($oneUser->email, ENT_COMPAT, 'UTF-8') . '</td></tr>'; } echo '</table>'; exit; }
function listing(){ global $Itemid; $app = JFactory::getApplication(); $my = JFactory::getUser(); $pathway = $app->getPathway(); $values = new stdClass(); $jsite = JFactory::getApplication('site'); $menus = $jsite->getMenu(); $menu = $menus->getActive(); $config = acymailing_config(); if(empty($menu) AND !empty($Itemid)){ $menus->setActive($Itemid); $menu = $menus->getItem($Itemid); } $myItem = empty($Itemid) ? '' : '&Itemid='.$Itemid; $this->assignRef('item',$myItem); if (is_object( $menu )) { jimport('joomla.html.parameter'); $menuparams = new acyParameter( $menu->params ); } $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->elements = new stdClass(); $paramBase = ACYMAILING_COMPONENT.'.'.$this->getName(); $pageInfo->filter->order->dir = $app->getUserStateFromRequest( $paramBase.".filter_order_Dir", 'filter_order_Dir', 'desc', 'word' ); if(strtolower($pageInfo->filter->order->dir) !== 'desc') $pageInfo->filter->order->dir = 'asc'; $pageInfo->search = $app->getUserStateFromRequest( $paramBase.".search", 'search', '', 'string' ); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $pageInfo->limit->value = $app->getUserStateFromRequest( $paramBase.'.list_limit', 'limit', $app->getCfg('list_limit'), 'int' ); $pageInfo->limit->start = JRequest::getInt('limitstart',0); $listClass = acymailing_get('class.list'); $listid = acymailing_getCID('listid'); if(empty($listid) AND !empty($menuparams)){ $listid = $menuparams->get('listid'); } if(empty($listid) AND acymailing_level(3)){ $listClass = acymailing_get('class.list'); $allAllowedLists = $listClass->getFrontendLists(); if(!empty($allAllowedLists)){ $firstList = reset($allAllowedLists); $listid = $firstList->listid; JRequest::setVar('listid',$listid); } } if(empty($listid)){ return JError::raiseError( 404, 'Mailing List not found' ); } $oneList = $listClass->get($listid); if(empty($oneList->listid)){ return JError::raiseError( 404, 'Mailing List not found : '.$listid ); } $access = new stdClass(); $access->frontEndManagement = false; $access->frontEndAccess = true; if(acymailing_level(3)){ if(!empty($my->id) AND (int)$my->id == (int)$oneList->userid){ $access->frontEndManagement = true; } if(!empty($my->id)){ if($oneList->access_manage == 'all' OR acymailing_isAllowed($oneList->access_manage)){ $access->frontEndManagement = true; } } if($oneList->access_sub != 'all' AND ($oneList->access_sub == 'none' OR empty($my->id) OR !acymailing_isAllowed($oneList->access_sub))){ $access->frontEndAccess = false; } if($access->frontEndManagement) JHTML::_('behavior.modal','a.modal'); } $doc = JFactory::getDocument(); $js = "function refreshCaptcha(){ var captchaLink = document.getElementById('captcha_picture').src; myregexp = new RegExp('val[-=]([0-9]+)'); valToChange=captchaLink.match(myregexp)[1]; document.getElementById('captcha_picture').src = captchaLink.replace(valToChange,valToChange+'0'); }"; $doc->addScriptDeclaration( $js ); if(!$access->frontEndManagement AND (!$oneList->published OR !$oneList->visible OR !$access->frontEndAccess)){ if(empty($my->id)){ $usercomp = !ACYMAILING_J16 ? 'com_user' : 'com_users'; $uri = JFactory::getURI(); $url = 'index.php?option='.$usercomp.'&view=login&return='.base64_encode($uri->toString()); $app->redirect($url, JText::_('ACY_NOTALLOWED') ); return false; }else{ $app->enqueueMessage(JText::_('ACY_NOTALLOWED'),'error'); $app->redirect(acymailing_completeLink('lists',false,true)); return false; } } if($config->get('open_popup',1)) JHTML::_('behavior.modal','a.modal'); if(!empty($menuparams)){ $values->suffix = $menuparams->get('pageclass_sfx',''); $values->page_title = $menuparams->get('page_title'); $values->page_heading = ACYMAILING_J16 ? $menuparams->get('page_heading') : $menuparams->get('page_title'); $values->show_page_heading = ACYMAILING_J16 ? $menuparams->get('show_page_heading',1) : $menuparams->get('show_page_title',1); }else{ $values->suffix = ''; $values->show_page_heading = 1; } $values->show_description = $config->get('show_description',1); $values->show_senddate = $config->get('show_senddate',1); $values->show_receiveemail = $config->get('show_receiveemail',0) && acymailing_level(1); $values->filter = $config->get('show_filter',1); if(empty($values->page_title)) $values->page_title = $oneList->name; if(empty($values->page_heading)) $values->page_heading = $oneList->name; if(empty($menuparams)){ $pathway->addItem(JText::_('MAILING_LISTS'),acymailing_completeLink('lists')); $pathway->addItem($values->page_title); }elseif(!$menuparams->get('listid')){ $pathway->addItem($values->page_title); } $document = JFactory::getDocument(); acymailing_setPageTitle($values->page_title); $this->addFeed(); $db = JFactory::getDBO(); $pageInfo->filter->order->value = $app->getUserStateFromRequest( $paramBase.".filter_order", 'filter_order', $access->frontEndManagement ? 'a.mailid' : 'a.senddate','cmd' ); $searchMap = array('a.mailid','a.subject','a.alias'); $filters = array(); if(!empty($pageInfo->search)){ $searchVal = '\'%'.acymailing_getEscaped($pageInfo->search,true).'%\''; $filters[] = implode(" LIKE $searchVal OR ",$searchMap)." LIKE $searchVal"; } $filters[] = 'a.type = \'news\''; if(!$access->frontEndManagement){ $filters[] = 'a.published = 1'; $filters[] = 'a.visible = 1'; } $filters[] = 'c.listid = '.$oneList->listid; $selection = array_merge($searchMap,array('a.senddate','a.created','a.visible','a.published','a.fromname','a.fromemail','a.replyname','a.replyemail','a.userid','a.summary','a.thumb')); $query = 'SELECT "" AS body, "" AS altbody, html AS sendHTML, '.implode(',',$selection); $query .= ' FROM '.acymailing_table('listmail').' as c'; $query .= ' JOIN '.acymailing_table('mail').' as a on a.mailid = c.mailid '; $query .= ' WHERE ('.implode(') AND (',$filters).')'; $query .= ' ORDER BY '.acymailing_secureField($pageInfo->filter->order->value).' '.acymailing_secureField($pageInfo->filter->order->dir).', c.mailid DESC'; $db->setQuery($query,$pageInfo->limit->start,$pageInfo->limit->value); $rows = $db->loadObjectList(); $pageInfo->elements->page = count($rows); if($pageInfo->limit->value > $pageInfo->elements->page){ $pageInfo->elements->total = $pageInfo->limit->start + $pageInfo->elements->page; }else{ $queryCount = 'SELECT COUNT(c.mailid) FROM '.acymailing_table('listmail').' as c'; $queryCount .= ' JOIN '.acymailing_table('mail').' as a on a.mailid = c.mailid '; $queryCount .= ' WHERE ('.implode(') AND (',$filters).')'; $db->setQuery($queryCount); $pageInfo->elements->total = $db->loadResult(); } if(!empty($my->email)){ $userClass = acymailing_get('class.subscriber'); $receiver = $userClass->get($my->email); } if(empty($receiver)){ $receiver = new stdClass(); $receiver->name = JText::_('VISITOR'); } JPluginHelper::importPlugin('acymailing'); $dispatcher = JDispatcher::getInstance(); foreach($rows as $mail){ if(strpos($mail->subject, "{") !== false){ $dispatcher->trigger('acymailing_replacetags',array(&$mail, false)); $dispatcher->trigger('acymailing_replaceusertags',array(&$mail,&$receiver, false)); } } jimport('joomla.html.pagination'); $pagination = new JPagination( $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value ); $js = 'function tableOrdering( order, dir, task ){ var form = document.adminForm; form.filter_order.value = order; form.filter_order_Dir.value = dir; document.adminForm.submit( task ); } function changeReceiveEmail(checkedbox){ var form = document.adminForm; if(checkedbox){ form.nbreceiveemail.value++; }else{ form.nbreceiveemail.value--; } if(form.nbreceiveemail.value > 0 ){ document.getElementById(\'receiveemailbox\').className = \'receiveemailbox receiveemailbox_visible\'; }else{ document.getElementById(\'receiveemailbox\').className = \'receiveemailbox receiveemailbox_hidden\'; } } '; $doc = JFactory::getDocument(); $doc->addScriptDeclaration( $js); $this->assignRef('access',$access); $this->assignRef('rows',$rows); $this->assignRef('values',$values); $this->assignRef('list',$oneList); $this->assignRef('pagination',$pagination); $this->assignRef('pageInfo',$pageInfo); $this->assignRef('config',$config); $this->assignRef('my',$my); }
public function acymailing_generateautonews(&$email) { $acypluginsHelper = acymailing_get('helper.acyplugins'); $return = new stdClass(); $return->status = true; $return->message = ''; $time = time(); $match = '#{autocontent:(.*)}#Ui'; $variables = array('subject', 'body', 'altbody'); $found = false; foreach ($variables as $var) { if (empty($email->{$var})) { continue; } $found = preg_match_all($match, $email->{$var}, $results[$var]) || $found; if (empty($results[$var][0])) { unset($results[$var]); } } if (!$found) { return $return; } $this->tags = array(); $db = JFactory::getDBO(); foreach ($results as $var => $allresults) { foreach ($allresults[0] as $i => $oneTag) { if (isset($this->tags[$oneTag])) { continue; } $parameter = $acypluginsHelper->extractTag($allresults[1][$i]); $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[] = (int) $oneCat; } } $query = 'SELECT a.id FROM `#__content` as a '; $where = array(); 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)) { $db->setQuery('SELECT lft,rgt FROM #__categories WHERE id IN (' . implode(',', $selectedArea) . ')'); $catinfos = $db->loadObjectList(); if (!empty($catinfos)) { $whereCats = array(); foreach ($catinfos as $onecat) { $whereCats[] = 'lft > ' . $onecat->lft . ' AND rgt < ' . $onecat->rgt; } $db->setQuery('SELECT id FROM #__categories WHERE (' . implode(') OR (', $whereCats) . ')'); $othercats = acymailing_loadResultArray($db); $selectedArea = array_merge($selectedArea, $othercats); } } if (!empty($selectedArea)) { if (!ACYMAILING_J16) { $where[] = implode(' OR ', $selectedArea); } else { $where[] = '`catid` IN (' . implode(',', $selectedArea) . ')'; } } if (!empty($parameter->excludedcats)) { $excludedCats = explode('-', $parameter->excludedcats); JArrayHelper::toInteger($excludedCats); $where[] = '`catid` NOT IN ("' . implode('","', $excludedCats) . '")'; } if (!empty($parameter->filter) and !empty($email->params['lastgenerateddate'])) { $condition = '`publish_up` >\'' . date('Y-m-d H:i:s', $email->params['lastgenerateddate'] - date('Z')) . '\''; $condition .= ' OR `created` >\'' . date('Y-m-d H:i:s', $email->params['lastgenerateddate'] - date('Z')) . '\''; if ($parameter->filter == 'modify') { $condition .= ' OR ('; $condition .= ' `modified` > \'' . date('Y-m-d H:i:s', $email->params['lastgenerateddate'] - date('Z')) . '\''; if (!empty($parameter->maxpublished)) { $condition .= ' AND `publish_up` > \'' . date('Y-m-d H:i:s', time() - date('Z') - (int) $parameter->maxpublished * 60 * 60 * 24) . '\''; } $condition .= ')'; } $where[] = $condition; } if (!empty($parameter->maxcreated)) { $date = strtotime($parameter->maxcreated); if (empty($date)) { acymailing_display('Wrong date format (' . $parameter->maxcreated . ' in ' . $oneTag . '), please use YYYY-MM-DD', 'warning'); } $where[] = '`created` < ' . $db->Quote(date('Y-m-d H:i:s', $date)); } if (!empty($parameter->mincreated)) { $date = strtotime($parameter->mincreated); if (empty($date)) { acymailing_display('Wrong date format (' . $parameter->mincreated . ' in ' . $oneTag . '), please use YYYY-MM-DD', 'warning'); } $where[] = '`created` > ' . $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_up` < \'' . date('Y-m-d H:i:s', $time - date('Z')) . '\''; $where[] = '`publish_down` > \'' . date('Y-m-d H:i:s', $time - date('Z')) . '\' OR `publish_down` = 0'; $where[] = 'state = 1'; 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)) { $where[] = 'access = ' . intval($parameter->access); } if (!empty($parameter->language)) { $allLanguages = explode(',', $parameter->language); $langWhere = 'language IN ('; foreach ($allLanguages as $oneLanguage) { $langWhere .= $db->Quote(trim($oneLanguage)) . ','; } $where[] = trim($langWhere, ',') . ')'; } $query .= ' WHERE (' . implode(') AND (', $where) . ')'; if (!empty($parameter->order)) { if ($parameter->order == 'rand') { $query .= ' ORDER BY rand()'; } else { $ordering = explode(',', $parameter->order); $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; $db->setQuery($query); $allArticles = acymailing_loadResultArray($db); if (!empty($parameter->min) and 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->type)) { $args[] = 'type:' . $parameter->type; } 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->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->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; } $arrayElements[] = '{' . implode('|', $args) . '}'; } $stringTag = $acypluginsHelper->getFormattedResult($arrayElements, $parameter); } } $this->tags[$oneTag] = $stringTag; } } return $return; }
function listing() { JHTML::_('behavior.modal', 'a.modal'); $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->elements = new stdClass(); $config = acymailing_config(); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".filter_order", 'filter_order', 'a.senddate', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . ".filter_order_Dir", 'filter_order_Dir', 'asc', 'word'); $pageInfo->search = $app->getUserStateFromRequest($paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $selectedMail = $app->getUserStateFromRequest($paramBase . "filter_mail", 'filter_mail', 0, 'int'); $pageInfo->limit->value = $app->getUserStateFromRequest($paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($paramBase . '.limitstart', 'limitstart', 0, 'int'); $database = JFactory::getDBO(); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . acymailing_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $this->searchFields) . " LIKE {$searchVal}"; } if (!empty($selectedMail)) { $filters[] = 'a.mailid = ' . intval($selectedMail); } $query = 'SELECT ' . implode(' , ', $this->selectFields); $query .= ' FROM ' . acymailing_table('queue') . ' as a'; $query .= ' JOIN ' . acymailing_table('subscriber') . ' as b on a.subid = b.subid'; $query .= ' JOIN ' . acymailing_table('mail') . ' as c on a.mailid = c.mailid'; if (!empty($filters)) { $query .= ' WHERE (' . implode(') AND (', $filters) . ')'; } if (!empty($pageInfo->filter->order->value)) { $query .= ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir . ', a.`subid` ASC'; } if (empty($pageInfo->limit->value)) { $pageInfo->limit->value = 100; } $database->setQuery($query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $database->loadObjectList(); $pageInfo->elements->page = count($rows); if ($pageInfo->limit->value > $pageInfo->elements->page) { $pageInfo->elements->total = $pageInfo->limit->start + $pageInfo->elements->page; } else { $queryCount = 'SELECT COUNT(a.mailid) FROM ' . acymailing_table('queue') . ' as a'; if (!empty($pageInfo->search)) { $queryCount .= ' JOIN ' . acymailing_table('subscriber') . ' as b on a.subid = b.subid'; $queryCount .= ' JOIN ' . acymailing_table('mail') . ' as c on a.mailid = c.mailid'; } if (!empty($filters)) { $queryCount .= ' WHERE (' . implode(') AND (', $filters) . ')'; } $database->setQuery($queryCount); $pageInfo->elements->total = $database->loadResult(); } jimport('joomla.html.pagination'); $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); $mailqueuetype = acymailing_get('type.queuemail'); $filtersType = new stdClass(); $filtersType->mail = $mailqueuetype->display('filter_mail', $selectedMail); acymailing_setTitle(JText::_('QUEUE'), 'process', 'queue'); $bar = JToolBar::getInstance('toolbar'); if (acymailing_isAllowed($config->get('acl_queue_process', 'all'))) { $bar->appendButton('Acypopup', 'process', JText::_('PROCESS'), "index.php?option=com_acymailing&ctrl=queue&task=process&tmpl=component&mailid=" . $selectedMail); } if (!empty($pageInfo->elements->total) and acymailing_isAllowed($config->get('acl_queue_delete', 'all'))) { JToolBarHelper::spacer(); JToolBarHelper::spacer(); $bar->appendButton('Confirm', JText::sprintf('CONFIRM_DELETE_QUEUE', $pageInfo->elements->total), 'delete', JText::_('ACY_DELETE'), 'remove', false, false); } JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'queue-listing'); if (acymailing_isAllowed($config->get('acl_cpanel_manage', 'all'))) { $bar->appendButton('Link', 'acymailing', JText::_('ACY_CPANEL'), acymailing_completeLink('dashboard')); } $toggleClass = acymailing_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('filters', $filtersType); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->assignRef('pagination', $pagination); }
function listing() { $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->elements = new stdClass(); $config = acymailing_config(); JHTML::_('behavior.modal', 'a.modal'); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName() . $this->getLayout(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".filter_order", 'filter_order', 'a.senddate', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->search = $app->getUserStateFromRequest($paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower($pageInfo->search); $pageInfo->limit->value = $app->getUserStateFromRequest($paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($paramBase . '.limitstart', 'limitstart', 0, 'int'); $database = JFactory::getDBO(); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . acymailing_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $this->searchFields) . " LIKE {$searchVal}"; } $query = 'SELECT ' . implode(' , ', $this->selectFields); $query .= ' FROM ' . acymailing_table('stats') . ' as a'; $query .= ' JOIN ' . acymailing_table('mail') . ' as b on a.mailid = b.mailid'; if (!empty($filters)) { $query .= ' WHERE (' . implode(') AND (', $filters) . ')'; } if (!empty($pageInfo->filter->order->value)) { $query .= ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } $database->setQuery($query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $database->loadObjectList(); $queryCount = 'SELECT COUNT(a.mailid) FROM ' . acymailing_table('stats') . ' as a'; if (!empty($pageInfo->search)) { $queryCount .= ' JOIN ' . acymailing_table('mail') . ' as b on a.mailid = b.mailid'; } if (!empty($filters)) { $queryCount .= ' WHERE (' . implode(') AND (', $filters) . ')'; } $database->setQuery($queryCount); $pageInfo->elements->total = $database->loadResult(); if (!empty($pageInfo->search)) { $rows = acymailing_search($pageInfo->search, $rows); } $pageInfo->elements->page = count($rows); jimport('joomla.html.pagination'); $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); acymailing_setTitle(JText::_('GLOBAL_STATISTICS'), 'stats', 'stats'); $bar = JToolBar::getInstance('toolbar'); if (acymailing_level(1)) { $bar->appendButton('Link', 'stats', JText::_('CHARTS'), acymailing_completeLink('diagram')); } JToolBarHelper::spacer(); JToolBarHelper::spacer(); if (acymailing_isAllowed($config->get('acl_statistics_delete', 'all'))) { JToolBarHelper::deleteList(JText::_('ACY_VALIDDELETEITEMS')); } JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'stats-listing'); if (acymailing_isAllowed($config->get('acl_cpanel_manage', 'all'))) { $bar->appendButton('Link', 'acymailing', JText::_('ACY_CPANEL'), acymailing_completeLink('dashboard')); } $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->assignRef('pagination', $pagination); }