function initModule() { static $i = 0; if (empty($i)) { $lang =& JFactory::getLanguage(); $lang->load(ACYMAILING_COMPONENT, JPATH_SITE); $doc =& JFactory::getDocument(); acymailing::initJSStrings(); $doc->addScript(ACYMAILING_JS . 'acymailing_module.js'); $config = acymailing::config(); $moduleCSS = $config->get('css_module', 'default'); if (!empty($moduleCSS)) { $doc->addStyleSheet(ACYMAILING_CSS . 'module_' . $moduleCSS . '.css'); } } $i++; return 'formAcymailing' . $i; }
function initModule($includejs, $params) { static $alreadyThere = false; if ($alreadyThere) { return; } $alreadyThere = true; $lang =& JFactory::getLanguage(); $lang->load(ACYMAILING_COMPONENT, JPATH_SITE); acymailing::initJSStrings($includejs, $params); $doc =& JFactory::getDocument(); $config = acymailing::config(); if ($includejs == 'header') { $doc->addScript(ACYMAILING_JS . 'acymailing_module.js'); } else { echo "\n" . '<script type="text/javascript" src="' . ACYMAILING_JS . 'acymailing_module.js" ></script>' . "\n"; } $moduleCSS = $config->get('css_module', 'default'); if (!empty($moduleCSS)) { $doc->addStyleSheet(ACYMAILING_CSS . 'module_' . $moduleCSS . '.css'); } }
function modify() { global $Itemid; $app =& JFactory::getApplication(); $pathway =& $app->getPathway(); $document =& JFactory::getDocument(); $listsClass = acymailing::get('class.list'); $subscriberClass = acymailing::get('class.subscriber'); $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 JParameter($menu->params); if (!empty($menuparams)) { $this->assignRef('introtext', $menuparams->get('introtext')); $this->assignRef('finaltext', $menuparams->get('finaltext')); } } $subscriber = $subscriberClass->identify(true); if (empty($subscriber)) { $subscription = $listsClass->getLists('listid'); $subscriber = null; $subscriber->html = 1; $subscriber->subid = 0; $subscriber->key = 0; if (!empty($subscription)) { foreach ($subscription as $id => $onesub) { $subscription[$id]->status = 1; if (!empty($menuparams) and strtolower($menuparams->get('listschecked', 'all')) != 'all' and !in_array($id, explode(',', $menuparams->get('listschecked', 'all')))) { $subscription[$id]->status = 0; } } } $pathway->addItem(JText::_('SUBSCRIPTION')); $document->setTitle(JText::_('SUBSCRIPTION')); } else { $subscription = $subscriberClass->getSubscription($subscriber->subid, 'listid'); $pathway->addItem(JText::_('MODIFY_SUBSCRIPTION')); $document->setTitle(JText::_('MODIFY_SUBSCRIPTION')); } acymailing::initJSStrings(); if (!empty($menuparams) and strtolower($menuparams->get('lists', 'all')) != 'all') { $visibleLists = strtolower($menuparams->get('lists', 'all')); if ($visibleLists == 'none') { $subscription = array(); } else { $newSubscription = array(); $visiblesListsArray = explode(',', $visibleLists); foreach ($subscription as $id => $onesub) { if (in_array($id, $visiblesListsArray)) { $newSubscription[$id] = $onesub; } } $subscription = $newSubscription; } } $displayLists = false; foreach ($subscription as $oneSub) { if (!empty($oneSub->published) and $oneSub->visible) { $displayLists = true; break; } } $this->assignRef('status', acymailing::get('type.festatus')); $this->assignRef('subscription', $subscription); $this->assignRef('subscriber', $subscriber); $this->assignRef('displayLists', $displayLists); $this->assignRef('config', acymailing::config()); }
function modify() { $app =& JFactory::getApplication(); $pathway =& $app->getPathway(); $document =& JFactory::getDocument(); $listsClass = acymailing::get('class.list'); $subscriberClass = acymailing::get('class.subscriber'); $subscriber = $subscriberClass->identify(true); if (empty($subscriber)) { $subscription = $listsClass->getLists(); $subscriber = null; $subscriber->html = 1; $subscriber->subid = 0; $subscriber->key = 0; if (!empty($subscription)) { foreach ($subscription as $id => $onesub) { $subscription[$id]->status = 1; } } $pathway->addItem(JText::_('SUBSCRIPTION')); $document->setTitle(JText::_('SUBSCRIPTION')); } else { $subscription = $subscriberClass->getSubscription($subscriber->subid); $pathway->addItem(JText::_('MODIFY_SUBSCRIPTION')); $document->setTitle(JText::_('MODIFY_SUBSCRIPTION')); } acymailing::initJSStrings(); if (acymailing::level(1)) { $subscription = $listsClass->onlyCurrentLanguage($subscription); } if (acymailing::level(3)) { $fieldsClass = acymailing::get('class.fields'); $this->assignRef('fieldsClass', $fieldsClass); $extraFields = $fieldsClass->getFields('frontcomp', $subscriber); $this->assignRef('extraFields', $extraFields); $requiredFields = array(); $validMessages = array(); foreach ($extraFields as $oneField) { if (in_array($oneField->namekey, array('name', 'email'))) { continue; } if (!empty($oneField->required)) { $requiredFields[] = $oneField->namekey; if (!empty($oneField->options['errormessage'])) { $validMessages[] = addslashes($fieldsClass->trans($oneField->options['errormessage'])); } else { $validMessages[] = addslashes(JText::sprintf('FIELD_VALID', $fieldsClass->trans($oneField->fieldname))); } } } if (!empty($requiredFields)) { $js = "<!--\r\r\n\t\t\t\tacymailing['reqFieldsComp'] = Array('" . implode("','", $requiredFields) . "');\r\r\n\t\t\t\tacymailing['validFieldsComp'] = Array('" . implode("','", $validMessages) . "');\r\r\n\t\t\t\t//-->"; $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($js); } $my = JFactory::getUser(); foreach ($subscription as $listid => $oneList) { if (!$subscription[$listid]->published) { continue; } if ($oneList->access_sub == 'all') { continue; } if ($oneList->access_sub == 'none' or empty($my->id) or empty($my->gid)) { $subscription[$listid]->published = false; continue; } if (!in_array($my->gid, explode(',', $oneList->access_sub))) { $subscription[$listid]->published = false; continue; } } } $displayLists = false; for ($i = 0, $a = count($subscription); $i < $a; $i++) { if (!empty($subscription[$i]->published) and $subscription[$i]->visible) { $displayLists = true; break; } } $this->assignRef('status', acymailing::get('type.festatus')); $this->assignRef('subscription', $subscription); $this->assignRef('subscriber', $subscriber); $this->assignRef('displayLists', $displayLists); $this->assignRef('config', acymailing::config()); }