function saveForm() { $rule = new stdClass(); $rule->ruleid = acymailing_getCID('ruleid'); if (empty($rule->ruleid)) { $this->database->setQuery('SELECT max(ordering) FROM `#__acymailing_rules`'); $rule->ordering = intval($this->database->loadResult()) + 1; } $rule->executed_on = ''; $rule->action_message = ''; $rule->action_user = ''; $formData = JRequest::getVar('data', array(), '', 'array'); foreach ($formData['rule'] as $column => $value) { acymailing_secureField($column); if (is_array($value)) { $rule->{$column} = serialize($value); } else { $rule->{$column} = strip_tags($value); } } $ruleid = $this->save($rule); if (!$ruleid) { return false; } JRequest::setVar('ruleid', $ruleid); return true; }
function saveForm() { $app = JFactory::getApplication(); $template = new stdClass(); $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')) { $className = str_replace(array(',', ' ', ':', '.', '#'), '', $className); $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,30})#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>'; } } $acypluginsHelper = acymailing_get('helper.acyplugins'); $acypluginsHelper->cleanHtml($template->body); $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 saveForm() { $app = JFactory::getApplication(); $action = new stdClass(); $action->action_id = acymailing_getCID('action_id'); $formData = JRequest::getVar('data', array(), '', 'array'); foreach ($formData['action'] as $column => $value) { if ($app->isAdmin() || $this->allowedField('action', $column)) { acymailing_secureField($column); $action->{$column} = strip_tags($value); } } if (empty($action->action_id)) { $action->nextdate = time() + intval($action->frequency); } if ($action->password == '********') { unset($action->password); } $action->conditions = json_encode($formData['conditions']); $action->actions = json_encode($formData['actions']); if (isset($action->published) && $action->published != 1) { $action->published = 0; } $action_id = $this->save($action); if (!$action_id) { return false; } JRequest::setVar('action_id', $action_id); return true; }
function continuesend() { $config = acymailing_config(); if (acymailing_level(1) && $config->get('queue_type') == 'onlyauto') { JRequest::setVar('tmpl', 'component'); acymailing_display(JText::_('ACY_ONLYAUTOPROCESS'), 'warning'); return; } $newcrontime = time() + 120; if ($config->get('cron_next') < $newcrontime) { $newValue = new stdClass(); $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'); $helperQueue->process(); JRequest::setVar('tmpl', 'component'); }
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'); $mailClass->loadedToSend = false; $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 = new stdClass(); $receiver->name = JText::_('VISITOR'); } $oneMail->sendHTML = true; $mailClass->dispatcher->trigger('acymailing_replaceusertags', array(&$oneMail, &$receiver, false)); $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 saveForm() { $app = JFactory::getApplication(); $list = new stdClass(); $list->listid = acymailing_getCID('listid'); $formData = JRequest::getVar('data', array(), '', 'array'); if (!empty($formData['list']['category']) && $formData['list']['category'] == -1) { $formData['list']['category'] = JRequest::getString('newcategory', ''); } foreach ($formData['list'] as $column => $value) { if ($app->isAdmin() || $this->allowedField('list', $column)) { acymailing_secureField($column); $list->{$column} = strip_tags($value); } } $list->description = JRequest::getVar('editor_description', '', '', 'string', JREQUEST_ALLOWHTML); if (isset($list->published) && $list->published != 1) { $list->published = 0; } $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 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 = new stdClass(); $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 continuesend() { $config = acymailing_config(); $newcrontime = time() + 120; if ($config->get('cron_next') < $newcrontime) { $newValue = new stdClass(); $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'); $helperQueue->process(); }
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;}"; } if (ACYMAILING_J30) { $js .= 'window.top.jQuery("#datalist' . ($type == 'unsub' ? 'unsub' : 'wel') . 'mailid").trigger("liszt:updated");'; } $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); } acymailing_display(JText::_('JOOMEXT_SUCC_SAVED'), 'success'); } else { acymailing_display(JText::_('ERROR_SAVING'), 'error'); } }
function scheduleconfirm(){ $this->chosen = false; $mailid = acymailing_getCID('mailid'); $listmailClass = acymailing_get('class.listmail'); $mailClass = acymailing_get('class.mail'); $listHours = array(); $listMinutess = array(); $defaultMinutes = floor(acymailing_getDate(time(),'%M')/5)*5; $defaultHours = acymailing_getDate(time(),'%H'); for($i=0; $i<24; $i++){ $listHours[] = JHTML::_('select.option', $i, ($i<10?'0'.$i:$i)); } $hours = JHTML::_('select.genericlist', $listHours, 'sendhours', 'class="inputbox" size="1" style="width:60px;"', 'value', 'text', $defaultHours); for($i=0; $i<60; $i+=5){ $listMinutess[] = JHTML::_('select.option', $i, ($i<10?'0'.$i:$i)); } $minutes = JHTML::_('select.genericlist', $listMinutess, 'sendminutes', 'class="inputbox" size="1" style="width:60px;"', 'value', 'text', $defaultMinutes); $this->assign('lists',$listmailClass->getReceivers($mailid)); $this->assign('mail',$mailClass->get($mailid)); $this->assign('hours', $hours); $this->assign('minutes', $minutes); }
function saveForm() { $app = JFactory::getApplication(); $config =& acymailing_config(); $mail = new stdClass(); $mail->mailid = acymailing_getCID('mailid'); $formData = JRequest::getVar('data', array(), '', 'array'); if (!empty($formData['mail']['subject'])) { $formData['mail']['subject'] = str_replace(chr(226) . chr(128) . chr(168), '', $formData['mail']['subject']); } foreach ($formData['mail'] as $column => $value) { if (!$app->isAdmin() && !in_array($column, $this->allowedFields)) { continue; } acymailing_secureField($column); if (in_array($column, array('params', 'summary'))) { $mail->{$column} = $value; } else { $mail->{$column} = strip_tags($value, '<ADV>'); } } $mail->body = JRequest::getVar('editor_body', '', '', 'string', JREQUEST_ALLOWRAW); if (ACYMAILING_J25) { $mail->body = JComponentHelper::filterText($mail->body); } $acypluginsHelper = acymailing_get('helper.acyplugins'); $acypluginsHelper->cleanHtml($mail->body); $mail->attach = array(); $attachments = JRequest::getVar('attachments', array(), '', 'array'); if (!empty($attachments)) { foreach ($attachments as $id => $filepath) { if (empty($filepath)) { continue; } $attachment = new stdClass(); $attachment->filename = strtolower($filepath); $attachment->size = filesize(JPATH_SITE . '/' . $filepath); $extension = substr($attachment->filename, strrpos($attachment->filename, '.')); if (preg_match('#\\.(php.?|.?htm.?|pl|py|jsp|asp|sh|cgi)#Ui', $attachment->filename)) { acymailing_enqueueMessage(JText::sprintf('ACCEPTED_TYPE', substr($attachment->filename, strrpos($attachment->filename, '.') + 1), $config->get('allowedfiles')), 'notice'); continue; } $attachment->filename = str_replace(array('.', ' '), '_', substr($attachment->filename, 0, strpos($attachment->filename, $extension))) . $extension; $mail->attach[] = $attachment; } } if (isset($mail->filter)) { $mail->filter = array(); $filterData = JRequest::getVar('filter'); foreach ($filterData['type'] as $num => $oneType) { if (empty($oneType)) { continue; } $mail->filter['type'][$num] = $oneType; $mail->filter[$num][$oneType] = $filterData[$num][$oneType]; } } $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) { $this->_publishfollowup($mail); } if ($oldMail->senddate != $mail->senddate) { $text = JText::_('FOLLOWUP_CHANGED_DELAY_INFORMED'); $text .= ' ' . $toggleHelper->toggleText('update', $mail->mailid, 'followup', JText::_('FOLLOWUP_CHANGED_DELAY')); acymailing_enqueueMessage($text, 'notice'); } } if (preg_match('#<a[^>]*subid=[0-9].*</a>#Uis', $mail->body, $pregResult)) { acymailing_enqueueMessage('There is a personal link in your Newsletter ( ' . $pregResult[0] . ' ) instead of a tag...<br />Please make sure to not copy/paste the link you received in your e-mail as it may break your unsubscribe or confirmation links.<br />Use our tags instead!', 'notice'); } if (empty($mail->thumb)) { unset($mail->thumb); } elseif ($mail->thumb == 'delete') { $mail->thumb = ''; } $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); } if (!empty($mail->type) && $mail->type == 'followup' && empty($mail->mailid) && !empty($mail->published)) { $mail->mailid = $mailid; $this->_publishfollowup($mail); } return $status; }
function saveastmpl() { $tmplClass = acymailing_get('class.template'); $newTmpl = new stdClass(); $formData = JRequest::getVar('data', array(), '', 'array'); if (!empty($formData['mail']['tempid'])) { $template = $tmplClass->get($formData['mail']['tempid']); $newTmpl->styles = $template->styles; $newTmpl->stylesheet = $template->stylesheet; $newTmpl->category = $template->category; } if (!empty($formData['mail']['subject'])) { $formData['mail']['subject'] = str_replace(chr(226) . chr(128) . chr(168), '', $formData['mail']['subject']); $newTmpl->subject = strip_tags($formData['mail']['subject']); $newTmpl->name = strip_tags($formData['mail']['subject']); } $newTmpl->body = JRequest::getVar('editor_body', '', '', 'string', JREQUEST_ALLOWRAW); if (ACYMAILING_J25) { $newTmpl->body = JComponentHelper::filterText($newTmpl->body); } $acypluginsHelper = acymailing_get('helper.acyplugins'); $acypluginsHelper->cleanHtml($newTmpl->body); if (!empty($formData['mail']['thumb']) && $formData['mail']['thumb'] == 'delete') { $newTmpl->thumb = null; } elseif (!empty($formData['mail']['thumb'])) { $newTmpl->thumb = strip_tags($formData['mail']['thumb']); } else { $mailid = acymailing_getCID('mailid'); if (!empty($mailid)) { $mail = $this->get($mailid); $newTmpl->thumb = $mail->thumb; } } if (!empty($formData['mail']['altbody'])) { $newTmpl->altbody = strip_tags($formData['mail']['altbody']); } if (!empty($formData['mail']['fromname'])) { $newTmpl->fromname = strip_tags($formData['mail']['fromname']); } if (!empty($formData['mail']['fromemail'])) { $newTmpl->fromemail = strip_tags($formData['mail']['fromemail']); } if (!empty($formData['mail']['replyname'])) { $newTmpl->replyname = strip_tags($formData['mail']['replyname']); } if (!empty($formData['mail']['replyemail'])) { $newTmpl->replyemail = strip_tags($formData['mail']['replyemail']); } if (!empty($formData['mail']['summary'])) { $newTmpl->description = strip_tags($formData['mail']['summary']); } $newTmpl->ordering = 1; $tempid = $tmplClass->save($newTmpl); if (!empty($tempid)) { $formData['mail']['tempid'] = $tempid; acymailing_enqueueMessage(JText::_('ACY_SAVEASTMPL_VALID'), 'message'); } else { acymailing_enqueueMessage(JText::_('ERROR_SAVING'), 'error'); } return true; }
function form() { $listid = acymailing_getCID('listid'); $listClass = acymailing_get('class.list'); if (!empty($listid)) { $list = $listClass->get($listid); if (empty($list->listid)) { acymailing_display('List ' . $listid . ' not found', 'error'); $listid = 0; } } if (empty($listid)) { $list = new stdClass(); $list->visible = 1; $list->description = ''; $list->category = ''; $list->published = 1; $user = JFactory::getUser(); $list->creatorname = $user->name; $list->access_manage = 'none'; $list->access_sub = 'all'; $list->languages = 'all'; $colors = array('#3366ff', '#7240A4', '#7A157D', '#157D69', '#ECE649'); $list->color = $colors[rand(0, count($colors) - 1)]; } $editor = acymailing_get('helper.editor'); $editor->name = 'editor_description'; $editor->content = $list->description; $editor->setDescription(); if (!ACYMAILING_J16) { $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 .= $editor->jsCode(); if (!ACYMAILING_J16) { $script .= 'submitform( pressbutton );}'; } else { $script .= 'Joomla.submitform(pressbutton,document.adminForm);}; '; } $script .= 'function affectUser(idcreator,name,email){ 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'), 'acylist', '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->assign('welcomeMsg', acymailing_get('type.welcome')); $this->assign('languages', acymailing_get('type.listslanguages')); } $unsubMsg = acymailing_get('type.unsub'); $this->assignRef('unsubMsg', $unsubMsg); $this->assignRef('list', $list); $this->assignRef('editor', $editor); }
function form(){ $urlid = acymailing_getCID('urlid'); $urlClass = acymailing_get('class.url'); $this->assign('url',$urlClass->get($urlid)); }
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 = new stdClass(); $infos->mailid = $mailid; $this->assignRef('queue', $queueStatus); $this->assignRef('nextqueue', $nextqueue); $this->assignRef('infos', $infos); }
function view(){ global $Itemid; $app = JFactory::getApplication(); $document = JFactory::getDocument(); $this->addFeed(); $pathway = $app->getPathway(); $my = JFactory::getUser(); $frontEndManagement = false; $listid = acymailing_getCID('listid'); $values = new stdClass(); $values->suffix = ''; $jsite = JFactory::getApplication('site'); $menus = $jsite->getMenu(); $menu = $menus->getActive(); if(empty($menu) AND !empty($Itemid)){ $menus->setActive($Itemid); $menu = $menus->getItem($Itemid); } if (is_object( $menu )) { jimport('joomla.html.parameter'); $menuparams = new acyParameter( $menu->params ); } if(!empty($menuparams)){ $values->suffix = $menuparams->get('pageclass_sfx',''); } if(empty($listid) && !empty($menuparams)){ $listid = $menuparams->get('listid'); if ($menuparams->get('menu-meta_description')) $document->setDescription($menuparams->get('menu-meta_description')); if ($menuparams->get('menu-meta_keywords')) $document->setMetadata('keywords',$menuparams->get('menu-meta_keywords')); if ($menuparams->get('robots')) $document->setMetadata('robots',$menuparams->get('robots')); if ($menuparams->get('page_title')) acymailing_setPageTitle($menuparams->get('page_title')); } $config = acymailing_config(); $indexFollow = $config->get('indexFollow', ''); $tagIndFol = array(); if(strpos($indexFollow, 'noindex') !== false) $tagIndFol[] = 'noindex'; if(strpos($indexFollow, 'nofollow') !== false) $tagIndFol[] = 'nofollow'; if(!empty($tagIndFol)) $document->setMetadata('robots',implode(',',$tagIndFol)); if(!empty($listid)){ $listClass = acymailing_get('class.list'); $oneList = $listClass->get($listid); if(!empty($oneList->visible) AND $oneList->published AND (empty($menuparams) || !$menuparams->get('listid'))){ $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->id)){ if($oneList->access_manage == 'all' OR acymailing_isAllowed($oneList->access_manage)){ $frontEndManagement = true; } } } } $mailid = JRequest::getString('mailid','nomailid'); if(empty($mailid)){ die('This is a Newsletter-template... and you can not access the online version of a Newsletter-template!<br />Please <a href="administrator/index.php?option=com_acymailing&ctrl=newsletter&task=edit" >create a Newsletter</a> using your template and then try again your "view it online" link!'); exit; } if($mailid == 'nomailid'){ $db = JFactory::getDBO(); $query = 'SELECT m.`mailid` FROM `#__acymailing_list` as l JOIN `#__acymailing_listmail` as lm ON l.listid=lm.listid 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 AND m.`type` = "news" AND l.`type` = "list"'; if(!empty($listid)) $query .= ' AND l.`listid` = '.(int) $listid; $query .= ' ORDER BY m.`senddate` DESC, m.`mailid` DESC LIMIT 1'; $db->setQuery($query); $mailid = $db->loadResult(); } $mailid = intval($mailid); 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(acymailing_isAllowed($alist->access_sub)){ $access_sub = true; break; } } } } $mailClass = acymailing_get('helper.mailer'); $mailClass->loadedToSend = false; $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::getCmd('key'); if(empty($key) OR $key !== $oneMail->key){ $reason = (!$oneMail->published) ? 'Newsletter not published' : (!$oneMail->visible ? 'Newsletter not visible' : (!$access_sub ? 'Access not allowed' : '')); $app->enqueueMessage('You can not have access to this e-mail : '.$reason,'error'); $app->redirect(acymailing_completeLink('lists',false,true)); return false; } } $fshare = ''; if(preg_match('#<img[^>]*id="pictshare"[^>]*>#i',$oneMail->body,$pregres) && preg_match('#src="([^"]*)"#i',$pregres[0],$pict)){ $fshare = $pict[1]; }elseif(preg_match('#<img[^>]*class="[^"]*pictshare[^"]*"[^>]*>#i',$oneMail->body,$pregres) && preg_match('#src="([^"]*)"#i',$pregres[0],$pict)){ $fshare = $pict[1]; }elseif(preg_match('#class="acymailing_content".*(<img[^>]*>)#is',$oneMail->body,$pregres) && preg_match('#src="([^"]*)"#i',$pregres[1],$pict)){ if(strpos($pregres[1],JText::_('JOOMEXT_READ_MORE')) === false) $fshare = $pict[1]; } if(!empty($fshare)){ $document->setMetadata('og:image', $fshare); } $document->setMetadata('og:url',acymailing_frontendLink('index.php?option=com_acymailing&ctrl=archive&task=view&mailid='.$oneMail->mailid,JRequest::getCmd('tmpl') == 'component' ? true : false)); $document->setMetadata('og:title',$oneMail->subject); if(!empty($oneMail->metadesc))$document->setMetadata('og:description',$oneMail->metadesc); $subkeys = JRequest::getString('subid',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) AND !empty($my->email)){ $userClass = acymailing_get('class.subscriber'); $receiver = $userClass->get($my->email); } if(empty($receiver)){ $receiver = new stdClass(); $receiver->name = JText::_('VISITOR'); } $oneMail->sendHTML = true; $mailClass->dispatcher->trigger('acymailing_replaceusertags',array(&$oneMail,&$receiver,false)); $pathway->addItem($oneMail->subject); $document = JFactory::getDocument(); acymailing_setPageTitle($oneMail->subject); if (!empty($oneMail->metadesc)) { $document->setDescription( $oneMail->metadesc ); } if (!empty($oneMail->metakey)) { $document->setMetadata('keywords', $oneMail->metakey); } $this->assignRef('mail',$oneMail); $this->assignRef('frontEndManagement',$frontEndManagement); $this->assignRef('list',$oneList); $config =& acymailing_config(); $this->assignRef('config',$config); $this->assignRef('my',$my); $this->assignRef('receiver',$receiver); $this->assignRef('values',$values); if($oneMail->html){ $templateClass = acymailing_get('class.template'); $templateClass->archiveSection = true; $templateClass->displayPreview('newsletter_preview_area',$oneMail->tempid,$oneMail->subject); } }
function saveForm() { $app = JFactory::getApplication(); $config = acymailing_config(); $allowUserModifications = (bool) ($config->get('allow_modif', 'data') == 'all') || $this->allowModif; $allowSubscriptionModifications = (bool) ($config->get('allow_modif', 'data') != 'none') || $this->allowModif; $subscriber = new stdClass(); $subscriber->subid = acymailing_getCID('subid'); if (!$this->allowModif && !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; } } if (!empty($subscriber->email)) { $this->database->setQuery('SELECT * FROM #__acymailing_subscriber WHERE email = ' . $this->database->Quote($subscriber->email) . ' AND subid != ' . intval(@$subscriber->subid)); $existSubscriber = $this->database->loadObject(); if (!empty($existSubscriber->subid)) { $overwritenow = true; if ($this->allowModif) { if ($app->isAdmin()) { $overwritenow = false; } else { $listClass = acymailing_get('class.list'); $allowedLists = $listClass->getFrontendLists('listid'); if (empty($allowedLists)) { $this->errors[] = "Not sure how you were able to edit this user if you don't own any list..."; return false; } $this->database->setQuery('SELECT listid FROM #__acymailing_listsub WHERE subid = ' . intval($existSubscriber->subid) . ' AND listid IN (' . implode(',', array_keys($allowedLists)) . ')'); $allowedlistid = $this->database->loadResult(); if (!empty($allowedlistid)) { $overwritenow = false; } } } if ($overwritenow) { $subscriber->subid = $existSubscriber->subid; $subscriber->confirmed = $existSubscriber->confirmed; } else { $this->errors[] = JText::sprintf('USER_ALREADY_EXISTS', $subscriber->email); $this->errors[] = '<a href="' . acymailing_completeLink(($app->isAdmin() ? 'subscriber' : 'frontsubscriber&listid=' . $allowedlistid) . '&task=edit&subid=' . $existSubscriber->subid) . '" >' . JText::_('CLICK_EDIT_USER') . '</a>'; return false; } } } if (!$this->allowModif && !empty($subscriber->subid) && !empty($subscriber->email)) { $existSubscriber = $this->get($subscriber->subid); if (trim(strtolower($subscriber->email)) != strtolower($existSubscriber->email)) { $subscriber->confirmed = 0; } } $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 (!$this->allowModif && isset($subscriber->accept) && $subscriber->accept == 0) { $formData['masterunsub'] = 1; } if (!$app->isAdmin()) { $hiddenlistsString = JRequest::getString('hiddenlists', ''); if (!empty($hiddenlistsString)) { $hiddenlists = explode(',', $hiddenlistsString); JArrayHelper::toInteger($hiddenlists); foreach ($hiddenlists as $oneListId) { $formData['listsub'][$oneListId] = array('status' => 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; } $subscriptionSaved = $this->saveSubscription($subid, $formData['listsub']); $notifContact = $config->get('notification_contact_menu'); if (!empty($notifContact) && !$app->isAdmin()) { $userHelper = acymailing_get('helper.user'); $mailer = acymailing_get('helper.mailer'); $listsubClass = acymailing_get('class.listsub'); $mailer->autoAddUser = true; $mailer->checkConfirmField = false; $mailer->report = false; foreach ($subscriber as $field => $value) { $mailer->addParam('user:'******'user:name', $myUser->name); $mailer->addParam('user:email', $myUser->email); } $mailer->addParam('user:subscription', $listsubClass->getSubscriptionString($subscriber->subid)); $mailer->addParam('user:ip', $userHelper->getIP()); if (!empty($this->geolocData)) { foreach ($this->geolocData as $map => $value) { $mailer->addParam('geoloc:notif_' . $map, $value); } } $mailer->addParamInfo(); $allUsers = explode(' ', trim(str_replace(array(';', ','), ' ', $notifContact))); foreach ($allUsers as $oneUser) { if (empty($oneUser)) { continue; } $mailer->sendOne('notification_contact_menu', $oneUser); } } return $subscriptionSaved; }
function test() { if (!$this->isAllowed($this->aclCat, 'manage')) { return; } $this->store(); $tempid = acymailing_getCID('tempid'); $test_selection = JRequest::getVar('test_selection', '', '', 'string'); if (empty($tempid) or empty($test_selection)) { return; } $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(); $receivers = array(); if ($test_selection == 'users') { $receiverEntry = JRequest::getVar('test_emails', '', '', 'string'); if (!empty($receiverEntry)) { if (substr_count($receiverEntry, '@') > 1) { $receivers = explode(',', trim(preg_replace('# +#', '', $receiverEntry))); } else { $receivers[] = trim($receiverEntry); } } } else { $gid = JRequest::getInt('test_group', '-1'); if ($gid == -1) { return false; } $db = JFactory::getDBO(); if (!ACYMAILING_J16) { $db->setQuery('SELECT email FROM ' . acymailing_table('users', false) . ' WHERE gid = ' . intval($gid)); } else { $db->setQuery('SELECT u.email FROM ' . acymailing_table('users', false) . ' AS u JOIN ' . acymailing_table('user_usergroup_map', false) . ' AS ugm ON u.id = ugm.user_id WHERE ugm.group_id = ' . intval($gid)); } $receivers = acymailing_loadResultArray($db); } if (empty($receivers)) { acymailing_enqueueMessage(JText::_('NO_SUBSCRIBER'), 'notice'); return $this->edit(); } $classTemplate = acymailing_get('class.template'); $myTemplate = $classTemplate->get($tempid); $myTemplate->sendHTML = 1; $myTemplate->mailid = 0; $myTemplate->template = $myTemplate; if (empty($myTemplate->subject)) { $myTemplate->subject = $myTemplate->name; } if (empty($myTemplate->altBody)) { $myTemplate->altbody = $mailer->textVersion($myTemplate->body); } $dispatcher->trigger('acymailing_replacetags', array(&$myTemplate, true)); $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 = new stdClass(); $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, true)); $mailer->isHTML(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 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); }'; $script .= 'var currentValueId = \'\'; function showthediv(valueid,e) { if(currentValueId != valueid){ try{ document.getElementById(\'wysija\').style.left = e.pageX-50+"px"; document.getElementById(\'wysija\').style.top = e.pageY-40+"px"; }catch(err){ document.getElementById(\'wysija\').style.left = e.x-50+"px"; document.getElementById(\'wysija\').style.top = e.y-40+"px"; } currentValueId = valueid; } document.getElementById(\'wysija\').style.display = \'block\'; initDiv(); } function spanChange(span) { input = currentValueId; if (document.getElementById(span).className == span.toLowerCase()+"elementselected") { document.getElementById(span).className = span.toLowerCase()+"element"; if(span == "B"){ document.getElementById("name_"+currentValueId).style.fontWeight = ""; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value.replace(/font-weight *: *bold(;)?/i, ""); } if(span == "I"){ document.getElementById("name_"+currentValueId).style.fontStyle = ""; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value.replace(/font-style *: *italic(;)?/i, ""); } if(span == "U"){ document.getElementById("name_"+currentValueId).style.textDecoration=""; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value.replace(/text-decoration *: *underline(;)?/i,""); } } else{ document.getElementById(span).className = span.toLowerCase()+"elementselected"; if(span == "B"){ document.getElementById("name_"+currentValueId).style.fontWeight = "bold"; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value + "font-weight:bold;"; } if(span == "I"){ document.getElementById("name_"+currentValueId).style.fontStyle = "italic"; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value + "font-style:italic;"; } if(span == "U"){ document.getElementById("name_"+currentValueId).style.textDecoration="underline"; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value + "text-decoration:underline;"; } } } function getValueSelect() { selec = currentValueId; var myRegex2 = new RegExp(/font-size *:[^;]*;/i); var MyValue = document.getElementById("style_select_wysija").value; document.getElementById("name_"+currentValueId).style.fontSize = MyValue; if(document.getElementById("style_"+currentValueId).value.search(myRegex2) != -1){ if(MyValue == ""){ document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value.replace(myRegex2, ""); } else{ document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value.replace(myRegex2, "font-size:"+MyValue+";"); } } else{ document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value + "font-size:"+MyValue+";"; } } function initDiv(){ var RegexSize = new RegExp(/font-size *:[^;]*(;)?/gi); var RegexColor = new RegExp(/([^a-z-])color *:[^;]*(;)?/gi); document.getElementById("colorexamplewysijacolor").style.backgroundColor = "#000000"; document.getElementById("colordivwysijacolor").style.display = "none"; spaced = document.getElementById("style_"+currentValueId).value.substr(0,1); if(spaced != " "){ stringToQuery = \' \' + document.getElementById("style_"+currentValueId).value; } else{ stringToQuery = document.getElementById("style_"+currentValueId).value; } NewColor = stringToQuery.match(RegexColor); if(NewColor != null){ NewColor = NewColor[0].match(/:[^;!]*/gi); NewColor = NewColor[0].replace(/(:| )/gi,""); document.getElementById("colorexamplewysijacolor").style.backgroundColor = NewColor; } document.getElementById("U").className = "uelement"; document.getElementById("I").className = "ielement"; document.getElementById("B").className = "belement"; if(document.getElementById("style_"+currentValueId).value.search(/font-weight: *bold(;)?/i) != -1){ document.getElementById("B").className += "selected"; } if(document.getElementById("style_"+currentValueId).value.search(/font-style: *italic(;)?/i) != -1){ document.getElementById("I").className += "selected"; } if(document.getElementById("style_"+currentValueId).value.search(/text-decoration: *underline(;)?/i) != -1){ document.getElementById("U").className += "selected"; } NewSize = stringToQuery.match(RegexSize); document.getElementById("style_select_wysija").options[0].selected = true; if(NewSize != null){ NewSize = NewSize[0].match(/:[^;]*/gi); NewSize = NewSize[0].replace(" ",""); NewSize = NewSize.substr(1); for(var i = 0; i < document.getElementById("style_select_wysija").length; i++) { if(document.getElementById("style_select_wysija").options[i].value == NewSize){ document.getElementById("style_select_wysija").options[i].selected = true; } } } }'; $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); $receiverClass = acymailing_get('type.testreceiver'); $this->assignRef('receiverClass', $receiverClass); $this->assignRef('template', $template); $colorBox = acymailing_get('type.color'); $this->assignRef('colorBox', $colorBox); $this->assignRef('infos', $infos); jimport('joomla.html.pane'); $tabs =& JPane::getInstance('tabs'); $this->assignRef('tabs', $tabs); }
static function getCID($field = '') { return acymailing_getCID($field); }
function _sendtest() { JRequest::checkToken() or die('Invalid Token'); $mailid = acymailing_getCID('mailid'); $test_selection = JRequest::getVar('test_selection', '', '', 'string'); if (empty($mailid) or empty($test_selection)) { return false; } $app = JFactory::getApplication(); $mailer = acymailing_get('helper.mailer'); $mailer->forceVersion = JRequest::getVar('test_html', 1, '', 'int'); $mailer->autoAddUser = true; if ($app->isAdmin()) { $mailer->SMTPDebug = 1; } $mailer->checkConfirmField = false; $comment = JRequest::getString('commentTest', ''); if (!empty($comment)) { $mailer->introtext = '<div align="center" style="width:600px;margin:auto;margin-top:10px;margin-bottom:10px;padding:10px;border:1px solid #cccccc;background-color:#f6f6f6;color:#333333;">' . nl2br($comment) . '</div>'; } $receivers = array(); if ($test_selection == 'users') { $receiverEntry = JRequest::getVar('test_emails', '', '', 'string'); if (!empty($receiverEntry)) { if (substr_count($receiverEntry, '@') > 1) { $receivers = explode(',', trim(preg_replace('# +#', '', $receiverEntry))); } else { $receivers[] = trim($receiverEntry); } } } else { $gid = JRequest::getInt('test_group', '-1'); if ($gid == -1) { return false; } $db = JFactory::getDBO(); if (!ACYMAILING_J16) { $db->setQuery('SELECT email FROM ' . acymailing_table('users', false) . ' WHERE gid = ' . intval($gid)); } else { $db->setQuery('SELECT u.email FROM ' . acymailing_table('users', false) . ' AS u JOIN ' . acymailing_table('user_usergroup_map', false) . ' AS ugm ON u.id = ugm.user_id WHERE ugm.group_id = ' . intval($gid)); } $receivers = acymailing_loadResultArray($db); } if (empty($receivers)) { $app->enqueueMessage(JText::_('NO_SUBSCRIBER'), 'notice'); return false; } $result = true; foreach ($receivers as $receiver) { $result = $mailer->sendOne($mailid, $receiver) && $result; } return $result; }
function preview() { $app = JFactory::getApplication(); $mailid = acymailing_getCID('mailid'); $config = acymailing_config(); JHTML::_('behavior.modal', 'a.modal'); $mailerHelper = acymailing_get('helper.mailer'); $mailerHelper->loadedToSend = false; $mail = $mailerHelper->load($mailid); $user = JFactory::getUser(); $userClass = acymailing_get('class.subscriber'); $receiver = $userClass->get($user->email); $mail->sendHTML = true; $mailerHelper->dispatcher->trigger('acymailing_replaceusertags', array(&$mail, &$receiver, false)); if (!empty($mail->altbody)) { $mail->altbody = $mailerHelper->textVersion($mail->altbody, false); } $listmailClass = acymailing_get('class.listmail'); $lists = $listmailClass->getReceivers($mail->mailid, true, false); $testreceiverType = acymailing_get('type.testreceiver'); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName(); $infos = new stdClass(); $infos->test_selection = $app->getUserStateFromRequest($paramBase . ".test_selection", 'test_selection', '', 'string'); $infos->test_group = $app->getUserStateFromRequest($paramBase . ".test_group", 'test_group', '', 'string'); $infos->test_emails = $app->getUserStateFromRequest($paramBase . ".test_emails", 'test_emails', '', 'string'); $infos->test_html = $app->getUserStateFromRequest($paramBase . ".test_html", 'test_html', 1, 'int'); if ($app->isAdmin()) { acymailing_setTitle(JText::_('ACY_PREVIEW') . ' : ' . $mail->subject, $this->icon, $this->ctrl . '&task=preview&mailid=' . $mailid); $bar = JToolBar::getInstance('toolbar'); if ($this->type == 'news') { if (acymailing_level(1) && acymailing_isAllowed($config->get('acl_newsletters_schedule', 'all'))) { if ($mail->published == 2) { JToolBarHelper::custom('unschedule', 'unschedule', '', JText::_('UNSCHEDULE'), false); } else { $bar->appendButton('Acypopup', 'schedule', JText::_('SCHEDULE'), "index.php?option=com_acymailing&ctrl=send&task=scheduleready&tmpl=component&mailid=" . $mailid); } } if (acymailing_isAllowed($config->get('acl_newsletters_send', 'all'))) { $bar->appendButton('Acypopup', 'acysend', JText::_('SEND'), "index.php?option=com_acymailing&ctrl=send&task=sendready&tmpl=component&mailid=" . $mailid); } JToolBarHelper::divider(); } if (acymailing_isAllowed($config->get('acl_' . $this->aclCat . '_spam_test', 'all'))) { if (acymailing_level(1)) { $height = 638; $width = 1000; } else { $height = 50; $width = 600; } $bar->appendButton('Acypopup', 'spamtest', JText::_('SPAM_TEST'), "index.php?option=com_acymailing&ctrl=send&task=spamtest&tmpl=component&mailid=" . $mailid, $width, $height); } JToolBarHelper::custom('edit', 'edit', '', JText::_('ACY_EDIT'), false); JToolBarHelper::cancel('cancel', JText::_('ACY_CLOSE')); JToolBarHelper::divider(); $bar->appendButton('Pophelp', $this->doc); if (acymailing_isAllowed($config->get('acl_cpanel_manage', 'all'))) { $bar->appendButton('Link', 'acymailing', JText::_('ACY_CPANEL'), acymailing_completeLink('dashboard')); } } $this->assignRef('lists', $lists); $this->assignRef('infos', $infos); $this->assignRef('testreceiverType', $testreceiverType); $this->assignRef('mail', $mail); if ($mail->html) { $templateClass = acymailing_get('class.template'); if (!empty($mail->tempid)) { $templateClass->createTemplateFile($mail->tempid); } $templateClass->displayPreview('newsletter_preview_area', $mail->tempid, $mail->subject); } }
function form() { $db = JFactory::getDBO(); $config = acymailing_config(); if (JRequest::getVar('task') == 'filterDisplayUsers') { $action = array(); $action['type'] = array('displayUsers'); $action[] = array('displayUsers' => array()); $filterClass = acymailing_get('class.filter'); $filterClass->subid = JRequest::getString('subid'); $filterClass->execute(JRequest::getVar('filter'), $action); if (!empty($filterClass->report)) { $this->assignRef('filteredUsers', $filterClass->report[0]); } } $filid = acymailing_getCID('filid'); $filterClass = acymailing_get('class.filter'); $testFilter = JRequest::getVar('filter'); if (!empty($filid) && empty($testFilter)) { $filter = $filterClass->get($filid); } else { $filter = new stdClass(); $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, 'massactions'))); $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(); foreach ($typesFilters as $oneType => $oneName) { $typevaluesFilters[] = JHTML::_('select.option', $oneType, $oneName); } foreach ($typesActions as $oneType => $oneName) { $typevaluesActions[] = JHTML::_('select.option', $oneType, $oneName); } $js = "function updateAction(actionNum){\r\n\t\t\t\tvar actiontype = window.document.getElementById('actiontype'+actionNum);\r\n\t\t\t\tif(actiontype == 'undefined' || actiontype == null) return;\r\n\t\t\t\tcurrentActionType = actiontype.value;\r\n\t\t\t\tif(!currentActionType){\r\n\t\t\t\t\twindow.document.getElementById('actionarea_'+actionNum).innerHTML = '';\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t\tactionArea = 'action__num__'+currentActionType;\r\n\t\t\t\twindow.document.getElementById('actionarea_'+actionNum).innerHTML = window.document.getElementById(actionArea).innerHTML.replace(/__num__/g,actionNum);\r\n\t\t\t\tif(typeof(window['onAcyDisplayAction_'+currentActionType]) == 'function') {\r\n\t\t\t\t\ttry{ window['onAcyDisplayAction_'+currentActionType](actionNum); }catch(e){alert('Error in the onAcyDisplayAction_'+currentActionType+' function : '+e); }\r\n\t\t\t\t}\r\n\r\n\t\t\t}"; $js .= "var numActions = 0;\r\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\tvar allactions = document.getElementById('allactions');\r\n\t\t\t\t\tif(allactions != 'undefined' && allactions != null) allactions.appendChild(newdiv); updateAction(numActions); numActions++;\r\n\t\t\t\t}"; $js .= "window.addEvent('domready', function(){ addAcyFilter(); addAction(); });"; if (!ACYMAILING_J16) { $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; }'; } if (ACYMAILING_J30) { $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\treturn false;}\r\n\t\t\t\t\tif(window.document.getElementById('title').value.length < 2){alert('" . JText::_('ENTER_TITLE', true) . "'); return false;}"; } else { $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\treturn false;}\r\n\t\t\t\t\tif(window.document.getElementById('title').value.length < 2){alert('" . JText::_('ENTER_TITLE', true) . "'); return false;}"; } if (!ACYMAILING_J16) { $js .= "submitform( pressbutton );} "; } else { $js .= "Joomla.submitform(pressbutton,document.adminForm);}; "; } $doc->addScriptDeclaration($js); $filterClass->addJSFilterFunctions(); $js = ''; $data = array('addAction' => 'action', 'addAcyFilter' => 'filter'); foreach ($data as $jsFunction => $datatype) { if (empty($filter->{$datatype})) { continue; } foreach ($filter->{$datatype}['type'] as $num => $oneType) { if (empty($oneType)) { continue; } $js .= "while(!document.getElementById('" . $datatype . "type{$num}')){" . $jsFunction . "();}\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) { if (is_array($value)) { $js .= "try{"; foreach ($value as $subkey => $subval) { $js .= "document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}][{$subkey}]'].value = '" . addslashes(str_replace(array("\n", "\r"), ' ', $subval)) . "';"; $js .= "if(document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}][{$subkey}]'].type && document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}][{$subkey}]'].type == 'checkbox'){ document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}][{$subkey}]'].checked = 'checked'; }"; } $js .= "}catch(e){}"; } $myVal = is_array($value) ? implode(',', $value) : $value; $js .= "try{"; $js .= "document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}]'].value = '" . addslashes(str_replace(array("\n", "\r"), ' ', $myVal)) . "';"; $js .= "if(document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}]'].type && document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}]'].type == 'checkbox'){ document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}]'].checked = 'checked'; }"; $js .= "}catch(e){}"; } $js .= "\n" . " if(typeof(onAcyDisplay" . ucfirst($datatype) . "_" . $oneType . ") == 'function'){\r\n\t\t\t\t\ttry{ onAcyDisplay" . ucfirst($datatype) . "_" . $oneType . "({$num}); }catch(e){alert('Error in the onAcyDisplay" . ucfirst($datatype) . "_" . $oneType . " function : '+e); }\r\n\t\t\t\t}"; if ($datatype == 'filter') { $js .= " countresults({$num});"; } } } $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'); $listHours = array(); $listMinutess = array(); for ($i = 0; $i < 24; $i++) { $listHours[] = JHTML::_('select.option', $i, $i < 10 ? '0' . $i : $i); } $hours = JHTML::_('select.genericlist', $listHours, 'triggerhours', 'class="inputbox" size="1" style="width:60px;"', 'value', 'text', acymailing_getDate($nextDate, 'H')); for ($i = 0; $i < 60; $i += 5) { $listMinutess[] = JHTML::_('select.option', $i, $i < 10 ? '0' . $i : $i); } $defaultMin = floor(acymailing_getDate($nextDate, 'i') / 5) * 5; $minutes = JHTML::_('select.genericlist', $listMinutess, 'triggerminutes', 'class="inputbox" size="1" style="width:60px;"', 'value', 'text', $defaultMin); $this->assign('hours', $hours); $this->assign('minutes', $minutes); $this->assign('nextDate', !empty($nextDate) ? ' (' . JText::_('NEXT_RUN') . ' : ' . acymailing_getDate($nextDate, '%d %B %Y %H:%M') . ')' : ''); $triggers['allcron'] = JText::_('ACY_EACH_TIME'); $triggers['subcreate'] = JText::_('ON_USER_CREATE'); $triggers['subchange'] = JText::_('ON_USER_CHANGE'); $this->dispatcher->trigger('onAcyDisplayTriggers', array(&$triggers)); $name = empty($filter->name) ? '' : ' : ' . $filter->name; if (JRequest::getCmd('tmpl', '') != 'component') { $acyToolbar = acymailing::get('helper.toolbar'); $acyToolbar->custom('filterDisplayUsers', JText::_('FILTER_VIEW_USERS'), 'user', false, ''); $acyToolbar->custom('process', JText::_('PROCESS'), 'process', false, ''); $acyToolbar->divider(); if (acymailing_level(3)) { $acyToolbar->save(); if (!empty($filter->filid)) { $acyToolbar->link(acymailing_completeLink('filter&task=edit&filid=0'), JText::_('ACY_NEW'), 'new'); } } $acyToolbar->link(acymailing_completeLink('dashboard'), JText::_('ACY_CLOSE'), 'cancel'); $acyToolbar->divider(); $acyToolbar->help('filter'); $acyToolbar->setTitle(JText::_('ACY_MASS_ACTIONS') . $name, 'filter&task=edit&filid=' . $filid); $acyToolbar->display(); } else { acymailing_setPageTitle(JText::_('ACY_MASS_ACTIONS') . $name); } $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); if (JRequest::getCmd('tmpl') == 'component') { $doc->addStyleSheet(ACYMAILING_CSS . 'frontendedition.css?v=' . filemtime(ACYMAILING_MEDIA . 'css' . DS . '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(); $toggleClass = acymailing_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('filters', $filters); } }
function saveForm() { $app = JFactory::getApplication(); $config = acymailing_config(); $allowUserModifications = (bool) ($config->get('allow_modif', 'data') == 'all') || $this->allowModif; $allowSubscriptionModifications = (bool) ($config->get('allow_modif', 'data') != 'none') || $this->allowModif; $subscriber = new stdClass(); $subscriber->subid = acymailing_getCID('subid'); if (!$this->allowModif && !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; } } if (!empty($subscriber->email)) { $this->database->setQuery('SELECT * FROM #__acymailing_subscriber WHERE email = ' . $this->database->Quote($subscriber->email) . ' AND subid != ' . intval(@$subscriber->subid)); $existSubscriber = $this->database->loadObject(); if (!empty($existSubscriber->subid)) { $overwritenow = true; if ($this->allowModif) { if ($app->isAdmin()) { $overwritenow = false; } else { $listClass = acymailing_get('class.list'); $allowedLists = $listClass->getFrontendLists('listid'); if (empty($allowedLists)) { $this->errors[] = "Not sure how you were able to edit this user if you don't own any list..."; return false; } $this->database->setQuery('SELECT listid FROM #__acymailing_listsub WHERE subid = ' . intval($existSubscriber->subid) . ' AND listid IN (' . implode(',', array_keys($allowedLists)) . ')'); $allowedlistid = $this->database->loadResult(); if (!empty($allowedlistid)) { $overwritenow = false; } } } if ($overwritenow) { $subscriber->subid = $existSubscriber->subid; $subscriber->confirmed = $existSubscriber->confirmed; } else { $this->errors[] = JText::sprintf('USER_ALREADY_EXISTS', $subscriber->email); $this->errors[] = '<a href="' . acymailing_completeLink(($app->isAdmin() ? 'subscriber' : 'frontsubscriber&listid=' . $allowedlistid) . '&task=edit&subid=' . $existSubscriber->subid) . '" >' . JText::_('CLICK_EDIT_USER') . '</a>'; return false; } } } if (!$this->allowModif && !empty($subscriber->subid) && !empty($subscriber->email)) { $existSubscriber = $this->get($subscriber->subid); if (trim(strtolower($subscriber->email)) != strtolower($existSubscriber->email)) { $subscriber->confirmed = 0; } } $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 (!$this->allowModif && 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 saveForm() { $filter = new stdClass(); $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 = new stdClass(); foreach ($alltriggers as $oneTrigger) { $name = 'triggerfilter_' . $oneTrigger; if ($config->get($name)) { continue; } $newConfig->{$name} = 1; } if (in_array('daycron', $alltriggers)) { $oldTime = $config->get('cron_plugins_next', 0); $newHours = JRequest::getVar('triggerhours'); $newMinutes = JRequest::getVar('triggerminutes'); $newTime = acymailing_getTime(date('Y') . '-' . date('m') . '-' . date('d') . ' ' . $newHours . ':' . $newMinutes); if ($newTime < $oldTime || $newTime < time()) { $newTime += 86400; } $newConfig->cron_plugins_next = $newTime; } 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 form() { acymailing_loadMootools(); $app = JFactory::getApplication(); $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 = new stdClass(); $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; $mail->alias = ''; } $values = new stdClass(); $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'); JHTML::_('behavior.modal', 'a.modal'); $acyToolbar = acymailing::get('helper.toolbar'); $acyToolbar->custom('', JText::_('ACY_TEMPLATES'), 'template', false, 'displayTemplates(); return false;'); $acyToolbar->custom('', JText::_('TAGS'), 'tag', false, 'try{IeCursorFix();}catch(e){}; displayTags(); return false;'); $acyToolbar->divider(); $acyToolbar->custom('test', JText::_('SEND_TEST'), 'send', false); $acyToolbar->custom('apply', JText::_('ACY_APPLY'), 'apply', false); $acyToolbar->setTitle(JText::_('ACY_EDIT')); $acyToolbar->topfixed = false; $acyToolbar->display(); $editor = acymailing_get('helper.editor'); $editor->setTemplate($mail->tempid); $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 .= '}'; $script = ' var attachmentNb = 1; function addFileLoader(){ if(attachmentNb > 9) return; window.document.getElementById("attachmentsdiv"+attachmentNb).style.display = ""; attachmentNb++; }'; if (!ACYMAILING_J16) { $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 (!ACYMAILING_J16) { $script .= 'submitform( pressbutton );} '; } else { $script .= 'Joomla.submitform(pressbutton,document.adminForm);}; '; } $script .= "function insertTag(tag){\n\t\ttry{\n\t\t\tif(window.parent.tinymce){ parentTinymce = window.parent.tinymce; window.parent.tinymce = false; }\n\t\t\tjInsertEditorText(tag,'editor_body');\n\t\t\tif(typeof parentTinymce !== 'undefined'){ window.parent.tinymce = parentTinymce; }\n\t\t\tdocument.getElementById('iframetag').style.display = 'none';\n\t\t\tdisplayTags();\n\t\t\treturn true;\n\t\t}catch(err){alert('Your editor does not enable AcyMailing to automatically insert the tag, please copy/paste it manually in your Newsletter'); return false;}}"; $typeMail = 'news'; if (strpos($mail->alias, 'notification') !== false) { $typeMail = 'notification'; } $iFrame = "'<iframe src=\\'index.php?option=com_acymailing&ctrl=tag&task=tag&type=" . $typeMail . "&tmpl=component\\' width=\\'100%\\' height=\\'100%\\' scrolling=\\'auto\\'></iframe>'"; $script .= "var openTag = true;\n\t\t\t\t\tfunction displayTags(){var box=\$('iframetag'); if(openTag){box.innerHTML = " . $iFrame . "; box.setStyle('display','block');}\n\t\t\t\t\ttry{\n\t\t\t\t\t\tvar fx = box.effects({duration: 1500, transition: Fx.Transitions.Quart.easeOut});\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');})};\n\t\t\t\t\t}catch(err){\n\t\t\t\t\t\tbox.style.height = '300px';\n\t\t\t\t\t\tvar myVerticalSlide = new Fx.Slide('iframetag');\n\t\t\t\t\t\tif(openTag){\n\t\t\t\t\t\t\tmyVerticalSlide.slideIn();\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tmyVerticalSlide.slideOut().chain(function() {\n\t\t\t\t\t\t\t\tbox.innerHTML='';\n\t\t\t\t\t\t\t\tbox.setStyle('display','none');\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\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;\n\t\t\t\t\tfunction displayTemplates(){var box=\$('iframetemplate'); if(openTemplate){box.innerHTML = " . $iFrame . "; box.setStyle('display','block');}\n\t\t\t\t\ttry{\n\t\t\t\t\t\tvar fx = box.effects({duration: 1500, transition: Fx.Transitions.Quart.easeOut});\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');})};\n\t\t\t\t\t}catch(err){\n\t\t\t\t\t\tbox.style.height = '300px';\n\t\t\t\t\t\tvar myVerticalSlide = new Fx.Slide('iframetemplate');\n\t\t\t\t\t\tif(openTemplate){\n\t\t\t\t\t\t\tmyVerticalSlide.slideIn();\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tmyVerticalSlide.slideOut().chain(function() {\n\t\t\t\t\t\t\t\tbox.innerHTML='';\n\t\t\t\t\t\t\t\tbox.setStyle('display','none');\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\topenTemplate = !openTemplate;}"; $script .= "function changeTemplate(newhtml,newtext,newsubject,stylesheet,fromname,fromemail,replyname,replyemail,tempid){\n\t\t\tif(newhtml.length>2){" . $editor->setContent('newhtml') . "}\n\t\t\tvar vartextarea =\$('altbody'); if(newtext.length>2) vartextarea.innerHTML = newtext;\n\t\t\tdocument.getElementById('tempid').value = tempid;\n\t\t\tif(fromname.length>1){document.getElementById('fromname').value = fromname;}\n\t\t\tif(fromemail.length>1){document.getElementById('fromemail').value = fromemail;}\n\t\t\tif(replyname.length>1){document.getElementById('replyname').value = replyname;}\n\t\t\tif(replyemail.length>1){document.getElementById('replyemail').value = replyemail;}\n\t\t\tif(newsubject.length>1){document.getElementById('subject').value = newsubject;}\n\t\t\t" . $editor->setEditorStylesheet('tempid') . "\n\t\t\tdocument.getElementById('iframetemplate').style.display = 'none'; displayTemplates();\n\t\t}\n\t\t"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js . $script); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('editor', $editor); $this->assignRef('values', $values); $this->assignRef('mail', $mail); $tabs = acymailing_get('helper.acytabs'); $tabs->setOptions(array('useCookie' => true)); $this->assignRef('tabs', $tabs); $this->assign('app', $app); }
function form() { $subid = acymailing_getCID('subid'); $db = JFactory::getDBO(); $app = JFactory::getApplication(); $config = acymailing_config(); if (!empty($subid)) { $subscriberClass = acymailing_get('class.subscriber'); $subscriber = $subscriberClass->getFull($subid); $subscription = $app->isAdmin() ? $subscriberClass->getSubscription($subid) : $subscriberClass->getFrontendSubscription($subid); if (empty($subscriber->subid)) { acymailing_display('User ' . $subid . ' not found', 'error'); $subid = 0; } } if (empty($subid)) { $listType = acymailing_get('class.list'); $subscription = $app->isAdmin() ? $listType->getLists() : $listType->getFrontendLists(); $subscriber = new stdClass(); $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 ($app->isAdmin()) { acymailing_setTitle(JText::_('ACY_USER'), 'acyusers', 'subscriber&task=edit&subid=' . $subid); $bar = JToolBar::getInstance('toolbar'); } if (!empty($subid)) { $query = 'SELECT a.`mailid`, a.`html`, a.`sent`, a.`senddate`,a.`open`, a.`opendate`, a.`bounce`, a.`fail`,b.`subject`,b.`alias`'; $query .= ' FROM `#__acymailing_userstats` as a'; $query .= ' JOIN ' . acymailing_table('mail') . ' as b on a.mailid = b.mailid'; $query .= ' WHERE a.subid = ' . intval($subid) . ' ORDER BY a.senddate DESC LIMIT 30'; $db->setQuery($query); $open = $db->loadObjectList(); $this->assignRef('open', $open); if (acymailing_level(3)) { $db->setQuery('SELECT DISTINCT `mailid` FROM `#__acymailing_urlclick` WHERE `subid` = ' . intval($subid)); $clickedNews = $db->loadObjectList('mailid'); $this->assignRef('clickedNews', $clickedNews); } $query = 'SELECT a.*,b.`subject`,b.`alias`'; $query .= ' FROM `#__acymailing_queue` as a'; $query .= ' JOIN ' . acymailing_table('mail') . ' as b on a.mailid = b.mailid'; $query .= ' WHERE a.subid = ' . intval($subid) . ' ORDER BY a.senddate ASC LIMIT 60'; $db->setQuery($query); $queue = $db->loadObjectList(); $this->assignRef('queue', $queue); $query = 'SELECT h.*,m.subject FROM #__acymailing_history as h LEFT JOIN #__acymailing_mail as m ON h.mailid = m.mailid WHERE h.subid = ' . intval($subid) . ' ORDER BY h.`date` DESC LIMIT 30'; $db->setQuery($query); $history = $db->loadObjectList(); $this->assignRef('history', $history); $query = 'SELECT * FROM #__acymailing_geolocation WHERE geolocation_subid=' . intval($subid) . ' ORDER BY geolocation_created DESC LIMIT 100'; $db->setQuery($query); $geoloc = $db->loadObjectList(); if (!empty($geoloc)) { $markCities = array(); $diffCountries = false; $dataDetails = array(); foreach ($geoloc as $mark) { $indexCity = array_search($mark->geolocation_city, $markCities); if ($indexCity === false) { array_push($markCities, $mark->geolocation_city); array_push($dataDetails, array('nbInCity' => 1, 'actions' => $mark->geolocation_type)); } else { $dataDetails[$indexCity]['nbInCity'] += 1; $dataDetails[$indexCity]['actions'] .= ", " . $mark->geolocation_type; } if (!$diffCountries) { if (!empty($region) && $region != $mark->geolocation_country_code) { $region = 'world'; $diffCountries = true; } else { $region = $mark->geolocation_country_code; } } } $this->assignRef('geoloc_region', $region); $this->assignRef('geoloc_city', $markCities); $this->assignRef('geoloc', $geoloc); $this->assignRef('geoloc_details', $dataDetails); } if (!empty($subscriber->ip)) { $query = 'SELECT * FROM #__acymailing_subscriber WHERE ip=' . $db->Quote($subscriber->ip) . ' AND subid != ' . intval($subid) . ' LIMIT 30'; $db->setQuery($query); $neighbours = $db->loadObjectList(); if (!empty($neighbours)) { $this->assignRef('neighbours', $neighbours); } } } if ($app->isAdmin()) { if (!empty($subscriber->userid)) { if (file_exists(ACYMAILING_ROOT . 'components' . DS . 'com_comprofiler' . DS . 'comprofiler.php')) { $editLink = 'index.php?option=com_comprofiler&task=edit&cid[]='; } elseif (!ACYMAILING_J16) { $editLink = 'index.php?option=com_users&task=edit&cid[]='; } else { $editLink = 'index.php?option=com_users&task=user.edit&id='; } $bar->appendButton('Link', 'edit', JText::_('EDIT_JOOMLA_USER'), $editLink . $subscriber->userid); JToolBarHelper::spacer(); } JToolBarHelper::save(); JToolBarHelper::apply(); if (ACYMAILING_J30) { JToolBarHelper::save2new(); } JToolBarHelper::cancel(); JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'subscriber-form'); } $filters = new stdClass(); $quickstatusType = acymailing_get('type.statusquick'); $filters->statusquick = $quickstatusType->display('statusquick'); $this->assignRef('subscriber', $subscriber); $toggleClass = acymailing_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('subscription', $subscription); $this->assignRef('filters', $filters); $statusType = acymailing_get('type.status'); $this->assignRef('statusType', $statusType); }
function preview() { $app = JFactory::getApplication(); $mailid = acymailing_getCID('mailid'); $config = acymailing_config(); JHTML::_('behavior.modal', 'a.modal'); $mailerHelper = acymailing_get('helper.mailer'); $mailerHelper->loadedToSend = false; $mail = $mailerHelper->load($mailid); $user = JFactory::getUser(); $userClass = acymailing_get('class.subscriber'); $receiver = $userClass->get($user->email); $mail->sendHTML = true; $mailerHelper->dispatcher->trigger('acymailing_replaceusertags', array(&$mail, &$receiver, false)); 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 = new stdClass(); $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::_('ACY_PREVIEW') . ' : ' . $mail->subject, $this->icon, $this->ctrl . '&task=preview&mailid=' . $mailid); $bar = JToolBar::getInstance('toolbar'); if ($this->type == 'news') { if (acymailing_level(1) && acymailing_isAllowed($config->get('acl_newsletters_schedule', 'all'))) { if ($mail->published == 2) { JToolBarHelper::custom('unschedule', 'unschedule', '', JText::_('UNSCHEDULE'), false); } else { $bar->appendButton('Acypopup', 'schedule', JText::_('SCHEDULE'), "index.php?option=com_acymailing&ctrl=send&task=scheduleready&tmpl=component&mailid=" . $mailid); } } if (acymailing_isAllowed($config->get('acl_newsletters_send', 'all'))) { $bar->appendButton('Acypopup', 'acysend', JText::_('SEND'), "index.php?option=com_acymailing&ctrl=send&task=sendready&tmpl=component&mailid=" . $mailid); } JToolBarHelper::divider(); } JToolBarHelper::custom('edit', 'edit', '', JText::_('ACY_EDIT'), false); JToolBarHelper::cancel('cancel', JText::_('ACY_CLOSE')); JToolBarHelper::divider(); $bar->appendButton('Pophelp', $this->doc); $this->assignRef('lists', $lists); $this->assignRef('infos', $infos); $this->assignRef('receiverClass', $receiversClass); $this->assignRef('mail', $mail); }
function display($tpl = null) { global $Itemid; $db = JFactory::getDBO(); $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $jsite = JFactory::getApplication('site'); $menus = $jsite->getMenu(); $menu = $menus->getActive(); if (empty($menu) and !empty($Itemid)) { $menus->setActive($Itemid); $menu = $menus->getItem($Itemid); } $myItem = empty($Itemid) ? '' : '&Itemid=' . $Itemid; if (is_object($menu)) { jimport('joomla.html.parameter'); $menuparams = new acyParameter($menu->params); } $listid = acymailing_getCID('listid'); if (empty($listid) and !empty($menuparams)) { $listid = $menuparams->get('listid'); } $doc->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')); } $config = acymailing_config(); $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.' . $config->get('acyrss_order', 'senddate') . ' ' . ($config->get('acyrss_order', 'senddate') == 'subject' ? 'ASC' : 'DESC'); $query .= ' LIMIT ' . $config->get('acyrss_element', '20'); $db->setQuery($query); $rows = $db->loadObjectList(); $doc->title = $config->get('acyrss_name', ''); $doc->description = $config->get('acyrss_description', ''); $receiver = new stdClass(); $receiver->name = JText::_('VISITOR'); $receiver->subid = 0; $mailClass = acymailing_get('helper.mailer'); foreach ($rows as $row) { $mailClass->loadedToSend = false; $oneMail = $mailClass->load($row->mailid); $oneMail->sendHTML = true; $mailClass->dispatcher->trigger('acymailing_replaceusertags', array(&$oneMail, &$receiver, false)); $title = $this->escape($oneMail->subject); $title = html_entity_decode($title); $link = JRoute::_('index.php?option=com_acymailing&ctrl=archive&task=view&listid=' . $oneList->listid . '-' . $oneList->alias . '&mailid=' . $row->mailid . '-' . $row->alias); $author = $oneMail->userid; $item = new JFeedItem(); $item->title = $title; $item->link = $link; $item->description = $oneMail->body; $item->date = $oneMail->created; $item->category = $oneMail->type; $item->author = $author; $doc->addItem($item); } }
function saveForm() { $app = JFactory::getApplication(); $db = JFactory::getDBO(); $config =& acymailing_config(); $mail = new stdClass(); $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, '<ADV>'); } } } $mail->body = JRequest::getVar('editor_body', '', '', 'string', JREQUEST_ALLOWRAW); $acypluginsHelper = acymailing_get('helper.acyplugins'); $acypluginsHelper->cleanHtml($mail->body); $mail->attach = array(); $attachments = JRequest::getVar('attachments', array(), 'files', 'array'); if (!empty($attachments['name'][0]) or !empty($attachments['name'][1])) { jimport('joomla.filesystem.file'); $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 = new stdClass(); $attachment->filename = strtolower(JFile::makeSafe($filename)); $attachment->size = $attachments['size'][$id]; if (!preg_match('#\\.(' . str_replace(array(',', '.'), array('|', '\\.'), $config->get('allowedfiles')) . ')$#Ui', $attachment->filename, $extension) || preg_match('#\\.(php.?|.?htm.?|pl|py|jsp|asp|sh|cgi)#Ui', $attachment->filename)) { $app->enqueueMessage(JText::sprintf('ACCEPTED_TYPE', substr($attachment->filename, strrpos($attachment->filename, '.') + 1), $config->get('allowedfiles')), 'notice'); continue; } $attachment->filename = str_replace(array('.', ' '), '_', substr($attachment->filename, 0, strpos($attachment->filename, $extension[0]))) . $extension[0]; 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', '<b><i>' . $attachments['tmp_name'][$id] . '</i></b>', '<b><i>' . $uploadPath . $attachment->filename . '</i></b>'), 'error'); continue; } } $mail->attach[] = $attachment; } } if (isset($mail->filter)) { $mail->filter = array(); $filterData = JRequest::getVar('filter'); foreach ($filterData['type'] as $num => $oneType) { if (empty($oneType)) { continue; } $mail->filter['type'][$num] = $oneType; $mail->filter[$num][$oneType] = $filterData[$num][$oneType]; } } $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) { $this->_publishfollowup($mail); } 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'); } } if (preg_match('#<a[^>]*subid=[0-9].*</a>#Uis', $mail->body, $pregResult)) { $app->enqueueMessage('There is a personal link in your Newsletter ( ' . $pregResult[0] . ' ) instead of a tag...<br/>Please make sure to not copy/paste the link you received in your e-mail as it may break your unsubscribe or confirmation links.<br/>Use our tags instead!', 'notice'); } $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); } if (!empty($mail->type) && $mail->type == 'followup' && empty($mail->mailid) && !empty($mail->published)) { $mail->mailid = $mailid; $this->_publishfollowup($mail); } return $status; }