function scheduleconfirm() { $mailid = acymailing::getCID('mailid'); $listmailClass = acymailing::get('class.listmail'); $mailClass = acymailing::get('class.mail'); $this->assignRef('lists', $listmailClass->getReceivers($mailid)); $this->assignRef('mail', $mailClass->get($mailid)); }
function saveForm() { $field = null; $field->fieldid = acymailing::getCID('fieldid'); $formData = JRequest::getVar('data', array(), '', 'array'); foreach ($formData['fields'] as $column => $value) { acymailing::secureField($column); $field->{$column} = strip_tags($value); } $fieldsOptions = JRequest::getVar('fieldsoptions', array(), '', 'array'); foreach ($fieldsOptions as $column => $value) { $fieldsOptions[$column] = strip_tags($value); } $field->options = serialize($fieldsOptions); $fieldValues = JRequest::getVar('fieldvalues', array(), '', 'array'); if (!empty($fieldValues)) { $field->value = array(); foreach ($fieldValues['title'] as $i => $title) { if (strlen($title) < 1 and strlen($fieldValues['value'][$i]) < 1) { continue; } $value = strlen($fieldValues['value'][$i]) < 1 ? $title : $fieldValues['value'][$i]; $field->value[] = strip_tags($title) . '::' . strip_tags($value); } $field->value = implode("\n", $field->value); } if (empty($field->fieldid)) { if (empty($field->namekey)) { $field->namekey = $field->fieldname; } $field->namekey = preg_replace('#[^a-z0-9_\\-]#i', '', strtolower($field->namekey)); if (empty($field->namekey)) { $this->errors[] = 'Please specify a namekey'; return false; } $columnsTable = $this->database->getTableFields(acymailing::table('subscriber')); $columns = reset($columnsTable); if (isset($columns[$field->namekey])) { $this->errors[] = 'The field "' . $field->namekey . '" already exists'; return false; } $query = 'ALTER TABLE `#__acymailing_subscriber` ADD `' . $field->namekey . '` VARCHAR ( 250 ) NULL'; $this->database->setQuery($query); $this->database->query(); } $fieldid = $this->save($field); if (!$fieldid) { return false; } if (empty($field->fieldid)) { $orderClass = acymailing::get('helper.order'); $orderClass->pkey = 'fieldid'; $orderClass->table = 'fields'; $orderClass->reOrder(); } JRequest::setVar('fieldid', $fieldid); return true; }
function saveForm() { $app =& JFactory::getApplication(); $template = null; $template->tempid = acymailing::getCID('tempid'); $formData = JRequest::getVar('data', array(), '', 'array'); foreach ($formData['template'] as $column => $value) { acymailing::secureField($column); $template->{$column} = strip_tags($value); } $styles = JRequest::getVar('styles', array(), '', 'array'); foreach ($styles as $class => $oneStyle) { $styles[$class] = str_replace('"', "'", $oneStyle); if (empty($oneStyle)) { unset($styles[$class]); } } $newStyles = JRequest::getVar('otherstyles', array(), '', 'array'); if (!empty($newStyles)) { foreach ($newStyles['classname'] as $id => $className) { if (!empty($className) and $className != JText::_('CLASS_NAME') and !empty($newStyles['style'][$id]) and $newStyles['style'][$id] != JText::_('CSS_STYLE')) { $styles[$className] = str_replace('"', "'", $newStyles['style'][$id]); } } } $template->styles = serialize($styles); $template->body = JRequest::getVar('editor_body', '', '', 'string', JREQUEST_ALLOWRAW); if (!empty($styles['color_bg'])) { $pat1 = '#^([^<]*<[^>]*background-color:)([^;">]{1,10})#i'; $found = false; if (preg_match($pat1, $template->body)) { $template->body = preg_replace($pat1, '$1' . $styles['color_bg'], $template->body); $found = true; } $pat2 = '#^([^<]*<[^>]*bgcolor=")([^;">]{1,10})#i'; if (preg_match($pat2, $template->body)) { $template->body = preg_replace($pat2, '$1' . $styles['color_bg'], $template->body); $found = true; } if (!$found) { $template->body = '<div style="background-color:' . $styles['color_bg'] . ';" width="100%">' . $template->body . '</div>'; } } $template->description = JRequest::getVar('editor_description', '', '', 'string', JREQUEST_ALLOWRAW); $tempid = $this->save($template); if (!$tempid) { return false; } if (empty($template->tempid)) { $orderClass = acymailing::get('helper.order'); $orderClass->pkey = 'tempid'; $orderClass->table = 'template'; $orderClass->reOrder(); } JRequest::setVar('tempid', $tempid); return true; }
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 view() { $mailid = acymailing::getCID('mailid'); if (empty($mailid)) { $db =& JFactory::getDBO(); $query = 'SELECT m.`mailid` FROM `#__acymailing_list` as l LEFT JOIN `#__acymailing_listmail` as lm ON l.listid=lm.listid LEFT JOIN `#__acymailing_mail` as m on lm.mailid = m.mailid'; $query .= ' WHERE l.`visible` = 1 AND l.`published` = 1 AND m.`visible`= 1 AND m.`published` = 1'; if (!empty($listid)) { $query .= ' AND l.`listid` = ' . (int) $listid; } $query .= ' ORDER BY m.`mailid` DESC LIMIT 1'; $db->setQuery($query); $mailid = $db->loadResult(); if (empty($mailid)) { return JError::raiseError(404, 'Newsletter not found'); } } $access_sub = true; $mailClass = acymailing::get('helper.mailer'); $oneMail = $mailClass->load($mailid); if (empty($oneMail->mailid)) { return JError::raiseError(404, 'Newsletter not found : ' . $mailid); } if (!$access_sub or !$oneMail->published or !$oneMail->visible) { $key = JRequest::getString('key'); if (empty($key) or $key !== $oneMail->key) { $app =& JFactory::getApplication(); $app->enqueueMessage('You can not have access to this e-mail', 'error'); $app->redirect(acymailing::completeLink('lists', false, true)); return false; } } $user =& JFactory::getUser(); if (!empty($user->email)) { $userClass = acymailing::get('class.subscriber'); $receiver = $userClass->get($user->email); } else { $receiver = null; $receiver->name = JText::_('VISITOR'); } $oneMail->sendHTML = true; $mailClass->dispatcher->trigger('acymailing_replaceusertagspreview', array(&$oneMail, &$receiver)); $document =& JFactory::getDocument(); $document->setTitle($oneMail->subject); if (!empty($oneMail->text)) { echo nl2br($mailClass->textVersion($oneMail->text, false)); } else { echo nl2br($mailClass->textVersion($oneMail->body, true)); } }
function form() { $fieldid = acymailing::getCID('fieldid'); $fieldsClass = acymailing::get('class.fields'); if (!empty($fieldid)) { $field = $fieldsClass->get($fieldid); } else { $field = null; $field->published = 1; $field->type = 'text'; $field->backend = 1; } if (!empty($field->fieldid)) { $fieldTitle = ' : ' . $field->namekey; } else { $fieldTitle = ''; } acymailing::setTitle(JText::_('FIELD') . $fieldTitle, 'fields', 'fields&task=edit&fieldid=' . $fieldid); $script = 'function addLine(){ var myTable=window.document.getElementById("tablevalues"); var newline = document.createElement(\'tr\'); var column = document.createElement(\'td\'); var column2 = document.createElement(\'td\'); var input = document.createElement(\'input\'); var input2 = document.createElement(\'input\'); input.type = \'text\'; input2.type = \'text\'; input.name = \'fieldvalues[title][]\'; input2.name = \'fieldvalues[value][]\'; column.appendChild(input); column2.appendChild(input2); newline.appendChild(column); newline.appendChild(column2); myTable.appendChild(newline); }'; $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($script); $bar =& JToolBar::getInstance('toolbar'); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'fields-form'); $this->assignRef('fieldtype', acymailing::get('type.fields')); $this->assignRef('field', $field); $this->assignRef('fieldsClass', $fieldsClass); }
function saveForm() { $object = null; $object->urlid = acymailing::getCID('urlid'); $formData = JRequest::getVar('data', array(), '', 'array'); foreach ($formData['url'] as $column => $value) { acymailing::secureField($column); $object->{$column} = strip_tags($value); } $urlid = $this->save($object); if (!$urlid) { return false; } $js = "window.addEvent('domready', function(){\r\r\n\t\t\t\tvar allLinks = window.parent.document.getElements('a[id^=urlink_" . $urlid . "_]');\r\r\n\t\t\t\ti=0;\r\r\n\t\t\t\twhile(allLinks[i]){\r\r\n\t\t\t\t\tallLinks[i].innerHTML = '" . str_replace(array("'", '"'), array("'", '"'), $object->name) . "';\r\r\n\t\t\t\t\ti++;\r\r\n\t\t\t\t}\r\r\n\t\t\t\twindow.parent.document.getElementById('sbox-window').close();\r\r\n\t\t\t\t})"; $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($js); return true; }
function saveForm() { $filter = null; $filter->filid = acymailing::getCID('filid'); $formData = JRequest::getVar('data', array(), '', 'array'); foreach ($formData['filter'] as $column => $value) { acymailing::secureField($column); $filter->{$column} = strip_tags($value); } $config = acymailing::config(); $alltriggers = array_keys((array) JRequest::getVar('trigger')); $filter->trigger = implode(',', $alltriggers); $newConfig = null; foreach ($alltriggers as $oneTrigger) { $name = 'triggerfilter_' . $oneTrigger; if ($config->get($name)) { continue; } $newConfig->{$name} = 1; } if (!empty($newConfig)) { $config->save($newConfig); } $data = array('action', 'filter'); foreach ($data as $oneData) { $filter->{$oneData} = array(); $formData = JRequest::getVar($oneData); foreach ($formData['type'] as $num => $oneType) { if (empty($oneType)) { continue; } $filter->{$oneData}['type'][$num] = $oneType; $filter->{$oneData}[$num][$oneType] = $formData[$num][$oneType]; } $filter->{$oneData} = serialize($filter->{$oneData}); } $filid = $this->save($filter); if (!$filid) { return false; } JRequest::setVar('filid', $filid); return true; }
function sendconfirm() { $mailid = acymailing::getCID('mailid'); $mailClass = acymailing::get('class.mail'); $listmailClass = acymailing::get('class.listmail'); $queueClass = acymailing::get('class.queue'); $mail = $mailClass->get($mailid); $values = null; $values->nbqueue = $queueClass->nbQueue($mailid); if (empty($values->nbqueue)) { $lists = $listmailClass->getReceivers($mailid); $this->assignRef('lists', $lists); $db =& JFactory::getDBO(); $db->setQuery('SELECT count(subid) FROM `#__acymailing_userstats` WHERE `mailid` = ' . intval($mailid)); $values->alreadySent = $db->loadResult(); } $this->assignRef('values', $values); $this->assignRef('mail', $mail); }
function saveForm() { $app =& JFactory::getApplication(); $list = null; $list->listid = acymailing::getCID('listid'); $formData = JRequest::getVar('data', array(), '', 'array'); foreach ($formData['list'] as $column => $value) { if ($app->isAdmin() or $this->allowedField('list', $column)) { acymailing::secureField($column); $list->{$column} = strip_tags($value); } } $list->description = JRequest::getVar('editor_description', '', '', 'string', JREQUEST_ALLOWRAW); $listid = $this->save($list); if (!$listid) { return false; } if (empty($list->listid)) { $orderClass = acymailing::get('helper.order'); $orderClass->pkey = 'listid'; $orderClass->table = 'list'; $orderClass->groupMap = 'type'; $orderClass->groupVal = empty($list->type) ? $this->type : $list->type; $orderClass->reOrder(); $this->newlist = true; } if (!empty($formData['listcampaign'])) { $affectedLists = array(); foreach ($formData['listcampaign'] as $affectlistid => $receiveme) { if (!empty($receiveme)) { $affectedLists[] = $affectlistid; } } $listCampaignClass = acymailing::get('class.listcampaign'); $listCampaignClass->save($listid, $affectedLists); } JRequest::setVar('listid', $listid); return true; }
function continuesend() { $config = acymailing::config(); $newcrontime = time() + 120; if ($config->get('cron_next') < $newcrontime) { $newValue = null; $newValue->cron_next = $newcrontime; $config->save($newValue); } $mailid = acymailing::getCID('mailid'); $totalSend = JRequest::getVar('totalsend', 0, '', 'int'); $alreadySent = JRequest::getVar('alreadysent', 0, '', 'int'); $helperQueue = acymailing::get('helper.queue'); $helperQueue->mailid = $mailid; $helperQueue->report = true; $helperQueue->total = $totalSend; $helperQueue->start = $alreadySent; $helperQueue->pause = $config->get('queue_pause'); //->Process will exit the current page if it needs to be continued $helperQueue->process(); ob_start(); }
function store() { JRequest::checkToken() or die('Invalid Token'); $oldMailid = acymailing::getCID('mailid'); $mailClass = acymailing::get('class.mail'); if ($mailClass->saveForm()) { $data = JRequest::getVar('data'); $type = @$data['mail']['type']; if (!empty($type) and in_array($type, array('unsub', 'welcome'))) { $subject = addslashes($data['mail']['subject']); $mailid = JRequest::getInt('mailid'); if ($type == 'unsub') { $js = "var mydrop = window.top.document.getElementById('datalistunsubmailid'); "; $js .= "var type = 'unsub';"; } else { //type=welcome $js = "var mydrop = window.top.document.getElementById('datalistwelmailid'); "; $js .= "var type = 'welcome';"; } if (empty($oldMailid)) { $js .= 'var optn = document.createElement("OPTION");'; $js .= "optn.text = '[{$mailid}] {$subject}'; optn.value = '{$mailid}';"; $js .= 'mydrop.options.add(optn);'; $js .= 'lastid = 0; while(mydrop.options[lastid+1]){lastid = lastid+1;} mydrop.selectedIndex = lastid;'; $js .= 'window.top.changeMessage(type,' . $mailid . ');'; } else { $js .= "lastid = 0; notfound = true; while(notfound && mydrop.options[lastid]){if(mydrop.options[lastid].value == {$mailid}){mydrop.options[lastid].text = '[{$mailid}] {$subject}';notfound = false;} lastid = lastid+1;}"; } $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($js); } acymailing::display(JText::_('JOOMEXT_SUCC_SAVED'), 'success'); } else { acymailing::display(JText::_('ERROR_SAVING'), 'error'); } }
function form() { $db =& JFactory::getDBO(); $config = acymailing::config(); $filid = acymailing::getCID('filid'); $filterClass = acymailing::get('class.filter'); if (!empty($filid)) { $filter = $filterClass->get($filid); } else { $filter = null; $filter->action = JRequest::getVar('action'); $filter->filter = JRequest::getVar('filter'); $filter->published = 1; } JPluginHelper::importPlugin('acymailing'); $this->dispatcher =& JDispatcher::getInstance(); $typesFilters = array(); $typesActions = array(); $outputFilters = implode('', $this->dispatcher->trigger('onAcyDisplayFilters', array(&$typesFilters))); $outputActions = implode('', $this->dispatcher->trigger('onAcyDisplayActions', array(&$typesActions))); $typevaluesFilters = array(); $typevaluesActions = array(); $typevaluesFilters[] = JHTML::_('select.option', '', JText::_('FILTER_SELECT')); $typevaluesActions[] = JHTML::_('select.option', '', JText::_('ACTION_SELECT')); $doc =& JFactory::getDocument(); $js = "function updateFilter(filterNum){"; foreach ($typesFilters as $oneType => $oneName) { $typevaluesFilters[] = JHTML::_('select.option', $oneType, $oneName); $js .= "filterArea = 'filter'+filterNum+'{$oneType}';\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\n\t\t\t\tif(window.document.getElementById(filterArea)){window.document.getElementById(filterArea).style.display = 'block';}\r\n\t\t\t}"; $js .= "function updateAction(actionNum){"; foreach ($typesActions as $oneType => $oneName) { $typevaluesActions[] = JHTML::_('select.option', $oneType, $oneName); $js .= "actionArea = 'action'+actionNum+'{$oneType}';\r\n\t\t\t\tif(window.document.getElementById(actionArea)){window.document.getElementById(actionArea).style.display = 'none';}"; } $js .= "actionArea = 'action'+actionNum+window.document.getElementById('actiontype'+actionNum).value;\r\n\t\t\t\tif(window.document.getElementById(actionArea)){window.document.getElementById(actionArea).style.display = 'block';}\r\n\t\t\t}"; $js .= "var numFilters = 0;\r\n\t\t\t\tvar numActions = 0;\r\n\t\t\t\tfunction addFilter(){\r\n\t\t\t\t\tvar newdiv = document.createElement('div');\r\n\t\t\t\t\tnewdiv.id = 'filter'+numFilters;\r\n\t\t\t\t\tnewdiv.className = 'plugarea';\r\n\t\t\t\t\tnewdiv.innerHTML = document.getElementById('filters_original').innerHTML.replace(/__num__/g, numFilters);\r\n\t\t\t\t\tdocument.getElementById('allfilters').appendChild(newdiv); updateFilter(numFilters); numFilters++; }\n\t\t\t\tfunction addAction(){\r\n\t\t\t\t\tvar newdiv = document.createElement('div');\r\n\t\t\t\t\tnewdiv.id = 'action'+numActions;\r\n\t\t\t\t\tnewdiv.className = 'plugarea';\r\n\t\t\t\t\tnewdiv.innerHTML = document.getElementById('actions_original').innerHTML.replace(/__num__/g, numActions);\r\n\t\t\t\t\tdocument.getElementById('allactions').appendChild(newdiv); updateAction(numActions); numActions++; }"; $js .= "window.addEvent('domready', function(){ addFilter(); addAction(); });"; if (version_compare(JVERSION, '1.6.0', '<')) { $js .= 'function submitbutton(pressbutton){ if (pressbutton != \'save\') { submitform( pressbutton ); return; }'; } else { $js .= 'Joomla.submitbutton = function(pressbutton) { if (pressbutton != \'save\') { Joomla.submitform(pressbutton,document.adminForm); return; }'; } $js .= "if(window.document.getElementById('filterinfo').style.display == 'none'){\r\n\t\t\t\t\t\twindow.document.getElementById('filterinfo').style.display = 'block';\r\n\t\t\t\t\t\ttry{allspans = window.document.getElementById('toolbar-save').getElementsByTagName(\"span\"); allspans[0].className = 'icon-32-apply';}catch(err){}\r\n\t\t\t\t\t\treturn false;}\r\n\t\t\t\t\tif(window.document.getElementById('title').value.length < 2){alert('" . JText::_('ENTER_TITLE', true) . "'); return false;}"; if (version_compare(JVERSION, '1.6.0', '<')) { $js .= "submitform( pressbutton );} "; } else { $js .= "Joomla.submitform(pressbutton,document.adminForm);}; "; } $doc->addScriptDeclaration($js); $js = ''; $data = array('action', 'filter'); foreach ($data as $datatype) { if (empty($filter->{$datatype})) { continue; } foreach ($filter->{$datatype}['type'] as $num => $oneType) { if (empty($oneType)) { continue; } $js .= "while(!document.getElementById('" . $datatype . "type{$num}')){add" . ucfirst($datatype) . "();}\r\n\t\t\t\t\t\tdocument.getElementById('" . $datatype . "type{$num}').value= '{$oneType}';\r\n\t\t\t\t\t\tupdate" . ucfirst($datatype) . "({$num});"; if (empty($filter->{$datatype}[$num][$oneType])) { continue; } foreach ($filter->{$datatype}[$num][$oneType] as $key => $value) { $js .= "document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}]'].value = '" . addslashes(str_replace(array("\n", "\r"), ' ', $value)) . "';"; } } } $listid = JRequest::getInt('listid'); if (!empty($listid)) { $js .= "document.getElementById('actiontype0').value = 'list'; updateAction(0); document.adminForm.elements['action[0][list][selectedlist]'].value = '" . $listid . "';"; } $doc->addScriptDeclaration("window.addEvent('domready', function(){ {$js} });"); $triggers = array(); $triggers['daycron'] = JText::_('AUTO_CRON_FILTER'); $nextDate = $config->get('cron_plugins_next'); if (!empty($nextDate)) { $triggers['daycron'] .= ' (' . JText::_('NEXT_RUN') . ' : ' . acymailing::getDate($nextDate, '%d %B %H:%M') . ')'; } $triggers['subcreate'] = JText::_('ON_USER_CREATE'); $triggers['subchange'] = JText::_('ON_USER_CHANGE'); $this->dispatcher->trigger('onAcyDisplayTriggers', array(&$triggers)); $name = empty($filter->name) ? '' : ' : ' . $filter->name; acymailing::setTitle(JText::_('ACY_FILTER') . $name, 'filter', 'filter&task=edit&filid=' . $filid); $bar =& JToolBar::getInstance('toolbar'); $bar->appendButton('Confirm', JText::_('PROCESS_CONFIRMATION'), 'process', JText::_('PROCESS'), 'process', false, false); JToolBarHelper::divider(); if (acymailing::level(3)) { JToolBarHelper::save(); if (!empty($filter->filid)) { $bar->appendButton('Link', 'new', JText::_('NEW'), acymailing::completeLink('filter&task=edit&filid=0')); } } $bar->appendButton('Link', 'cancel', JText::_('ACY_CLOSE'), acymailing::completeLink('list')); JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'filter'); $subid = JRequest::getString('subid'); if (!empty($subid)) { $subArray = explode(',', trim($subid, ',')); JArrayHelper::toInteger($subArray); $db->setQuery('SELECT `name`,`email` FROM `#__acymailing_subscriber` WHERE `subid` IN (' . implode(',', $subArray) . ')'); $users = $db->loadObjectList(); if (!empty($users)) { $this->assignRef('users', $users); $this->assignRef('subid', $subid); } } $this->assignRef('typevaluesFilters', $typevaluesFilters); $this->assignRef('typevaluesActions', $typevaluesActions); $this->assignRef('outputFilters', $outputFilters); $this->assignRef('outputActions', $outputActions); $this->assignRef('filter', $filter); $this->assignRef('triggers', $triggers); $doc->addStyleSheet(ACYMAILING_CSS . 'frontendedition.css'); if (acymailing::level(3) and JRequest::getCmd('tmpl') != 'component') { $db->setQuery('SELECT * FROM #__acymailing_filter ORDER BY `published` DESC, `filid` DESC'); $filters = $db->loadObjectList(); $this->assignRef('toggleClass', acymailing::get('helper.toggle')); $this->assignRef('filters', $filters); } }
function form() { $tempid = acymailing::getCID('tempid'); $app =& JFactory::getApplication(); $config = acymailing::config(); if (!empty($tempid)) { $templateClass = acymailing::get('class.template'); $template = $templateClass->get($tempid); if (!empty($template->body)) { $template->body = acymailing::absoluteURL($template->body); } } else { $template->body = ''; $template->tempid = 0; $template->published = 1; } $editor = acymailing::get('helper.editor'); $editor->setTemplate($template->tempid); $editor->name = 'editor_body'; $editor->content = $template->body; $editor->prepareDisplay(); if (version_compare(JVERSION, '1.6.0', '<')) { $script = 'function submitbutton(pressbutton){ if (pressbutton == \'cancel\') { submitform( pressbutton ); return; }'; } else { $script = 'Joomla.submitbutton = function(pressbutton) { if (pressbutton == \'cancel\') { Joomla.submitform(pressbutton,document.adminForm); return; }'; } $script .= 'if(window.document.getElementById("name").value.length < 2){alert(\'' . JText::_('ENTER_TITLE', true) . '\'); return false;}'; $script .= "if(pressbutton == 'test' && window.document.getElementById('sendtest') && window.document.getElementById('sendtest').style.display == 'none'){ window.document.getElementById('sendtest').style.display = 'block'; return false;}"; $script .= $editor->jsCode(); if (version_compare(JVERSION, '1.6.0', '<')) { $script .= 'submitform( pressbutton );} '; } else { $script .= 'Joomla.submitform(pressbutton,document.adminForm);}; '; } $script .= "function insertTag(tag){ try{jInsertEditorText(tag,'editor_body'); return true;} catch(err){alert('Your editor does not enable AcyMailing to automatically insert the tag, please copy/paste it manually in your Newsletter'); return false;}}"; $script .= 'function addStyle(){ var myTable=window.document.getElementById("classtable"); var newline = document.createElement(\'tr\'); var column = document.createElement(\'td\'); var column2 = document.createElement(\'td\'); var input = document.createElement(\'input\'); var input2 = document.createElement(\'input\'); input.type = \'text\'; input2.type = \'text\'; input.size = \'30\'; input2.size = \'50\'; input.name = \'otherstyles[classname][]\'; input2.name = \'otherstyles[style][]\'; input.value = "' . JText::_('CLASS_NAME', true) . '"; input2.value = "' . JText::_('CSS_STYLE', true) . '"; column.appendChild(input); column2.appendChild(input2); newline.appendChild(column); newline.appendChild(column2); myTable.appendChild(newline); }'; $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($script); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName(); $infos = null; $infos->receiver_type = $app->getUserStateFromRequest($paramBase . ".receiver_type", 'receiver_type', '', 'string'); $infos->test_email = $app->getUserStateFromRequest($paramBase . ".test_email", 'test_email', '', 'string'); acymailing::setTitle(JText::_('ACY_TEMPLATE'), 'acytemplate', 'template&task=edit&tempid=' . $tempid); $bar =& JToolBar::getInstance('toolbar'); if (acymailing::isAllowed($config->get('acl_tags_view', 'all'))) { $bar->appendButton('Acytags'); } JToolBarHelper::divider(); JToolBarHelper::custom('test', 'send', '', JText::_('SEND_TEST'), false); JToolBarHelper::spacer(); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'template-form'); $this->assignRef('editor', $editor); $this->assignRef('receiverClass', acymailing::get('type.testreceiver')); $this->assignRef('template', $template); $this->assignRef('colorBox', acymailing::get('type.color')); $this->assignRef('infos', $infos); jimport('joomla.html.pane'); $tabs =& JPane::getInstance('tabs'); $this->assignRef('tabs', $tabs); }
function process() { $mailid = acymailing::getCID('mailid'); $queueClass = acymailing::get('class.queue'); $queueStatus = $queueClass->queueStatus($mailid); $nextqueue = $queueClass->queueStatus($mailid, true); if (acymailing::level(1)) { $scheduleClass = acymailing::get('helper.schedule'); $scheduleNewsletter = $scheduleClass->getScheduled(); $this->assignRef('schedNews', $scheduleNewsletter); } if (empty($queueStatus) and empty($scheduleNewsletter)) { acymailing::display(JText::_('NO_PROCESS'), 'info'); } $infos = null; $infos->mailid = $mailid; $this->assignRef('queue', $queueStatus); $this->assignRef('nextqueue', $nextqueue); $this->assignRef('infos', $infos); }
function form() { $urlid = acymailing::getCID('urlid'); $urlClass = acymailing::get('class.url'); $this->assignRef('url', $urlClass->get($urlid)); }
function test() { if (!$this->isAllowed($this->aclCat, 'manage')) { return; } $this->store(); $tempid = acymailing::getCID('tempid'); $receiver_type = JRequest::getVar('receiver_type', '', '', 'string'); if (empty($tempid) or empty($receiver_type)) { return false; } $mailer = acymailing::get('helper.mailer'); $mailer->report = true; $config = acymailing::config(); $subscriberClass = acymailing::get('class.subscriber'); $userHelper = acymailing::get('helper.user'); JPluginHelper::importPlugin('acymailing'); $dispatcher =& JDispatcher::getInstance(); $app =& JFactory::getApplication(); $receivers = array(); if ($receiver_type == 'user') { $user = JFactory::getUser(); $receivers[] = $user->email; } elseif ($receiver_type == 'other') { $receivers[] = JRequest::getVar('test_email', '', '', 'string'); } else { $gid = substr($receiver_type, strpos($receiver_type, '_') + 1); if (empty($gid)) { return false; } $db =& JFactory::getDBO(); $db->setQuery('SELECT email from ' . acymailing::table('users', false) . ' WHERE gid = ' . intval($gid)); $receivers = $db->loadResultArray(); } if (empty($receivers)) { $app->enqueueMessage(JText::_('NO_SUBSCRIBER'), 'notice'); return $this->edit(); } $classTemplate = acymailing::get('class.template'); $myTemplate = $classTemplate->get($tempid); $myTemplate->sendHTML = 1; $myTemplate->mailid = 0; if (empty($myTemplate->subject)) { $myTemplate->subject = $myTemplate->name; } if (empty($myTemplate->altBody)) { $myTemplate->altbody = $mailer->textVersion($myTemplate->body); } $dispatcher->trigger('acymailing_replacetags', array(&$myTemplate)); $myTemplate->body = acymailing::absoluteURL($myTemplate->body); $result = true; foreach ($receivers as $receiveremail) { $copy = $myTemplate; $mailer->clearAll(); $mailer->setFrom($copy->fromemail, $copy->fromname); if (!empty($copy->replyemail)) { $replyToName = $config->get('add_names', true) ? $mailer->cleanText($copy->replyname) : ''; $mailer->AddReplyTo($mailer->cleanText($copy->replyemail), $replyToName); } $receiver = $subscriberClass->get($receiveremail); if (empty($receiver->subid)) { if ($userHelper->validEmail($receiveremail)) { $newUser = null; $newUser->email = $receiveremail; $subscriberClass->sendConf = false; $subid = $subscriberClass->save($newUser); $receiver = $subscriberClass->get($subid); } if (empty($receiver->subid)) { continue; } } $addedName = $config->get('add_names', true) ? $mailer->cleanText($receiver->name) : ''; $mailer->AddAddress($mailer->cleanText($receiver->email), $addedName); $dispatcher->trigger('acymailing_replaceusertags', array(&$copy, &$receiver)); $mailer->IsHTML(true); $mailer->sendHTML = true; $mailer->Body = $copy->body; $mailer->Subject = $copy->subject; if ($config->get('multiple_part', false)) { $mailer->AltBody = $copy->altbody; } $mailer->send(); } return $this->edit(); }
function _sendtest() { JRequest::checkToken() or die('Invalid Token'); if (!$this->checkAccess()) { return; } $mailid = acymailing::getCID('mailid'); $receiver_type = JRequest::getVar('receiver_type', '', '', 'string'); if (empty($mailid) or empty($receiver_type)) { return false; } $mailer = acymailing::get('helper.mailer'); $mailer->forceVersion = JRequest::getVar('test_html', 1, '', 'int'); $mailer->autoAddUser = true; $mailer->checkConfirmField = false; $receivers = array(); if ($receiver_type == 'user') { $user = JFactory::getUser(); $receivers[] = $user->email; } elseif ($receiver_type == 'other') { $receivers[] = JRequest::getVar('test_email', '', '', 'string'); } else { $gid = substr($receiver_type, strpos($receiver_type, '_') + 1); if (empty($gid)) { return false; } $db =& JFactory::getDBO(); $db->setQuery('SELECT email from ' . acymailing::table('users', false) . ' WHERE gid = ' . intval($gid)); $receivers = $db->loadResultArray(); } if (empty($receivers)) { $app =& JFactory::getApplication(); $app->enqueueMessage(JText::_('NO_SUBSCRIBER'), 'notice'); return false; } $result = true; foreach ($receivers as $receiver) { $result = $mailer->sendOne($mailid, $receiver) && $result; } return $result; }
function saveunsub() { acymailing::checkRobots(); $app =& JFactory::getApplication(); $subscriberClass = acymailing::get('class.subscriber'); $listsubClass = acymailing::get('class.listsub'); $userHelper = acymailing::get('helper.user'); $config = acymailing::config(); $subscriber = null; $subscriber->subid = acymailing::getCID('subid'); $user = $subscriberClass->identify(); if ($user->subid != $subscriber->subid) { echo "<script>alert('ERROR : You are not allowed to modify this user'); window.history.go(-1);</script>"; exit; } $refusemails = JRequest::getInt('refuse'); $unsuball = JRequest::getInt('unsuball'); $unsublist = JRequest::getInt('unsublist'); $mailid = JRequest::getInt('mailid'); $oldUser = $subscriberClass->get($subscriber->subid); $survey = JRequest::getVar('survey', array(), '', 'array'); $tagSurvey = ''; $data = array(); if (!empty($survey)) { foreach ($survey as $oneResult) { $data[] = "REASON::" . str_replace(array("\n", "\r"), array('<br/>', ''), strip_tags($oneResult)); } $tagSurvey = str_replace(array('REASON::', 'UNSUB_SURVEY_FREQUENT', 'UNSUB_SURVEY_RELEVANT'), array('<br />' . JText::_('REASON') . ' : ', JText::_('UNSUB_SURVEY_FREQUENT'), JText::_('UNSUB_SURVEY_RELEVANT')), implode('<br />', $data)); } $historyClass = acymailing::get('class.acyhistory'); $historyClass->insert($subscriber->subid, 'unsubscribed', $data); if ($refusemails) { $subscriber->accept = 0; $subscriberClass->save($subscriber); if ($config->get('unsubscription_message', 1)) { $app->enqueueMessage(JText::_('CONFIRM_UNSUB_FULL')); } $notifyUsers = $config->get('notification_refuse'); if (!empty($notifyUsers)) { $mailer = acymailing::get('helper.mailer'); $mailer->autoAddUser = true; $mailer->checkConfirmField = false; $mailer->report = false; foreach ($oldUser as $field => $value) { $mailer->addParam('user:'******'user:ip', $userHelper->getIP()); $mailer->addParam('survey', $tagSurvey); $allUsers = explode(',', $notifyUsers); foreach ($allUsers as $oneUser) { $mailer->sendOne('notification_refuse', $oneUser); } } } elseif ($unsuball) { $notifyUsers = $config->get('notification_unsuball'); if (!empty($notifyUsers)) { $mailer = acymailing::get('helper.mailer'); $mailer->autoAddUser = true; $mailer->checkConfirmField = false; $mailer->report = false; foreach ($oldUser as $field => $value) { $mailer->addParam('user:'******'user:ip', $userHelper->getIP()); $mailer->addParam('survey', $tagSurvey); $mailer->addParamInfo(); $allUsers = explode(',', $notifyUsers); foreach ($allUsers as $oneUser) { $mailer->sendOne('notification_unsuball', $oneUser); } } } $incrementUnsub = false; if ($refusemails or $unsuball) { $subscription = $subscriberClass->getSubscriptionStatus($subscriber->subid); $updatelists = array(); foreach ($subscription as $listid => $oneList) { if ($oneList->status != -1) { $updatelists[-1][] = $listid; } } $listsubClass->sendNotif = false; if (!empty($updatelists)) { $status = $listsubClass->updateSubscription($subscriber->subid, $updatelists); if ($config->get('unsubscription_message', 1)) { $app->enqueueMessage(JText::_('CONFIRM_UNSUB_ALL')); } $incrementUnsub = true; } else { if ($config->get('unsubscription_message', 1)) { $app->enqueueMessage(JText::_('ERROR_NOT_SUBSCRIBED')); } } } elseif ($unsublist) { $subscription = $subscriberClass->getSubscriptionStatus($subscriber->subid); $db = JFactory::getDBO(); $db->setQuery('SELECT b.listid, b.name, b.type FROM ' . acymailing::table('listmail') . ' as a LEFT JOIN ' . acymailing::table('list') . ' as b on a.listid = b.listid WHERE a.mailid = ' . $mailid); $allLists = $db->loadObjectList(); if (empty($allLists)) { $db->setQuery('SELECT b.listid, b.name, b.type FROM ' . acymailing::table('list') . ' as b WHERE b.welmailid = ' . $mailid . ' OR b.unsubmailid = ' . $mailid); $allLists = $db->loadObjectList(); } if (empty($allLists)) { echo "<script>alert('ERROR : Could not get the list for the mailing {$mailid}'); window.history.go(-1);</script>"; exit; } $campaignList = array(); $unsubList = array(); foreach ($allLists as $oneList) { if (isset($subscription[$oneList->listid]) and $subscription[$oneList->listid]->status != -1) { if ($oneList->type == 'campaign') { $campaignList[] = $oneList->listid; } else { $unsubList[$oneList->listid] = $oneList; } } } if (!empty($campaignList)) { $db->setQuery('SELECT b.listid, b.name, b.type FROM ' . acymailing::table('listcampaign') . ' as a LEFT JOIN ' . acymailing::table('list') . ' as b on a.listid = b.listid WHERE a.campaignid IN (' . implode(',', $campaignList) . ')'); $otherLists = $db->loadObjectList(); if (!empty($otherLists)) { foreach ($otherLists as $oneList) { if (isset($subscription[$oneList->listid]) and $subscription[$oneList->listid]->status != -1) { $unsubList[$oneList->listid] = $oneList; } } } } if (!empty($unsubList)) { $updatelists = array(); $updatelists[-1] = array_keys($unsubList); $listsubClass->survey = $tagSurvey; $status = $listsubClass->updateSubscription($subscriber->subid, $updatelists); if ($config->get('unsubscription_message', 1)) { $app->enqueueMessage(JText::_('CONFIRM_UNSUB_CURRENT')); } $incrementUnsub = true; } else { if ($config->get('unsubscription_message', 1)) { $app->enqueueMessage(JText::_('ERROR_NOT_SUBSCRIBED_CURRENT')); } } } if ($incrementUnsub) { $db =& JFactory::getDBO(); $db->setQuery('UPDATE ' . acymailing::table('stats') . ' SET `unsub` = `unsub` +1 WHERE `mailid` = ' . (int) $mailid); $db->query(); } $redirectUnsub = $config->get('unsub_redirect'); if (!empty($redirectUnsub)) { $this->setRedirect($redirectUnsub); return; } JRequest::setVar('layout', 'saveunsub'); return parent::display(); }
function saveForm() { $app =& JFactory::getApplication(); $db =& JFactory::getDBO(); $config =& acymailing::config(); $mail = null; $mail->mailid = acymailing::getCID('mailid'); $formData = JRequest::getVar('data', array(), '', 'array'); foreach ($formData['mail'] as $column => $value) { if ($app->isAdmin() or in_array($column, $this->allowedFields)) { acymailing::secureField($column); if ($column == 'params') { $mail->{$column} = $value; } else { $mail->{$column} = strip_tags($value); } } } $mail->body = JRequest::getVar('editor_body', '', '', 'string', JREQUEST_ALLOWRAW); $pregreplace = array(); $pregreplace['#<tr([^>"]*>([^<]*<td[^>]*>[ \\n\\s]*<img[^>]*>[ \\n\\s]*</ *td[^>]*>[ \\n\\s]*)*</ *tr)#Uis'] = '<tr style="line-height: 0px;" $1'; $pregreplace['#<td(((?!style|>).)*>[ \\n\\s]*<img[^>]*>[ \\n\\s]*</ *td)#Uis'] = '<td style="line-height: 0px;" $1'; $pregreplace['#<xml>.*</xml>#Uis'] = ''; $newbody = preg_replace(array_keys($pregreplace), $pregreplace, $mail->body); if (!empty($newbody)) { $mail->body = $newbody; } $mail->attach = array(); $attachments = JRequest::getVar('attachments', array(), 'files', 'array'); if (!empty($attachments['name'][0]) or !empty($attachments['name'][1])) { jimport('joomla.filesystem.file'); $allowedFiles = explode(',', strtolower($config->get('allowedfiles'))); $uploadFolder = JPath::clean(html_entity_decode($config->get('uploadfolder'))); $uploadFolder = trim($uploadFolder, DS . ' ') . DS; $uploadPath = JPath::clean(ACYMAILING_ROOT . $uploadFolder); acymailing::createDir($uploadPath, true); if (!is_writable($uploadPath)) { @chmod($uploadPath, '0755'); if (!is_writable($uploadPath)) { $app->enqueueMessage(JText::sprintf('WRITABLE_FOLDER', $uploadPath), 'notice'); } } foreach ($attachments['name'] as $id => $filename) { if (empty($filename)) { continue; } $attachment = null; $attachment->filename = strtolower(JFile::makeSafe($filename)); $attachment->size = $attachments['size'][$id]; $attachment->extension = strtolower(substr($attachment->filename, strrpos($attachment->filename, '.') + 1)); if (!in_array($attachment->extension, $allowedFiles)) { $app->enqueueMessage(JText::sprintf('ACCEPTED_TYPE', $attachment->extension, $config->get('allowedfiles')), 'notice'); continue; } if (!JFile::upload($attachments['tmp_name'][$id], $uploadPath . $attachment->filename)) { if (!move_uploaded_file($attachments['tmp_name'][$id], $uploadPath . $attachment->filename)) { $app->enqueueMessage(JText::sprintf('FAIL_UPLOAD', $attachments['tmp_name'][$id], $uploadPath . $attachment->filename), 'error'); continue; } } $mail->attach[] = $attachment; } } $toggleHelper = acymailing::get('helper.toggle'); if (!empty($mail->type) && $mail->type == 'followup' && !empty($mail->mailid)) { $oldMail = $this->get($mail->mailid); if (!empty($mail->published) and !$oldMail->published) { $text = JText::_('FOLLOWUP_PUBLISHED_INFORMED'); $text .= ' ' . $toggleHelper->toggleText('add', $mail->mailid, 'followup', JText::_('FOLLOWUP_PUBLISHED')); $app->enqueueMessage($text, 'notice'); } if ($oldMail->senddate != $mail->senddate) { $text = JText::_('FOLLOWUP_CHANGED_DELAY_INFORMED'); $text .= ' ' . $toggleHelper->toggleText('update', $mail->mailid, 'followup', JText::_('FOLLOWUP_CHANGED_DELAY')); $app->enqueueMessage($text, 'notice'); } } $mailid = $this->save($mail); if (!$mailid) { return false; } JRequest::setVar('mailid', $mailid); if (!empty($mail->type) && $mail->type == 'followup' && empty($mail->mailid) && !empty($mail->published)) { $text = JText::_('FOLLOWUP_PUBLISHED_INFORMED'); $text .= ' ' . $toggleHelper->toggleText('add', $mailid, 'followup', JText::_('FOLLOWUP_PUBLISHED')); $app->enqueueMessage($text, 'notice'); } $status = true; if (!empty($formData['listmail'])) { $receivers = array(); $remove = array(); foreach ($formData['listmail'] as $listid => $receiveme) { if (!empty($receiveme)) { $receivers[] = $listid; } else { $remove[] = $listid; } } $listMailClass = acymailing::get('class.listmail'); $status = $listMailClass->save($mailid, $receivers, $remove); } return $status; }
function form() { $mailid = acymailing::getCID('mailid'); if (empty($mailid)) { $mailid = JRequest::getString('mailid'); } $mailClass = acymailing::get('class.mail'); $mail = $mailClass->get($mailid); if (empty($mail)) { $config =& acymailing::config(); $mail->created = time(); $mail->fromname = $config->get('from_name'); $mail->fromemail = $config->get('from_email'); $mail->replyname = $config->get('reply_name'); $mail->replyemail = $config->get('reply_email'); $mail->subject = ''; $mail->type = JRequest::getString('type'); $mail->published = 1; $mail->visible = 0; $mail->html = 1; $mail->body = ''; $mail->altbody = ''; $mail->tempid = 0; } jimport('joomla.html.pane'); $tabs =& JPane::getInstance('tabs'); $values = null; $values->maxupload = acymailing::bytes(ini_get('upload_max_filesize')) > acymailing::bytes(ini_get('post_max_size')) ? ini_get('post_max_size') : ini_get('upload_max_filesize'); $toggleClass = acymailing::get('helper.toggle'); $editor = acymailing::get('helper.editor'); $editor->name = 'editor_body'; $editor->content = $mail->body; $js = "function updateEditor(htmlvalue){"; $js .= 'if(htmlvalue == \'0\'){window.document.getElementById("htmlfieldset").style.display = \'none\'}else{window.document.getElementById("htmlfieldset").style.display = \'block\'}'; $js .= '}'; $js .= 'window.addEvent(\'load\', function(){ updateEditor(' . $mail->html . '); });'; $script = 'function addFileLoader(){ var divfile=window.document.getElementById("loadfile"); var input = document.createElement(\'input\'); input.type = \'file\'; input.size = \'30\'; input.name = \'attachments[]\'; divfile.appendChild(document.createElement(\'br\')); divfile.appendChild(input);} '; $script .= 'function submitbutton(pressbutton){ if (pressbutton == \'cancel\') { submitform( pressbutton ); return; }'; $script .= 'if(window.document.getElementById("subject").value.length < 2){alert(\'' . JText::_('ENTER_SUBJECT', true) . '\'); return false;}'; $script .= $editor->jsCode(); $script .= 'submitform( pressbutton );}'; $script .= "function changeTemplate(newhtml,newtext,tempid){\r\r\n\t\t\tif(newhtml.length>2){" . $editor->setContent('newhtml') . "}\r\r\n\t\t\tvar vartextarea =\$('altbody'); if(newtext.length>2){vartextarea.setHTML(newtext);}\r\r\n\t\t\tvar vartempid =\$('tempid'); vartempid.value = tempid;\r\r\n\t\t}"; $script .= "function insertTag(tag){jInsertEditorText(tag,'editor_body');}"; $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($js . $script); $doc->addStyleSheet(ACYMAILING_CSS . 'frontendedition.css'); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('editor', $editor); $this->assignRef('values', $values); $this->assignRef('mail', $mail); $this->assignRef('tabs', $tabs); }
function schedule() { $mailid = acymailing::getCID('mailid'); JRequest::checkToken() && !empty($mailid) or die('Invalid Token'); $senddate = JRequest::getString('senddate', ''); $user =& JFactory::getUser(); if (empty($senddate)) { acymailing::display(JText::_('SPECIFY_DATE'), 'warning'); return $this->scheduleready(); } $realSendDate = acymailing::getTime($senddate); if ($realSendDate < time()) { acymailing::display(JText::_('DATE_FUTURE'), 'warning'); return $this->scheduleready(); } $mail = null; $mail->mailid = $mailid; $mail->senddate = $realSendDate; $mail->sentby = $user->id; $mail->published = 2; $mailClass = acymailing::get('class.mail'); $mailClass->save($mail); $myNewsletter = $mailClass->get($mailid); acymailing::display(JText::sprintf('AUTOSEND_DATE', $myNewsletter->subject, acymailing::getDate($realSendDate)), 'success'); $js = "window.top.document.getElementById('toolbar-popshed').innerHTML = '<a class=\"toolbar\" onclick=\"javascript: submitbutton(\\'unschedule\\')\" href=\"#\"><span class=\"icon-32-unschedule\" title=\"" . JText::_('UNSCHEDULE', true) . "\"> </span>" . JText::_('UNSCHEDULE') . "</a>'"; $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($js); }
function form() { $listid = acymailing::getCID('listid'); $listClass = acymailing::get('class.list'); if (!empty($listid)) { $list = $listClass->get($listid); } else { $list->published = 0; $list->visible = 1; $list->description = ''; $user = JFactory::getUser(); $list->creatorname = $user->name; $list->access_manage = 'none'; $list->access_sub = 'all'; $list->languages = 'all'; $list->color = '#3366ff'; } $editor = acymailing::get('helper.editor'); $editor->name = 'editor_description'; $editor->content = $list->description; $editor->setDescription(); $script = 'function submitbutton(pressbutton){ if (pressbutton == \'cancel\') { submitform( pressbutton ); return; }'; $script .= 'if(window.document.getElementById("name").value.length < 2){alert(\'' . JText::_('ENTER_NAME', true) . '\'); return false;}'; $script .= $editor->jsCode(); $script .= 'submitform( pressbutton );}'; $script .= 'function affectUser(idcreator,name){ window.document.getElementById("creatorname").innerHTML = name; window.document.getElementById("listcreator").value = idcreator; }'; $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($script); $colorBox = acymailing::get('type.color'); acymailing::setTitle(JText::_('LIST'), 'categories', 'list&task=edit&listid=' . $listid); $bar =& JToolBar::getInstance('toolbar'); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'list-form'); $this->assignRef('colorBox', $colorBox); if (acymailing::level(1)) { $this->assignRef('welcomeMsg', acymailing::get('type.welcome')); $this->assignRef('languages', acymailing::get('type.listslanguages')); } $this->assignRef('unsubMsg', acymailing::get('type.unsub')); $this->assignRef('list', $list); $this->assignRef('editor', $editor); }
function form() { JHTML::_('behavior.mootools'); $mailid = acymailing::getCID('mailid'); if (empty($mailid)) { $mailid = JRequest::getString('mailid'); } $mailClass = acymailing::get('class.mail'); $mail = $mailClass->get($mailid); if (empty($mail)) { $config =& acymailing::config(); $mail->created = time(); $mail->fromname = $config->get('from_name'); $mail->fromemail = $config->get('from_email'); $mail->replyname = $config->get('reply_name'); $mail->replyemail = $config->get('reply_email'); $mail->subject = ''; $mail->type = JRequest::getString('type'); $mail->published = 1; $mail->visible = 0; $mail->html = 1; $mail->body = ''; $mail->altbody = ''; $mail->tempid = 0; } jimport('joomla.html.pane'); $tabs =& JPane::getInstance('tabs'); $values = null; $values->maxupload = acymailing::bytes(ini_get('upload_max_filesize')) > acymailing::bytes(ini_get('post_max_size')) ? ini_get('post_max_size') : ini_get('upload_max_filesize'); $toggleClass = acymailing::get('helper.toggle'); $editor = acymailing::get('helper.editor'); $editor->name = 'editor_body'; $editor->content = $mail->body; $js = "function updateAcyEditor(htmlvalue){"; $js .= 'if(htmlvalue == \'0\'){window.document.getElementById("htmlfieldset").style.display = \'none\'}else{window.document.getElementById("htmlfieldset").style.display = \'block\'}'; $js .= '}'; $js .= 'window.addEvent(\'load\', function(){ updateAcyEditor(' . $mail->html . '); });'; $script = 'function addFileLoader(){ var divfile=window.document.getElementById("loadfile"); var input = document.createElement(\'input\'); input.type = \'file\'; input.size = \'30\'; input.name = \'attachments[]\'; divfile.appendChild(document.createElement(\'br\')); divfile.appendChild(input);} '; if (version_compare(JVERSION, '1.6.0', '<')) { $script .= 'function submitbutton(pressbutton){ if (pressbutton == \'cancel\') { submitform( pressbutton ); return; }'; } else { $script .= 'Joomla.submitbutton = function(pressbutton) { if (pressbutton == \'cancel\') { Joomla.submitform(pressbutton,document.adminForm); return; }'; } $script .= 'if(window.document.getElementById("subject").value.length < 2){alert(\'' . JText::_('ENTER_SUBJECT', true) . '\'); return false;}'; $script .= $editor->jsCode(); if (version_compare(JVERSION, '1.6.0', '<')) { $script .= 'submitform( pressbutton );} '; } else { $script .= 'Joomla.submitform(pressbutton,document.adminForm);}; '; } $script .= "function insertTag(tag){ try{jInsertEditorText(tag,'editor_body'); document.getElementById('iframetag').style.display = 'none'; displayTags(); return true;} catch(err){alert('Your editor does not enable AcyMailing to automatically insert the tag, please copy/paste it manually in your Newsletter'); return false;}}"; $iFrame = "'<iframe src=\\'index.php?option=com_acymailing&ctrl=tag&task=tag&type=news\\' width=\\'100%\\' height=\\'100%\\' scrolling=\\'auto\\'></iframe>'"; $script .= "var openTag = true;\r\n\t\t\t\t\tfunction displayTags(){var box=\$('iframetag'); if(openTag){box.innerHTML = " . $iFrame . "; box.setStyle('display','block');}\r\n\t\t\t\t\ttry{\r\n\t\t\t\t\t\tvar fx = box.effects({duration: 1500, transition: Fx.Transitions.Quart.easeOut});\r\n\t\t\t\t\t\tif(openTag){fx.start({'height': 300});}else{fx.start({'height': 0}).chain(function() {box.innerHTML = '';box.setStyle('display','none');})};\r\n\t\t\t\t\t}catch(err){\r\n\t\t\t\t\t\tbox.style.height = '300px';\r\n\t\t\t\t\t\tvar myVerticalSlide = new Fx.Slide('iframetag');\r\n\t\t\t\t\t\tif(openTag){\r\n\t\t\t\t\t\t\tmyVerticalSlide.slideIn();\r\n\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\tmyVerticalSlide.slideOut().chain(function() {\r\n\t\t\t\t\t\t\t\tbox.innerHTML='';\r\n\t\t\t\t\t\t\t\tbox.setStyle('display','none');\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\topenTag = !openTag;}"; $iFrame = "'<iframe src=\\'index.php?option=com_acymailing&ctrl=template&task=theme&tmpl=component\\' width=\\'100%\\' height=\\'100%\\' scrolling=\\'auto\\'></iframe>'"; $script .= "var openTemplate = true;\r\n\t\t\t\t\tfunction displayTemplates(){var box=\$('iframetemplate'); if(openTemplate){box.innerHTML = " . $iFrame . "; box.setStyle('display','block');}\r\n\t\t\t\t\ttry{\r\n\t\t\t\t\t\tvar fx = box.effects({duration: 1500, transition: Fx.Transitions.Quart.easeOut});\r\n\t\t\t\t\t\tif(openTemplate){fx.start({'height': 300});}else{fx.start({'height': 0}).chain(function() {box.innerHTML = '';box.setStyle('display','none');})};\r\n\t\t\t\t\t}catch(err){\r\n\t\t\t\t\t\tbox.style.height = '300px';\r\n\t\t\t\t\t\tvar myVerticalSlide = new Fx.Slide('iframetemplate');\r\n\t\t\t\t\t\tif(openTemplate){\r\n\t\t\t\t\t\t\tmyVerticalSlide.slideIn();\r\n\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\tmyVerticalSlide.slideOut().chain(function() {\r\n\t\t\t\t\t\t\t\tbox.innerHTML='';\r\n\t\t\t\t\t\t\t\tbox.setStyle('display','none');\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\topenTemplate = !openTemplate;}"; $script .= "function changeTemplate(newhtml,newtext,newsubject,stylesheet,fromname,fromemail,replyname,replyemail,tempid){\r\n\t\t\tif(newhtml.length>2){" . $editor->setContent('newhtml') . "}\r\n\t\t\tvar vartextarea =\$('altbody'); if(newtext.length>2) vartextarea.innerHTML = newtext;\r\n\t\t\tdocument.getElementById('tempid').value = tempid;\r\n\t\t\tif(fromname.length>1){document.getElementById('fromname').value = fromname;}\r\n\t\t\tif(fromemail.length>1){document.getElementById('fromemail').value = fromemail;}\r\n\t\t\tif(replyname.length>1){document.getElementById('replyname').value = replyname;}\r\n\t\t\tif(replyemail.length>1){document.getElementById('replyemail').value = replyemail;}\r\n\t\t\tif(newsubject.length>1){document.getElementById('subject').value = newsubject;}\r\n\t\t\tdocument.getElementById('iframetemplate').style.display = 'none'; displayTemplates();\r\n\t\t}\r\n\t\t"; $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($js . $script); $doc->addStyleSheet(ACYMAILING_CSS . 'frontendedition.css'); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('editor', $editor); $this->assignRef('values', $values); $this->assignRef('mail', $mail); $this->assignRef('tabs', $tabs); }
function view() { $app =& JFactory::getApplication(); $pathway =& $app->getPathway(); $my = JFactory::getUser(); $frontEndManagement = false; $listid = acymailing::getCID('listid'); if (!empty($listid)) { $listClass = acymailing::get('class.list'); $oneList = $listClass->get($listid); if (!empty($oneList->visible) and $oneList->published) { $pathway->addItem($oneList->name, acymailing::completeLink('archive&listid=' . $oneList->listid . ':' . $oneList->alias)); } if (!empty($oneList->listid) and acymailing::level(3)) { if (!empty($my->id) and (int) $my->id == (int) $oneList->userid) { $frontEndManagement = true; } if (!empty($my->gid) and !empty($my->id)) { if ($oneList->access_manage == 'all' or in_array($my->gid, explode(',', $oneList->access_manage))) { $frontEndManagement = true; } } } } $mailid = acymailing::getCID('mailid'); if (empty($mailid)) { $db =& JFactory::getDBO(); $query = 'SELECT m.`mailid` FROM `#__acymailing_list` as l LEFT JOIN `#__acymailing_listmail` as lm ON l.listid=lm.listid LEFT JOIN `#__acymailing_mail` as m on lm.mailid = m.mailid'; $query .= ' WHERE l.`visible` = 1 AND l.`published` = 1 AND m.`visible`= 1 AND m.`published` = 1'; if (!empty($listid)) { $query .= ' AND l.`listid` = ' . (int) $listid; } $query .= ' ORDER BY m.`mailid` DESC LIMIT 1'; $db->setQuery($query); $mailid = $db->loadResult(); if (empty($mailid)) { return JError::raiseError(404, 'Newsletter not found'); } } $access_sub = true; if (acymailing::level(3)) { $listmail = acymailing::get('class.listmail'); $allLists = $listmail->getLists($mailid); $access_sub = false; if (!empty($allLists)) { foreach ($allLists as $alist) { if (empty($alist->mailid)) { continue; } if (!$alist->published or !$alist->visible or $alist->access_sub == 'none') { continue; } if ($alist->access_sub == 'all') { $access_sub = true; break; } if (empty($my->id) or empty($my->gid)) { continue; } if (in_array($my->gid, explode(',', $alist->access_sub))) { $access_sub = true; break; } } } } $mailClass = acymailing::get('helper.mailer'); $oneMail = $mailClass->load($mailid); if (empty($oneMail->mailid)) { return JError::raiseError(404, 'Newsletter not found : ' . $mailid); } if (!$frontEndManagement and (!$access_sub or !$oneMail->published or !$oneMail->visible)) { $key = JRequest::getString('key'); if (empty($key) or $key !== $oneMail->key) { $app->enqueueMessage('You can not have access to this e-mail', 'error'); $app->redirect(acymailing::completeLink('lists', false, true)); return false; } } if (!empty($my->email)) { $userClass = acymailing::get('class.subscriber'); $receiver = $userClass->get($my->email); } else { $subkeys = JRequest::getString('sub'); if (!empty($subkeys)) { $db =& JFactory::getDBO(); $subid = intval(substr($subkeys, 0, strpos($subkeys, '-'))); $subkey = substr($subkeys, strpos($subkeys, '-') + 1); $db->setQuery('SELECT * FROM ' . acymailing::table('subscriber') . ' WHERE `subid` = ' . $db->Quote($subid) . ' AND `key` = ' . $db->Quote($subkey) . ' LIMIT 1'); $receiver = $db->loadObject(); } if (empty($receiver)) { $receiver = null; $receiver->name = JText::_('VISITOR'); } } $oneMail->sendHTML = true; $mailClass->dispatcher->trigger('acymailing_replaceusertagspreview', array(&$oneMail, &$receiver)); $pathway->addItem($oneMail->subject); $document =& JFactory::getDocument(); $document->setTitle($oneMail->subject); $this->assignRef('mail', $oneMail); $this->assignRef('frontEndManagement', $frontEndManagement); $this->assignRef('list', $oneList); $this->assignRef('config', acymailing::config()); $this->assignRef('my', $my); }
function saveForm() { $app =& JFactory::getApplication(); $config = acymailing::config(); $allowUserModifications = (bool) ($config->get('allow_modif', 'data') == 'all') || $app->isAdmin(); $allowSubscriptionModifications = (bool) ($config->get('allow_modif', 'data') != 'none') || $app->isAdmin(); $subscriber = null; $subscriber->subid = acymailing::getCID('subid'); if (!$app->isAdmin() && !empty($subscriber->subid)) { $user = $this->identify(); $allowUserModifications = true; $allowSubscriptionModifications = true; if ($user->subid != $subscriber->subid) { die('You are not allowed to modify this user'); } } $formData = JRequest::getVar('data', array(), '', 'array'); if (!empty($formData['subscriber'])) { $this->checkFields($formData['subscriber'], $subscriber); } if (empty($subscriber->subid)) { if (empty($subscriber->email)) { echo "<script>alert('" . JText::_('VALID_EMAIL', true) . "'); window.history.go(-1);</script>"; exit; } $existSubscriber = $this->get($subscriber->email); if (!empty($existSubscriber->subid)) { if ($app->isAdmin()) { $this->errors[] = 'A user already exists with the e-mail ' . $subscriber->email; $this->errors[] = 'You can <a href="' . acymailing::completeLink('subscriber&task=edit&subid=' . $existSubscriber->subid) . '">edit this user</a>'; return false; } else { $subscriber->subid = $existSubscriber->subid; $subscriber->confirmed = $existSubscriber->confirmed; } } } $this->recordHistory = true; $this->newUser = empty($subscriber->subid) ? true : false; if (empty($subscriber->subid) or $allowUserModifications) { $subid = $this->save($subscriber); $allowSubscriptionModifications = true; } else { $subid = $subscriber->subid; if (isset($subscriber->confirmed) && empty($subscriber->confirmed)) { $this->sendConf($subid); } } JRequest::setVar('subid', $subid); if (empty($subid)) { return false; } if (!$app->isAdmin() && isset($subscriber->accept) && $subscriber->accept == 0) { $formData['masterunsub'] = 1; } if (empty($formData['listsub'])) { return true; } if (!$allowSubscriptionModifications) { $mailClass = acymailing::get('helper.mailer'); $mailClass->checkConfirmField = false; $mailClass->checkEnabled = false; $mailClass->report = false; $mailClass->sendOne('modif', $subid); $this->requireId = true; return false; } return $this->saveSubscription($subid, $formData['listsub']); }
function form() { $subid = acymailing::getCID('subid'); if (!empty($subid)) { $subscriberClass = acymailing::get('class.subscriber'); $subscriber = $subscriberClass->getFull($subid); $subscription = $subscriberClass->getSubscription($subid); } else { $listType = acymailing::get('class.list'); $subscription = $listType->getLists(); $subscriber = null; $subscriber->created = time(); $subscriber->html = 1; $subscriber->confirmed = 1; $subscriber->blocked = 0; $subscriber->accept = 1; $subscriber->enabled = 1; $iphelper = acymailing::get('helper.user'); $subscriber->ip = $iphelper->getIP(); } if (acymailing::level(3)) { $fieldsClass = acymailing::get('class.fields'); $this->assignRef('fieldsClass', $fieldsClass); $this->assignRef('extraFields', $fieldsClass->getFields('backend', $subscriber)); } acymailing::setTitle(JText::_('USER'), 'user', 'subscriber&task=edit&subid=' . $subid); $bar =& JToolBar::getInstance('toolbar'); if (!empty($subid) && acymailing::level(2)) { $bar->appendButton('Popup', 'send', JText::_('SEND'), acymailing::completeLink("send&task=addqueue&subid=" . $subid, true)); JToolBarHelper::divider(); } if (!empty($subscriber->userid)) { $bar->appendButton('Link', 'edit', JText::_('EDIT_JOOMLA_USER'), 'index.php?option=com_users&task=edit&cid[]=' . $subscriber->userid); JToolBarHelper::spacer(); } JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'subscriber-form'); $filters = null; $quickstatusType = acymailing::get('type.statusquick'); $filters->statusquick = $quickstatusType->display('statusquick'); $this->assignRef('subscriber', $subscriber); $this->assignRef('subscription', $subscription); $this->assignRef('filters', $filters); $this->assignRef('statusType', acymailing::get('type.status')); }
function preview() { $app =& JFactory::getApplication(); $mailid = acymailing::getCID('mailid'); $mailerHelper = acymailing::get('helper.mailer'); $mail = $mailerHelper->load($mailid); $user =& JFactory::getUser(); $userClass = acymailing::get('class.subscriber'); $receiver = $userClass->get($user->email); $mail->sendHTML = true; $mailerHelper->dispatcher->trigger('acymailing_replaceusertagspreview', array(&$mail, &$receiver)); if (!empty($mail->altbody)) { $mail->altbody = $mailerHelper->textVersion($mail->altbody, false); } $listmailClass = acymailing::get('class.listmail'); $lists = $listmailClass->getReceivers($mail->mailid, true, false); $receiversClass = acymailing::get('type.testreceiver'); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName(); $infos = null; $infos->receiver_type = $app->getUserStateFromRequest($paramBase . ".receiver_type", 'receiver_type', '', 'string'); $infos->test_html = $app->getUserStateFromRequest($paramBase . ".test_html", 'test_html', 1, 'int'); $infos->test_email = $app->getUserStateFromRequest($paramBase . ".test_email", 'test_email', '', 'string'); acymailing::setTitle(JText::_('PREVIEW') . ' : ' . $mail->subject, $this->icon, $this->ctrl . '&task=preview&mailid=' . $mailid); $bar =& JToolBar::getInstance('toolbar'); if ($this->type == 'news') { if (acymailing::level(1)) { if ($mail->published == 2) { JToolBarHelper::custom('unschedule', 'unschedule', '', JText::_('UNSCHEDULE'), false); } else { $bar->appendButton('Popsched', acymailing::completeLink("send&task=scheduleready&mailid=" . $mailid, true)); } } $bar->appendButton('Popup', 'send', JText::_('SEND'), acymailing::completeLink("send&task=sendready&mailid=" . $mailid, true)); JToolBarHelper::divider(); } JToolBarHelper::custom(JText::_('EDIT'), 'edit', '', JText::_('EDIT'), false); JToolBarHelper::cancel('cancel', JText::_('CLOSE')); JToolBarHelper::divider(); $bar->appendButton('Pophelp', $this->ctrl . '-preview'); $this->assignRef('lists', $lists); $this->assignRef('infos', $infos); $this->assignRef('receiverClass', $receiversClass); $this->assignRef('mail', $mail); }
function saveForm() { $app =& JFactory::getApplication(); $mail = null; $mail->mailid = acymailing::getCID('mailid'); $formData = JRequest::getVar('data', array(), '', 'array'); foreach ($formData['mail'] as $column => $value) { if ($app->isAdmin() or in_array($column, $this->allowedFields)) { acymailing::secureField($column); if ($column == 'params') { $mail->{$column} = $value; } else { $mail->{$column} = strip_tags($value); } } } $mail->body = JRequest::getVar('editor_body', '', '', 'string', JREQUEST_ALLOWRAW); $mail->attach = array(); $attachments = JRequest::getVar('attachments', array(), 'files', 'array'); if (!empty($attachments['name'][0]) or !empty($attachments['name'][1])) { jimport('joomla.filesystem.file'); $config =& acymailing::config(); $allowedFiles = explode(',', strtolower($config->get('allowedfiles'))); $uploadFolder = JPath::clean(html_entity_decode($config->get('uploadfolder'))); $uploadFolder = trim($uploadFolder, DS . ' ') . DS; $uploadPath = JPath::clean(ACYMAILING_ROOT . $uploadFolder); if (!is_dir($uploadPath)) { jimport('joomla.filesystem.folder'); JFolder::create($uploadPath); } if (!is_writable($uploadPath)) { @chmod($uploadPath, '0755'); if (!is_writable($uploadPath)) { $app->enqueueMessage(JText::sprintf('WRITABLE_FOLDER', $uploadPath), 'notice'); } } foreach ($attachments['name'] as $id => $filename) { if (empty($filename)) { continue; } $attachment = null; $attachment->filename = strtolower(JFile::makeSafe($filename)); $attachment->size = $attachments['size'][$id]; $attachment->extension = strtolower(substr($attachment->filename, strrpos($attachment->filename, '.') + 1)); if (!in_array($attachment->extension, $allowedFiles)) { $app->enqueueMessage(JText::sprintf('ACCEPTED_TYPE', $attachment->extension, $config->get('allowedfiles')), 'notice'); continue; } if (!move_uploaded_file($attachments['tmp_name'][$id], $uploadPath . $attachment->filename)) { if (!JFile::upload($attachments['tmp_name'][$id], $uploadPath . $attachment->filename)) { $app->enqueueMessage(JText::sprintf('FAIL_UPLOAD', $attachments['tmp_name'][$id], $uploadPath . $attachment->filename), 'error'); continue; } } $mail->attach[] = $attachment; } } $mailid = $this->save($mail); if (!$mailid) { return false; } JRequest::setVar('mailid', $mailid); $status = true; if (!empty($formData['listmail'])) { $receivers = array(); $remove = array(); foreach ($formData['listmail'] as $listid => $receiveme) { if (!empty($receiveme)) { $receivers[] = $listid; } else { $remove[] = $listid; } } $listMailClass = acymailing::get('class.listmail'); $status = $listMailClass->save($mailid, $receivers, $remove); } return $status; }
function preview() { $mailid = acymailing::getCID('mailid'); $app =& JFactory::getApplication(); $mailerHelper = acymailing::get('helper.mailer'); $mail = $mailerHelper->load($mailid); $user =& JFactory::getUser(); $userClass = acymailing::get('class.subscriber'); $receiver = $userClass->get($user->email); $mail->sendHTML = true; $mailerHelper->dispatcher->trigger('acymailing_replaceusertagspreview', array(&$mail, &$receiver)); if (!empty($mail->altbody)) { $mail->altbody = $mailerHelper->textVersion($mail->altbody, false); } $listmailClass = acymailing::get('class.listmail'); $lists = $listmailClass->getReceivers($mail->mailid, true, false); $receiversClass = acymailing::get('type.testreceiver'); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName(); $infos = null; $infos->receiver_type = $app->getUserStateFromRequest($paramBase . ".receiver_type", 'receiver_type', '', 'string'); $infos->test_html = $app->getUserStateFromRequest($paramBase . ".test_html", 'test_html', 1, 'int'); $infos->test_email = $app->getUserStateFromRequest($paramBase . ".test_email", 'test_email', '', 'string'); $this->assignRef('lists', $lists); $this->assignRef('infos', $infos); $this->assignRef('receiverClass', $receiversClass); $this->assignRef('mail', $mail); }