/** Function that will remove the attachment text save into column attachments in the table #__jnews_mailings * @param string $filename - name of the file to be removed * @param int $mailingID - newsletter id - default to 0 if the should be remove from all newsletters that been using the file */ function deleteAttachmentQuery($filename, $mailingID = 0) { // set database static $db = null; if (!isset($db)) { $db = JFactory::getDBO(); } // check mailing id $mailingIDsA = null; if (empty($mailingID)) { // load the mailing ids that used the file to be detached $query = 'SELECT `id` FROM `#__jnews_mailings` WHERE `attachments` LIKE "%' . $filename . '%"'; $db->setQuery($query); $loadResultArray = $db->loadObjectList(); $mailingIDsA = jnews::convertObjectList2Array($loadResultArray); if (!empty($mailingIDsA)) { // if found then replace it with an empty string foreach ($mailingIDsA as $mailingID) { jNews_Attachment::_setAttachments($mailingID, $filename); } } } else { // if found then replace it with an empty string jNews_Attachment::_setAttachments($mailingID, $filename); } return true; }
public static function reportType($selected) { $values = array(); $values[] = jnews::HTML_SelectOption('listing', JText::_(_JNEWS_REPORT_LISTING)); $values[] = jnews::HTML_SelectOption('graph', JText::_(_JNEWS_REPORT_GRAPH)); return jnews::HTML_RadioList($values, "rpttype", 'class="inputbox" size="1"', 'value', 'text', $selected); }
public static function subscirbersType() { $values = array(); $values[] = jnews::HTML_SelectOption('all-users', JText::_(_JNEWS_SUBSCRIBERS_ALL_USERS)); $values[] = jnews::HTML_SelectOption('registered', JText::_(_JNEWS_SUBSCRIBERS_REGISTERED)); $values[] = jnews::HTML_SelectOption('guests', JText::_(_JNEWS_SUBSCRIBERS_GUESTS)); return jnews::HTML_RadioList($values, "subcscriberstype", 'class="inputbox" size="1"', 'value', 'text', "subcscriberstype"); }
public static function intervalType($selected) { $values = array(); $values[] = jnews::HTML_SelectOption('daily', JText::_(_JNEWS_INTERVAL_DAILY)); $values[] = jnews::HTML_SelectOption('weekly', JText::_(_JNEWS_INTERVAL_WEEKLY)); $values[] = jnews::HTML_SelectOption('monthly', JText::_(_JNEWS_INTERVAL_MONTHLY)); $values[] = jnews::HTML_SelectOption('yearly', JText::_(_JNEWS_INTERVAL_YEARLY)); return jnews::HTML_RadioList($values, "rptinterval", 'class="inputbox" size="1"', 'value', 'text', $selected); }
public function Process() { // Newsletter component disabled or not found. Aborting. if (!$this->enabled) { return true; } $config = new jNews_Config(); // Build subscriber object $subscriber = new stdClass(); // Lists $cumulative = $this->JInput->post->get("jnews_subscribe_cumulative", NULL, "int"); $checkboxes = $this->JInput->post->get("jnews_subscribe", array(), "array"); $subscriber->list_id = $cumulative ? $checkboxes : array(); // No lists selected. Skip here to avoid annoying the user with email confirmation. It is useless to confirm a subscription to no lists. if (empty($subscriber->list_id)) { return true; } // Name field may be absent. JNews will assign an empty name to the user. $subscriber->name = isset($this->FieldsBuilder->Fields['sender0']) ? $this->FieldsBuilder->Fields['sender0']['Value'] : ""; $subscriber->email = empty($this->FieldsBuilder->Fields['sender1']['Value']) ? NULL : JMailHelper::cleanAddress($this->FieldsBuilder->Fields['sender1']['Value']); // JNews saves users with empty email address, so we have to check it if (empty($subscriber->email)) { $this->logger->Write(get_class($this) . " Process(): Email address empty. User save aborted."); return true; } // It seems that $subscriber->confirmed defaults to unconfirmed if unset, so we need to read and pass the actual value from the configuration $subscriber->confirmed = !(bool) $config->get('require_confirmation'); $subscriber->receive_html = 1; // Avoid Notice: Undefined property while JNews libraries access undefined properties $subscriber->ip = jNews_Subscribers::getIP(); $subscriber->subscribe_date = jnews::getNow(); $subscriber->language_iso = "eng"; $subscriber->timezone = "00:00:00"; $subscriber->blacklist = 0; $subscriber->user_id = JFactory::getUser()->id; // Subscription $sub_id = null; jNews_Subscribers::saveSubscriber($subscriber, $sub_id, true); if (empty($sub_id)) { // User save failed. Probably email address is empty or invalid $this->logger->Write(get_class($this) . " Process(): User save failed"); return true; } // Subscribe $subscriber to $subscriber->list_id //$subscriber->id = $sub_id; // jNews_ListsSubs::saveToListSubscribers() doesn't work well. When only one list is passed to, it reads the value $listids[0], // but the element 0 is not always the first element of the array. In our case is $listids[1] //jNews_ListsSubs::saveToListSubscribers($subscriber); $this->SaveSubscription($subscriber); // Log $this->logger->Write(get_class($this) . " Process(): subscribed " . $this->FieldsBuilder->Fields['sender0']['Value'] . " (" . $this->FieldsBuilder->Fields['sender1']['Value'] . ") to lists " . implode(",", $subscriber->list_id)); return true; }
public static function rangeType($selected) { $values = array(); $values[] = jnews::HTML_SelectOption('yesterday', JText::_(_JNEWS_DEFINED_RANGE_YESTERDAY)); $values[] = jnews::HTML_SelectOption('today', JText::_(_JNEWS_DEFINED_RANGE_TODAY)); $values[] = jnews::HTML_SelectOption('this-week', JText::_(_JNEWS_DEFINED_RANGE_THIS_WEEK)); $values[] = jnews::HTML_SelectOption('last-week', JText::_(_JNEWS_DEFINED_RANGE_LAST_WEEK)); $values[] = jnews::HTML_SelectOption('last-2-weeks', JText::_(_JNEWS_DEFINED_RANGE_LAST_TWO_WEEK)); $values[] = jnews::HTML_SelectOption('this-month', JText::_(_JNEWS_DEFINED_RANGE_THIS_MONTH)); $values[] = jnews::HTML_SelectOption('last-month', JText::_(_JNEWS_DEFINED_RANGE_LAST_MONTH)); $values[] = jnews::HTML_SelectOption('this-year', JText::_(_JNEWS_DEFINED_RANGE_THIS_YEAR)); $values[] = jnews::HTML_SelectOption('last-year', JText::_(_JNEWS_DEFINED_RANGE_LAST_YEAR)); $values[] = jnews::HTML_SelectOption('2-years-ago', JText::_(_JNEWS_DEFINED_RANGE_TWO_YEARS_AGO)); $values[] = jnews::HTML_SelectOption('3-years-ago', JText::_(_JNEWS_DEFINED_RANGE_3_YEARS_AGO)); return jnews::HTML_GenericList($values, "rptrange", 'class="inputbox" size="1"', 'value', 'text', $selected); }
function fetchElement($name, $value, &$node, $control_name) { $db = JFactory::getDBO(); $db->setQuery('SELECT `virtuemart_custom_id`, `custom_title` FROM #__virtuemart_customs '); $tableField = $db->loadObjectList(); if (empty($tableField)) { //old VM version $tableField = $db->getTableFields('#__vm_user_info'); $fields = reset($tableField); $dropdown = array(); foreach ($fields as $oneField => $fieldType) { $dropdown[] = jnews::HTML_SelectOption($oneField, $oneField); } return jnews::HTML_GenericList($dropdown, $control_name . '[' . $name . ']', 'size="1"', 'value', 'text', $value); } //new VM version $dropdown = array(); foreach ($tableField as $oneField => $fieldType) { $dropdown[] = jnews::HTML_SelectOption($fieldType->virtuemart_custom_id, $fieldType->custom_title); } return jnews::HTML_GenericList($dropdown, $control_name . '[' . $name . ']', 'size="1"', 'value', 'text', $value); }
public static function checkAcajoom() { static $acaExist = null; if (is_bool($acaExist)) { return $acaExist; } $db = JFactory::getDBO(); static $resultAcajoom = null; if (empty($resultAcajoom)) { $queryshow = "SHOW TABLES LIKE '%acajoom%'"; $db->setQuery($queryshow); $loadResultArray = $db->loadObjectList(); $resultAcajoom = jnews::convertObjectList2Array($loadResultArray); if (empty($resultAcajoom)) { return false; } $query = " SELECT `akey` FROM `#__acajoom_xonfig` "; $db->setQuery($query); $result = $db->loadResult(); $acaExist = !empty($result) ? true : false; } return $acaExist; }
function jnewsbot_k2_editab() { $limit = 5; $limittotal = countK2Items(); $setLimitk2 = jnews::setLimitPagination($limittotal); $task = JRequest::getVar('task'); //filter if (isset($_POST['contentsearchk2'])) { $contentsearch = JRequest::getVar('contentsearchk2', 'post', '', 'string'); } else { $contentsearch = ""; } $toSearch = new stdClass(); $toSearch->forms = ''; //$toSearch->hidden = $hidden; $toSearch->listsearch = $contentsearch; $toSearch->id = 'contentsearchk2'; $app = JFactory::getApplication(); $setSortk2 = new stdClass(); if (!isset($_POST['k2_filter_order'])) { $setSortk2->orderValue = "a.id"; } else { $setSortk2->orderValue = $_POST['filter_order']; } $setSortk2->orderDir = $app->getUserStateFromRequest(JNEWS_OPTION . '.k2content.filter_order_Dir', 'filter_order_Dir', 'desc', 'word'); $sort_select = JRequest::getVar('filter_category_id_k2', '', 'POST', 'int'); $k2contentitems = jnewsbot_k2_getitems($contentsearch, $setLimitk2, $setSortk2, $sort_select); ob_start(); $js = "var id_global, content_type, hide_title_global;\n function setContentTag(id, hide_title_or_rendering)\n {\n if(id != null) {\n\n if(document.getElementById('for_disabled').checked === false)\n {\n document.getElementById('hide_title_yes').disabled=false;\n }\n\n if(hide_title_or_rendering ==undefined && hide_title_global == undefined)\n {\n hide_title_global = 0;\n }\n if(hide_title_or_rendering ==undefined && content_type == undefined)\n {\n content_type = 0;\n }\n if(id ==='rendering')\n {\n content_type = hide_title_or_rendering;\n if(id_global == undefined) id_global = 0;\n if(hide_title_global == undefined) hide_title_global = 0;\n if(hide_title_or_rendering == 2)\n {\n // hide_title_global = 0;\n document.getElementById('hide_title_no').click();\n document.getElementById('hide_title_yes').disabled=true;\n\n }\n }\n if(id == 'hide_title')\n {\n hide_title_global = hide_title_or_rendering;\n if(id_global == undefined) id_global = 0;\n if(content_type == undefined) content_type = 0;\n }\n if( id % 1 === 0)\n {\n id_global = id;\n if(content_type == undefined) content_type = 0;\n if(hide_title_global == undefined) hide_title_global = 0;\n }\n\n var form = document.adminForm;\n if(!form){\n form = document.mosForm;\n }\n var tag = '{k2item:' + id_global + '|' + content_type +'|'+hide_title_global+ '}';\n form.k2tag.value = tag;\n\n }\n else\n { var form = document.adminForm;\n if(!form){\n form = document.mosForm;\n }\n var tag = form.k2tag.value; "; if (version_compare(JVERSION, '1.6.0', '<')) { //1.5 $js .= " if(window.top.insertTag(tag)){window.top.document.getElementById('sbox-window').close();}"; } else { if (version_compare(JVERSION, '3.0.0', '<')) { $js .= ' if(window.top.insertTag(tag)) {window.parent.SqueezeBox.close();}'; } else { $js .= ' if(window.top.insertTag(tag)) { var need_click = jQuery(window.top.document).find("div.modal-backdrop"); if(need_click.length == 0) window.parent.SqueezeBox.close(); else jQuery(window.top.document).find("div.modal-backdrop").click();}'; } } $js .= "}\n\t}"; //if(window.top.insertTag(tag)){window.top.document.getElementById('sbox-window').close();} $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); ?> <style type="text/css"> table.smartcontent { border: 1px solid #D5D5D5; background-color: #F6F6F6; width: 100%; margin-bottom: 10px; -moz-border-radius:3px; -webkit-border-radius:3px; padding: 5px; } table.smartcontent td.key { background-color: #f6f6f6; text-align: left; width: 140px; color: #666; font-weight: bold; border-bottom: 1px solid #e9e9e9; border-right: 1px solid #e9e9e9; } </style> <div id="element-box"> <div class="t"> <div class="t"> <div class="t"></div> </div> </div> <div class="m"> <form id="adminForm" name="adminForm" method="post" action="index.php?option=<?php echo JNEWS_OPTION; ?> &tmpl=component&act=tags&task=k2content"> <table class="smartcontent" width="100%"> <tr> <td width="185" class="key"> <span class="editlinktip"> <?php $tip = _JNEWS_AUTONEWS_TYPE_TIPS; $title = _JNEWS_AUTONEWS_TYPE; echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0); ?> </span> </td> <td style="vertical-align: top;"> <span class="editlinktip"> <?php $tip = _JNEWS_TITLE_ONLY_TIPS; $title = _JNEWS_TITLE_ONLY; $title_only = "<span class=\"editlinktip\">" . jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0) . "</span>"; $tip = _JNEWS_INTRO_ONLY_TIPS; $title = _JNEWS_INTRO_ONLY; $intro_only = "<span class=\"editlinktip\">" . jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0) . "</span>"; $tip = _JNEWS_FULL_ARTICLE_TIPS; $title = _JNEWS_FULL_ARTICLE; $full_article = "<span class=\"editlinktip\">" . jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0) . "</span>"; ?> </span> <span class="editlinktip"> <input type="radio" onclick="setContentTag('rendering', 0)" name="content_type" value="0" checked="checked" /><?php echo $full_article; ?> <input type="radio" onclick="setContentTag('rendering', 1)" name="content_type" value="1" /><?php echo $intro_only; ?> <input id="for_disabled" type="radio" onclick="setContentTag('rendering', 2)" name="content_type" value="2" /><?php echo $title_only; ?> </span> </td> <td rowspan="2"> <input onclick="setContentTag(null)" class="inserttag" type="button" label="Insert Tag" name="Insert Tag" value="<?php echo _JNEWS_TAG_INSERT_TAG; ?> "/> </td> </tr> <tr> <td width="185" class="key"> <span class="editlinktip"> Tag </span> </td> <td style="vertical-align: top;"> <!-- <input type="text" onchange="setCaptionTags();" size="60px" name="jnewstagcaption"> --> <input type="text" size="60px" name="k2tag"> </td> </tr> <tr> <td width="185" class="key"> <span class="editlinktip"> <?php $tip = _JNEWS_HIDE_TITTLE_ARTICLE_TIPS; $title = _JNEWS_HIDE_TITLE; echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0); ?> </span> </td> <td style="vertical-align: top;"> <span class="hide_title" > <input id="hide_title_no" onclick="setContentTag('hide_title', 0);" type="radio" name="hide_title" value="0" checked="checked" /><?php echo 'No'; ?> <input id="hide_title_yes" onclick="setContentTag('hide_title', 1);" type="radio" name="hide_title" value="1" /><?php echo 'Yes'; ?> </span> </td> </tr> </table> <div id="element-box"> <div class="t"> <div class="t"> <div class="t"></div> </div> </div> <div class="m" style="position:relative;"> <input type="hidden" name="option" value="<?php echo JNEWS_OPTION; ?> " /> <input type="hidden" name="limit" value="<?php echo $limit; ?> " /> <!--////////////////////////////////////////////////////--> <?php echo jnews::setTop($toSearch, null); $category_list_k2 = getAllCategoriesK2(); ?> <div style="position:absolute;top:5px; left:55%;"> <select name="filter_category_id_k2" class="inputbox" onchange="this.form.submit()"> <option value=""><?php echo JText::_('JOPTION_SELECT_CATEGORY'); ?> </option> <?php for ($i = 0; $i < count($category_list_k2); $i++) { ?> <option value="<?php echo $category_list_k2[$i]->id; ?> " <?php if ($sort_select == $category_list_k2[$i]->id) { echo "selected"; } ?> > <?php echo $category_list_k2[$i]->name; ?> </option> <?php } ?> </select> </div> <table class="<?php echo jnews::myTheme(); ?> " cellpadding="0" cellspacing="0"> <tbody> <thead> <tr> <th width="80px" class="title"> <?php if ($setSortk2->orderDir == 'asc') { $new_sort = "desc"; } else { $new_sort = "asc"; } ?> <a class="hasTip" title="" onclick="Joomla.tableOrdering('a.title','<?php echo $new_sort; ?> ', 'k2content');" href="#"> <?php echo _JNEWS_TAGPICKLIST_TITLE; ?> <?php if ($setSortk2->orderValue == 'a.title') { ?> <i class="icon-arrow-<?php echo $new_sort == "asc" ? "up" : "down"; ?> "></i><?php } ?> </a> </th> <th width="80px" class="title"> <?php if ($setSortk2->orderDir == 'asc') { $new_sort = "desc"; } else { $new_sort = "asc"; } ?> <a class="hasTip" title="" onclick="Joomla.tableOrdering('a.title_2','<?php echo $new_sort; ?> ', 'k2content');" href="#"> <?php echo _JNEWS_TAG_ARTICLESECTION; ?> <?php if ($setSortk2->orderValue == 'a.title_2') { ?> <i class="icon-arrow-<?php echo $new_sort == "asc" ? "up" : "down"; ?> "></i><?php } ?> </a> </th> <th width="80px" class="title"> <?php if ($setSortk2->orderDir == 'asc') { $new_sort = "desc"; } else { $new_sort = "asc"; } ?> <a class="hasTip" title="" onclick="Joomla.tableOrdering('a.catid','<?php echo $new_sort; ?> ', 'k2content');" href="#"> <?php echo _JNEWS_TAG_ARTICLECATEGORY; ?> <?php if ($setSortk2->orderValue == 'a.catid') { ?> <i class="icon-arrow-<?php echo $new_sort == "asc" ? "up" : "down"; ?> "></i><?php } ?> </a> </th> <th width="80px" class="title"> <?php if ($setSortk2->orderDir == 'asc') { $new_sort = "desc"; } else { $new_sort = "asc"; } ?> <a class="hasTip" title="" onclick="Joomla.tableOrdering('a.id','<?php echo $new_sort; ?> ', 'k2content');" href="#"> <?php echo " ID"; ?> <?php if ($setSortk2->orderValue == 'a.id') { ?> <i class="icon-arrow-<?php echo $new_sort == "asc" ? "up" : "down"; ?> "></i><?php } ?> </a> </th> </tr> </thead> <?php if (sizeof($k2contentitems) > 0) { $k = 0; foreach ($k2contentitems as $k2contentitem) { if (empty($k2contentitem->section)) { $k2contentitem->section = JText::_('Uncategorised'); } if (empty($k2contentitem->category)) { $k2contentitem->category = JText::_('Uncategorised'); } echo '<tr style="cursor:pointer" class="row' . $k . '" onclick="setContentTag(\'' . $k2contentitem->id . '\');" ><td>' . $k2contentitem->title . '</td><td nowrap="nowrap" align="center">' . $k2contentitem->section . '</td><td nowrap="nowrap" align="center">' . $k2contentitem->category . '</td><td nowrap="nowrap" align="center">' . $k2contentitem->id . '</td></tr>'; $k = 1 - $k; } } ?> </tbody> </table> <?php echo jnews::setPaginationBot($setLimitk2, 'margin:auto;'); ?> </div> <div class="b"> <div class="b"> <div class="b"></div> </div> </div> </div> <input type="hidden" value="<?php echo $task; ?> " name="task"/> <input type="hidden" value="<?php echo $setSortk2->orderValue; ?> " name="k2_filter_order"/> <input type="hidden" value="<?php echo $setSortk2->orderValue; ?> " name="filter_order"/> <input type="hidden" value="<?php echo $setSortk2->orderDir; ?> " name="filter_order_Dir"/> </form> </div> <div class="b"> <div class="b"> <div class="b"></div> </div> </div> </div> <?php $return = ob_get_contents(); ob_end_clean(); return array(_JNEWS_CONTENT_ITEM, $return); }
public static function export($listId) { $total = 0; $doShowSubscribers = false; @set_time_limit(0); $subtype = JRequest::getVar('subtype', 0); //If memory_limit less than 128M $limit = jnews::convertToBytes(@ini_get('memory_limit')); if ($limit < jnews::convertToBytes('128M')) { @ini_set('memory_limit', '128M'); } if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $HTTP_USER_AGENT)) { $UserBrowser = 'Opera'; } elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT)) { $UserBrowser = 'IE'; } else { $UserBrowser = ''; } $mime_type = $UserBrowser == 'IE' || $UserBrowser == 'Opera' ? 'application/octetstream' : 'application/octet-stream'; $filename = "subscribers_list_" . $listId . "_" . date("Y.d.m"); ob_end_clean(); ob_start(); // header of the imported file $export = ''; //confirmed is set to 2 so that it will also take those unconfirmed subscribers $subscribers = jNews_Subscribers::getSubscribers(-1, -1, '', $total, $listId, '', 1, 2, 'name', '', 0, null, $subtype); //added one parameter for mailid foreach ($subscribers as $subscriber) { if (get_magic_quotes_runtime()) { $subscriber->name = stripslashes($subscriber->name); $subscriber->email = stripslashes($subscriber->email); } $export .= $subscriber->name . ''; $export .= ',' . $subscriber->email . ''; $export .= ',' . $subscriber->receive_html . ''; $export .= ',' . $subscriber->confirmed . ''; //export column1 - column5 if ($GLOBALS[JNEWS . 'level'] > 2) { if (!empty($subscriber->column1)) { $export .= ',' . $subscriber->column1 . ''; } if (!empty($subscriber->column2)) { $export .= ',' . $subscriber->column2 . ''; } if (!empty($subscriber->column3)) { $export .= ',' . $subscriber->column3 . ''; } if (!empty($subscriber->column4)) { $export .= ',' . $subscriber->column4 . ''; } if (!empty($subscriber->column5)) { $export .= ',' . $subscriber->column5 . ''; } } if (!empty($subscriber->ip)) { $export .= ',' . $subscriber->ip; } $export .= "\r\n"; } header('Content-Type: ' . $mime_type); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); if ($UserBrowser == 'IE') { header('Content-Disposition: inline; filename="' . $filename . '.csv"'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header('Content-Disposition: attachment; filename="' . $filename . '.csv"'); header('Pragma: no-cache'); } print $export; exit; return true; }
static function edit($listEdit, $lists, $show, $html) { ?> <fieldset class="jnewscss"> <legend><?php echo _JNEWS_AUTO_RESP_OPTION; ?> </legend> <table class="jnewstable" cellspacing="1"> <tbody> <tr> <td width="185" class="key"> <span class="editlinktip"> <?php $tip = _JNEWS_INFO_LIST_FOLLOW_UP; $title = _JNEWS_FOLLOW_UP; echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0); ?> </span> </td> <td> <input type="text" name="follow_up" class="inputbox" size="6" maxlength="10" value="<?php if (isset($listEdit->follow_up)) { echo $listEdit->follow_up; } else { echo ''; } ?> " /> <?php if (!jNews_Auto::good()) { echo jnews::printM('no', _JNEWS_NOTSO_GOOD_LIC); echo _JNEWS_PLEASE_LIC; } ?> </td> </tr> </tbody> </table> </fieldset> <?php }
function _getTableQuery($query, $loadAction = 'loadResult') { // check parameters // return empty if invalid if (empty($query)) { return ''; } // set database static $db = null; if (!isset($db)) { $db = JFactory::getDBO(); } $db->setQuery($query); if ($loadAction == 'loadResultArray') { $loadResultArray = $db->loadObjectList(); $resultsSubClA = jnews::convertObjectList2Array($loadResultArray); return $resultsSubClA; } else { // set and load query return $db->{$loadAction}(); } }
/** * <p>public static function to create the header or the subject area of the smart newsletter</p> */ public static function smartNewsHead($mailingEdit, $lists, $show) { $option = array(); $my = JFactory::getUser(); $acl = JFactory::getACL(); //$gtree = $acl->get_group_children_tree( null, 'USERS', false ); $option[] = jnews::HTML_SelectOption('1800', 'Every 30 minutes'); $option[] = jnews::HTML_SelectOption('3600', 'Every hour'); $option[] = jnews::HTML_SelectOption('43200', 'Every 12 hours'); $option[] = jnews::HTML_SelectOption('1', _JNEWS_AUTO_DAY_CH1); $option[] = jnews::HTML_SelectOption('3', _JNEWS_AUTO_DAY_CH3); $option[] = jnews::HTML_SelectOption('5', _JNEWS_AUTO_DAY_CH5); $option[] = jnews::HTML_SelectOption('6', _JNEWS_AUTO_DAY_CH6); $option[] = jnews::HTML_SelectOption('7', _JNEWS_AUTO_DAY_CH7); $option[] = jnews::HTML_SelectOption('8', _JNEWS_AUTO_DAY_CH8); $option[] = jnews::HTML_SelectOption('9', _JNEWS_AUTO_DAY_CH9); $auto_option[] = jnews::HTML_SelectOption('0', _JNEWS_AUTO_OPTION_NONE); $auto_option[] = jnews::HTML_SelectOption('1', _JNEWS_AUTO_OPTION_NEW); if (isset($mailingEdit->new_letter) && $mailingEdit->new_letter == 1) { $auto_option[] = jnews::HTML_SelectOption('2', _JNEWS_AUTO_OPTION_ALL); } if (!isset($lists['delay_min'])) { $lists['delay_min'] = null; } $lists['delay_min'] = jnews::HTML_GenericList($option, 'delay_min', 'class="inputbox" size="1"', 'value', 'text', isset($mailingEdit->delay_min) ? $mailingEdit->delay_min : 1); $lists['catid'] = !empty($mailingEdit->cat_id) ? $mailingEdit->cat_id : ''; $lists['notify_id'] = !empty($mailingEdit->notify_id) ? $mailingEdit->notify_id : ''; $lists['delay_max'] = !empty($mailingEdit->delay_max) ? $mailingEdit->delay_max : ''; $lists['smart_date'] = !empty($mailingEdit->smart_date) ? $mailingEdit->smart_date : ''; if (!empty($mailingEdit->delay_max)) { JRequest::setVar('delay_max', $mailingEdit->delay_max); } if (!empty($mailingEdit->notify_id)) { JRequest::setVar('notify_id', $mailingEdit->notify_id); } if (!empty($mailingEdit->cat_id)) { JRequest::setVar('cat_id', base64_encode($mailingEdit->cat_id)); } // if(!empty($mailingEdit->template_id))JRequest::setVar('template_id', base64_encode($mailingEdit->template_id)); jNews_Autonews::edit($mailingEdit, $lists, $show); }
public static function FEmenu() { $my = JFactory::getUser(); //we check if the user is an admin, is an owner of a list and has access to any list $gid = !empty($GLOBALS[JNEWS . 'list_creatorfe']) ? $GLOBALS[JNEWS . 'list_creatorfe'] : 0; if (version_compare(JVERSION, '1.6.0', '<')) { $listsAddEdit = jNews_Lists::getIDswithacclevel($my->gid); } else { $groups = JAccess::getGroupsByUser($my->id); $listsAddEdit = jNews_Lists::getIDswithacclevel($groups); } if (!jnews::checkPermissions('admin') && !jnews::checkPermissions($gid) && empty($listsAddEdit)) { return ''; } $Itemid = JRequest::getInt('Itemid'); if (empty($Itemid)) { $Itemid = $GLOBALS[JNEWS . 'itemidAca']; } $active = JRequest::getVar('mid', '0'); if ($my->id <= 0) { return true; } $status = false; if (version_compare(JVERSION, '1.6.0', '>=')) { //j15 $usergid = JAccess::getGroupsByUser($my->id, false); $my->gid = $usergid[0]; } $gid = !empty($GLOBALS[JNEWS . 'list_creatorfe']) ? $GLOBALS[JNEWS . 'list_creatorfe'] : 0; $gids = array(); $gids = explode(',', $gid); if (empty($gids)) { $gids = $gid; } $ownedlists = jNews_Lists::getOwnedlists($my->id); if (empty($my->id)) { $ownedlists = jNews_Lists::getOwnedlists($my->id); } if ($GLOBALS[JNEWS . 'type'] != 'PRO') { return false; } if (!$status) { if ((!empty($my->id) || !empty($ownedlists)) && jnews::checkPermissions('all') || in_array($my->gid, $gids)) { $status = true; } } if (!$status) { $db = JFactory::getDBO(); $query = 'SELECT * FROM `#__jnews_lists` WHERE `hidden` = 1 AND `published` = 1'; $db->setQuery($query); $lists = $db->loadObjectList(); $access = false; foreach ($lists as $list) { $bit = jnews::checkPermissions($list->acc_level); if ($bit) { $access = true; break; } } $gidAdmins = array(24, 25, 7, 8); if (jnews::checkPermissions($gid) || in_array($my->gid, $gidAdmins) || $access) { $status = true; } } if ($status) { $doc6 = JFactory::getDocument(); $doc6->addStyleSheet(JNEWS_JPATH_LIVE . '/components/' . JNEWS_OPTION . '/css/menu.css'); $gid = !empty($GLOBALS[JNEWS . 'list_creatorfe']) ? $GLOBALS[JNEWS . 'list_creatorfe'] : 0; ?> <div class="m"> <ul id="submenu"> <li><a <?php echo $active == 1 ? 'class="active"' : ''; ?> href="index.php?option=<?php echo JNEWS_OPTION; ?> &act=list&listype=1&mid=1&Itemid=<?php echo $Itemid; ?> "><?php echo _JNEWS_EMAIL_LISTS; ?> </a></li> <?php if (!empty($ownedlists) || jnews::checkPermissions('admin') || jnews::checkPermissions($gid)) { if (@(include_once JNEWSPATH_ADMIN . 'social' . DS . 'class.social.php')) { if (class_exists('jNews_Social')) { ?> <li><a <?php echo $active == 2 ? 'class="active"' : ''; ?> href="index.php?option=<?php echo JNEWS_OPTION; ?> &act=subscribers&mid=2&Itemid=<?php echo $Itemid; ?> "><?php echo _JNEWS_MENU_SUBSCRIBERS; ?> </a></li> <?php } } } // if(class_exists('jNews_Social')) { //8254465 ?> <li><a <?php echo $active == 3 ? 'class="active"' : ''; ?> href="index.php?option=<?php echo JNEWS_OPTION; ?> &act=mailing&listype=1&mid=3&Itemid=<?php echo $Itemid; ?> "><?php echo _JNEWS_MENU_NEWSLETTERS; ?> </a></li> <?php if ($GLOBALS[JNEWS . 'allow_sn']) { ?> <li><a <?php echo $active == 4 ? 'class="active"' : ''; ?> href="index.php?option=<?php echo JNEWS_OPTION; ?> &act=mailing&listype=7&mid=4&Itemid=<?php echo $Itemid; ?> "><?php echo _JNEWS_MENU_AUTONEWS; ?> </a></li> <?php } // } if (class_exists('jNews_Social') && $GLOBALS[JNEWS . 'allow_fe_autoresponder']) { ?> <li><a <?php // 88744551 - auto-responder should be list not mailing echo $active == 5 ? 'class="active"' : ''; ?> href="index.php?option=<?php echo JNEWS_OPTION; ?> &act=list&listype=2&mid=5&Itemid=<?php echo $Itemid; ?> "><?php echo _JNEWS_MENU_AUTOS; ?> </a></li> <?php } // if(class_exists('jNews_Social')) { //8254465 if (!empty($ownedlists) || jnews::checkPermissions('admin') || jnews::checkPermissions($gid)) { ?> <li><a <?php echo $active == 6 ? 'class="active"' : ''; ?> href="index.php?option=<?php echo JNEWS_OPTION; ?> &act=statistics&mid=6&Itemid=<?php echo $Itemid; ?> "><?php echo _JNEWS_MENU_STATS_REPORTS; ?> </a></li> <?php } // }endif social ?> </ul> <div class="clr"></div> </div> <?php } return true; }
function subscribers($action, $task, $userid, $listId, $cid, $front = false) { $Itemid = JRequest::getInt('Itemid'); $mainframe = JFactory::getApplication(); $newSubscriber = null; $subscriberId = JRequest::getInt('subscriber_id'); $message = JRequest::getVar('message', ''); $css = '.icon-48-subscribers { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/subscribers.png)}'; $doc = JFactory::getDocument(); $doc->addStyleDeclaration($css, $type = 'text/css'); $img = 'subscribers.png'; $emailField = JRequest::getVar('email', ''); $new = true; //new subscriber $my = JFactory::getUser(); //START OF DATA FROM REQUEST $subscriber = new stdClass(); $subscriber->user_id = JRequest::getInt('user_id'); $subscriber->name = JRequest::getVar('name', ''); $subscriber->email = JRequest::getVar('email', '', '', 'STRING'); if (!jNews_Subscribers::validEmail($subscriber->email)) { $subscriber->email = ''; } $subscriber->receive_html = JRequest::getInt('receive_html', 0); if (empty($subscriberId)) { //if it is a new user the confirmed depends if the require confirmation is turned on if ($GLOBALS[JNEWS . 'require_confirmation'] == '1') { $subscriber->confirmed = 0; } else { $subscriber->confirmed = JRequest::getInt('confirmed'); } } else { $subscriber->confirmed = JRequest::getInt('confirmed'); } $subscriber->blacklist = JRequest::getVar('blacklist', 0); $subscriber->timezone = JRequest::getVar('timezone', ''); $subscriber->language_iso = JRequest::getVar('language_iso', ''); if (empty($subscriber->ip)) { $subscriber->ip = jNews_Subscribers::getIP(); } if ($subscriber->ip == '0.0.0.0') { $subscriber->ip = '0'; } $subscriber->subscribe_date = time(); $subscriber->params = JRequest::getVar('params', ''); //column if ($GLOBALS[JNEWS . 'level'] > 2) { $subscriber->column1 = JRequest::getVar('column1', ''); $subscriber->column2 = JRequest::getVar('column2', ''); $subscriber->column3 = JRequest::getVar('column3', ''); $subscriber->column4 = JRequest::getVar('column4', ''); $subscriber->column5 = JRequest::getVar('column5', ''); } //end check of version pro //END OF DATA FROM REQUEST $doShowSubscribers = true; switch ($task) { case 'updateOneSub': JRequest::checkToken() or die('Invalid Token'); $doShowSubscribers = true; $new = false; //we addslashes the name incase an ' is entered in the name $subscriber->name = addslashes($subscriber->name); $message = jnews::printYN(jNews_Subscribers::saveSubscriber($subscriber, $subscriberId, $new), _JNEWS_UPDATED_SUCCESSFULLY, _JNEWS_ERROR); backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action); break; case 'deleteOneSub': JRequest::checkToken() or die('Invalid Token'); $doShowSubscribers = true; $message = jnews::printYN(jNews_Subscribers::deleteSubscriber($subscriberId), _JNEWS_SUBSCRIBER_DELETED, _JNEWS_ERROR); backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action); break; case 'cancelSub': $doShowSubscribers = true; backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action); break; case 'edit': foreach ($cid as $id) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=subscribers&task=show&userid=' . $id); } break; case 'show': $doShowSubscribers = false; $qid[0] = $userid; $subscriber = jNews_Subscribers::getSubscribersFromId($qid, false); $lists = jNews_Lists::getLists(0, 0, 1, '', false, false); $queues = jNews_ListsSubs::getSubscriberLists($userid); $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action); backHTML::formStart('', 0, ''); echo jNews_SubscribersHTML::editSubscriber($subscriber, $lists, $queues, $forms, jnews::checkPermissions('admin'), false, false); $go[] = jnews::makeObj('act', $action); $go[] = jnews::makeObj('subscriber_id', $subscriber->id); $go[] = jnews::makeObj('user_id', $subscriber->user_id); backHTML::formEnd($go); break; case 'new': case 'add': $doShowSubscribers = false; $newSubscriber = new stdClass(); $newSubscriber->id = ''; $newSubscriber->user_id = 0; $newSubscriber->name = ''; $newSubscriber->email = ''; $newSubscriber->ip = jNews_Subscribers::getIP(); $newSubscriber->receive_html = 1; $newSubscriber->confirmed = 1; $newSubscriber->blacklist = 0; $newSubscriber->timezone = '00:00:00'; $newSubscriber->language_iso = 'eng'; $newSubscriber->params = ''; $newSubscriber->subscribe_date = time(); //column if ($GLOBALS[JNEWS . 'level'] > 2) { //check if the version of jnews is pro $newSubscriber->column1 = ''; $newSubscriber->column2 = ''; $newSubscriber->column3 = ''; $newSubscriber->column4 = ''; $newSubscriber->column5 = ''; } $lists = jNews_Lists::getLists(0, 0, 1, '', false, false); $queues = ''; $forms['main'] = " <form action='index.php' method='post' name=\"adminForm\" id=\"adminForm\">"; if ($mainframe->isAdmin() || $GLOBALS[JNEWS . 'use_backendview']) { backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action); backHTML::formStart('addsubsback', 0, ''); echo jNews_SubscribersHTML::editSubscriber($newSubscriber, $lists, $queues, $forms, jnews::checkPermissions('admin'), false, false); } else { backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action); backHTML::formStart('addsubsfront', 0, ''); echo jNews_SubscribersHTML::editSubscriberFE($newSubscriber, $lists, $queues, $forms, jnews::checkPermissions('admin'), false, false); } $go[] = jnews::makeObj('act', $action); $go[] = jnews::makeObj('subscriber_id', $newSubscriber->id); $go[] = jnews::makeObj('user_id', $newSubscriber->user_id); backHTML::formEnd($go); break; case 'doNew': JRequest::checkToken() or die('Invalid Token'); $doShowSubscribers = true; if ($mainframe->isAdmin() || $GLOBALS[JNEWS . 'use_backendview']) { $message = jnews::printYN(jNews_Subscribers::saveSubscriber($subscriber, $subscriberId, $new), _JNEWS_NEW_SUBSCRIBER, _JNEWS_ERROR); backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action); } else { $status = jNews_Subscribers::importBis(); if ($mainframe->isAdmin()) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=subscribers&mid=2'); } else { $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION . '&act=subscribers&mid=2'); jNews_Tools::redirect($mainLink); } } break; case 'delete': JRequest::checkToken() or die('Invalid Token'); if (!is_array($cid) || count($cid) < 1) { echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n"; return false; } else { $status = true; foreach ($cid as $id) { if (!jNews_Subscribers::deleteSubscriber($id)) { $status = false; } } $message = jnews::printYN($status, _JNEWS_SUBSCRIBER_DELETED, _JNEWS_ERROR); backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action); } break; case 'update': JRequest::checkToken() or die('Invalid Token'); if (!is_array($cid) || count($cid) < 1) { echo "<script> alert('Select an item to update'); window.history.go(-1);</script>\n"; return false; } else { foreach ($cid as $id) { $changes = JRequest::getVar($id, array(0)); if (!isset($changes['receive_html'])) { $changes['receive_html'] = 0; } if (!isset($changes['confirmed'])) { $changes['confirmed'] = 0; } } } $message = jnews::print_message(_JNEWS_UPDATED_SUCCESSFULLY, 1); break; case 'export': $doShowSubscribers = false; backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action); jNews_SubscribersHTML::export($action, $listId); break; case 'doExport': $message = jnews::printYN(jNews_Subscribers::export($listId), _EXPORT, _JNEWS_ERROR); backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action); break; case 'import': $doShowSubscribers = false; backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action); $lists = jNews_Lists::getLists('', 0, '', '', false, true, true, false, false); jNews_SubscribersHTML::import($action, $lists, $listId); break; case 'doImport': JRequest::checkToken() or die('Invalid Token'); $message = jNews_Subscribers::importBis(); backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action); $message = !empty($message) && $message !== true ? $message : ($message === false ? 'Import failed' : _JNEWS_IMPORT_FINISHED); if ($mainframe->isAdmin()) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=subscribers', $message); } else { $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION . '&act=subscribers&mid=2'); jNews_Tools::redirect($mainLink); } break; case 'subscribeAll': case 'unsubscribeAll': JRequest::checkToken() or die('Invalid Token'); break; case 'cancel': if ($listId != 0) { $listId = 0; } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION); } backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action); break; case 'cpanel': $mainframe = JFactory::getApplication(); if ($mainframe->isAdmin()) { backHTML::controlPanel(); } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION); } $doShowSubscribers = 0; break; case 'toggle': $subid = JRequest::getVar('subid'); $column = JRequest::getVar('col'); if (!empty($subid) && !empty($column)) { $passObj = new stdClass(); $passObj->tableName = '#__jnews_subscribers'; $passObj->columnName = $column; $passObj->whereColumn = 'id'; $passObj->whereColumnValue = $subid; jnews::toggle($passObj); // change suspend status if column toggled is confirmed if ($column == 'confirmed') { $passObj = new stdClass(); $passObj->tableName = '#__jnews_queue'; $passObj->columnName = 'suspend'; $passObj->whereColumn = 'subscriber_id'; $passObj->whereColumnValue = $subid; jnews::toggle($passObj); } } jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=subscribers&listid=' . $listId); break; default: backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action); break; } if ($doShowSubscribers) { $limit = -1; $emailsearch = JRequest::getVar('emailsearch', '', '', 'STRING'); $emailsearch = htmlentities($emailsearch, ENT_COMPAT, "UTF-8"); $paginationStart = JRequest::getVar('pg'); $lll = JRequest::getVar('limitstart'); if (empty($lll)) { JRequest::setVar('limitstart', 0, 'int'); } $app = JFactory::getApplication(); $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int'); $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int'); $subscirberTypeID = JRequest::getVar('subtype', 1); if (empty($listId) && in_array($subscirberTypeID, array(1, 2))) { $subscirberTypeID = 0; } if (!empty($listId) && in_array($subscirberTypeID, array(3, 4))) { $subscirberTypeID = 0; } if (!empty($my->id)) { $ownedlists = jNews_Lists::getOwnedlists($my->id); } $ztozto = null; $limittotal = jNews_Subscribers::getSubscribers(0, 0, $emailsearch, $ztozto, $listId, '', '', '', 'sub_dateD', '', $ownedlists, '', $subscirberTypeID, true); //added one parameter for mailid $setLimit = new stdClass(); $setLimit->total = !empty($limittotal) ? $limittotal : 0; $setLimit->start = !empty($limitstart) ? $limitstart : 0; $setLimit->end = !empty($limitend) ? $limitend : 20; $setSort = new stdClass(); $setSort->orderValue = $app->getUserStateFromRequest(JNEWS_OPTION . '.subscribers.filter_order', 'filter_order', 'subscribe_date', 'cmd'); $setSort->orderDir = $app->getUserStateFromRequest(JNEWS_OPTION . '.subscribers.filter_order_Dir', 'filter_order_Dir', 'desc', 'word'); if (empty($limitstart)) { $limitstart = 0; } if ($setLimit->end > 200) { $setLimit->end = 200; } if ($setLimit->total == $setLimit->end) { $setLimit->start = 0; } $subscribers = jNews_Subscribers::getSubscribers($setLimit->start, $setLimit->end, $emailsearch, $setLimit->total, $listId, '', '', '', 'sub_dateD', '', $ownedlists, $setSort, $subscirberTypeID); //added one parameter for mailid if ($listId != 0) { $showAdmin = true; } else { $showAdmin = false; } $dropDownList = jNews_ListType::getListsDropList(0, '', ''); $subTypeA = array(); $subTypeA[0] = new stdClass(); $subTypeA[0]->id = 0; $subTypeA[0]->subtype = _JNEWS_SUB_LISTTYPE_ALL; if ($listId != 0) { $subTypeA[1] = new stdClass(); $subTypeA[1]->id = 1; $subTypeA[1]->subtype = _JNEWS_SUB_LISTTYPE_ONLY_SUBCRIBED; $subTypeA[2] = new stdClass(); $subTypeA[2]->id = 2; $subTypeA[2]->subtype = _JNEWS_SUB_LISTTYPE_ONLY_UNSUBCRIBED; } else { $subTypeA[3] = new stdClass(); $subTypeA[3]->id = 3; $subTypeA[3]->subtype = _JNEWS_SUB_LISTTYPE_ONLY_WAITINGCONF; $subTypeA[4] = new stdClass(); $subTypeA[4]->id = 4; $subTypeA[4]->subtype = _JNEWS_SUB_LISTTYPE_ONLY_BLOCKED; } $lists['listid'] = jnews::HTML_GenericList($dropDownList, 'listid', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'id', 'list_name', $listId); $lists['subscirberType'] = jnews::HTML_GenericList($subTypeA, 'subtype', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'id', 'subtype', $subscirberTypeID); if ($mainframe->isAdmin()) { $forms['main'] = " <form action='index.php' method='post' name=\"adminForm\" id=\"adminForm\">"; } else { if (empty($setLimit->start)) { $setLimit->start = 0; } $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION); $forms['main'] = "<form action='" . $mainLink . "' method='post' name=\"adminForm\" id=\"adminForm\">"; } $forms['select'] = " <form method='post' name='jNewsFilterForm'> \n"; backHTML::formStart('show_mailing', 0, ''); jNews_SubscribersHTML::showSubscribers($subscribers, $action, $listId, $lists, $setLimit->start, $setLimit->end, $setLimit->total, $showAdmin, $listId, $emailsearch, $forms, $setLimit, $front, $setSort); } return true; }
function installPlugin() { $database = JFactory::getDBO(); $return = '<b>' . _JNEWS_INSTALL_PLUGIN . '</b> : '; $error = ''; $files = array('jnews_cb.php', 'jnews_cb.xml', 'index.html'); if (!is_file(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin' . DS . 'jnews_cb.php')) { @mkdir(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin', 0755); @chmod(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin', 0755); } foreach ($files as $file) { if (is_file(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin' . DS . $file)) { @unlink(JNEWSPATH_ADMIN . 'extensions' . DS . 'cbplugin/' . $file); } else { if (!@rename(JNEWSPATH_ADMIN . 'extensions' . DS . 'cbplugin/' . $file, JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin' . DS . $file)) { $error .= '<br /> Error copying plugin file ' . $file . ' to CB plugin directory.'; } } //endelseif } if (is_file(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin' . DS . 'jnews_cb.php')) { @chmod(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin', 0755); } if (!@rmdir(JNEWSPATH_ADMIN . 'extensions' . DS . 'cbplugin/')) { $error .= '<br /> Error deleting the temporary cbplugin directory.'; } $query = "SELECT `id` FROM `#__comprofiler_plugin` WHERE `folder` = 'plug_jnewscbplugin' "; $database->setQuery($query); $database->query(); $id = $database->loadResult(); $mysqlerror = $database->getErrorMsg(); if (!empty($mysqlerror)) { $error .= '<br />Error getting plugin information from cb plugin table. Database error: <br />' . $mysqlerror . ''; } else { if ($id < 1) { $row->name = 'jNews CB Plugin'; $row->element = 'jnews_cb'; $row->type = 'user'; $row->folder = 'plug_jnewscbplugin'; $row->ordering = '99'; $query = "INSERT INTO `#__comprofiler_plugin` (`name` , `element`, `type`, `ordering`, `folder`) VALUES ( " . "'{$row->name}', " . "'{$row->element}', " . "'{$row->type}', " . "'{$row->ordering}', " . " '{$row->folder}' ) "; $database->setQuery($query); $database->query(); $error .= $database->getErrorMsg(); if (!empty($error)) { $error .= '<br />Error adding plug information to CB plug table.'; } $query = "SELECT `id` FROM `#__comprofiler_plugin` WHERE `folder` = 'plug_jnewscbplugin' "; $database->setQuery($query); $database->query(); $id = $database->loadResult(); $error .= $database->getErrorMsg(); $row = ''; $row->title = 'Mailing Lists'; $row->description = 'Listing of all the mailing lists for jNews'; $row->ordering = '99'; $row->width = '.5'; $row->enabled = '0'; $row->pluginclass = 'getjNewsTab'; $row->pluginid = $id; $row->sys = '0'; $row->params = 'NULL'; $row->displaytype = 'tab'; $row->position = 'cb_tabmain'; $query = "INSERT INTO `#__comprofiler_tabs` (`title` , `description`, `ordering`, `width`, `enabled`, " . " `pluginclass` , `pluginid`, `sys`, `displaytype`, `params` , `position` ) VALUES ( " . "'{$row->title}', " . "'{$row->description}', " . "'{$row->ordering}', " . "'{$row->width}', " . "'{$row->enabled}', " . "'{$row->pluginclass}', " . "'{$row->pluginid}', " . "'{$row->sys}', " . "'{$row->displaytype}', " . "'{$row->params}', " . "'{$row->position}' ) "; $database->setQuery($query); $database->query(); $error .= $database->getErrorMsg(); if (!empty($error)) { $error .= '<br />Error adding plug information to CB tab table.'; } } } //endelse if (empty($error)) { $xf = new jNews_Config(); $xf->update('cb_pluginInstalled', '1'); //$return .= jnews::M('green' , _JNEWS_INSTALL_SUCCESS,false) .'<br />'; jnews::displayInfo(_JNEWS_INSTALL_SUCCESS, 'success'); } else { //$return .= $error.jnews::M('red' , _JNEWS_INSTALL_ERROR,false) .'<br />'; jnews::displayInfo($error, 'error'); } //return $return; }
function update($action, $task) { require_once JNEWSPATH_CLASS . 'class.update.php'; $update = new jNews_Update(); $showListing = true; $showComplete = false; $message = JRequest::getVar('message', ''); if (!ini_get('safe_mode')) { @set_time_limit(60 * $GLOBALS[JNEWS . 'script_timeout']); } //css injection for the images $doc = JFactory::getDocument(); $css = '.icon-48-import { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/import.png)}'; $doc->addStyleDeclaration($css, $type = 'text/css'); switch ($task) { case 'doUpdate': backHTML::_header(_JNEWS_MENU_UPDATE, 'update', $message, $task, $action); $update->doUpdate(); $showListing = false; $showComplete = false; break; case 'version': $update->getVersion(); break; case 'complete': $showComplete = true; $showListing = false; break; case 'cancel': jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=update'); $showListing = false; break; case 'cpanel': jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION); $showListing = false; break; case 'new1': backHTML::_header(_JNEWS_MENU_UPDATE, 'import.png', $message, $task, $action); $message = jnews::printYN(jnews::upgrade_News1(), '<br />' . _JNEWS_IMPORT_SUCCESS . ' Anjel data', _JNEWS_ERROR); jnews::resetUpgrade(1); echo '<br />' . $message; break; case 'new2': backHTML::_header(_JNEWS_MENU_UPDATE, 'import.png', $message, $task, $action); $message = jnews::printYN(jnews::upgrade_News2(), '<br />' . _JNEWS_IMPORT_SUCCESS . ' Letterman data', _JNEWS_ERROR); jnews::resetUpgrade(2); echo '<br />' . $message; break; case 'new3': backHTML::_header(_JNEWS_MENU_UPDATE, 'import.png', $message, $task, $action); $message = jnews::printYN(jnews::upgrade_News3(), '<br />' . _JNEWS_IMPORT_SUCCESS . ' YaNC data', _JNEWS_ERROR); jnews::resetUpgrade(3); echo '<br />' . $message; break; } if ($showListing) { backHTML::_header(_JNEWS_MENU_UPDATE, 'import.png', $message, $task, $action); backHTML::_upgrade(); $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; echo $forms['main']; backHTML::formStart('', '', ''); backHTML::showCompsList($update); $go[] = jnews::makeObj('act', $action); backHTML::formEnd($go); } elseif ($showComplete) { backHTML::_header(_JNEWS_MENU_UPDATE, 'import.png', $message, $task, $action); $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; echo $forms['main']; backHTML::formStart('', '', ''); backHTML::showUpdateOptions($update); $go[] = jnews::makeObj('act', $action); backHTML::formEnd($go); } }
function mailing($action, $task, $listId, $listType, $mailingId, $message) { $showMailings = false; $db = JFactory::getDBO(); switch ($task) { case 'edit': $issue_nb = JRequest::getInt('issue_nb', 1); $mailingType = JRequest::getVar('listype'); $isEdit = JRequest::getVar('isEdit', true); $mySess = JFactory::getSession(); $mySess->set('listype', $mailingType, 'LType'); if (!empty($listId)) { $list = jNews_Lists::getOneList($listId); } else { $list = jNews_Lists::getListFirstEntry(); } $new = empty($mailingId) || $mailingId == 0 ? true : false; $mailing = jNews_Mailing::getOneMailing($list, $mailingId, $issue_nb, $new, false, true); $mailing->mailing_type = $mailingType; // if(empty($isEdit)) $isEdit = true; // set default mailing parameters $my = JFactory::getUser(); $subscribers = jNews_Subscribers::getSubscriberInfoFromUserId($my->id); if (!isset($subscribers)) { $subscribers = new stdClass(); } $subscribers->name = isset($subscribers->name) ? $subscribers->name : ''; $subscribers->email = isset($subscribers->email) ? $subscribers->email : ''; // $mailing->fromname = ( !isset( $mailing->fromname ) || empty( $mailing->fromname ) ) ? $subscribers->name : $mailing->fromname; // $mailing->fromemail = ( !isset( $mailing->fromemail ) || empty( $mailing->fromemail ) ) ? $subscribers->email : $mailing->fromemail; // $mailing->frombounce = ( !isset( $mailing->frombounce ) || empty( $mailing->frombounce ) ) ? $GLOBALS[JNEWS.'sendmail_from'] : $mailing->frombounce; $show = jNews_ListType::showType($mailing->mailing_type, 'editmailing'); if ($mailing->published != 1 or $mailing->mailing_type != 1 or isset($show['admin']) and $show['admin']) { $forms['main'] = " <form action='index.php' method='post' enctype='multipart/form-data' name='adminForm' id=\"adminForm\">"; jNews_Mailing::_header($task, $action, $mailing->mailing_type, $message, 'edit'); jNews_MailingsHTML::editMailing($mailing, $new, $listId, $forms, $show, $isEdit); $go[] = jnews::makeObj('act', $action); backHTML::formEnd($go); } else { $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; jNews_Mailing::_header($task, $action, $mailing->mailing_type, $message); //backHTML::formStart(); jNews_MailingsHTML::viewMailing($mailing, $forms); $go[] = jnews::makeObj('act', 'mailing'); $go[] = jnews::makeObj('task', 'viewmailing'); $go[] = jnews::makeObj('mailingid', $mailing->id); backHTML::formEnd($go); } break; case 'new': case 'add': // check if atleast one list exist and published // if false then restrict entry $mailingType = JRequest::getVar('listype'); $type = $mailingType == 2 ? 2 : 1; $result = jNews_Lists::checkListNotEmpty($type); if (!$result) { if ($type == 2) { $disp = addslashes(_JNEWS_CHECKCAMPAIGNFOUND); } else { $disp = addslashes(_JNEWS_CHECKLISTFOUND); } echo "<script> alert('" . $disp . "'); window.history.go(-1);</script>\n"; break; } $mailingType = JRequest::getVar('listype'); if (empty($listId)) { $listId = JRequest::getVar('listid'); } if (!empty($listId)) { $mailingType = jNews_Lists::getListType($listId) == 2 ? 2 : 1; } JRequest::setVar('listype', $mailingType); $total = jNews_Mailing::countMailings($listId, $mailingType); $total++; jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&task=edit&mailingid=0&issue_nb=' . $total . '&listype=' . $mailingType . '&listid=' . $listId . '&isEdit=0'); //mariap break; case 'saveSend': JRequest::checkToken() or die('Invalid Token'); $mySess = JFactory::getSession(); $mailingType = $mySess->get('listype', '', 'LType'); $status = checkMailingSave($mailingType); if (!$status) { return false; } jNews_Mailing::saveMailing($mailingId, $listId); case 'sendready': //we update the senddate of the newsletter jNews_Mailing::updatesenddate($mailingId); jNews_MailingsHTML::sendReady($mailingId, $listId, $listType); break; case 'generate': if (class_exists('jNews_Auto')) { $still = false; $message = jnews::printYN(jNews_Auto::processQueue(true, true, $still, true), 'Queue processed', _JNEWS_ERROR); jNews_Auto::displayStatus(); } return; break; case 'send': $queueC = new jNews_Queue(); $queueC->checkForNewsletters($mailingId); $queueCount = jNews_Queue::getQueueCount($mailingId); $totalSub = JRequest::setVar('totalsend', $queueCount); $linkURL = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=mailing&task=continuesend&mailingid=' . $mailingId . '&totalsend=' . $totalSub, true, false, true); jNews_Tools::redirect($linkURL); break; case 'continuesend': $queueC = new jNews_Queue(); //we update the senddate of the mailing to be now to be able to continue the sending and send it after we click continue // $queueC->updateSenddateToNow($mailingId); $totalSend = JRequest::getVar('totalsend', 0, '', 'int'); $alreadySent = JRequest::getVar('alreadysent', 0, '', 'int'); $queueC->start = $alreadySent; $queueC->total = $totalSend; $queueC->pause = $GLOBALS[JNEWS . 'pause_time']; $queueC->sendQueue(false, $mailingId, false, true); ob_start(); exit; break; case 'testspam': if (empty($message)) { $message = _JNEWS_MESSAGE_NOT; } $mailingId = $mailingId == 0 ? jNews_Mailing::getLastMailingId() : $mailingId; $my = JFactory::getUser(); if ($listId > 0) { $archivemailing = jNews_Mailing::getMailingView($mailingId, $listId); } else { $archivemailing = jNews_Mailing::getMailingView($mailingId); } $mailing = new stdClass(); $receivers = new stdClass(); $receivers->email = '*****@*****.**'; $receivers->name = $archivemailing->fromname; $receivers->receive_html = 1; $receivers->id = jNews_Subscribers::getSubscriberIdFromUserId($my->id); //if email are different we dont replace because we want to make sure the spam cehck count the fact that //sender and bounce back are different if ($archivemailing->fromemail == $archivemailing->frombounce) { $archivemailing->frombounce = $my->email; } $archivemailing->fromemail = $my->email; $mailerC = new jNews_ProcessMail(); $status = $mailerC->send($archivemailing, $receivers); $message = jnews::printYN($status, _JNEWS_SPAMTEXT_MESSAGE_SENT_SUCCESSFULLY, $message); $link = 'http://www.joobi.co/index.php?option=com_jlinks&controller=redirect&link=SpamCheck&alt=jnewsdoc_glossary'; $iFrame = '<iframe src="' . $link . '" width="100%" height="680px" scrolling="auto"></iframe>'; echo $iFrame; break; case 'savePreview': JRequest::checkToken() or die('Invalid Token'); $status = checkMailingSave($mailingType); if (!$status) { return false; } if ($mailingType == 7) { $mailing = JRequest::getVar('mailing', ''); $ContentStatus = checkTag(); if (!$ContentStatus) { return false; } } jNews_Mailing::saveMailing($mailingId, $listId); case 'preview': $emailaddress = JRequest::getVar('emailaddress', ''); $mailingId = $mailingId == 0 ? jNews_Mailing::getLastMailingId() : $mailingId; if (!empty($emailaddress)) { $status = jNews_Mailing::sendTestEmail($mailingId, $listId); if (empty($message)) { $message = _JNEWS_MESSAGE_NOT; } $message = jnews::printYN($status, _JNEWS_MESSAGE_SENT_SUCCESSFULLY, $message); } if ($listId > 0) { $archivemailing = jNews_Mailing::getMailingView($mailingId, $listId); } else { $archivemailing = jNews_Mailing::getMailingView($mailingId); } $doc = JFactory::getDocument(); $css = '.icon-48-preview{ background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/preview.png)}'; $doc->addStyleDeclaration($css, $type = 'text/css'); $title = _JNEWS_PREVIEW_TITLE . ': ' . $archivemailing->subject; backHTML::_header(_JNEWS_PREVIEW_TITLE, 'preview.png', $message, $task, $action); //new view for the preview mailing echo '<table cellpadding="0" cellspacing="2" border="0" width="100%"><tr><td width="40%">'; jNews_MailingsHTML::previewMailingHTML($mailingId, $listId, $listType, $archivemailing->html); echo '</td><td width="60%">'; $forms['main'] = ''; $list = jNews_Lists::getOneList($archivemailing->list_id); $textonly = ''; $mailerC = new jNews_ProcessMail(); $queueInfo = new stdClass(); $queueInfo->mailingid = $mailingId; $queueInfo->listid = @$listId; $mailerC->getContent($archivemailing->images, $archivemailing->html, $archivemailing->textonly, $archivemailing->subject, false, true, $queueInfo); //new $archivemailing->subject if ($archivemailing->html == 1) { if (empty($template_id)) { $template_id = $archivemailing->template_id; } if (!empty($template_id)) { jNews_Templates::includeStyles($archivemailing->htmlcontent, $template_id); } } else { $archivemailing->textonly = jNews_ProcessMail::htmlToText($archivemailing->textonly); } //new view for the preview mailing jNews_MailingsHTML::viewHeading($archivemailing); echo '</td></tr><tr><td colspan="2">'; jNews_MailingsHTML::viewMailing($archivemailing, $forms); echo '</td></tr></tbody></table>'; if ($mailingId == 0) { JRequest::setVar('mailingid', $mailingId); } break; case 'view': $mailingType = JRequest::getVar('listype'); if (!empty($mailingType)) { $mySess = JFactory::getSession(); $mySess->set('listype', $mailingType, 'LType'); } if ($mailingId != 0) { if ($listId > 0) { $archivemailing = jNews_Mailing::getMailingView($mailingId, $listId); } else { $archivemailing = jNews_Mailing::getMailingView($mailingId); } if (empty($template_id)) { $template_id = $archivemailing->template_id; } if (!empty($template_id)) { jNews_Templates::includeStyles($archivemailing->htmlcontent, $template_id); } $forms['main'] = "<form action='index.php?option=" . JNEWS_OPTION . "&act=mailing&listype=" . $listType . "&listid=" . $listId . "' method='post' name='adminForm' id=\"adminForm\">"; jNews_Mailing::_header($task, $action, $listType, $message); backHTML::formStart('show_mailing', 0, ''); jNews_MailingsHTML::viewMailing($archivemailing, $forms); $go[] = jnews::makeObj('act', 'mailing'); $go[] = jnews::makeObj('task', 'viewmailing'); $go[] = jnews::makeObj('listId', $archivemailing->list_id); //listid to listId--original backHTML::formEnd($go); } break; case 'deletequeue': //implement here what are we going to do with the delete queueu column on the mailing $mailingID = JRequest::getVar('mailingid'); $mailingType = JRequest::getVar('listype'); if (!empty($mailingID)) { $db = JFactory::getDBO(); $db->setQuery('DELETE FROM `#__jnews_queue` WHERE `mailing_id` = ' . $mailingID); $db->query(); $message = jnews::printYN(true, _JNEWS_MAILING_QUEUE_DELETED, _JNEWS_ERROR); } else { $message = jnews::printYN(false, _JNEWS_MAILING_QUEUE_DELETED, _JNEWS_ERROR); } jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType, $message); break; case 'deleteMailing': JRequest::checkToken() or die('Invalid Token'); $d['mailing'] = jNews_Mailing::getOneMailing('', $mailingId, '', $new); $message = jnews::printYN(jNews_Mailing::delete($d), @constant($GLOBALS[JNEWS . 'listname' . $d['mailing']->list_type]) . '"' . $d['mailing']->subject . '"' . _JNEWS_SUCCESS_DELETED, _JNEWS_ERROR); $showMailings = true; break; case 'cancel': $url = 'index.php?option=' . JNEWS_OPTION . '&act=mailing&mailingid=' . $mailingId; $url .= (!empty($listId) ? '&listid=' . $listId : '') . '&listype=' . $mailingType; jNews_Tools::redirect($url); break; case 'copy': JRequest::checkToken() or die('Invalid Token'); $message = jnews::printYN(jNews_Mailing::copyMailing($mailingId), _JNEWS_MAILING_COPY, _JNEWS_ERROR); $showMailings = true; break; case 'cancelMailing': $showMailings = true; break; case 'publishMailing': JRequest::checkToken() or die('Invalid Token'); $mailing = jNews_Mailing::getOneMailing('', $mailingId, '', $new); $message = jnews::printYN(jNews_Mailing::publishMailing($mailingId), @constant($GLOBALS[JNEWS . 'listname' . $mailing->mailing_type]) . ' ' . _JNEWS_PUBLISHED, _JNEWS_ERROR); $mailingType = jNews_Mailing::getMailingInfoz($mailingId); jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType); break; case 'unpublishMailing': JRequest::checkToken() or die('Invalid Token'); $mailing = jNews_Mailing::getOneMailing('', $mailingId, '', $new); $message = jnews::printYN(jNews_Mailing::unpublishMailing($mailingId), @constant($GLOBALS[JNEWS . 'listname' . $mailing->mailing_type]) . ' ' . _JNEWS_UNPUBLISHED, _JNEWS_ERROR); $mailingType = jNews_Mailing::getMailingInfoz($mailingId); jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId); break; case 'cpanel': backHTML::controlPanel(); break; case 'save': JRequest::checkToken() or die('Invalid Token'); $subject = JRequest::getVar('subject', ''); if (empty($subject)) { echo "<script> alert('subject needs to be not empty'); window.history.go(-1);</script>\n"; return false; } if (!isset($mailingType)) { $mySess = JFactory::getSession(); $mailingType = $mySess->get('listype', '', 'LType'); } $status = checkMailingSave($mailingType); if ($mailingType == 7) { $mailing = JRequest::getVar('mailing', ''); $ContentStatus = checkTag(); if (!$ContentStatus) { return false; } } if (!$status) { return false; } $message = jnews::printYN(jNews_Mailing::saveMailing($mailingId, $listId), _JNEWS_MAILING_SAVED, _JNEWS_ERROR); if (!empty($mailingtype)) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId); } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId); $showMailings = true; unset($GLOBALS["task"]); unset($_REQUEST["task"]); } break; case 'apply': JRequest::checkToken() or die('Invalid Token'); $mailingid = JRequest::getVar('mailingid', '0'); if (!isset($mailingType)) { $mySess = JFactory::getSession(); $mailingType = $mySess->get('listype', '', 'LType'); } $status = checkMailingSave($mailingType); if ($mailingType == 7) { $mailing = JRequest::getVar('mailing', ''); $ContentStatus = checkTag(); if (!$ContentStatus) { return false; } } if (!$status) { return false; } $message = jnews::printYN(jNews_Mailing::saveMailing($mailingId, $listId), _JNEWS_MAILING_SAVED, _JNEWS_ERROR); $mailingid = $mailingid == 0 ? jNews_Mailing::getLastMailingId() : $mailingid; if (!empty($mailingtype)) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&task=edit&listype=' . $mailingType . '&mailingid=' . $mailingid . '&listid=' . $listId); } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&task=edit&listype=' . $mailingType . '&mailingid=' . $mailingid . '&listid=' . $listId); $showMailings = true; unset($GLOBALS["task"]); unset($_REQUEST["task"]); } break; case 'show': $id = JRequest::getVar('mailingid'); $mySess = JFactory::getSession(); $mailingType = JRequest::getVar('listype', 0); $listId = JRequest::getVar('listid', 0); $link = 'index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId; jNews_Tools::redirect($link); $showMailings = true; break; case 'toggle': $listid = JRequest::getVar('listid'); $column = JRequest::getVar('col'); $mailingid = JRequest::getVar('mailingid'); if (!empty($mailingid) && !empty($column)) { $passObj = new stdClass(); $passObj->tableName = '#__jnews_mailings'; $passObj->columnName = $column; $passObj->whereColumn = 'id'; $passObj->whereColumnValue = $mailingid; jnews::toggle($passObj); } if ($listType == 1) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listid . '&listype=1'); } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listid . '&listype=2'); } break; default: $showMailings = true; break; } if ($showMailings) { if (empty($listType)) { $listType = JRequest::getVar('listype', 0); } if (empty($listId)) { $listId = JRequest::getVar('listid', 0); } $paginationStart = JRequest::getVar('pg'); if (!empty($paginationStart)) { $limitstart = 0; $limitend = $paginationStart; } else { $app = JFactory::getApplication(); $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int'); $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int'); } $limittotal = jNews_Mailing::countMailings(0, $listType); $setLimit = new stdClass(); $setLimit->total = !empty($limittotal) ? $limittotal : 0; $setLimit->start = !empty($limitstart) ? $limitstart : 0; $setLimit->end = !empty($limitend) ? $limitend : $limittotal; if ($setLimit->total == $setLimit->end) { $setLimit->start = 0; } jNews_Mailing::showMailings($task, $action, $listId, $listType, $message, true, _JNEWS_MENU_MAILING, $setLimit); } return true; }
function moveTo($dir_dest, $overwrite = true) { if (!$this->isValid()) { return jnews::printM('error', $this->upload['error']); } if (!$this->_evalValidExtensions()) { return jnews::printM('error', _JNEWS_NOT_ALLOWED_EXTENSION); } $err_code = $this->_chk_dir_dest($dir_dest); if ($err_code !== false) { return jnews::printM('error', $err_code); } if (!$this->mode_name_selected) { $this->setName('safe'); } $name_dest = $dir_dest . DIRECTORY_SEPARATOR . $this->upload['name']; if (@is_file($name_dest)) { if ($overwrite !== true) { return jnews::printM('error', _JNEWS_FILE_EXISTS); } elseif (!is_writable($name_dest)) { return jnews::printM('error', _JNEWS_CANNOT_OVERWRITE); } } if (!@move_uploaded_file($this->upload['tmp_name'], $name_dest)) { return jnews::printM('error', _JNEWS_E_FAIL_MOVE); } @chmod($name_dest, $this->_chmod); return $this->getProp('name'); }
function onAfterStoreUser($user, $isnew, $success, $msg) { if ($success === false) { return false; } if (strtolower(substr(JPATH_ROOT, strlen(JPATH_ROOT) - 13)) == 'administrator') { $adminPath = strtolower(substr(JPATH_ROOT, strlen(JPATH_ROOT) - 13)); } else { $adminPath = JPATH_ROOT; } if (!@(include_once $adminPath . DS . 'components' . DS . 'com_jnews' . DS . 'defines.php')) { return; } include_once JNEWSPATH_CLASSN . 'class.jnews.php'; require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . 'class.subscribers.php'; require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . 'class.listssubscribers.php'; jimport('joomla.html.parameter'); $plugin =& JPluginHelper::getPlugin('user', 'jnewssyncuser'); $params = new JParameter($plugin->params); $db =& JFactory::getDBO(); $subscriber = null; $confirmed = 1; if ($user['block']) { $confirmed = 0; } $subscriber->email = trim(strip_tags($user['email'])); if (!empty($user['name'])) { $subscriber->name = trim(strip_tags($user['name'])); } if (empty($user['block'])) { $subscriber->confirmed = 1; } $subscriber->user_id = $user['id']; $subscriber->ip = jNews_Subscribers::getIP(); $subscriber->receive_html = 1; $subscriber->confirmed = $confirmed; $subscriber->subscribe_date = jnews::getNow(); $subscriber->language_iso = 'eng'; $subscriber->timezone = '00:00:00'; $subscriber->blacklist = 0; //check if the version of jnews is pro if ($GLOBALS[JNEWS . 'type'] == 'PRO') { $subscriber->column1 = ''; $subscriber->column2 = ''; $subscriber->column3 = ''; $subscriber->column4 = ''; $subscriber->column5 = ''; } //end if check if the version is pro if (!$isnew and !empty($this->oldUser['email']) and $user['email'] != $this->oldUser['email']) { $d['email'] = $this->oldUser['email']; $infos = jNews_Subscribers::getSubscriberIdFromEmail($this->oldUser); $subscriber->id = $infos['subscriberId']; } if ($isnew) { //new registered user $status = jNews_Subscribers::saveSubscriber($subscriber, $subscriber->user_id, true); if (empty($subscriber->id)) { $subscriber->id = jNews_Subscribers::getSubscriberIdFromUserId($subscriber->user_id); } if (!$status) { return; } $listsToSubscribe = $params->get('lists', ''); if (!empty($listsToSubscribe)) { $condition = ' WHERE `id` IN (' . $listsToSubscribe . ')'; } else { $condition = ' WHERE `auto_add` > 0'; } //get list ids of auto_add lists $query = 'SELECT `id`, `list_type`, `params` from `#__jnews_lists`' . $condition; $db->setQuery($query); $autoListId = $db->loadObjectList(); $error = $db->getErrorMsg(); if (!empty($error)) { echo $error; return false; } else { //use for masterlists $listsA = array(); foreach ($autoListId as $autoId) { if (!empty($autoId->params)) { //use for masterlists $listsA[] = $autoId->id; } else { //for non-masterlists $subscriber->list_id = $autoId->id; jNews_ListsSubs::saveToListSubscribers($subscriber); } if ($autoId->list_type == 2) { $subscribe = array(); $subscribe[] = $autoId->id; if (!empty($subscribe)) { jNews_ListsSubs::subscribeARtoQueue($subscriber->id, $subscribe); } } } //end of foreach } if (!empty($listsA)) { //we check if the social class file exists for the implementation of master lists if (@(include_once JNEWSPATH_ADMIN . 'social' . DS . 'class.social.php')) { if (class_exists('social')) { $listidSubsA = array(); $masterListSubscriber = null; //we check if configuration for master lists is enabled if ($GLOBALS[JNEWS . 'use_masterlists']) { if ($GLOBALS[JNEWS . 'type'] == 'PLUS' || $GLOBALS[JNEWS . 'type'] == 'PRO') { //we validate if the user can be subscribed to the list then we return the masterlistid //1 - MasterLists for all Potential Users $listidSubsA[] = jNews_Social::includeMasterListIds($subscriber->id, 1, $listsA); //2 - MasterLists for all Registered Subscribers $listidSubsA[] = jNews_Social::includeMasterListIds($subscriber->id, 2, $listsA); } if ($GLOBALS[JNEWS . 'type'] == 'PRO') { //we validate if the user can be subscribed to the list then we return the masterlistid //3 - MasterLists for all Front-end Subscribers $listidSubsA[] = jNews_Social::includeMasterListIds($subscriber->id, 3, $listsA); } } $masterListSubscriber->id = $subscriber->id; $masterListSubscriber->list_id = $listidSubsA; jNews_ListsSubs::saveToListSubscribers($masterListSubscriber); } } } } else { //confirmed registered user // if(!empty($this->oldUser['block']) AND !empty($subscriber->confirmed)){ if (empty($subscriber->id)) { $subscriber->id = jNews_Subscribers::getSubscriberIdFromUserId($subscriber->user_id); } plgUserjNewssyncuser::_confirmUserSubscription($subscriber->id); // } } //endelse return true; }
/** * <p>Function to insert a date tag<p> */ function tagdatetime() { $js = 'function insertjnewstag(tag){ '; if (version_compare(JVERSION, '1.6.0', '<')) { //1.5 $js .= ' if(window.top.insertTag(tag)){window.top.document.getElementById(\'sbox-window\').close();}'; } else { if (version_compare(JVERSION, '3.0.0', '<')) { $js .= ' if(window.top.insertTag(tag)) {window.parent.SqueezeBox.close();}'; } else { $js .= ' if(window.top.insertTag(tag)) { var need_click = jQuery(window.top.document).find("div.modal-backdrop"); if(need_click.length == 0) window.parent.SqueezeBox.close(); else jQuery(window.top.document).find("div.modal-backdrop").click();}'; } } $js .= '}'; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); echo '<style type="text/css">table.' . jnews::myTheme() . 'tr:hover {cursor: pointer;}</style>'; ?> <div id="element-box"> <div class="t"> <div class="t"> <div class="t"></div> </div> </div> <div class="m"> <table class="<?php echo jnews::myTheme(); ?> "> <tbody> <thead> <tr> <th class="title"><center><?php echo _JNEWS_MAILING_TAG; ?> </center></th> <th class="title"><center><?php echo _JNEWS_TEMPLATE_DESC; ?> </center></th> </tr> </thead> <tr class="row0" onclick="insertjnewstag('{tag:date}')"> <td> <strong><?php echo '{tag:date}'; ?> </strong> </td> <td> <?php if (version_compare(JVERSION, '3.0.0', '<')) { $date = JHTML::_('date', jnews::getNow(), JText::_('DATE_FORMAT_LC'), JNEWS_TIME_OFFSET); } else { $date = JHtml::_('date', jnews::getNow(), JText::_('DATE_FORMAT_LC'), JNEWS_TIME_OFFSET); } echo $date; ?> </td> </tr> <tr class="row0" onclick="insertjnewstag('{tag:date format=1}')"> <td> <strong><?php echo '{tag:date format=1}'; ?> </strong> </td> <td> <?php if (version_compare(JVERSION, '3.0.0', '<')) { $date = JHTML::_('date', jnews::getNow(), JText::_('DATE_FORMAT_LC1'), JNEWS_TIME_OFFSET); } else { $date = JHtml::_('date', jnews::getNow(), JText::_('DATE_FORMAT_LC1'), JNEWS_TIME_OFFSET); } echo $date; ?> </td> </tr> <tr class="row0" onclick="insertjnewstag('{tag:date format=2}')"> <td> <strong><?php echo '{tag:date format=2}'; ?> </strong> </td> <td> <?php if (version_compare(JVERSION, '3.0.0', '<')) { $date = JHTML::_('date', jnews::getNow(), JText::_('DATE_FORMAT_LC2'), JNEWS_TIME_OFFSET); } else { $date = JHtml::_('date', jnews::getNow(), JText::_('DATE_FORMAT_LC2'), JNEWS_TIME_OFFSET); } echo $date; ?> </td> </tr> <tr class="row0" onclick="insertjnewstag('{tag:date format=3}')"> <td> <strong><?php echo '{tag:date format=3}'; ?> </strong> </td> <td> <?php if (version_compare(JVERSION, '3.0.0', '<')) { $date = JHTML::_('date', jnews::getNow(), JText::_('DATE_FORMAT_LC3'), JNEWS_TIME_OFFSET); } else { $date = JHtml::_('date', jnews::getNow(), JText::_('DATE_FORMAT_LC3'), JNEWS_TIME_OFFSET); } echo $date; ?> </td> </tr> <tr class="row0" onclick="insertjnewstag('{tag:date format=4}')"> <td> <strong><?php echo '{tag:date format=4}'; ?> </strong> </td> <td> <?php if (version_compare(JVERSION, '3.0.0', '<')) { $date = JHTML::_('date', jnews::getNow(), JText::_('DATE_FORMAT_LC4'), JNEWS_TIME_OFFSET); } else { $date = JHtml::_('date', jnews::getNow(), JText::_('DATE_FORMAT_LC4'), JNEWS_TIME_OFFSET); } echo $date; ?> </td> </tr> </tbody> </table> </div> <div class="b"> <div class="b"> <div class="b"></div> </div> </div> </div> <?php }
public static function import($action, $lists, $listId) { ?> <script language="javascript" type="text/javascript"> function submitbutton(pressbutton) { var form = document.adminForm; if (form.importfile.value == "") { alert( "<?php echo addslashes(_JNEWS_SELECT_FILE) . ' ' . addslashes(_JNEWS_MENU_IMPORT) . '!'; ?> " ); } else { submitform(pressbutton); } } </script> <form action="index.php?option=<?php echo JNEWS_OPTION; ?> &act=<?php echo $action; ?> &listid=<?php echo $listId; ?> " method="post" name="adminForm" enctype="multipart/form-data" id="adminForm"> <input type="hidden" name="task" value="<?php $task = JRequest::getVar('task', 'import'); echo $task; ?> " /> <input type="hidden" name="action" value="<?php echo $action; ?> " /> <table border="0" width="100%" cellpadding="1" cellspacing="1" class="<?php echo jnews::myTheme(); ?> "> <tbody> <?php if (!$GLOBALS[JNEWS . 'disabletooltip']) { if (version_compare(JVERSION, '3.0.0', '<')) { JHTML::_('behavior.tooltip'); } else { JHtml::_('behavior.tooltip'); } } echo _JNEWS_LIST_IMPORT; $i = 0; $k = 0; foreach ($lists as $list) { $i++; echo '<tr class=row' . $k . '><td width="40px">'; echo "\n" . '<input type="checkbox" class="inputbox" value="1" name="subscribed[' . $i . ']" />'; echo "\n" . '<input type="hidden" name="sub_list_id[' . $i . ']" value="' . $list->id . '" />'; echo '</td><td>'; echo "\n" . '<span class="aca_list_name onclick=\'return false;\'">' . jNews_Tools::toolTip($list->list_desc, $list->list_name, '', '', $list->list_name, '#', 1) . '</span>'; echo "\n" . '<input type="hidden" name="acc_level[' . $i . ']" value="0" />'; echo '</td></tr>'; $k = 1 - $k; } ?> <tr> <td colspan="2"> <br/> <?php echo _JNEWS_IMPORTSUB_TIPS; ?> <div style="border: 1px solid #D5D5D5; padding: 5px; margin: 2px; background-color: #F9F9F9"> <?php echo _JNEWS_SELECT_IMPORT_FILE . ' :'; ?> <input type="file" name="importfile" size="57" class="inputbox" /> <input type="button" value="Import" class="button" onclick="submitbutton('doImport')" /> </div> </td> </tr> </table> <?php if (version_compare(JVERSION, '3.0.0', '<')) { echo JHTML::_('form.token'); } else { echo JHtml::_('form.token'); } ?> </form><?php }
public static function showType($listType, $screen) { $gid = !empty($GLOBALS[JNEWS . 'list_creatorfe']) ? $GLOBALS[JNEWS . 'list_creatorfe'] : 0; if (is_array($listType)) { $listType = array_pop($listType); } switch ($screen) { case 'editmailing': $className = JNEWS . (!isset($GLOBALS[JNEWS . 'classes' . $listType]) ? $GLOBALS[JNEWS . 'classes' . $listType] : ''); if (class_exists($className)) { $view = new $className(); $show = $view->editmailing(); } else { $show['sender_info'] = true; $show['published'] = true; $show['pub_date'] = true; $show['hide'] = true; $show['issuenb'] = true; $show['delay'] = false; $show['htmlcontent'] = true; $show['textcontent'] = true; $show['attachement'] = true; $show['auto_option'] = true; $show['images'] = true; $show['sitecontent'] = true; $show['admin'] = true; } break; case 'editlist': $show['access'] = $GLOBALS[JNEWS . 'level'] > 2 ? true : false; $className = JNEWS . (!isset($GLOBALS[JNEWS . 'classes' . $listType]) ? $GLOBALS[JNEWS . 'classes' . $listType] : ''); if (class_exists($className)) { $view = new $className(); $show = array_merge($show, $view->editlist()); } else { $show['sender_info'] = true; $show['hide'] = true; $show['auto_option'] = true; $show['htmlmailing'] = true; $show['auto_subscribe'] = true; $show['email_unsubcribe'] = false; $show['unsusbcribe'] = false; } break; case 'showMailings': $show['admin'] = jnews::checkPermissions('admin'); $show['index'] = 'index2'; $show['buttons'] = false; if ($show['admin']) { if (empty($listType)) { $listType = 1; } $className = JNEWS . (!isset($GLOBALS[JNEWS . 'classes' . $listType]) ? $GLOBALS[JNEWS . 'classes' . $listType] : ''); if (class_exists($className)) { $view = new $className(); $show = array_merge($show, $view->showMailings()); } else { $show['id'] = true; $show['dropdown'] = true; $show['select'] = true; $show['issue'] = true; $show['sentdate'] = true; $show['delay'] = false; $show['status'] = true; } } else { $show['id'] = false; $show['dropdown'] = false; $show['select'] = false; $show['issue'] = true; $show['sentdate'] = true; $show['delay'] = false; $show['status'] = false; } break; case 'showListsBack': if (jnews::checkPermissions('admin')) { $show['id'] = true; } else { $show['id'] = false; } $show['index'] = 'index2'; $show['select'] = true; $show['published'] = true; $show['sender'] = true; $show['sender_email'] = false; $show['mailings_link'] = true; $show['mailings_sub'] = true; $show['list_type'] = true; $show['visible'] = true; $show['color'] = true; $show['buttons'] = false; $show['front'] = false; break; case 'showListsFront': $db = JFactory::getDBO(); $query = 'SELECT * FROM `#__jnews_lists` WHERE `hidden` = 1 AND `published` = 1 AND '; if (is_array($listType)) { $query .= ' `list_type` IN (' . jnews::implode(',', $listType) . ') '; } else { $query .= ' `list_type`=' . intval($listType); } $db->setQuery($query); $lists = $db->loadObjectList(); $access = false; $my = JFactory::getUser(); foreach ($lists as $list) { $bit = jnews::checkPermissions($list->acc_level); if ($bit) { $access = true; break; } } if (jnews::checkPermissions($gid) || $access && $my->id > 0) { $show['id'] = true; $show['published'] = true; $show['sender'] = true; $show['sender_email'] = false; $show['list_type'] = true; $show['visible'] = true; $show['mailings_sub'] = false; $show['color'] = true; $show['mailings_link'] = true; $show['front'] = true; } else { $show['id'] = false; $show['published'] = false; $show['sender'] = false; $show['sender_email'] = false; $show['list_type'] = false; $show['visible'] = false; $show['mailings_sub'] = false; $show['mailings_link'] = false; $show['color'] = false; $show['front'] = true; } $show['index'] = 'index'; $show['select'] = false; $show['buttons'] = true; break; default: $show = ''; break; } return $show; }
//j16 $db->setQuery("SELECT `enabled` FROM `#__extensions` WHERE `type` = 'plugin' AND `element`='cache' "); } $published = $db->loadResult(); if ($published) { jNews::printM('warning', 'ONLY IF YOU USE YOUR OWN SERVER CRON TASK!'); jNews::printM('warning', 'You NEED to reduce the cache time on your website in order for the cron task to work properly!'); jNews::printM('warning', 'You need to put the cache time less than :' . $GLOBALS[JNEWS . 'cron_max_freq'] * 0.8 . ' minutes'); jNews::printM('warning', 'Or increase your jNews scheduler to :' . $cacheTime * 1.2 . ' minutes'); } } } else { jnews::printM('error', _JNEWS_NOCRON_USED); } break; default: $showPanel = true; break; } } else { $showPanel = true; } break; } echo $message; if ($showPanel) { frontEnd::introduction($subscriberId, $listId, $lisType); } frontHTML::_footer(); echo "\n\r" . '<!-- End : ' . jnews::version() . ' -->' . "\n\r";
function statistics($listId, $listType, $mailingId, $message, $task, $action) { //From Specified fieldset $sDate = JRequest::getVar('startdate'); $eDate = JRequest::getVar('enddate'); if ($task == 'cpanel') { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION); } //Predefined fieldset $currentInterval = JRequest::getVar('rptinterval'); $currentRange = JRequest::getVar('rptrange'); if (empty($currentRange)) { $currentRange = 'this-month'; } if (empty($currentInterval)) { $currentInterval = 'weekly'; } if ($sDate == '0000-00-00' && $eDate == '0000-00-00') { $sDate = 0; $eDate = 0; } if (!empty($sDate) && !empty($eDate)) { if ($sDate != '0000-00-00' && $eDate != '0000-00-00') { $sDate = strtotime($sDate); $sDate = $sDate - jnews::calculateOffset(JNEWS_TIME_OFFSET) + date('Z'); $eDate = strtotime($eDate); $eDate = $eDate - jnews::calculateOffset(JNEWS_TIME_OFFSET) + date('Z'); } elseif ($sDate != '0000-00-00' && $eDate == '0000-00-00') { $sDate = strtotime($sDate); $sDate = $sDate - jnews::calculateOffset(JNEWS_TIME_OFFSET) + date('Z'); $eDate = time(); // - JNEWS_TIME_OFFSET * 3600 ; } elseif ($sDate == '0000-00-00' && $eDate != '0000-00-00') { echo jnews::printM('warning', _JNEWS_REPORT_WARN_MESSAGE); $sDate = 0; $eDate = 0; } } else { //Set the correct startDateTime and endDateTime //Set also the correct intervals appropriate for each range //current datetime base on the website setting configuration $currDate = $eDate = time(); // - JNEWS_TIME_OFFSET * 3600 ; switch ($currentRange) { case 'today': //today $sDate = mktime(0, 0, 0, date('m'), date('d'), date('Y')); $eDate = mktime(23, 59, 59, date('m'), date('d'), date('Y')); $currentInterval = 'daily'; break; case 'yesterday': //yesterday $sDate = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y')); $eDate = mktime(23, 59, 59, date('m'), date('d') - 1, date('Y')); $currentInterval = 'daily'; break; case 'this-week': //this week $sDate = mktime(0, 0, 0, date('n'), date('j'), date('Y')) - (date('N') - 1) * 3600 * 24; //if selected intervals is monthly or yearly if ($currentInterval == 'monthly' || $currentInterval == 'yearly') { $currentInterval = 'weekly'; } break; case 'last-week': //last week..start of the week is Monday at 00:00:00 and will end on Sunday at 23:59:59: $sDate = mktime(0, 0, 0, date('n'), date('j') - 6, date('Y')) - date('N') * 3600 * 24; $eDate = mktime(23, 59, 59, date('n'), date('j'), date('Y')) - date('N') * 3600 * 24; //if selected intervals is monthly or yearly if ($currentInterval == 'monthly' || $currentInterval == 'yearly') { $currentInterval = 'weekly'; } break; case 'last-2-weeks': //last 2 weeks $sDate = mktime(0, 0, 0, date('n'), date('j') - 13, date('Y')) - date('N') * 3600 * 24; $eDate = mktime(23, 59, 59, date('n'), date('j'), date('Y')) - date('N') * 3600 * 24; //if selected intervals is monthly or yearly if ($currentInterval == 'monthly' || $currentInterval == 'yearly') { $currentInterval = 'weekly'; } break; case 'last-month': //last month..starts at the first day to the last day $sDate = strtotime(date('m') - 1 . '/01/' . date('Y'), $currDate); $eDate = $sDate + 30 * 24 * 3600; //mktime(23, 59, 59, date('m')); if ($currentInterval == 'yearly') { $currentInterval = 'weekly'; } break; case 'this-year': //this year..starts $sDate = strtotime('01/01/' . date('Y'), $currDate); break; case 'last-year': //last year...starts jan 1 and ends dec 31 $sDate = mktime(0, 0, 0, 1, 1, date('Y') - 1); $eDate = mktime(23, 59, 59, 12, 31, date('Y') - 1); break; case '2-years-ago': //2 Years ago if ($currentInterval == 'yearly') { //if the interval is yearly $sDate = mktime(0, 0, 0, 1, 1, date('Y') - 2); //starts jan 1 } else { $eDate = mktime(23, 59, 59, 12, 31, date('Y') - 2); //ends dec 31 $sDate = mktime(0, 0, 0, 1, 1, date('Y') - 2); //starts jan 1 } break; case '3-years-ago': //3 Years ago if ($currentInterval == 'yearly') { //if the interval is yearly $sDate = mktime(0, 0, 0, 1, 1, date('Y') - 3); //starts jan 1 } else { $eDate = mktime(23, 59, 59, 12, 31, date('Y') - 3); //ends dec 31 $sDate = mktime(0, 0, 0, 1, 1, date('Y') - 3); //starts jan 1 } break; case 'this-month': //this month //this month default: $sDate = strtotime(date('m') . '/01/' . date('Y'), $currDate); if ($currentInterval == 'yearly') { $currentInterval = 'weekly'; } break; } } //Still need to double check if there's really values on the start and end date if (!empty($sDate) && !empty($eDate)) { //Title header $doc = JFactory::getDocument(); $css = '.icon-48-statistics_header { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/statistics.png)}'; $doc->addStyleDeclaration($css, $type = 'text/css'); $img = 'statistics_header.png'; $message = ''; $start = date('F j, Y', jnews::getNow(0, true, $sDate)); $end = date('F j, Y', jnews::getNow(0, true, $eDate)); if ($currentRange == 'today' || $currentRange == 'yesterday') { $title = _JNEWS_REPORT_HEADER . ': ' . $start; $fileNameExport = $start; } else { $title = _JNEWS_REPORT_HEADER . ': ' . $start . ' ' . _JNEWS_REPORT_HEADER_TO . ' ' . $end; $fileNameExport = $start . ' ' . _JNEWS_REPORT_HEADER_TO . ' ' . $end; } backHTML::_header($title, $img, $message, $task, $action); } $dateFormat = 'FROM_UNIXTIME('; switch ($currentInterval) { case 'yearly': //yearly $specialFormat = ',\'%Y\''; $dateFormat4DateNumber = 'FROM_UNIXTIME('; //.$columnModif.', \'' .substr($special, 10).'\'))'; $specialNo = ',\'%Y\')'; break; case 'weekly': //weekly $specialFormat = ',\'%M %d, %Y\''; $dateFormat4DateNumber = 'WEEK(' . $dateFormat; $dateFormat4DateNumber = 'WEEK(FROM_UNIXTIME('; //'dtfrmtweek%Y-%m-%d'; // WEEK(DATE_FORMAT(cdate, '%Y-%m-%d')) $specialNo = ',\'%Y-%m-%d\'))'; break; case 'daily': //daily $specialFormat = ',\'%M %d, %Y\''; $dateFormat4DateNumber = 'FROM_UNIXTIME('; //'dateformat%Y%m%d'; $specialNo = ',\'%Y%m%d\')'; break; case 'monthly': //monthly //monthly default: $specialFormat = ',\'%M, %Y\''; $dateFormat4DateNumber = 'FROM_UNIXTIME('; //'dateformat%Y%m%d'; $specialNo = ',\'%Y%m\')'; break; } $queryfilters = array(); $queryfilters['enddate'] = '\'' . $eDate . '\''; $queryfilters['startdate'] = '\'' . $sDate . '\''; $queryfilters['dateFormat'] = $dateFormat; $queryfilters['specialFormat'] = $specialFormat; $queryfilters['dateFormat4DateNumber'] = $dateFormat4DateNumber; $queryfilters['specialNo'] = $specialNo; $queryfilters['mailingId'] = $mailingId; $queryfilters['task'] = $task; //go to class.stats to display the view of stats require_once JNEWSPATH_CLASS . 'class.statistics.php'; outputReportGraph::initIncludes(); echo '<form action="index.php" method="post" name="adminForm" id="adminForm">'; if ($task == 'graph') { $results = array(); $results['subject'] = JRequest::getVar('subject', ''); $results['html_sent'] = JRequest::getVar('html_sent', '0'); $results['text_sent'] = JRequest::getVar('text_sent', '0'); $results['html_views'] = JRequest::getVar('html_views', '0'); $results['html_unread'] = JRequest::getVar('html_unread', '0'); $results['pending'] = JRequest::getVar('pending', '0'); // $results['failed'] = JRequest::getVar( 'failed', '0' ); // $results['bounces'] = JRequest::getVar( 'bounces', '0' ); $results['sent'] = JRequest::getVar('sent', '0'); // $results['sent'] = intval( $results['html_sent'] + $results['text_sent'] ); //fixed $results['id'] = JRequest::getVar('id'); $queryfilters['startdate'] = '\'' . JRequest::getInt('startdate') . '\''; $queryfilters['enddate'] = '\'' . JRequest::getVar('enddate') . '\''; outputReportGraph::mailingSpecificGraph($results, $queryfilters); } else { outputReportGraph::headerFilter($currentInterval); if (empty($fileNameExport)) { $fileNameExport = null; } outputReportGraph::tabReports($queryfilters, $task, $fileNameExport); } echo '</form>'; return true; }
public static function statisticsFE($action, $task, $listId, $listType = '', $mailingId, $message, $Itemid) { $my = JFactory::getUser(); if (empty($my->id)) { return true; } $linkForm = 'option=' . JNEWS_OPTION; $linkForm = jNews_Tools::completeLink($linkForm, false); $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION); $forms['main'] = "<form action='{$mainLink}' method='post' name='adminForm' enctype='multipart/form-data' onsubmit='submitbutton();return false;' id=\"adminForm\">"; // menu cpanel $menuCpanel = new stdClass(); $menuCpanel->popup = new stdClass(); $menuCpanel->popup->isPop = false; $menuCpanel->popup->isPop = false; $menuCpanel->link = $linkForm; $menuCpanel->action = 'cpanel'; $menuCpanel->onclick = new stdClass(); $menuCpanel->onclick->custom = true; $menuCpanel->onclick->js = "javascript: submitbutton('cpanel')"; $menuCpanel->title = _JNEWS_MENU_CPANEL; $menuGenerate = new stdClass(); $menuGenerate->popup = new stdClass(); $menuGenerate->popup->isPop = false; $menuGenerate->link = '#'; $menuGenerate->action = 'generate'; $menuGenerate->onclick = new stdClass(); $menuGenerate->onclick->custom = true; $menuGenerate->onclick->js = "javascript: submitbutton('generate')"; $menuGenerate->title = _JNEWS_BUTTON_GENERATE; $menuRefresh = new stdClass(); $menuRefresh->popup = new stdClass(); $menuRefresh->popup->isPop = false; $menuRefresh->link = '#'; $menuRefresh->action = 'refresh'; $menuRefresh->onclick = new stdClass(); $menuRefresh->onclick->custom = true; $menuRefresh->onclick->js = "javascript: submitbutton('refresh')"; $menuRefresh->title = _JNEWS_BUTTON_REFRESH; $menuA = array(); $menuA['refresh'] = $menuRefresh; $menuA['generate'] = $menuGenerate; $menuA['cpanel'] = $menuCpanel; frontHTML::formStart(_JNEWS_MENU_STATS_REPORTS, 0, '', $menuA); $go[] = jnews::makeObj('list_id', $listId); $go[] = jnews::makeObj('act', $action); $go[] = jnews::makeObj('task', ''); //save frontHTML::FEmenu(); require_once JNEWSPATH_ADMIN . 'controllers' . DS . 'statistics.jnews.php'; statistics($listId, '', $mailingId, $message, $task, $action); frontHTML::formEndFN(null, $go); return true; }
/** * * display in the module when registered */ function forLoggedIn($Itemid) { $HTML = ''; $checked = $this->receivehtmldefault; if ($this->showreceivehtml) { $checkedPrint = $checked != 0 ? 'checked="checked"' : ''; $text = '<input id="wz_2" type="checkbox" class="inputbox" value="1" name="receive_html" ' . $checkedPrint . ' />'; $text .= ' <span class="receiveHTML">' . _JNEWS_RECEIVE_HTML . '</span>'; $HTML .= jnews::printLine($this->linear, $text); } else { $HTML .= '<input id="wz_2" type="hidden" value="' . $checked . '" name="receive_html" />' . "\n"; } $my = JFactory::getUser(); $subscriber = jNews_Subscribers::getSubscriberInfoFromUserId($my->id); //get the user subscriber info if ($GLOBALS[JNEWS . 'show_unsubscribe_all']) { if ($subscriber) { $link = 'option=' . JNEWS_OPTION . '&act=unsubscribeall&subscriber=' . $subscriber->id . '&Itemid=' . $Itemid; $link = jNews_Tools::completeLink($link, false); $text = '<span class="aca_list_name"><a href="' . $link . '">' . _JNEWS_UNSUBSCRIBE_ALL . '</a></span>'; $HTML .= jnews::printLine($this->linear, $text); } } $HTML .= $this->_showButton(true); return $HTML; }
/** * <p>Templates controller</p> * <p>This function is the controller to view the templates view</p> * @author Joobi Limited <wwww.joobi.co> */ function templates($action, $task, $template_id) { $my = JFactory::getUser(); $css = '.icon-48-templates { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/templates.png)}'; $doc = JFactory::getDocument(); $doc->addStyleDeclaration($css, $type = 'text/css'); $img = 'templates.png'; $templatesearch = JRequest::getVar('templatesearch', ''); $showTemplates = true; // defined toggle for publish and unpublish of mailings $willRedirect = false; $checkToggle = false; $cid = JRequest::getVar('cid'); if (empty($template_id)) { if (!empty($cid) && is_array($cid)) { $template_id = $cid[key($cid)]; } } else { if (empty($cid)) { $cid[] = $template_id; } } if (!empty($task) && $task == 'togle') { $checkToggle = true; // $id = JRequest::getVar( 'templateid' ); $id = $template_id; $col = JRequest::getVar('col'); $template_id = !empty($id) && !empty($col) ? $id : $template_id; $task = !empty($template_id) && !empty($col) ? $col : $task; $willRedirect = true; } switch ($task) { case 'new': case 'add': $showTemplates = false; $template = null; $form['main'] = " <form action='index.php' method='post' name='adminForm' enctype='multipart/form-data' id=\"adminForm\"> \n"; $message = isset($message) ? $message : ''; backHTML::_header(_JNEWS_TEMPLATES, 'templates.png', $message, $task, $action); backHTML::formStart('template', 0, ''); echo jNews_TemplatesHTML::createTemplate($template, $form); $go[] = jnews::makeObj('act', $action); backHTML::formEnd($go); break; case 'edit': $showTemplates = false; $template = jNews_Templates::loadOneTemplate('*', $template_id); $form['main'] = " <form action='index.php' method='post' name='adminForm' enctype='multipart/form-data' id=\"adminForm\">"; $message = isset($message) ? $message : ''; backHTML::_header(_JNEWS_TEMPLATES, 'templates.png', $message, $task, $action); backHTML::formStart('template', 0, ''); echo jNews_TemplatesHTML::createTemplate($template, $form); $go[] = jnews::makeObj('act', $action); $go[] = jnews::makeObj('template_id', $template_id); backHTML::formEnd($go); break; case 'save': JRequest::checkToken() or die('Invalid Token'); $message = jnews::printYN(jNews_Templates::saveTemplate($task, $template_id), _JNEWS_TEMPLATE_SAVED, _JNEWS_ERROR); jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message); break; case 'apply': JRequest::checkToken() or die('Invalid Token'); $message = ''; $message .= jnews::printYN(jNews_Templates::saveTemplate($task, $template_id), _JNEWS_TEMPLATE_SAVED, _JNEWS_ERROR); $id = empty($template_id) ? jNews_Templates::loadOneTemplate('template_id', '', 'template_id', 'DESC') : $template_id; $converMessage = JRequest::getVar('message', '', '', 'string', JREQUEST_ALLOWRAW); if (!empty($converMessage)) { $message .= '<br/>'; $message .= implode("", $converMessage); } jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates&task=edit&template_id=' . $id, $message); break; case 'publish': if (!$checkToggle) { JRequest::checkToken() or die('Invalid Token'); } $message = jnews::printYN(jNews_Templates::updateTemplate($cid, 'published', true), 'Successfully published template!', 'Error publishing the template!'); jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message); break; case 'unpublish': if (!$checkToggle) { JRequest::checkToken() or die('Invalid Token'); } $condition = jNews_Templates::updateTemplate($cid, 'published', false); if ($condition) { $message = jnews::printM('ok', 'Successfully unpublished template!'); } else { $message = jnews::printM('defaulterror', 'Unable to unpublished default template!'); } // $message = jnews::defaultYN( jNews_Templates::updateTemplate($template_id,'published', false) , 'Successfully unpublished template!' , 'Unable to unpublished default template!' ); if ($willRedirect) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message); } break; case 'copy': JRequest::checkToken() or die('Invalid Token'); $message = jnews::printYN(jNews_Templates::copyTemplate($template_id), _JNEWS_TEMPLATE . _JNEWS_SUCCESS_COPIED, _JNEWS_ERROR); $showTemplates = true; break; case 'default': $success = false; //set all the templates to premium = 0 if (jNews_Templates::updateTemplate($template_id, 'default', false, false)) { $success = true; } //set the template published and premium if ($success) { jNews_Templates::updateTemplate($template_id, 'default', true, true); } $message = jnews::printYN($success, 'Successfully set the template to default!', 'Unable to set template to default!'); jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message); break; case 'delete': JRequest::checkToken() or die('Invalid Token'); $showTemplates = true; $isDefault = jNews_Templates::loadOneTemplate('premium', $template_id); if (!$isDefault) { $message = jnews::printYN(jNews_Templates::deleteTemplate($cid), _JNEWS_TEMPLATE . _JNEWS_SUCCESS_DELETED, _JNEWS_ERROR); } else { $message = jnews::printM('red', _JNEWS_TEMPLATE_DEFAULT_NODEL); } break; case 'cpanel': backHTML::controlPanel(); return true; break; case 'toggle': JRequest::checkToken() or die('Invalid Token'); // main toggle for all usage $listid = JRequest::getVar('listid'); $column = JRequest::getVar('col'); if (!empty($listid) && !empty($column)) { $passObj = new stdClass(); $passObj->tableName = '#__jnews_lists'; $passObj->columnName = $column; $passObj->whereColumn = 'id'; $passObj->whereColumnValue = $listid; jnews::toggle($passObj); } jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates'); break; case 'tempupload': // HTML for upload template // JRequest::checkToken() or die( 'Invalid Token' ); $html = '<form action="index.php?option=' . JNEWS_OPTION . '&act=templates&task=upload" method="post" name="adminForm" enctype="multipart/form-data" id="adminForm">'; $html .= '<table style="width:100%;padding:100px;">'; $html .= '<tr>'; $html .= '<td style="text-align:center;"> <input type="FILE" name="tempupload"> </td>'; $html .= '</tr><tr">'; $html .= '<td style="text-align:center;padding:20px;"> <input type="submit" value="Upload Template" style="width:130px;height:25px;"> </td>'; $html .= '</tr>'; $html .= '</table>'; if (version_compare(JVERSION, '3.0.0', '<')) { $html .= JHTML::_('form.token'); } else { $html .= JHtml::_('form.token'); } $html .= '</form><br/><br/>'; echo $html; $showTemplates = false; break; case 'sendtest': JRequest::checkToken() or die('Invalid Token'); //we save first the template $saveStatus = jNews_Templates::saveTemplate($task, $template_id); //then we send it if the template is successfully saved if ($saveStatus) { $message = jnews::printM('ok', _JNEWS_TEMPLATE_SAVED); $my = JFactory::getUser(); $mailing = new stdClass(); $receiver = new stdClass(); $status = false; $mailing->id = 1; $mailing->html = 1; $mailing->images = ''; $mailing->attachments = ''; $mailing->subject = jNews_Templates::loadOneTemplate('name', $template_id); $mailing->htmlcontent = jNews_Templates::loadOneTemplate('body', $template_id); $mailing->template_id = $template_id; $receiver->name = $my->name; $receiver->email = $my->email; $receiver->receive_html = 1; $receiver->user_id = $my->id; $mailerC = new jNews_ProcessMail(); $sendStatus = $mailerC->send($mailing, $receiver); $success = 'Template ' . $mailing->subject . ' successfully sent to ' . $receiver->email; $error = 'There is a problem in sending the template ' . $mailing->subject . ' <br/>' . _JNEWS_SENDTEST_CONFIGERROR; $message = $sendStatus ? jnews::printM('ok', $success) : jnews::printM('error', $error); } else { //otherwise we give an error message $message = jnews::printM('error', _JNEWS_ERROR); } jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates&task=edit&template_id=' . $template_id, $message); break; case 'upload': JRequest::checkToken() or die('Invalid Token'); $db = JFactory::getDBO(); $fileName = $_FILES['tempupload']['name']; $folderName = substr($fileName, 0, -4); // explode to array to compare and check if the uploaded file is a zip file $type = $_FILES['tempupload']['type']; // if zip is not found then return to previous upload page if (strtolower($type) != 'application/zip') { if (strtolower(substr($fileName, -4)) != '.zip') { if (version_compare(JVERSION, '1.6.0', '<')) { //j15 echo "<script> alert('" . addslashes(_JNEWS_UPLOAD_ZIP_INVALID) . "'); document.location.href='index.php?option='.JNEWS_OPTION.'&act=templates';</script>"; } else { if (version_compare(JVERSION, '3.0.0', '<')) { echo "<script> alert('" . addslashes(_JNEWS_UPLOAD_ZIP_INVALID) . "'); window.parent.SqueezeBox.close();</script>"; } else { echo "<script> alert('" . addslashes(_JNEWS_UPLOAD_ZIP_INVALID) . "'); jQuery(window.top.document).find(\"div.modal-backdrop\").click(); </script>"; } } break; } } $result = jNews_Templates::uploadTemplate(); if ($result) { // if success // read index.html of file for template body content $tempPath = JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'media' . DS . JNEWS_OPTION . DS . 'templates' . DS; $file = fopen($tempPath . $folderName . DS . 'index.html', "r") or exit("Unable to open file!"); $tempbody = array(); while (!feof($file)) { $tempbody[] = fgets($file); } //endwhile fclose($file); $tempbody = implode(' ', $tempbody); $standardCSSA = array(); $extraCSSStyles = ''; if (is_file($tempPath . $folderName . DS . 'css' . DS . 'style.css')) { //new template package with style.css file //we get here the css codes from the uploaded template $cssfile = fopen($tempPath . $folderName . DS . 'css' . DS . 'style.css', "r") or exit("Unable to open file!"); $cssstyle = array(); while (!feof($cssfile)) { $cssstyle[] = fgets($cssfile); } //endwhile fclose($cssfile); $cssstyle = implode(' ', $cssstyle); $cleanCSSstyle = jNews_Templates::cleanCSSComments($cssstyle); //cleancsscomments @(require_once JNEWSPATH_CLASS . 'class.cssinlinestyles.php'); if (class_exists('CSSToInlineStyles')) { $newCSSProcess = new CSSToInlineStyles(); $newCSSProcess->setCSS($cleanCSSstyle); $newCSSProcess->processCSS(); //we define the predefined selectors for the css $standardSelectorsA = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'a', 'ul', 'li', '.unsubscribe', '.subscriptions', '.content', '.title', '.readmore', '.online', '.aca_content', '.aca_title', '.aca_readmore', '.aca_online', '.aca_subscribe', '.aca_unsubscribe', '.aca_subscriptions'); $standardCSSA = $newCSSProcess->getStandardCSSTag($newCSSProcess->cssRules, $standardSelectorsA); $extraCSSStyles = $newCSSProcess->getExtraCSSTag($newCSSProcess->cssRules, $standardSelectorsA); } } // replace source image paths from 'images/' to 'media/.../templates/$FOLDERNAME/' $bodyImgA = JRequest::getVar('bodyImg'); if (is_file($tempPath . $folderName . DS . 'css' . DS . 'style.css')) { //new template package // $body = preg_replace('#images\/#', JNEWS_JPATH_LIVE . '/media/'. JNEWS_OPTION . '/templates/' . $folderName .'/images/', $tempbody); $origin = '"images/'; $destination = '"' . JNEWS_JPATH_LIVE . '/media/' . JNEWS_OPTION . '/templates/' . $folderName . '/images/'; $body = str_replace($origin, $destination, $tempbody); } else { // $body = preg_replace('#images\/#', JNEWS_JPATH_LIVE . '/media/'. JNEWS_OPTION . '/templates/'. $folderName.'/' , $tempbody); $origin = 'media/' . JNEWS_OPTION . '/templates/' . $folderName . '/'; $destination = JNEWS_JPATH_LIVE . '/media/' . JNEWS_OPTION . '/templates/' . $folderName . '/'; $body = str_replace($origin, $destination, $tempbody); } $template = null; $template->name = ucfirst($folderName); $template->description = ''; $template->created = time(); $template->body = addslashes($body); $template->altbody = ''; $template->premium = 0; $template->namekey = $folderName; $template->published = 1; $template->styles = addslashes(serialize($standardCSSA)); $template->csstyle = addslashes($extraCSSStyles); $template->thumbnail = ''; $templateA = (array) $template; $query = 'SELECT * FROM `#__jnews_templates` WHERE `namekey` = \'' . $template->namekey . '\' '; $db->setQuery($query); $findresult = $db->loadObject(); if (empty($findresult)) { // store template $status = jNews_Templates::storeTemplate($templateA); } else { //update template $query = 'UPDATE `#__jnews_templates` SET `body` = \'' . $template->body . '\' , `availability` = 1 WHERE `namekey`= \'' . $template->namekey . '\' AND `template_id`=' . $findresult->template_id; $db->setQuery($query); $status = $db->query(); } // upload success // display success message if ($status) { if (version_compare(JVERSION, '1.6.0', '<')) { //j15 echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_SUCCESS) . "'); document.location.href='index.php?option=" . JNEWS_OPTION . "&act=templates';</script>"; } else { //j16 echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_SUCCESS) . "'); window.parent.location.reload();</script>"; } } } else { // failed uploading // display an error message if (version_compare(JVERSION, '1.6.0', '<')) { //j15 echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_FAIL) . "'); document.location.href='index.php?option=" . JNEWS_OPTION . "&act=templates';</script>"; } else { if (version_compare(JVERSION, '3.0.0', '<')) { echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_FAIL) . "'); window.parent.SqueezeBox.close();</script>"; } else { echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_FAIL) . "'); jQuery(window.top.document).find(\"div.modal-backdrop\").click(); </script>"; } } } $showTemplates = false; break; case 'preview': $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; $forms['filter'] = " <form name='jnewsFilterForm' method='POST' action='index.php'> \n"; $id = JRequest::getInt('template_id', 0, 'request'); $body = jNews_Templates::loadOneTemplate('body', $id); jNews_Templates::includeStyles($body, $id); jNews_TemplatesHTML::previewTemplate($body, $forms); $showTemplates = false; break; case 'assign': $templatesearch = JRequest::getVar('templatesearch', ''); $linkTh = jNews_Tools::completeLink('option=' . JNEWS_OPTION, true, false, true); $forms['main'] = "<form action=" . $linkTh . " method='post' name='adminForm' id=\"adminForm\">"; $paginationStart = JRequest::getVar('pg'); if (!empty($paginationStart)) { $limitstart = 0; $limitend = $paginationStart; } else { $app = JFactory::getApplication(); $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int'); $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int'); } $limittotal = jNews_Templates::countTemplates(1, 1); $setLimit = new stdClass(); $setLimit->total = !empty($limittotal) ? $limittotal : 0; $setLimit->start = !empty($limitstart) ? $limitstart : 0; $setLimit->end = !empty($limitend) ? $limitend : 20; $templates = jNews_Templates::getTemplates(true, false, $templatesearch, $setLimit->start, $setLimit->end, null, 1); //first param to true to show only the published jNews_TemplatesHTML::assignTemplate($templates, $forms, $setLimit, $templatesearch); $showTemplates = false; break; } if ($showTemplates) { $start = JRequest::getVar('start', '0'); $templatesearch = JRequest::getVar('templatesearch', ''); $limit = -1; $message = isset($message) ? $message : ''; backHTML::_header(_JNEWS_TEMPLATES, $img, $message, $task, $action); $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; $forms['filter'] = " <form name='jnewsFilterForm' method='POST' action='index.php'> \n"; backHTML::formStart('show_template', '', ''); // added this code for pagination =========================== $paginationStart = JRequest::getVar('pg'); $app = JFactory::getApplication(); if (!empty($paginationStart)) { $limitstart = 0; $limitend = $paginationStart; } else { $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int'); $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int'); } $setSort = new stdClass(); $setSort->orderValue = $app->getUserStateFromRequest(JNEWS_OPTION . '.templates.filter_order', 'filter_order', 'premium', 'cmd'); $setSort->orderDir = $app->getUserStateFromRequest(JNEWS_OPTION . '.templates.filter_order_Dir', 'filter_order_Dir', 'desc', 'word'); $limittotal = jNews_Templates::countTemplates(); $setLimit = new stdClass(); $setLimit->total = !empty($limittotal) ? $limittotal : 0; $setLimit->start = !empty($limitstart) ? $limitstart : 0; $setLimit->end = !empty($limitend) ? $limitend : $limittotal; // recheck start if ($setLimit->total == $setLimit->end) { $setLimit->start = 0; } $templates = jNews_Templates::getTemplates(false, false, $templatesearch, $setLimit->start, $setLimit->end, $setSort); //recheck limit total [pagination] if (isset($setLimit->total) && !empty($templatesearch)) { $setLimit->total = !empty($temps) ? count($templates) : $setLimit->total; } jNews_TemplatesHTML::displayTemplateList($templates, $forms, $setLimit->start, $setLimit->end, $templatesearch, $action, $setLimit, $setSort); $go[] = jnews::makeObj('act', 'templates'); $go[] = jnews::makeObj('filter_order', $setSort->orderValue); $go[] = jnews::makeObj('filter_order_Dir', $setSort->orderDir); backHTML::formEnd($go); } return true; }
/** * Front-end Management Tab */ public static function frontendManagement($listEdit, $lists, $show, $html) { $mainframe = JFactory::getApplication(); ?> <fieldset class="jnewscss"> <table class="jnewstable" cellspacing="1"> <tbody> <tr> <td width="185" class="key"> <span class="editlinktip"> <?php $tip = _JNEWS_INFO_LIST_ACCESS; $title = 'List Subscription Access'; echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0); ?> </span> </td> <td> <fieldset style="width:200px"> <?php echo jnews::displayAccessRoles('acc_id', $listEdit->acc_id); ?> </fieldset> </td> </tr> </tbody> </table> </fieldset> <?php if ($mainframe->isAdmin() && $GLOBALS[JNEWS . 'level'] > 2) { ?> <fieldset class="jnewscss"> <table class="jnewstable" cellspacing="1"> <tbody> <tr> <td width="185" class="key"> <span class="editlinktip"> <?php $tip = _JNEWS_INFO_LIST_ACCESS_EDIT; $title = 'Mailing Add/Edit Access'; echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0); ?> </span> </td> <td> <fieldset style="width:200px"> <?php echo jnews::displayAccessRoles('acc_level', $listEdit->acc_level); ?> </fieldset> </td> </tr> </tbody> </table> </fieldset> <?php } }
function jnewsbot_content_editab($forms) { if (version_compare(JVERSION, '3.0.0', '<')) { JHTML::_('behavior.mootools'); } else { JHtmlBehavior::framework(); } $siteContent = new siteContent(); // $limit = -1; $limit = 5; $limittotal = $siteContent->countSiteCount(); $setLimit = jnews::setLimitPagination($limittotal); $action = JRequest::getVar('act', '', '', 'WORD'); $task = JRequest::getVar('task'); $contentsearch = JRequest::getVar('contentsearch', ''); echo $forms['main']; $hidden = '<input type="hidden" name="option" value="' . JNEWS_OPTION . '" />'; $hidden .= '<input type="hidden" name="limit" value="' . $limit . '" />'; $toSearch = new stdClass(); $toSearch->forms = ''; $toSearch->hidden = $hidden; $toSearch->listsearch = $contentsearch; $toSearch->id = 'contentsearch'; $app = JFactory::getApplication(); $setSort = new stdClass(); if (!isset($_POST['c_filter_order'])) { $setSort->orderValue = "a.id"; } else { $setSort->orderValue = $_POST['filter_order']; } //$setSort->orderValue = $app->getUserStateFromRequest(JNEWS_OPTION . '.content.filter_order', 'filter_order', 'a.id', 'cmd'); $setSort->orderDir = $app->getUserStateFromRequest(JNEWS_OPTION . '.content.filter_order_Dir', 'filter_order_Dir', 'desc', 'word'); //$setSort->orderValue = "a.id"; $contentItems = jnewsbot_content_getitems($contentsearch, $setLimit, $setSort); ob_start(); $js = "function setContentTag(id, url, changeType , hide_title)\n {\n\n if(hide_title ==undefined)\n {\n var check_title = document.getElementById('hide_title_no').checked;\n if(check_title) hide_title = 0;\n else hide_title = 1;\n\n }\n\n\n\n var form = document.adminForm;\n if(!form)\n {\n form = document.mosForm;\n }\n\n if(form.content_type[2].checked === false)\n {\n document.getElementById('hide_title_yes').disabled=false;\n }\n else\n {\n document.getElementById('hide_title_no').click();\n hide_title = 0;\n document.getElementById('hide_title_yes').disabled=true;\n }\n if(id!=null)\n {\n for (i=0; i<form.content_type.length; i++)\n {\n if (form.content_type[i].checked)\n {\n var content_type = form.content_type[i].value;\n }\n }"; // if ( @include_once( JNEWSPATH_ADMIN . 'social' .DS. 'class.social.php' ) ) { if (!$GLOBALS[JNEWS . 'use_tags'] and class_exists('jNews_Social') or !$GLOBALS[JNEWS . 'use_tags'] and $GLOBALS[JNEWS . 'level'] > 2) { $js .= "\n if(changeType!=null)\n id = document.getElementById('insertbot').value;\n\n template = window.top.document.getElementById('template_id');\n templateid = template.value;\n\n var tag = id;\n if(id != 0)\n getContent(id, content_type, url,templateid);\n\n form.contenttag.value = tag;\n }\n //if id == null\n else\n {\n var tag = form.contentreplace.value;"; if (version_compare(JVERSION, '1.6.0', '<')) { //1.5 $js .= " if(window.top.insertTag(tag)){window.top.document.getElementById('sbox-window').close();}"; } else { if (version_compare(JVERSION, '3.0.0', '<')) { $js .= ' if(window.top.insertTag(tag)) {window.parent.SqueezeBox.close();}'; } else { $js .= 'if(window.top.insertTag(tag)) { var need_click = jQuery(window.top.document).find("div.modal-backdrop"); if(need_click.length == 0) window.parent.SqueezeBox.close(); else jQuery(window.top.document).find("div.modal-backdrop").click();}'; } } $js .= "}\n }"; } else { $js .= "\n if(changeType==null)\n form.botID.value= id;\n\n var tag = '{contentitem:' + form.botID.value + '|' + content_type +'|'+hide_title+ '}';\n\n form.contenttag.value = tag;\n }\n //if id -- null\n else\n {\n\n var tag = form.contenttag.value;"; if (version_compare(JVERSION, '1.6.0', '<')) { //1.5 $js .= " if(window.top.insertTag(tag)){window.top.document.getElementById('sbox-window').close();}"; } else { if (version_compare(JVERSION, '3.0.0', '<')) { $js .= ' if(window.top.insertTag(tag)) {window.parent.SqueezeBox.close();}'; } else { $js .= ' if(window.top.insertTag(tag)) { var need_click = jQuery(window.top.document).find("div.modal-backdrop"); if(need_click.length == 0) window.parent.SqueezeBox.close(); else jQuery(window.top.document).find("div.modal-backdrop").click();}'; } } $js .= "}\n }"; } //end function if (version_compare(JVERSION, '1.6.0', '<')) { //1.5 $js .= "\n\n \t\t\tfunction getContent(id, content_type, url, templateid){\n\n \t\t\t\tvar ajax = new Ajax(url,\n \t\t\t\t\t{data: 'artId='+id+'&content_type='+content_type+'&templateid='+templateid,\n \t\t\t\t\tmethod: 'POST',\n \t\t\t\t\tonComplete : function(result){insertContent(result, id); }\n \t\t\t\t\t}\n \t\t\t\t);\n \t\t\t\tajax.request();\n \t\t\t}"; } else { $js .= "\n \t\t\tfunction getContent(id, content_type, url,templateid){\n\n\t\t\t\tvar ajax = new Request({\n\t\t\t\turl : url,\n\t\t\t\tdata: 'artId='+id+'&content_type='+content_type+'&templateid='+templateid,\n\t\t\t\tmethod: 'POST',\n\t\t\t\tonComplete : function(result){insertContent(result, id); }\n\t\t\t\t});\n\t\t\t\tajax.send();\n \t\t\t}"; } $js .= "\n \t\t\tfunction insertContent(html, id){\n\t\t\t\tvar form = document.adminForm;\n\t\t\t\tif(!form){\n\t\t\t\t\tform = document.mosForm;\n\t\t\t\t}\n\n\t\t\t\tvar root = document.createElement('div');\n\n\t\t\t\troot.innerHTML = html;\n\t\t\t\tvar body = document.getElementsByTagName('body')[0].appendChild(root);\n\n\t\t\t\troot.setAttribute(\"style\", \"width:150px; display:none\");\n\t\t\t\tvar element = document.getElementById('artcontent_'+id);\n\n\t\t\t\tform.contentreplace.value = element.innerHTML;\n\n\t\t\t\tdocument.getElementsByTagName('body')[0].removeChild(root);\n\t\t\t}\n\t\t\t"; $url = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=mailing&task=articleContent', false, false, true); $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); ?> <style type="text/css"> table.smartcontent { border: 1px solid #D5D5D5; background-color: #F6F6F6; width: 100%; margin-bottom: 10px; -moz-border-radius:3px; -webkit-border-radius:3px; padding: 5px; } table.smartcontent td.key { background-color: #f6f6f6; text-align: left; width: 140px; color: #666; font-weight: bold; border-bottom: 1px solid #e9e9e9; border-right: 1px solid #e9e9e9; } </style> <div id="element-box"> <div class="t"> <div class="t"> <div class="t"></div> </div> </div> <div class="m"> <!--<form name="adminForm" method="post" action="index.php?option=<?php echo JNEWS_OPTION; ?> &tmpl=component">--> <table class="smartcontent" width="100%""> <tr> <td width="185" class="key"> <span class="editlinktip"> <?php $tip = _JNEWS_AUTONEWS_TYPE_TIPS; $title = _JNEWS_AUTONEWS_TYPE; echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0); ?> </span> </td> <td style="vertical-align: top;"> <span class="editlinktip"> <?php $tip = _JNEWS_TITLE_ONLY_TIPS; $title = _JNEWS_TITLE_ONLY; $title_only = "<span class=\"editlinktip\">" . jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0) . "</span>"; $tip = _JNEWS_INTRO_ONLY_TIPS; $title = _JNEWS_INTRO_ONLY; $intro_only = "<span class=\"editlinktip\">" . jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0) . "</span>"; $tip = _JNEWS_FULL_ARTICLE_TIPS; $title = _JNEWS_FULL_ARTICLE; $full_article = "<span class=\"editlinktip\">" . jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0) . "</span>"; // $tip = _JNEWS_HIDE_TITTLE_ARTICLE_TIPS; // $title = _JNEWS_HIDE_TITLE ; // $hide_title = "<span class=\"editlinktip\">" . jNews_Tools::toolTip( $tip, '', 280, 'tooltip.png', $title, '', 0 ) . "</span>"; ?> </span> <span class="editlinktip"> <input id="content_type" type="radio" name="content_type" value="0" checked="checked" onclick="setContentTag(1,'<?php echo $url; ?> ', 0);"/><?php echo $full_article; ?> <input id="content_type" type="radio" name="content_type" value="1" onclick="setContentTag(1, '<?php echo $url; ?> ', 1);"/><?php echo $intro_only; ?> <input id="content_type" type="radio" name="content_type" value="2" onclick="setContentTag(1, '<?php echo $url; ?> ', 2);"/><?php echo $title_only; ?> <!--<input id="content_type" type="radio" name="content_type" value="3" onclick="setContentTag(1, '<?php //echo $url ?> ', 3);"/><?php //echo $hide_title; ?> --> </span> </td> <td rowspan="2"> <input onclick="setContentTag(null,'<?php echo $url; ?> ')" class="inserttag" type="button" label="Insert Content" name="Insert Content" value="Insert Content"/> </td> </tr> <tr> <td width="185" class="key"> <span class="editlinktip"> <?php $tip = _JNEWS_CONTENT_TIP; $title = _JNEWS_CONTENT_ID; echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0); ?> </span> </td> <td style="vertical-align: top;"> <!-- <input type="text" onchange="setCaptionTags();" size="60px" name="jnewstagcaption"> --> <input id="insertbot" type="text" size="20px" name="contenttag" value="0"/> </td> </tr> <tr> <td colspan="2"> <input id="insertbot" type="hidden" size="60px" name="contentreplace" /> </td> </tr> <tr> <td colspan="2"> <input id="botID" size="10px" name="botID" value="0" type="hidden"/> </td> </tr> <tr> <td width="185" class="key"> <span class="editlinktip"> <?php $tip = _JNEWS_HIDE_TITTLE_ARTICLE_TIPS; $title = _JNEWS_HIDE_TITLE; echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0); ?> </span> </td> <td style="vertical-align: top;"> <input id="hide_title_no" onclick="setContentTag(1, '<?php echo $url; ?> ', 2, 0);" type="radio" name="hide_title" value="0" checked="checked" /><?php echo 'No'; ?> <input id="hide_title_yes" onclick="setContentTag(1, '<?php echo $url; ?> ', 2, 1);" type="radio" name="hide_title" value="1" /><?php echo 'Yes'; ?> </td> </tr> </table> <div id="element-box"> <div class="t"> <div class="t"> <div class="t"></div> </div> </div> <div class="m" style="position:relative;"> <?php echo jnews::setTop($toSearch, null); $select_cat = version_compare(JVERSION, '1.6.0', '<') ? 'SELECT CATEGORY' : 'JOPTION_SELECT_CATEGORY'; ?> <div style="position:absolute;top:5px; left:55%;"> <?php $sort_select = JRequest::getVar('filter_category_id', '', 'POST', 'int'); ?> <select name="filter_category_id" class="inputbox" onchange="this.form.submit()"> <option value=""><?php echo JText::_($select_cat); ?> </option> <?php if (version_compare(JVERSION, '1.6.0', '<')) { echo getCatListFromJoomla15($sort_select); } else { echo JHtml::_('select.options', JHtml::_('category.options', 'com_content'), 'value', 'text', $sort_select); } ?> </select> </div> <!-- border: 1px solid #CCCCCC;--> <table class="joobilist" cellpadding="0" cellspacing="0"> <tbody> <thead> <tr> <th class="title"> <?php if ($setSort->orderDir == 'asc') { $new_sort = "desc"; } else { $new_sort = "asc"; } ?> <a class="hasTip" title="" onclick="Joomla.tableOrdering('a.title','<?php echo $new_sort; ?> ', 'content');" href="#"> <?php echo JText::_(_JNEWS_TAGPICKLIST_TITLE); ?> <?php if ($setSort->orderValue == 'a.title') { ?> <i class="icon-arrow-<?php echo $new_sort == "asc" ? "up" : "down"; ?> "></i><?php } ?> </a> <?php //echo _JNEWS_TAGPICKLIST_TITLE; // echo jnews::HTML_GridSort(_JNEWS_TAGPICKLIST_TITLE, 'a.title', $setSort->orderDir, $setSort->orderValue); ?> </th> <th width="80px" class="title"> <?php //echo _JNEWS_TAG_ARTICLESECTION; if (version_compare(JVERSION, '1.6.0', '<')) { //j15 echo jnews::HTML_GridSort(_JNEWS_TAG_ARTICLESECTION, 'b.title', $setSort->orderDir, $setSort->orderValue); } else { ?> <?php if ($setSort->orderDir == 'asc') { $new_sort = "desc"; } else { $new_sort = "asc"; } ?> <a class="hasTip" title="" onclick="Joomla.tableOrdering('c.title_2','<?php echo $new_sort; ?> ', 'content');" href="#"> <?php echo JText::_(_JNEWS_TAG_ARTICLESECTION); ?> <?php if ($setSort->orderValue == 'c.title_2') { ?> <i class="icon-arrow-<?php echo $new_sort == "asc" ? "up" : "down"; ?> "></i><?php } ?> </a> <!-- echo jnews::HTML_GridSort(_JNEWS_TAG_ARTICLESECTION, 'b.title', $setSort->orderDir, $setSort->orderValue);--> <?php } ?> </th> <th width="80px" class="title"> <?php if ($setSort->orderDir == 'asc') { $new_sort = "desc"; } else { $new_sort = "asc"; } ?> <a class="hasTip" title="" onclick="Joomla.tableOrdering('c.title','<?php echo $new_sort; ?> ', 'content');" href="#"> <?php echo JText::_(_JNEWS_TAG_ARTICLECATEGORY); ?> <?php if ($setSort->orderValue == 'c.title') { ?> <i class="icon-arrow-<?php echo $new_sort == "asc" ? "up" : "down"; ?> "></i><?php } ?> </a> <?php //echo _JNEWS_TAG_ARTICLECATEGORY; // echo jnews::HTML_GridSort(_JNEWS_TAG_ARTICLECATEGORY, 'c.title', $setSort->orderDir, $setSort->orderValue); ?> </th> <th width="30px" class="title"> <?php if ($setSort->orderDir == 'asc') { $new_sort = "desc"; } else { $new_sort = "asc"; } ?> <a class="hasTip" title="" onclick="Joomla.tableOrdering('a.id','<?php echo $new_sort; ?> ', 'content');" href="#"> ID <?php if ($setSort->orderValue == 'a.id') { ?> <i class="icon-arrow-<?php echo $new_sort == "asc" ? "up" : "down"; ?> "></i><?php } ?> </a> <?php //echo jnews::HTML_GridSort('ID', 'a.id', $setSort->orderDir, $setSort->orderValue, 'task'); ?> </th> </tr> </thead> <?php if (sizeof($contentItems) > 0) { $k = 0; foreach ($contentItems as $contentItem) { if (empty($contentItem->section)) { $contentItem->section = JText::_('Uncategorised'); } if (empty($contentItem->category)) { $contentItem->category = JText::_('Uncategorised'); } echo '<tr style="cursor:pointer" class="row' . $k . '" onclick="setContentTag(\'' . $contentItem->id . '\',\'' . $url . '\');" ><td>' . $contentItem->title . '</td><td nowrap="nowrap" align="center">' . $contentItem->section . '</td><td nowrap="nowrap" align="center">' . $contentItem->category . '</td><td nowrap="nowrap" align="center">' . $contentItem->id . '</td></tr>'; //echo '<tr style="cursor:pointer" class="row'.$k.'" onclick="setContentTag(\''.$contentItem->id.'\',\''.$url.'\');" ><td>'.$contentItem->title.'</td><td nowrap="nowrap" align="center">'.$contentItem->section.'</td><td nowrap="nowrap" align="center">'.$contentItem->category.'</td><td nowrap="nowrap" align="center">'.$contentItem->id.'</td></tr>'; $k = 1 - $k; } } ?> </tbody> </table> <?php echo jnews::setPaginationBot($setLimit, 'margin:auto;'); ?> <input type="hidden" value="<?php echo JNEWS_OPTION; ?> " name="option"/> <input type="hidden" value="<?php echo $action; ?> " name="act"/> <input type="hidden" value="<?php echo $task; ?> " name="task"/> <input type="hidden" value="<?php echo $setSort->orderValue; ?> " name="c_filter_order"/> <input type="hidden" value="<?php echo $setSort->orderValue; ?> " name="filter_order"/> <input type="hidden" value="<?php echo $setSort->orderDir; ?> " name="filter_order_Dir"/> </form> </div> <div class="b"> <div class="b"> <div class="b"></div> </div> </div> </div> </div> <div class="b"> <div class="b"> <div class="b"></div> </div> </div> </div> <?php $return = ob_get_contents(); ob_end_clean(); return array(_JNEWS_CONTENT_ITEM, $return); }