public static function getMails() { $db = JFactory::getDbo(); $query = "SELECT * FROM " . acymailing::table('mail') . " WHERE published = 1 AND visible = 1"; $db->setQuery($query); return $db->loadObjectList(); }
function listing() { $app =& JFactory::getApplication(); $pageInfo = null; $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".filter_order", 'filter_order', 'a.listid', '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); $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(); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . $database->getEscaped($pageInfo->search) . '%\''; $filters[] = "a.name LIKE {$searchVal} OR a.description LIKE {$searchVal} OR a.listid LIKE {$searchVal}"; } $filters[] = 'a.type = \'campaign\''; if (!empty($selectedCreator)) { $filters[] = 'a.userid = ' . $selectedCreator; } $query = 'SELECT SQL_CALC_FOUND_ROWS 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) . ') '; $query .= ' GROUP BY a.listid'; 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(); if (!empty($pageInfo->search)) { $rows = acymailing::search($pageInfo->search, $rows); } $pageInfo->elements->page = count($rows); $followupClass = acymailing::get('class.listmail'); if (!empty($rows)) { foreach ($rows as $id => $onerow) { $rows[$id]->followup = $followupClass->getFollowup($onerow->listid); } } jimport('joomla.html.pagination'); $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); acymailing::setTitle(JText::_('CAMPAIGN'), 'campaign', 'campaign'); JToolBarHelper::addNew(); JToolBarHelper::editList(); JToolBarHelper::deleteList(JText::_('VALIDDELETEITEMS', true)); JToolBarHelper::divider(); $bar =& JToolBar::getInstance('toolbar'); $bar->appendButton('Pophelp', 'campaign-listing'); $bar->appendButton('Link', 'acymailing', JText::_('JOOMEXT_CPANEL'), acymailing::completeLink('dashboard')); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->assignRef('pagination', $pagination); $this->assignRef('toggleClass', acymailing::get('helper.toggle')); $this->assignRef('delay', acymailing::get('type.delaydisp')); }
function acymailingtagsubscriber_show() { $descriptions['subid'] = JText::_('SUBSCRIBER_ID'); $descriptions['email'] = JText::_('SUBSCRIBER_EMAIL'); $descriptions['name'] = JText::_('SUBSCRIBER_NAME'); $descriptions['userid'] = JText::_('SUBSCRIBER_USERID'); $descriptions['ip'] = JText::_('SUBSCRIBER_IP'); $descriptions['created'] = JText::_('SUBSCRIBER_CREATED'); $text = '<table class="adminlist" cellpadding="1">'; $db =& JFactory::getDBO(); $tableInfos = $db->getTableFields(acymailing::table('subscriber')); $others = array(); $others['{subtag:name|part:first|ucfirst}'] = array('name' => JText::_('SUBSCRIBER_FIRSTPART'), 'desc' => JText::_('SUBSCRIBER_FIRSTPART') . ' ' . JText::_('SUBSCRIBER_FIRSTPART_DESC')); $others['{subtag:name|part:last|ucfirst}'] = array('name' => JText::_('SUBSCRIBER_LASTPART'), 'desc' => JText::_('SUBSCRIBER_LASTPART') . ' ' . JText::_('SUBSCRIBER_LASTPART_DESC')); $k = 0; $fields = reset($tableInfos); foreach ($fields as $fieldname => $oneField) { if (!isset($descriptions[$fieldname]) and $oneField != 'varchar') { continue; } $type = ''; if ($fieldname == 'created') { $type = '|type:time'; } $text .= '<tr style="cursor:pointer" class="row' . $k . '" onclick="setTag(\'{subtag:' . $fieldname . $type . '}\');insertTag();" ><td>' . $fieldname . '</td><td>' . @$descriptions[$fieldname] . '</td></tr>'; $k = 1 - $k; } foreach ($others as $tagname => $tag) { $text .= '<tr style="cursor:pointer" class="row' . $k . '" onclick="setTag(\'' . $tagname . '\');insertTag();" ><td>' . $tag['name'] . '</td><td>' . $tag['desc'] . '</td></tr>'; $k = 1 - $k; } $text .= '</table>'; echo $text; }
function addClick($urlid, $mailid, $subid) { $mailid = intval($mailid); $urlid = intval($urlid); $subid = intval($subid); if (empty($mailid) or empty($urlid) or empty($subid)) { return false; } $statsClass = acymailing::get('class.stats'); $statsClass->countReturn = false; if (!$statsClass->saveStats()) { return false; } $date = time(); $query = 'INSERT IGNORE INTO ' . acymailing::table('urlclick') . ' (urlid,mailid,subid,date,click) VALUES (' . $urlid . ',' . $mailid . ',' . $subid . ',' . $date . ',1)'; $this->database->setQuery($query); $this->database->query(); if (!$this->database->getAffectedRows()) { $query = 'UPDATE ' . acymailing::table('urlclick') . ' SET click = click +1,`date` = ' . $date . ' WHERE mailid = ' . $mailid . ' AND urlid = ' . $urlid . ' AND subid = ' . $subid . ' LIMIT 1'; $this->database->setQuery($query); $this->database->query(); } $query = 'SELECT SUM(click) FROM ' . acymailing::table('urlclick') . ' WHERE mailid = ' . $mailid . ' AND subid = ' . $subid; $this->database->setQuery($query); $totalUserClick = $this->database->loadResult(); $query = 'UPDATE ' . acymailing::table('stats') . ' SET clicktotal = clicktotal + 1 '; if ($totalUserClick <= 1) { $query .= ' , clickunique = clickunique + 1'; } $query .= ' WHERE mailid = ' . $mailid . ' LIMIT 1'; $this->database->setQuery($query); $this->database->query(); return true; }
function saveStats() { $subid = JRequest::getInt('subid'); $mailid = JRequest::getInt('mailid'); if (empty($subid) or empty($mailid)) { return false; } $db = JFactory::getDBO(); $db->setQuery('SELECT open FROM ' . acymailing::table('userstats') . ' WHERE mailid = ' . $mailid . ' AND subid = ' . $subid . ' LIMIT 1'); $actual = $db->loadObject(); if (empty($actual)) { return false; } $open = 0; if (empty($actual->open)) { $open = 1; $unique = ',openunique = openunique +1'; } elseif ($this->countReturn) { $open = $actual->open + 1; $unique = ''; } if (empty($open)) { return true; } $db->setQuery('UPDATE ' . acymailing::table('userstats') . ' SET open = ' . $open . ', opendate = ' . time() . ' WHERE mailid = ' . $mailid . ' AND subid = ' . $subid . ' LIMIT 1'); $db->query(); $db->setQuery('UPDATE ' . acymailing::table('stats') . ' SET opentotal = opentotal +1 ' . $unique . ' WHERE mailid = ' . $mailid . ' LIMIT 1'); $db->query(); return true; }
function get($urlid) { $column = is_numeric($urlid) ? 'urlid' : 'url'; $query = 'SELECT * FROM ' . acymailing::table('url') . ' WHERE ' . $column . ' = ' . $this->database->Quote($urlid) . ' LIMIT 1'; $this->database->setQuery($query); return $this->database->loadObject(); }
function generate() { $app =& JFactory::getApplication(); $autoNewsHelper = acymailing::get('helper.autonews'); if (!$autoNewsHelper->generate()) { $app->enqueueMessage(JText::_('NO_AUTONEWS'), 'notice'); $db =& JFactory::getDBO(); $db->setQuery("SELECT * FROM " . acymailing::table('mail') . " WHERE `type` = 'autonews'"); $allAutonews = $db->loadObjectList(); if (!empty($allAutonews)) { $time = time(); foreach ($allAutonews as $oneAutonews) { if ($oneAutonews->published != 1) { $app->enqueueMessage(JText::sprintf('AUTONEWS_NOT_PUBLISHED', $oneAutonews->subject), 'notice'); } elseif ($oneAutonews->senddate >= $time) { $app->enqueueMessage(JText::sprintf('AUTONEWS_NOT_READY', $oneAutonews->subject), 'notice'); } } } } else { foreach ($autoNewsHelper->messages as $oneMessage) { $app->enqueueMessage($oneMessage); } } return $this->listing(); }
function export() { $listClass = acymailing::get('class.list'); $db =& JFactory::getDBO(); $fields = reset($db->getTableFields(acymailing::table('subscriber'))); acymailing::setTitle(JText::_('ACY_EXPORT'), 'acyexport', 'data&task=export'); $bar =& JToolBar::getInstance('toolbar'); JToolBarHelper::custom('doexport', 'acyexport', '', JText::_('ACY_EXPORT'), false); $bar->appendButton('Link', 'cancel', JText::_('ACY_CANCEL'), acymailing::completeLink('subscriber')); JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'data-export'); $this->assignRef('charset', $charsetType = acymailing::get('type.charset')); $this->assignRef('lists', $listClass->getLists()); $this->assignRef('fields', $fields); if (JRequest::getInt('sessionvalues') and !empty($_SESSION['acymailing']['exportusers'])) { $i = 1; $subids = array(); foreach ($_SESSION['acymailing']['exportusers'] as $subid) { $subids[] = (int) $subid; $i++; if ($i > 10) { break; } } $db->setQuery('SELECT `name`,`email` FROM `#__acymailing_subscriber` WHERE `subid` IN (' . implode(',', $subids) . ')'); $users = $db->loadObjectList(); $this->assignRef('users', $users); } }
function save($list) { if (empty($list->listid)) { if (empty($list->userid)) { $user =& JFactory::getUser(); $list->userid = $user->id; } if (empty($list->alias)) { $list->alias = $list->name; } } if (isset($list->alias)) { if (empty($list->alias)) { $list->alias = $list->name; } $list->alias = JFilterOutput::stringURLSafe(trim($list->alias)); } if (empty($list->listid)) { $status = $this->database->insertObject(acymailing::table('list'), $list); } else { $status = $this->database->updateObject(acymailing::table('list'), $list, 'listid'); } if ($status) { return empty($list->listid) ? $this->database->insertid() : $list->listid; } return false; }
function insert($subid, $action, $data = array()) { $user =& JFactory::getUser(); if (!empty($user->id)) { $data[] = 'EXECUTED_BY::' . $user->id . ' ( ' . $user->username . ' )'; } $history = null; $history->subid = intval($subid); $history->action = strip_tags($action); $history->data = implode("\n", $data); $history->date = time(); $userHelper = acymailing::get('helper.user'); $history->ip = $userHelper->getIP(); if (!empty($_SERVER)) { $source = array(); $vars = array('HTTP_REFERER', 'HTTP_USER_AGENT', 'HTTP_HOST', 'SERVER_ADDR', 'REMOTE_ADDR', 'REQUEST_URI', 'QUERY_STRING'); foreach ($vars as $oneVar) { if (!empty($_SERVER[$oneVar])) { $source[] = $oneVar . '::' . strip_tags($_SERVER[$oneVar]); } } $history->source = implode("\n", $source); } return $this->database->insertObject(acymailing::table('history'), $history); }
function listsType() { $query = 'SELECT name,listid,color,description FROM ' . acymailing::table('list') . ' WHERE type = \'list\' ORDER BY ordering ASC'; $db =& JFactory::getDBO(); $db->setQuery($query); $this->data = $db->loadObjectList('listid'); $this->values = array(); $this->values[] = JHTML::_('select.option', '0', JText::_('ALL_LISTS')); foreach ($this->data as $onelist) { $this->values[] = JHTML::_('select.option', $onelist->listid, $onelist->name); } }
function welcomeType() { $query = 'SELECT `subject`, `mailid` FROM ' . acymailing::table('mail') . ' WHERE `type`= \'welcome\''; $db =& JFactory::getDBO(); $db->setQuery($query); $messages = $db->loadObjectList(); $this->values = array(); $this->values[] = JHTML::_('select.option', '0', JText::_('NO_WELCOME_MESSAGE')); foreach ($messages as $oneMessage) { $this->values[] = JHTML::_('select.option', $oneMessage->mailid, '[' . $oneMessage->mailid . '] ' . $oneMessage->subject); } }
function save($configObject) { $query = 'REPLACE INTO ' . acymailing::table('config') . ' (namekey,value) VALUES '; $params = array(); foreach ($configObject as $namekey => $value) { $this->values[$namekey]->value = $value; $params[] = '(' . $this->database->Quote(strip_tags($namekey)) . ',' . $this->database->Quote(strip_tags($value, '<br/>')) . ')'; } $query .= implode(',', $params); $this->database->setQuery($query); return $this->database->query(); }
function queuemailType() { $query = 'SELECT count(distinct a.subid) as totalsub, b.subject, a.mailid FROM ' . acymailing::table('queue') . ' as a'; $query .= ' LEFT JOIN ' . acymailing::table('mail') . ' as b on a.mailid = b.mailid GROUP BY a.mailid ORDER BY b.subject ASC'; $db =& JFactory::getDBO(); $db->setQuery($query); $emails = $db->loadObjectList(); $this->values = array(); $this->values[] = JHTML::_('select.option', '0', JText::_('ALL_EMAILS')); foreach ($emails as $oneMail) { $this->values[] = JHTML::_('select.option', $oneMail->mailid, $oneMail->subject . ' ( ' . $oneMail->totalsub . ' )'); } }
function detailstatsmailType() { $query = 'SELECT DISTINCT b.subject, a.mailid FROM ' . acymailing::table('userstats') . ' as a'; $query .= ' LEFT JOIN ' . acymailing::table('mail') . ' as b on a.mailid = b.mailid ORDER BY a.senddate DESC'; $db =& JFactory::getDBO(); $db->setQuery($query); $emails = $db->loadObjectList(); $this->values = array(); $this->values[] = JHTML::_('select.option', '0', JText::_('ALL_EMAILS')); foreach ($emails as $oneMail) { $this->values[] = JHTML::_('select.option', $oneMail->mailid, $oneMail->subject); } }
function display($tpl = null) { global $Itemid; $db =& JFactory::getDBO(); $app =& JFactory::getApplication(); $document =& JFactory::getDocument(); $params =& $app->getParams(); $feedEmail = @$app->getCfg('feed_email') ? $app->getCfg('feed_email') : 'author'; $siteEmail = $app->getCfg('mailfrom'); $menus =& JSite::getMenu(); $menu = $menus->getActive(); if (empty($menu) and !empty($Itemid)) { $menus->setActive($Itemid); $menu = $menus->getItem($Itemid); } $myItem = empty($Itemid) ? '' : '&Itemid=' . $Itemid; if (is_object($menu)) { jimport('joomla.html.parameter'); $menuparams = new JParameter($menu->params); } $listid = acymailing::getCID('listid'); if (empty($listid) and !empty($menuparams)) { $listid = $menuparams->get('listid'); } $document->link = acymailing::completeLink('archive&listid=' . intval($listid)); $listClass = acymailing::get('class.list'); 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); } if (!acymailing::isAllowed($oneList->access_sub) || !$oneList->published || !$oneList->visible) { return JError::raiseError(404, JText::_('ACY_NOTALLOWED')); } $filters = array(); $filters[] = 'a.type = \'news\''; $filters[] = 'a.published = 1'; $filters[] = 'a.visible = 1'; $filters[] = 'c.listid = ' . $oneList->listid; $query = 'SELECT a.*'; $query .= ' FROM ' . acymailing::table('listmail') . ' as c'; $query .= ' LEFT JOIN ' . acymailing::table('mail') . ' as a on a.mailid = c.mailid '; $query .= ' WHERE (' . implode(') AND (', $filters) . ')'; $query .= ' ORDER BY a.senddate DESC, c.mailid DESC'; $db->setQuery($query, 0, $app->getCfg('feed_limit')); $rows = $db->loadObjectList(); foreach ($rows as $row) { } }
function filterType() { $db =& JFactory::getDBO(); $types = array('group', 'list', 'acymailingfield', 'joomlafield'); $this->type = array(); $this->type[] = JHTML::_('select.option', '', JText::_('FILTER_SELECT')); $this->type[] = JHTML::_('select.option', 'group', JText::_('GROUP')); $this->type[] = JHTML::_('select.option', 'list', JText::_('ACYMAILING_LIST')); $this->type[] = JHTML::_('select.option', 'acymailingfield', JText::_('ACYMAILING_FIELD')); $this->type[] = JHTML::_('select.option', 'joomlafield', JText::_('JOOMLA_FIELD')); $tables = $db->getTableList(); if (in_array($db->getPrefix() . 'comprofiler', $tables)) { $this->type[] = JHTML::_('select.option', 'cbfield', JText::_('CB_FIELD')); $types[] = 'cbfield'; $fields = reset($db->getTableFields($db->getPrefix() . 'comprofiler')); $this->cbfield = array(); foreach ($fields as $oneField => $fieldType) { $this->cbfield[] = JHTML::_('select.option', $oneField, $oneField); } } if (acymailing::level(3)) { include dirname(__FILE__) . DS . 'filterenterprise.php'; } $acl =& JFactory::getACL(); $this->groups = $acl->get_group_children_tree(null, 'USERS', false); $list = acymailing::get('class.list'); $lists = $list->getLists(); $this->lists = array(); foreach ($lists as $oneList) { $this->lists[] = JHTML::_('select.option', $oneList->listid, $oneList->name); } $fields = reset($db->getTableFields(acymailing::table('subscriber'))); $this->acymailingfields = array(); foreach ($fields as $oneField => $fieldType) { $this->acymailingfields[] = JHTML::_('select.option', $oneField, $oneField); } $fields = reset($db->getTableFields(acymailing::table('users', false))); $this->joomlafields = array(); foreach ($fields as $oneField => $fieldType) { $this->joomlafields[] = JHTML::_('select.option', $oneField, $oneField); } $doc =& JFactory::getDocument(); $js = "function updateFilter(filterNum){"; foreach ($types as $oneType) { $js .= "filterArea = 'filter_'+filterNum+'{$oneType}';\r\r\n\t\t\t\tif(window.document.getElementById(filterArea)){window.document.getElementById(filterArea).style.display = 'none';}"; } $js .= "filterArea = 'filter_'+filterNum+window.document.getElementById('filtertype'+filterNum).value;\r\r\n\t\t\t\tif(window.document.getElementById(filterArea)){window.document.getElementById(filterArea).style.display = 'block';}\r\r\n\t\t\t}"; $doc->addScriptDeclaration($js); $this->operators = acymailing::get('type.operators'); $this->status = acymailing::get('type.statusfilterlist'); }
function unsubscribe($subid, $listids) { $app =& JFactory::getApplication(); if (acymailing::level(3)) { $campaignClass = acymailing::get('helper.campaign'); $campaignClass->stop($subid, $listids); } $config = acymailing::config(); static $alreadySent = false; if ($this->sendNotif and !$alreadySent and $config->get('notification_unsub') and !$app->isAdmin()) { $alreadySent = true; $mailer = acymailing::get('helper.mailer'); $mailer->report = false; $mailer->autoAddUser = true; $mailer->checkConfirmField = false; $userClass = acymailing::get('class.subscriber'); $subscriber = $userClass->get($subid); $ipClass = acymailing::get('helper.user'); $mailer->addParam('survey', $this->survey); $mailer->addParamInfo(); $subscriber->ip = $ipClass->getIP(); foreach ($subscriber as $fieldname => $value) { $mailer->addParam('user:'******',', $config->get('notification_unsub')); foreach ($allUsers as $oneUser) { $mailer->sendOne('notification_unsub', $oneUser); } } $db =& JFactory::getDBO(); if ($this->sendConf and !$app->isAdmin()) { $db->setQuery('SELECT DISTINCT `unsubmailid` FROM ' . acymailing::table('list') . ' WHERE `listid` IN (' . implode(',', $listids) . ') AND `published` = 1 AND `unsubmailid` > 0'); $messages = $db->loadResultArray(); if (!empty($messages)) { $config = acymailing::config(); $mailHelper = acymailing::get('helper.mailer'); $mailHelper->report = $config->get('unsub_message', true); $mailHelper->checkAccept = false; foreach ($messages as $mailid) { $mailHelper->sendOne($mailid, $subid); } } } //end only frontend $db->setQuery('DELETE FROM ' . acymailing::table('queue') . ' WHERE `subid` = ' . (int) $subid . ' AND `mailid` IN (SELECT `mailid` FROM ' . acymailing::table('listmail') . ' WHERE `listid` IN (' . implode(',', $listids) . '))'); $db->query(); JPluginHelper::importPlugin('acymailing'); $dispatcher =& JDispatcher::getInstance(); $resultsTrigger = $dispatcher->trigger('onAcyUnsubscribe', array($subid, $listids)); }
function fetchElement($name, $value, &$node, $control_name) { if (!(include_once rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_acymailing' . DS . 'helpers' . DS . 'helper.php')) { echo 'AcyMailing is required for this plugin'; return; } $db =& JFactory::getDBO(); $fields = reset($db->getTableFields(acymailing::table('vm_user_info', false))); $dropdown = array(); foreach ($fields as $oneField => $fieldType) { $dropdown[] = JHTML::_('select.option', $oneField, $oneField); } return JHTML::_('select.genericlist', $dropdown, $control_name . '[' . $name . ']', 'size="1"', 'value', 'text', $value); }
function urlmailType() { $query = 'SELECT b.subject,b.mailid,count(distinct a.urlid) as totalmail FROM ' . acymailing::table('urlclick') . ' as a'; $query .= ' LEFT JOIN ' . acymailing::table('mail') . ' as b ON a.mailid = b.mailid'; $query .= ' GROUP BY a.mailid ORDER BY a.mailid DESC'; $db =& JFactory::getDBO(); $db->setQuery($query); $mails = $db->loadObjectList(); $this->values = array(); $this->values[] = JHTML::_('select.option', '0', JText::_('ALL_EMAILS')); foreach ($mails as $oneMail) { $this->values[] = JHTML::_('select.option', $oneMail->mailid, $oneMail->subject . ' ( ' . $oneMail->totalmail . ' )'); } }
function editorType() { $query = 'SELECT element,name FROM ' . acymailing::table('plugins', false) . ' WHERE folder=\'editors\' AND published=1 ORDER BY ordering ASC, name ASC'; $db =& JFactory::getDBO(); $db->setQuery($query); $joomEditors = $db->loadObjectList(); $this->values = array(); $this->values[] = JHTML::_('select.option', '0', JText::_('DEFAULT')); if (!empty($joomEditors)) { foreach ($joomEditors as $myEditor) { $this->values[] = JHTML::_('select.option', $myEditor->element, $myEditor->name); } } }
function unsubType() { $query = 'SELECT `subject`, `mailid` FROM ' . acymailing::table('mail') . ' WHERE `type`= \'unsub\''; $db =& JFactory::getDBO(); $db->setQuery($query); $messages = $db->loadObjectList(); $this->values = array(); $this->values[] = JHTML::_('select.option', '0', JText::_('NO_UNSUB_MESSAGE')); foreach ($messages as $oneMessage) { $this->values[] = JHTML::_('select.option', $oneMessage->mailid, '[' . $oneMessage->mailid . '] ' . $oneMessage->subject); } $js = "function changeMessage(idField,value){\r\r\n\t\t\tlinkEdit = idField+'_edit';\r\r\n\t\t\tif(value>0){\r\r\n\t\t\t\twindow.document.getElementById(linkEdit).href = 'index.php?option=com_acymailing&tmpl=component&ctrl=email&task=edit&mailid='+value;\r\r\n\t\t\t\twindow.document.getElementById(linkEdit).style.display = 'inline';\r\r\n\t\t\t}else{\r\r\n\t\t\t\twindow.document.getElementById(linkEdit).style.display = 'none';\r\r\n\t\t\t}\r\r\n\t\t}"; $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($js); }
function listcreatorType() { $query = 'SELECT b.name,a.userid,count(distinct a.listid) as total FROM ' . acymailing::table('list') . ' as a '; $query .= ' LEFT JOIN ' . acymailing::table('users', false) . ' as b on a.userid = b.id WHERE a.type = \'list\' GROUP BY a.userid ORDER BY b.name ASC'; $db =& JFactory::getDBO(); $db->setQuery($query); $creators = $db->loadObjectList(); $this->values = array(); $this->values[] = JHTML::_('select.option', '0', JText::_('ALL_CREATORS')); foreach ($creators as $oneCreator) { if (!empty($oneCreator->userid)) { $this->values[] = JHTML::_('select.option', $oneCreator->userid, $oneCreator->name . ' ( ' . $oneCreator->total . ' )'); } } }
function queueStatus($mailid, $all = false) { $query = 'SELECT a.mailid, count(a.subid) as nbsub,min(a.senddate) as senddate, b.subject FROM ' . acymailing::table('queue') . ' as a'; $query .= ' LEFT JOIN ' . acymailing::table('mail') . ' as b on a.mailid = b.mailid'; $query .= ' WHERE b.published > 0'; if (!$all) { $query .= ' AND a.senddate < ' . time(); if (!empty($mailid)) { $query .= ' AND a.mailid = ' . $mailid; } } $query .= ' GROUP BY a.mailid'; $this->database->setQuery($query); $queueStatus = $this->database->loadObjectList('mailid'); return $queueStatus; }
function stop($subid, $listids) { $listCampaignClass = acymailing::get('class.listcampaign'); $campaignids = $listCampaignClass->getAffectedCampaigns($listids); if (empty($campaignids)) { return true; } $selectquery = 'SELECT `mailid` FROM ' . acymailing::table('listmail') . ' WHERE `listid` IN (' . implode(',', $campaignids) . ')'; $query = 'DELETE FROM ' . acymailing::table('queue') . ' WHERE `subid` = ' . $subid . ' AND `mailid` IN (' . $selectquery . ')'; $db = JFactory::getDBO(); $db->setQuery($query); $db->query(); $time = time(); $db->setQuery('UPDATE ' . acymailing::table('listsub') . ' SET `unsubdate` = ' . $time . ', `status` = -1 WHERE `subid` = ' . $subid . '. AND `listid` IN (' . implode(',', $campaignids) . ')'); return $db->query(); }
function urlType() { $selectedMail = JRequest::getInt('filter_mail'); if (!empty($selectedMail)) { $query = 'SELECT DISTINCT a.name,a.urlid FROM ' . acymailing::table('urlclick') . ' as b LEFT JOIN ' . acymailing::table('url') . ' as a on a.urlid = b.urlid WHERE b.mailid = ' . $selectedMail; } else { $query = 'SELECT a.name,a.urlid FROM ' . acymailing::table('url') . ' as a'; } $db =& JFactory::getDBO(); $db->setQuery($query); $urls = $db->loadObjectList(); $this->values = array(); $this->values[] = JHTML::_('select.option', '0', JText::_('ALL_URLS')); foreach ($urls as $onrUrl) { $this->values[] = JHTML::_('select.option', $onrUrl->urlid, $onrUrl->name); } }
function load() { $query = 'SELECT b.name,a.listid,count(distinct a.mailid) as totalmail FROM ' . acymailing::table('mail') . ' as c'; $query .= ' LEFT JOIN ' . acymailing::table('listmail') . ' as a ON a.mailid = c.mailid'; $query .= ' LEFT JOIN ' . acymailing::table('list') . ' as b on a.listid = b.listid'; $query .= ' WHERE c.type = \'' . $this->type . '\' GROUP BY a.listid ORDER BY b.ordering ASC'; $db =& JFactory::getDBO(); $db->setQuery($query); $lists = $db->loadObjectList(); $this->values = array(); $this->values[] = JHTML::_('select.option', '0', JText::_('ALL_LISTS')); foreach ($lists as $onelist) { if (empty($onelist->listid)) { continue; } $this->values[] = JHTML::_('select.option', $onelist->listid, $onelist->name . ' ( ' . $onelist->totalmail . ' )'); } }
function queueScheduled() { $this->messages = array(); $mailReady = $this->getReadyMail(); if (empty($mailReady)) { $this->messages[] = JText::_('NO_SCHED'); return false; } $this->nbNewsletterScheduled = count($mailReady); $queueClass = acymailing::get('class.queue'); foreach ($mailReady as $mailid => $mail) { $nbQueue = $queueClass->queue($mailid, $mail->senddate); $this->messages[] = JText::sprintf('ADDED_QUEUE_SCHEDULE', $nbQueue, $mailid, $mail->subject); } $db =& JFactory::getDBO(); $db->setQuery('UPDATE ' . acymailing::table('mail') . ' SET published = 1 WHERE mailid IN (' . implode(',', array_keys($mailReady)) . ')'); $db->query(); return true; }
function _generateAutoNews($newNewsletter) { $newNewsletter->senddate = $this->time; $newNewsletter->type = 'news'; if (!empty($newNewsletter->params['generate'])) { $newNewsletter->published = 2; } else { $newNewsletter->published = 0; } $notification = $newNewsletter->params['generateto']; $mailidModel = $newNewsletter->mailid; unset($newNewsletter->mailid); unset($newNewsletter->username); unset($newNewsletter->name); unset($newNewsletter->email); $issueNb = $newNewsletter->params['issuenb']; $newNewsletter->body = str_replace('{issuenb}', $issueNb, $newNewsletter->body); $newNewsletter->altbody = str_replace('{issuenb}', $issueNb, $newNewsletter->altbody); $newNewsletter->subject = str_replace('{issuenb}', $issueNb, $newNewsletter->subject); $newNewsletter->mailid = $this->mailClass->save($newNewsletter); $this->dispatcher->trigger('acymailing_replacetags', array(&$newNewsletter)); $this->mailClass->save($newNewsletter); $query = 'INSERT IGNORE INTO ' . acymailing::table('listmail') . ' (mailid,listid) SELECT ' . $newNewsletter->mailid . ', b.`listid` FROM ' . acymailing::table('listmail') . ' as b'; $query .= ' WHERE b.mailid = ' . $mailidModel; $db = JFactory::getDBO(); $db->setQuery($query); $db->query(); $this->messages[] = JText::sprintf('NEWSLETTER_GENERATED', $newNewsletter->mailid, $newNewsletter->subject); if (!empty($notification)) { $app =& JFactory::getApplication(); $mailer = acymailing::get('helper.mailer'); $mailer->report = $app->isAdmin(); $mailer->autoAddUser = true; $mailer->checkConfirmField = false; $mailer->addParam('mailid', $newNewsletter->mailid); $mailer->addParam('subject', $newNewsletter->subject); $mailer->addParam('body', acymailing::absoluteURL($newNewsletter->body)); $mailer->addParam('issuenb', $issueNb); $mailer->forceTemplate = $newNewsletter->tempid; $mailer->sendOne('notification_autonews', $notification); } }
function send() { if (!$this->isAllowed('newsletters', 'send')) { return; } JRequest::checkToken() or die('Invalid Token'); $mailid = acymailing::getCID('mailid'); if (empty($mailid)) { exit; } $user =& JFactory::getUser(); $time = time(); $queueClass = acymailing::get('class.queue'); $onlyNew = JRequest::getInt('onlynew'); $totalSub = $queueClass->queue($mailid, $time, $onlyNew); if (empty($totalSub)) { acymailing::display(JText::_('NO_RECEIVER'), 'warning'); return; } $mailObject = null; $mailObject->senddate = $time; $mailObject->published = 1; $mailObject->mailid = $mailid; $mailObject->sentby = $user->id; $db =& JFactory::getDBO(); $db->updateObject(acymailing::table('mail'), $mailObject, 'mailid'); $config =& acymailing::config(); $queueType = $config->get('queue_type'); if ($queueType == 'onlyauto') { $messages = array(); $messages[] = JText::sprintf('ADDED_QUEUE', $totalSub); $messages[] = JText::_('AUTOSEND_CONFIRMATION'); acymailing::display($messages, 'success'); return; } else { JRequest::setVar('totalsend', $totalSub); $app =& JFactory::getApplication(); $app->redirect(acymailing::completeLink('send&task=continuesend&mailid=' . $mailid . '&totalsend=' . $totalSub, true, true)); exit; } }