function doexport() { if (!$this->isAllowed('subscriber', 'export')) { return; } JRequest::checkToken() or die('Invalid Token'); acymailing_increasePerf(); $filtersExport = JRequest::getVar('exportfilter'); $listsToExport = JRequest::getVar('exportlists'); $fieldsToExport = JRequest::getVar('exportdata'); $fieldsToExportList = JRequest::getVar('exportdatalist'); $fieldsToExportOthers = JRequest::getVar('exportdataother'); $inseparator = JRequest::getString('exportseparator'); $inseparator = str_replace(array('semicolon', 'colon', 'comma'), array(';', ',', ','), $inseparator); $exportFormat = JRequest::getString('exportformat'); if (!in_array($inseparator, array(',', ';'))) { $inseparator = ';'; } $exportLists = array(); if (!empty($filtersExport['subscribed'])) { foreach ($listsToExport as $listid => $checked) { if (!empty($checked)) { $exportLists[] = (int) $listid; } } } $exportFields = array(); $exportFieldsList = array(); $exportFieldsOthers = array(); $selectOthers = ''; foreach ($fieldsToExport as $fieldName => $checked) { if (!empty($checked)) { $exportFields[] = acymailing_secureField($fieldName); } } foreach ($fieldsToExportList as $fieldName => $checked) { if (!empty($checked)) { $exportFieldsList[] = acymailing_secureField($fieldName); } } if (!empty($fieldsToExportOthers)) { foreach ($fieldsToExportOthers as $fieldName => $checked) { if (!empty($checked)) { $exportFieldsOthers[] = acymailing_secureField($fieldName); } } } $selectFields = 's.`' . implode('`, s.`', $exportFields) . '`'; $config = acymailing_config(); $newConfig = new stdClass(); $newConfig->export_fields = implode(',', array_merge($exportFields, $exportFieldsOthers, $exportFieldsList)); $newConfig->export_lists = implode(',', $exportLists); $newConfig->export_separator = JRequest::getString('exportseparator'); $newConfig->export_format = $exportFormat; $filterActive = array(); foreach ($filtersExport as $filterKey => $value) { if ($value == 1) { $filterActive[] = $filterKey; } } $newConfig->export_filters = implode(',', $filterActive); $config->save($newConfig); $where = array(); if (empty($exportLists)) { $querySelect = 'SELECT s.`subid`, ' . $selectFields . ' FROM ' . acymailing_table('subscriber') . ' as s'; } else { $querySelect = 'SELECT DISTINCT s.`subid`, ' . $selectFields . ' FROM ' . acymailing_table('listsub') . ' as a JOIN ' . acymailing_table('subscriber') . ' as s on a.subid = s.subid'; $where[] = 'a.listid IN (' . implode(',', $exportLists) . ')'; $where[] = 'a.status = 1'; } if (!empty($filtersExport['confirmed'])) { $where[] = 's.confirmed = 1'; } if (!empty($filtersExport['registered'])) { $where[] = 's.userid > 0'; } if (!empty($filtersExport['enabled'])) { $where[] = 's.enabled = 1'; } if (JRequest::getInt('sessionvalues') and !empty($_SESSION['acymailing']['exportusers'])) { $where[] = 's.subid IN (' . implode(',', $_SESSION['acymailing']['exportusers']) . ')'; } $query = $querySelect; if (!empty($where)) { $query .= ' WHERE (' . implode(') AND (', $where) . ')'; } if (JRequest::getInt('sessionquery')) { $currentSession = JFactory::getSession(); $selectOthers = ''; if (!empty($exportFieldsOthers)) { foreach ($exportFieldsOthers as $oneField) { $selectOthers .= ' , ' . $oneField . ' AS ' . str_replace('.', '_', $oneField); } } $query = 'SELECT DISTINCT s.`subid`, ' . $selectFields . $selectOthers . ' ' . $currentSession->get('acyexportquery'); } $query .= ' ORDER BY s.subid'; $db = JFactory::getDBO(); $encodingClass = acymailing_get('helper.encoding'); $exportHelper = acymailing_get('helper.export'); $fileName = 'export_' . date('Y-m-d'); if (!empty($exportLists)) { $fileName = ''; $db->setQuery('SELECT name FROM #__acymailing_list WHERE listid IN (' . implode(',', $exportLists) . ')'); $allExportedLists = $db->loadObjectList(); foreach ($allExportedLists as $oneList) { $fileName .= '__' . $oneList->name; } $fileName = trim($fileName, '__'); } $exportHelper->addHeaders($fileName); $eol = "\r\n"; $before = '"'; $separator = '"' . $inseparator . '"'; $after = '"'; $allFields = array_merge($exportFields, $exportFieldsOthers); if (!empty($exportFieldsList)) { $allFields = array_merge($allFields, $exportFieldsList); $selectFields = 'l.`' . implode('`, l.`', $exportFieldsList) . '`'; $selectFields = str_replace('listname', 'name', $selectFields); } echo $before . implode($separator, $allFields) . $after . $eol; if (acymailing_bytes(ini_get('memory_limit')) > 150000000) { $nbExport = 50000; } elseif (acymailing_bytes(ini_get('memory_limit')) > 80000000) { $nbExport = 15000; } else { $nbExport = 5000; } if (!empty($exportFieldsList)) { $nbExport = 500; } $valDep = 0; $dateFields = array('created', 'confirmed_date', 'lastopen_date', 'lastclick_date', 'lastsent_date', 'userstats_opendate', 'userstats_senddate', 'urlclick_date', 'hist_date'); do { $db->setQuery($query . ' LIMIT ' . $valDep . ', ' . $nbExport); $valDep += $nbExport; $allData = $db->loadAssocList(); if (empty($allData)) { break; } $dataUser = array(); $subids = array(); for ($i = 0, $a = count($allData); $i < $a; $i++) { $subids[] = (int) $allData[$i]['subid']; if (!in_array('subid', $exportFields)) { array_shift($allData[$i]); } foreach ($allData[$i] as $fieldName => $oneUser) { if (!in_array($fieldName, $dateFields)) { $dataUser[$subids[$i]][$fieldName] = $oneUser; } else { $dataUser[$subids[$i]][$fieldName] = acymailing_getDate($oneUser, '%Y-%m-%d %H:%M:%S'); } } } if (!empty($exportFieldsList) && !empty($subids)) { $queryList = 'SELECT ' . $selectFields . ', ls.subid FROM #__acymailing_listsub as ls JOIN #__acymailing_list as l ON ls.listid=l.listid JOIN #__acymailing_subscriber as s on ls.subid = s.subid WHERE (ls.status = 1) and ls.subid IN (' . implode(',', $subids) . ')'; if (!empty($exportLists)) { $queryList .= ' AND ls.listid IN (' . implode(',', $exportLists) . ')'; } $db->setQuery($queryList); $resList = $db->loadObjectList(); $userListid = array(); $userListname = array(); foreach ($resList as $listsub) { if (in_array('listid', $exportFieldsList)) { $userListid[$listsub->subid] = empty($userListid[$listsub->subid]) ? $listsub->listid : $userListid[$listsub->subid] . ' - ' . $listsub->listid; } if (in_array('listname', $exportFieldsList)) { $userListname[$listsub->subid] = empty($userListname[$listsub->subid]) ? $listsub->name : $userListname[$listsub->subid] . ' - ' . $listsub->name; } } } foreach ($subids as $subid) { if (!empty($exportFieldsList)) { $listDetail = array(); if (in_array('listid', $exportFieldsList)) { $listDetail[] = !empty($userListid[$subid]) ? $userListid[$subid] : ''; } if (in_array('listname', $exportFieldsList)) { $listDetail[] = !empty($userListname[$subid]) ? $userListname[$subid] : ''; } $dataexport = implode($separator, $dataUser[$subid]) . $separator . implode($separator, $listDetail); } else { $dataexport = implode($separator, $dataUser[$subid]); } echo $before . $encodingClass->change($dataexport, 'UTF-8', $exportFormat) . $after . $eol; } } while (!empty($allData)); exit; }
<?php /** * @package AcyMailing for Joomla! * @version 4.9.3 * @author acyba.com * @copyright (C) 2009-2015 ACYBA S.A.R.L. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?> <table class="admintable" cellspacing="1"> <tr id="trfileupload"> <td class="key" > <?php echo JText::_('UPLOAD_FILE'); ?> </td> <td> <input type="file" style="width:auto;" name="importfile" /> <?php echo '<br />' . JText::sprintf('MAX_UPLOAD', acymailing_bytes(ini_get('upload_max_filesize')) > acymailing_bytes(ini_get('post_max_size')) ? ini_get('post_max_size') : ini_get('upload_max_filesize')); ?> </td> </tr> </table>
function form() { $mailid = acymailing_getCID('mailid'); $templateClass = acymailing_get('class.template'); $config =& acymailing_config(); if (!empty($mailid)) { $mailClass = acymailing_get('class.mail'); $mail = $mailClass->get($mailid); if (!empty($mail->tempid)) { $myTemplate = $templateClass->get($mail->tempid); } } else { $mail = new stdClass(); $mail->created = time(); $mail->published = 0; if ($this->type == 'followup') { $mail->published = 1; } $mail->visible = 1; $mail->html = 1; $mail->body = ''; $mail->altbody = ''; $mail->tempid = 0; $templateid = JRequest::getInt('templateid'); if (empty($templateid)) { $myTemplate = $templateClass->getDefault(); } else { $myTemplate = $templateClass->get($templateid); } if (!empty($myTemplate->tempid)) { $mail->body = acymailing_absoluteURL($myTemplate->body); $mail->altbody = $myTemplate->altbody; $mail->tempid = $myTemplate->tempid; $mail->subject = $myTemplate->subject; $mail->replyname = $myTemplate->replyname; $mail->replyemail = $myTemplate->replyemail; $mail->fromname = $myTemplate->fromname; $mail->fromemail = $myTemplate->fromemail; } if ($this->type == 'autonews') { $mail->frequency = 604800; } } $sentbyname = ''; if (!empty($mail->sentby)) { $db = JFactory::getDBO(); $db->setQuery('SELECT `name` FROM `#__users` WHERE `id`= ' . intval($mail->sentby) . ' LIMIT 1'); $sentbyname = $db->loadResult(); } $this->assignRef('sentbyname', $sentbyname); if (JRequest::getVar('task', '') == 'replacetags') { $mailerHelper = acymailing_get('helper.mailer'); JPluginHelper::importPlugin('acymailing'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('acymailing_replacetags', array(&$mail, false)); if (!empty($mail->altbody)) { $mail->altbody = $mailerHelper->textVersion($mail->altbody, false); } } $extraInfos = ''; $values = new stdClass(); if ($this->type == 'followup') { $campaignid = JRequest::getInt('campaign', 0); $extraInfos .= '&campaign=' . $campaignid; $values->delay = acymailing_get('type.delay'); $this->assignRef('campaignid', $campaignid); } else { $listmailClass = acymailing_get('class.listmail'); $lists = $listmailClass->getLists($mailid); } acymailing_setTitle(JText::_($this->nameForm), $this->icon, $this->ctrl . '&task=edit&mailid=' . $mailid . $extraInfos); $bar = JToolBar::getInstance('toolbar'); if (acymailing_isAllowed($config->get('acl_templates_view', 'all'))) { $bar->appendButton('Acypopup', 'acytemplate', JText::_('ACY_TEMPLATE'), "index.php?option=com_acymailing&ctrl=template&task=theme&tmpl=component", 750, 550); } if (acymailing_isAllowed($config->get('acl_tags_view', 'all'))) { $bar->appendButton('Acytags', $this->type); } if (in_array($this->type, array('news', 'followup')) && acymailing_isAllowed($config->get('acl_tags_view', 'all'))) { JToolBarHelper::custom('replacetags', 'replacetag', '', JText::_('REPLACE_TAGS'), false); } $buttonPreview = JText::_('ACY_PREVIEW'); if ($this->type == 'news') { $buttonPreview .= ' / ' . JText::_('SEND'); } JToolBarHelper::divider(); JToolBarHelper::custom('savepreview', 'acypreview', '', $buttonPreview, false); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); JToolBarHelper::divider(); $bar->appendButton('Pophelp', $this->doc); $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->setTemplate($mail->tempid); $editor->name = 'editor_body'; $editor->content = $mail->body; $editor->prepareDisplay(); $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 (!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 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}\r\n\t\t"; $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;}}"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js . $script); if ($this->type == 'autonews') { JHTML::_('behavior.modal', 'a.modal'); $this->assign('delay', acymailing_get('type.delay')); $this->assign('generatingMode', acymailing_get('type.generatemode')); $link = 'index.php?option=com_acymailing&tmpl=component&ctrl=email&task=edit&mailid=notification_autonews'; $values->editnotification = '<a class="modal" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 800, y: 500}}"><button class="btn" onclick="return false">' . JText::_('EDIT_NOTIFICATION_MAIL') . '</button></a>'; } $this->assignRef('toggleClass', $toggleClass); $this->assignRef('lists', $lists); $this->assignRef('editor', $editor); $this->assignRef('mail', $mail); $tabs = acymailing_get('helper.acytabs'); $tabs->setOptions(array('useCookie' => true)); $this->assignRef('tabs', $tabs); $this->assignRef('values', $values); $this->assignRef('config', $config); }
function form() { $this->chosen = false; $app = JFactory::getApplication(); $mailid = acymailing_getCID('mailid'); $templateClass = acymailing_get('class.template'); $config =& acymailing_config(); $my = JFactory::getUser(); if (!empty($mailid)) { $mailClass = acymailing_get('class.mail'); $mail = $mailClass->get($mailid); if (!empty($mail->tempid)) { $myTemplate = $templateClass->get($mail->tempid); } if (empty($mail->mailid)) { acymailing_display('Newsletter ' . $mailid . ' not found', 'error'); $mailid = 0; } } if (empty($mailid)) { $mail = new stdClass(); $mail->created = time(); $mail->published = 0; $mail->thumb = ''; if ($this->type == 'followup') { $mail->published = 1; } $mail->visible = 1; $mail->html = 1; $mail->body = ''; $mail->altbody = ''; $mail->tempid = 0; $templateid = JRequest::getInt('templateid'); if (empty($templateid) and !empty($my->email)) { $subscriberClass = acymailing_get('class.subscriber'); $currentSubscriber = $subscriberClass->get($my->email); if (!empty($currentSubscriber->template)) { $templateid = $currentSubscriber->template; } } if (empty($templateid)) { $myTemplate = $templateClass->getDefault(); } else { $myTemplate = $templateClass->get($templateid); } if (!empty($myTemplate->tempid)) { $mail->body = acymailing_absoluteURL($myTemplate->body); $mail->altbody = $myTemplate->altbody; $mail->tempid = $myTemplate->tempid; $mail->subject = $myTemplate->subject; $mail->replyname = $myTemplate->replyname; $mail->replyemail = $myTemplate->replyemail; $mail->fromname = $myTemplate->fromname; $mail->fromemail = $myTemplate->fromemail; } if ($this->type == 'autonews') { $mail->frequency = 0; } if (!$app->isAdmin()) { if ($config->get('frontend_sender', 0)) { $mail->fromname = $my->name; $mail->fromemail = $my->email; } else { if (empty($mail->fromname)) { $mail->fromname = $config->get('from_name'); } if (empty($mail->fromemail)) { $mail->fromemail = $config->get('from_email'); } } if ($config->get('frontend_reply', 0)) { $mail->replyname = $my->name; $mail->replyemail = $my->email; } else { if (empty($mail->replyname)) { $mail->replyname = $config->get('reply_name'); } if (empty($mail->replyemail)) { $mail->replyemail = $config->get('reply_email'); } } } } $sentbyname = ''; if (!empty($mail->sentby)) { $db = JFactory::getDBO(); $db->setQuery('SELECT `name` FROM `#__users` WHERE `id`= ' . intval($mail->sentby) . ' LIMIT 1'); $sentbyname = $db->loadResult(); } $this->assignRef('sentbyname', $sentbyname); if (JRequest::getVar('task', '') == 'replacetags') { $mailerHelper = acymailing_get('helper.mailer'); $templateClass = acymailing_get('class.template'); $mail->template = $templateClass->get($mail->tempid); JPluginHelper::importPlugin('acymailing'); $mailerHelper->triggerTagsWithRightLanguage($mail, false); if (!empty($mail->altbody)) { $mail->altbody = $mailerHelper->textVersion($mail->altbody, false); } } $extraInfos = ''; $values = new stdClass(); if ($this->type == 'followup') { $campaignid = JRequest::getInt('campaign', 0); $extraInfos .= '&campaign=' . $campaignid; $values->delay = acymailing_get('type.delay'); $this->assignRef('campaignid', $campaignid); } else { $listmailClass = acymailing_get('class.listmail'); $lists = $listmailClass->getLists($mailid); } if ($app->isAdmin()) { acymailing_setTitle(JText::_($this->nameForm), $this->icon, $this->ctrl . '&task=edit&mailid=' . $mailid . $extraInfos); $bar = JToolBar::getInstance('toolbar'); if (acymailing_isAllowed($config->get('acl_templates_view', 'all'))) { $bar->appendButton('Acypopup', 'acytemplate', JText::_('ACY_TEMPLATE'), "index.php?option=com_acymailing&ctrl=template&task=theme&tmpl=component", 750, 550); } if (acymailing_isAllowed($config->get('acl_tags_view', 'all'))) { $bar->appendButton('Acypopup', 'acytags', JText::_('TAGS'), JURI::base() . "index.php?option=com_acymailing&ctrl=tag&task=tag&tmpl=component&type=" . $this->type, 780, 550); } if (in_array($this->type, array('news', 'followup')) && acymailing_isAllowed($config->get('acl_tags_view', 'all'))) { JToolBarHelper::custom('replacetags', 'replacetag', '', JText::_('REPLACE_TAGS'), false); } $buttonPreview = JText::_('ACY_PREVIEW'); if ($this->type == 'news') { $buttonPreview .= ' / ' . JText::_('SEND'); } JToolBarHelper::divider(); JToolBarHelper::custom('savepreview', 'acypreview', '', $buttonPreview, false); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); JToolBarHelper::divider(); $bar->appendButton('Pophelp', $this->doc); } $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'); if (!$app->isAdmin()) { $toggleClass->ctrl = 'frontnewsletter'; $toggleClass->extra = '&listid=' . JRequest::getInt('listid'); $copyAllLists = $lists; foreach ($copyAllLists as $listid => $oneList) { if (!$oneList->published or empty($my->id)) { unset($lists[$listid]); continue; } if ($oneList->access_manage == 'all') { continue; } if ((int) $my->id == (int) $oneList->userid) { continue; } if (!acymailing_isAllowed($oneList->access_manage)) { unset($lists[$listid]); continue; } } if (empty($lists)) { $app = JFactory::getApplication(); $app->enqueueMessage('You don\'t have the rights to add or edit an e-mail', 'error'); $app->redirect(acymailing_completeLink('frontnewsletter', false, true)); } } $editor = acymailing_get('helper.editor'); $editor->setTemplate($mail->tempid); $editor->name = 'editor_body'; $editor->content = $mail->body; $editor->prepareDisplay(); $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.style.width = \'auto\'; input.name = \'attachments[]\'; divfile.appendChild(document.createElement(\'br\')); divfile.appendChild(input);} '; 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(pressbutton == \'save\' || pressbutton == \'apply\' || pressbutton == \'savepreview\' || pressbutton == \'replacetags\'){ var emailVars = ["fromemail","replyemail"]; var val = ""; for(var key in emailVars){ if(isNaN(key)) continue; val = document.getElementById(emailVars[key]).value; if(!validateEmail(val, emailVars[key])){ 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 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}\n\t\t"; if ($mail->html == 1) { $script .= "var zoneEditor = 'editor_body';"; } else { $script .= "var zoneEditor = 'altbody';"; } $script .= "\n\t\t\tvar zoneToTag = 'altbody';\n\t\t\tfunction initTagZone(html){ if(html == 0){ zoneEditor = 'altbody'; }else{ zoneEditor = 'editor_body'; }}\n\t\t"; $script .= "var previousSelection = false;\n\t\t\tfunction insertTag(tag){\n\t\t\t\tif(zoneEditor == 'editor_body'){\n\t\t\t\t\ttry{\n\t\t\t\t\t\tjInsertEditorText(tag,'editor_body',previousSelection);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t} catch(err){\n\t\t\t\t\t\talert('Your editor does not enable AcyMailing to automatically insert the tag, please copy/paste it manually in your Newsletter');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t} else{\n\t\t\t\t\ttry{\n\t\t\t\t\t\tsimpleInsert(document.getElementById(zoneToTag), tag);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t} catch(err){\n\t\t\t\t\t\talert('Error inserting the tag in the '+ zoneToTag + 'zone. Please copy/paste it manually in your Newsletter.');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t"; $script .= "function simpleInsert(myField, myValue) {\n\t\t\t\tif (document.selection) {\n\t\t\t\t\tmyField.focus();\n\t\t\t\t\tsel = document.selection.createRange();\n\t\t\t\t\tsel.text = myValue;\n\t\t\t\t} else if (myField.selectionStart || myField.selectionStart == '0') {\n\t\t\t\t\tvar startPos = myField.selectionStart;\n\t\t\t\t\tvar endPos = myField.selectionEnd;\n\t\t\t\t\tmyField.value = myField.value.substring(0, startPos)\n\t\t\t\t\t\t+ myValue\n\t\t\t\t\t\t+ myField.value.substring(endPos, myField.value.length);\n\t\t\t\t} else {\n\t\t\t\t\tmyField.value += myValue;\n\t\t\t\t}\n\t\t\t}"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js . $script); if ($this->type == 'autonews') { JHTML::_('behavior.modal', 'a.modal'); $this->assign('frequencyType', acymailing_get('type.frequency')); $this->assign('generatingMode', acymailing_get('type.generatemode')); } $this->assignRef('toggleClass', $toggleClass); $this->assignRef('lists', $lists); $this->assignRef('editor', $editor); $this->assignRef('mail', $mail); $tabs = acymailing_get('helper.acytabs'); $tabs->setOptions(array('useCookie' => true)); $this->assignRef('tabs', $tabs); $this->assignRef('values', $values); $this->assignRef('config', $config); }
function doexport() { if (!$this->isAllowed('subscriber', 'export')) { return; } JRequest::checkToken() or die('Invalid Token'); acymailing_increasePerf(); $filtersExport = JRequest::getVar('exportfilter', array(), '', 'array'); $listsToExport = JRequest::getVar('exportlists'); $fieldsToExport = JRequest::getVar('exportdata'); $fieldsToExportList = JRequest::getVar('exportdatalist'); $fieldsToExportOthers = JRequest::getVar('exportdataother'); $fieldsToExportGeoloc = JRequest::getVar('exportdatageoloc'); $inseparator = JRequest::getString('exportseparator'); $inseparator = str_replace(array('semicolon', 'colon', 'comma'), array(';', ',', ','), $inseparator); $exportFormat = JRequest::getString('exportformat'); if (!in_array($inseparator, array(',', ';'))) { $inseparator = ';'; } $exportUnsubLists = array(); $exportWaitLists = array(); $exportLists = array(); if (!empty($filtersExport['subscribed'])) { foreach ($listsToExport as $listid => $status) { if ($status == -1) { $exportUnsubLists[] = (int) $listid; } elseif ($status == 2) { $exportWaitLists[] = (int) $listid; } elseif (!empty($status)) { $exportLists[] = (int) $listid; } } } $app = JFactory::getApplication(); if (!$app->isAdmin() && (empty($filtersExport['subscribed']) || empty($exportLists) && empty($exportUnsubLists) && empty($exportWaitLists))) { $listClass = acymailing_get('class.list'); $frontLists = $listClass->getFrontendLists(); foreach ($frontLists as $frontList) { $exportLists[] = (int) $frontList->listid; } } $exportFields = array(); $exportFieldsList = array(); $exportFieldsOthers = array(); $exportFieldsGeoloc = array(); foreach ($fieldsToExport as $fieldName => $checked) { if (!empty($checked)) { $exportFields[] = acymailing_secureField($fieldName); } } foreach ($fieldsToExportList as $fieldName => $checked) { if (!empty($checked)) { $exportFieldsList[] = acymailing_secureField($fieldName); } } if (!empty($fieldsToExportOthers)) { foreach ($fieldsToExportOthers as $fieldName => $checked) { if (!empty($checked)) { $exportFieldsOthers[] = acymailing_secureField($fieldName); } } } if (!empty($fieldsToExportGeoloc)) { foreach ($fieldsToExportGeoloc as $fieldName => $checked) { if (!empty($checked)) { $exportFieldsGeoloc[] = acymailing_secureField($fieldName); } } } $selectFields = 's.`' . implode('`, s.`', $exportFields) . '`'; $config = acymailing_config(); $newConfig = new stdClass(); $newConfig->export_fields = implode(',', array_merge($exportFields, $exportFieldsOthers, $exportFieldsList, $exportFieldsGeoloc)); $newConfig->export_lists = implode(',', $exportLists); $newConfig->export_separator = JRequest::getString('exportseparator'); $newConfig->export_format = $exportFormat; $filterActive = array(); foreach ($filtersExport as $filterKey => $value) { if ($value == 1) { $filterActive[] = $filterKey; } } $newConfig->export_filters = implode(',', $filterActive); $config->save($newConfig); $where = array(); if (empty($exportLists) && empty($exportUnsubLists) && empty($exportWaitLists)) { $querySelect = 'SELECT s.`subid`, ' . $selectFields . ' FROM ' . acymailing_table('subscriber') . ' as s'; } else { $querySelect = 'SELECT DISTINCT s.`subid`, ' . $selectFields . ' FROM ' . acymailing_table('listsub') . ' as a JOIN ' . acymailing_table('subscriber') . ' as s on a.subid = s.subid'; if (!empty($exportLists)) { $conditions[] = 'a.status = 1 AND a.listid IN (' . implode(',', $exportLists) . ')'; } if (!empty($exportUnsubLists)) { $conditions[] = 'a.status = -1 AND a.listid IN (' . implode(',', $exportUnsubLists) . ')'; } if (!empty($exportWaitLists)) { $conditions[] = 'a.status = 2 AND a.listid IN (' . implode(',', $exportWaitLists) . ')'; } if (count($conditions) == 1) { $where[] = $conditions[0]; } else { $where[] = '(' . implode(') OR (', $conditions) . ')'; } } if (!empty($filtersExport['confirmed'])) { $where[] = 's.confirmed = 1'; } if (!empty($filtersExport['registered'])) { $where[] = 's.userid > 0'; } if (!empty($filtersExport['enabled'])) { $where[] = 's.enabled = 1'; } if (JRequest::getInt('sessionvalues') and !empty($_SESSION['acymailing']['exportusers'])) { $where[] = 's.subid IN (' . implode(',', $_SESSION['acymailing']['exportusers']) . ')'; } if (JRequest::getInt('fieldfilters')) { foreach ($_SESSION['acymailing']['fieldfilter'] as $field => $value) { $where[] = 's.' . acymailing_secureField($field) . ' LIKE "%' . acymailing_getEscaped($value, true) . '%"'; } } $query = $querySelect; if (!empty($where)) { $query .= ' WHERE (' . implode(') AND (', $where) . ')'; } if (JRequest::getInt('sessionquery')) { $currentSession = JFactory::getSession(); $selectOthers = ''; if (!empty($exportFieldsOthers)) { foreach ($exportFieldsOthers as $oneField) { $selectOthers .= ' , ' . $oneField . ' AS ' . str_replace('.', '_', $oneField); } } $query = 'SELECT DISTINCT s.`subid`, ' . $selectFields . $selectOthers . ' ' . $currentSession->get('acyexportquery'); } $query .= ' ORDER BY s.subid'; $db = JFactory::getDBO(); $encodingClass = acymailing_get('helper.encoding'); $exportHelper = acymailing_get('helper.export'); $fileName = 'export_' . date('Y-m-d'); if (!empty($exportLists)) { $fileName = ''; $db->setQuery('SELECT name FROM #__acymailing_list WHERE listid IN (' . implode(',', $exportLists) . ')'); $allExportedLists = $db->loadObjectList(); foreach ($allExportedLists as $oneList) { $fileName .= '__' . $oneList->name; } $fileName = trim($fileName, '__'); } $exportHelper->addHeaders($fileName); acymailing_displayErrors(); $eol = "\r\n"; $before = '"'; $separator = '"' . $inseparator . '"'; $after = '"'; $allFields = array_merge($exportFields, $exportFieldsOthers); if (!empty($exportFieldsList)) { $allFields = array_merge($allFields, $exportFieldsList); $selectFields = 'l.`' . implode('`, l.`', $exportFieldsList) . '`'; $selectFields = str_replace('listname', 'name', $selectFields); } if (!empty($exportFieldsGeoloc)) { $allFields = array_merge($allFields, $exportFieldsGeoloc); } $titleLine = $before . implode($separator, $allFields) . $after . $eol; $titleLine = str_replace('listid', 'listids', $titleLine); echo $titleLine; if (acymailing_bytes(ini_get('memory_limit')) > 150000000) { $nbExport = 50000; } elseif (acymailing_bytes(ini_get('memory_limit')) > 80000000) { $nbExport = 15000; } else { $nbExport = 5000; } if (!empty($exportFieldsList)) { $nbExport = 500; } $valDep = 0; $dateFields = array('created', 'confirmed_date', 'lastopen_date', 'lastclick_date', 'lastsent_date', 'userstats_opendate', 'userstats_senddate', 'urlclick_date', 'hist_date'); do { $db->setQuery($query . ' LIMIT ' . $valDep . ', ' . $nbExport); $valDep += $nbExport; $allData = $db->loadAssocList('subid'); if ($allData === false) { echo $eol . $eol . 'Error : ' . $db->getErrorMsg(); } if (empty($allData)) { break; } foreach ($allData as $subid => &$oneUser) { if (!in_array('subid', $exportFields)) { unset($allData[$subid]['subid']); } foreach ($dateFields as &$fieldName) { if (isset($allData[$subid][$fieldName])) { $allData[$subid][$fieldName] = acymailing_getDate($allData[$subid][$fieldName], '%Y-%m-%d %H:%M:%S'); } } } if (!empty($exportFieldsList) && !empty($allData)) { $queryList = 'SELECT ' . $selectFields . ', ls.subid FROM #__acymailing_listsub as ls JOIN #__acymailing_list as l ON ls.listid=l.listid JOIN #__acymailing_subscriber as s on ls.subid = s.subid WHERE (ls.status = 1) and ls.subid IN (' . implode(',', array_keys($allData)) . ')'; if (!empty($exportLists)) { $queryList .= ' AND ls.listid IN (' . implode(',', $exportLists) . ')'; } $db->setQuery($queryList); $resList = $db->loadObjectList(); foreach ($resList as &$listsub) { if (in_array('listid', $exportFieldsList)) { $allData[$listsub->subid]['listid'] = empty($allData[$listsub->subid]['listid']) ? $listsub->listid : $allData[$listsub->subid]['listid'] . ' - ' . $listsub->listid; } if (in_array('listname', $exportFieldsList)) { $allData[$listsub->subid]['listname'] = empty($allData[$listsub->subid]['listname']) ? $listsub->name : $allData[$listsub->subid]['listname'] . ' - ' . $listsub->name; } } unset($resList); } if (!empty($exportFieldsGeoloc) && !empty($allData)) { $orderGeoloc = JRequest::getCmd('exportgeolocorder'); if (strtolower($orderGeoloc) !== 'desc') { $orderGeoloc = 'asc'; } $db->setQuery('SELECT geolocation_subid,' . implode(', ', $exportFieldsGeoloc) . ' FROM (SELECT * FROM #__acymailing_geolocation WHERE geolocation_subid IN (' . implode(',', array_keys($allData)) . ') ORDER BY geolocation_id ' . $orderGeoloc . ') as geoloc GROUP BY geolocation_subid'); $resGeol = $db->loadObjectList(); foreach ($resGeol as $geolData) { foreach ($exportFieldsGeoloc as $geolField) { $allData[$geolData->geolocation_subid][$geolField] = $geolField == 'geolocation_created' ? acymailing_getDate($geolData->{$geolField}, '%Y-%m-%d %H:%M:%S') : $geolData->{$geolField}; } } unset($resGeol); } foreach ($allData as $subid => &$oneUser) { $dataexport = implode($separator, $oneUser); echo $before . $encodingClass->change($dataexport, 'UTF-8', $exportFormat) . $after . $eol; } unset($allData); } while (true); exit; }
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() { 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\r\n\t\t\t\t\tfunction displayTags(){var box=\$('iframetag'); if(openTag){box.innerHTML = " . $iFrame . "; box.setStyle('display','block');}\r\r\n\t\t\t\t\ttry{\r\r\n\t\t\t\t\t\tvar fx = box.effects({duration: 1500, transition: Fx.Transitions.Quart.easeOut});\r\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\r\n\t\t\t\t\t}catch(err){\r\r\n\t\t\t\t\t\tbox.style.height = '300px';\r\r\n\t\t\t\t\t\tvar myVerticalSlide = new Fx.Slide('iframetag');\r\r\n\t\t\t\t\t\tif(openTag){\r\r\n\t\t\t\t\t\t\tmyVerticalSlide.slideIn();\r\r\n\t\t\t\t\t\t}else{\r\r\n\t\t\t\t\t\t\tmyVerticalSlide.slideOut().chain(function() {\r\r\n\t\t\t\t\t\t\t\tbox.innerHTML='';\r\r\n\t\t\t\t\t\t\t\tbox.setStyle('display','none');\r\r\n\t\t\t\t\t\t\t});\r\r\n\t\t\t\t\t\t}\r\r\n\t\t\t\t\t}\r\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\r\n\t\t\t\t\tfunction displayTemplates(){var box=\$('iframetemplate'); if(openTemplate){box.innerHTML = " . $iFrame . "; box.setStyle('display','block');}\r\r\n\t\t\t\t\ttry{\r\r\n\t\t\t\t\t\tvar fx = box.effects({duration: 1500, transition: Fx.Transitions.Quart.easeOut});\r\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\r\n\t\t\t\t\t}catch(err){\r\r\n\t\t\t\t\t\tbox.style.height = '300px';\r\r\n\t\t\t\t\t\tvar myVerticalSlide = new Fx.Slide('iframetemplate');\r\r\n\t\t\t\t\t\tif(openTemplate){\r\r\n\t\t\t\t\t\t\tmyVerticalSlide.slideIn();\r\r\n\t\t\t\t\t\t}else{\r\r\n\t\t\t\t\t\t\tmyVerticalSlide.slideOut().chain(function() {\r\r\n\t\t\t\t\t\t\t\tbox.innerHTML='';\r\r\n\t\t\t\t\t\t\t\tbox.setStyle('display','none');\r\r\n\t\t\t\t\t\t\t});\r\r\n\t\t\t\t\t\t}\r\r\n\t\t\t\t\t}\r\r\n\t\t\t\t\topenTemplate = !openTemplate;}"; $script .= "function changeTemplate(newhtml,newtext,newsubject,stylesheet,fromname,fromemail,replyname,replyemail,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.innerHTML = newtext;\r\r\n\t\t\tdocument.getElementById('tempid').value = tempid;\r\r\n\t\t\tif(fromname.length>1){document.getElementById('fromname').value = fromname;}\r\r\n\t\t\tif(fromemail.length>1){document.getElementById('fromemail').value = fromemail;}\r\r\n\t\t\tif(replyname.length>1){document.getElementById('replyname').value = replyname;}\r\r\n\t\t\tif(replyemail.length>1){document.getElementById('replyemail').value = replyemail;}\r\r\n\t\t\tif(newsubject.length>1){document.getElementById('subject').value = newsubject;}\r\r\n\t\t\tdocument.getElementById('iframetemplate').style.display = 'none'; displayTemplates();\r\r\n\t\t}\r\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); }