public static function importBis() { @set_time_limit(0); $returnMessage = ''; //If memory_limit less than 128M $limit = jnews::convertToBytes(@ini_get('memory_limit')); if ($limit < jnews::convertToBytes('128M')) { @ini_set('memory_limit', '128M'); } $allAvailableListsA = JRequest::getVar('sub_list_id', ''); $list2SubcribeToA = JRequest::getVar('subscribed', ''); $filename = $_FILES['importfile']['name']; if (!empty($filename)) { //if we import a file //the flag is true coz we add subscribers in frontend through rows $saveSubsInRows = true; $path = JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'upload_url']; $path = str_replace(array('/', '\\'), DS, $path); if (!is_writable($path)) { $returnMessage .= '<br/>The file could not be imported because the folder is not writable.'; $returnMessage .= '<br/>Please make sure the path "' . JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'upload_url'] . '" is writable'; return $returnMessage; } if (!@move_uploaded_file($_FILES['importfile']['tmp_name'], $path . $filename)) { $path .= DS; if (!@move_uploaded_file($_FILES['importfile']['tmp_name'], $path . $filename)) { $returnMessage .= _JNEWS_ERROR_MOVING_UPLOAD; $returnMessage .= '<br/>Please make sure the path "' . JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'upload_url'] . '" is writable'; return $returnMessage; } } $import = file_get_contents($path . $filename); $import = str_replace(array("\r\n", "\r"), "\n", $import); $allLinesA = explode("\n", $import); } else { //if we add subscribers in frontend through rows //the flag is true coz we add subscribers in frontend through rows $saveSubsInRows = true; //we get the number of rows $rows = JRequest::getVar('count', ''); $nRows = intval($rows) - 1; if ($nRows == 0) { $nRows = intval($GLOBALS[JNEWS . 'create_newsubsrows']); } //we get the value of each element from the rows for ($count = 1; $count <= $nRows; $count++) { $allLinesA[$count] = JRequest::getVar('name' . $count, '') . ', ' . JRequest::getVar('email' . $count, '') . ', ' . JRequest::getVar('receive_html' . $count, '') . ', ' . JRequest::getVar('confirmed' . $count, '') . ', ' . JRequest::getVar('column1' . $count, '') . ', ' . JRequest::getVar('column2' . $count, '') . ', ' . JRequest::getVar('column3' . $count, '') . ', ' . JRequest::getVar('column4' . $count, '') . ', ' . JRequest::getVar('column5' . $count, ''); } } if (empty($allLinesA)) { return false; } $db = JFactory::getDBO(); $insertQuery = ''; $selectQuery = ''; $firstValue = true; $time = time(); $totalInsert = 0; $allSubscribersIDA = array(); foreach ($allLinesA as $line) { $line = trim($line); if (empty($line)) { continue; } $line = str_replace(';', ',', $line); $subscriberA = explode(',', $line); $email = trim($subscriberA[1], ' "\''); if (!jNews_Subscribers::validEmail($email)) { if (!$saveSubsInRows) { //if import of file is done echo '<br />' . jnews::printM('red', _JNEWS_EMAIL_INVALID . ': ' . $email); continue; } else { continue; } } if ($GLOBALS[JNEWS . 'level'] > 2) { $column4 = !empty($subscriberA[4]) ? mysql_escape_string(trim($subscriberA[4], '"')) : ''; $column5 = !empty($subscriberA[5]) ? mysql_escape_string(trim($subscriberA[5], '"')) : ''; $column6 = !empty($subscriberA[6]) ? mysql_escape_string(trim($subscriberA[6], '"')) : ''; $column7 = !empty($subscriberA[7]) ? mysql_escape_string(trim($subscriberA[7], '"')) : ''; $column8 = !empty($subscriberA[8]) ? mysql_escape_string(trim($subscriberA[8], '"')) : ''; $ip = !empty($subscriberA[9]) ? mysql_escape_string(trim($subscriberA[9], '"')) : ''; } $comfirmation = $GLOBALS[JNEWS . 'require_confirmation'] ? 0 : (int) trim($subscriberA[3], ' "\''); // i need to know if exist user $db = JFactory::getDBO(); $quer = "SELECT id FROM `#__jnews_subscribers` WHERE `email` = '{$email}'"; $db->setQuery($quer); $res = $db->loadResult(); if ($res) { //i need to update $isResiveHtml = (int) trim($subscriberA[2], ' "\''); $querUpdate = "UPDATE `#__jnews_subscribers` SET confirmed = '{$comfirmation}', receive_html= '{$isResiveHtml}',column1 = '{$column4}', column2 = '{$column5}', column3 = '{$column5}', column4 = '{$column7}', column5= '{$column8}',ip = '{$ip}' WHERE `email` = '{$email}'"; $db->setQuery($querUpdate); $db->query(); if (!empty($allAvailableListsA) && !empty($list2SubcribeToA)) { foreach ($list2SubcribeToA as $oneneedList => $noneed) { $listId = $allAvailableListsA[$oneneedList]; // $query = "INSERT IGNORE `#__jnews_listssubscribers` (`list_id`,`subscriber_id`,`subdate`) VALUES ({$listId}, {$res}, {$time})"; $db->setQuery($query); $db->query(); } } continue; } if (!$firstValue) { $insertQuery .= ','; } /*$insertQuery .= '(\''. htmlentities(trim($subscriberA[0],' "\'') ) . '\',\''.$email.'\','.$comfirmation.','.(int)trim($subscriberA[2],' "\'').',\''.$time.'\',\''.$column4.'\',\''.$column5.'\',\''.$column6.'' . '\',\''.$column7.'\',\''.$column8.'\',\''.$ip.'\')';*/ $insertQuery .= '(\'' . addslashes(trim($subscriberA[0], ' "\'')) . '\',\'' . $email . '\',' . $comfirmation . ',' . (int) trim($subscriberA[2], ' "\'') . ',\'' . $time . '\',\'' . $column4 . '\',\'' . $column5 . '\',\'' . $column6 . '' . '\',\'' . $column7 . '\',\'' . $column8 . '\',\'' . $ip . '\')'; if (!$firstValue) { $selectQuery .= ','; } $selectQuery .= '\'' . $email . '\''; $firstValue = false; $totalInsert++; if ($totalInsert % 50 == 0) { if (empty($insertQuery)) { continue; } $db = JFactory::getDBO(); $query = 'INSERT IGNORE `#__jnews_subscribers` (`name`,`email`,`confirmed`,`receive_html`,`subscribe_date`,`column1`,`column2`,`column3`,`column4`,`column5`,`ip`) VALUES ' . $insertQuery; $db->setQuery($query); $db->query(); $firstValue = true; $insertQuery = ''; //get the id of the subscribers $query = 'SELECT `id` FROM `#__jnews_subscribers` WHERE `email` IN (' . $selectQuery . ')'; $db->setQuery($query); $loadResultArray = $db->loadObjectList(); $resultsSubClA = jnews::convertObjectList2Array($loadResultArray); $allSubscribersIDA = array_merge($allSubscribersIDA, $resultsSubClA); $selectQuery = ''; } else { if (empty($insertQuery)) { return false; } $db = JFactory::getDBO(); $query = 'INSERT IGNORE `#__jnews_subscribers` (`name`,`email`,`confirmed`,`receive_html`,`subscribe_date`,`column1`,`column2`,`column3`,`column4`,`column5`,`ip`) VALUES ' . $insertQuery; $db->setQuery($query); $db->query(); } } //send confirmation email if required if ($GLOBALS[JNEWS . 'require_confirmation'] && !empty($list2SubcribeToA)) { $list4Message = $allAvailableListsA[key($list2SubcribeToA)]; $myList = jNews_Lists::getOneList($list4Message); $myList->subscribemessage = trim($myList->subscribemessage); if (empty($myList->subscribemessage) || substr_count($myList->subscribemessage, '{tag:confirm}') < 1) { $Sub_TAG = '{tag:confirm}'; //'[CONFIRM]'; } else { $Sub_TAG = ''; } $mailing = new stdClass(); if (!empty($myList->subscribemessage)) { $mailing->htmlcontent = $myList->subscribemessage; $mailing->textonly = $myList->subscribemessage; } else { // default message $mailing->textonly = 'Please confirm your subscription to our website by clicking on the following link.'; $mailing->htmlcontent = '<br />' . $mailing->textonly . '<br /><br />'; } $mailing->textonly .= $Sub_TAG; $mailing->htmlcontent .= $Sub_TAG; //insert the mailing in the mailing table $mailing->mailing_type = 1; $mailing->template_id = 0; $mailing->senddate = $time; $mailing->subject = _JNEWS_SUBSCRIBE_SUBJECT_MESS; $mailing->attachments = ''; $mailing->images = ''; $mailing->published = 1; $mailing->html = 1; $mailing->visible = 0; $mailing->fromname = ''; $mailing->fromemail = ''; $mailing->frombounce = ''; $mailing->author_id = 0; $mailing->delay = 0; $mailing->follow_up = 0; $mailing->cat_id = 0; $mailing->delay_min = 0; $mailing->delay_max = 0; $mailing->notify_id = 0; $mailing->next_date = 0; $mailing->start_date = $time - 2; $mailing->issue_nb = 0; $mailing->createdate = $time; $mailing->acc_level = 0; $mailingID = jNews_Mailing::insertMailingData($mailing); //enter the emails in the queue $query = 'INSERT IGNORE INTO `#__jnews_queue` (`subscriber_id`,`mailing_id`,`send_date`,`priority`) '; $query .= 'SELECT `id`,' . intval($mailingID) . ',' . $time . ',1'; $query .= ' FROM `#__jnews_subscribers` '; $query .= 'WHERE `subscribe_date`=' . $time . ' AND `confirmed`=0'; $db->setQuery($query); $db->query(); } if (!empty($selectQuery)) { //get the id of the subscribers $query = 'SELECT `id` FROM `#__jnews_subscribers` WHERE `email` IN (' . $selectQuery . ')'; $db->setQuery($query); $loadResultArray = $db->loadObjectList(); $resultsSubClA = jnews::convertObjectList2Array($loadResultArray); $allSubscribersIDA = array_merge($allSubscribersIDA, $resultsSubClA); } if (!empty($allAvailableListsA)) { //if lists in checkbox are not empty if (empty($list2SubcribeToA)) { jnews::printM('red', 'You need to select at least one list. Emails have been imported but not subscribed.'); if ($GLOBALS[JNEWS . 'require_confirmation']) { return 'The confirmation email cannot be sent because there is not list selected to subscribe the users.'; } else { return _JNEWS_IMPORT_FINISHED; } } foreach ($list2SubcribeToA as $oneselected => $vval) { $seleeected[] = $allAvailableListsA[$oneselected]; } foreach ($list2SubcribeToA as $oneneedList => $noneed) { $listId = $allAvailableListsA[$oneneedList]; // $query = 'INSERT IGNORE `#__jnews_listssubscribers` (`list_id`,`subscriber_id`,`subdate`) VALUES '; $firstTime = true; if (!empty($allSubscribersIDA)) { foreach ($allSubscribersIDA as $oneSubcriber) { if (!$firstTime) { $query .= ','; } $query .= '(' . $listId . ',' . $oneSubcriber . ',' . $time . ')'; $firstTime = false; if (jNews_Lists::getListType($listId) == 2) { //we add directly the imported subscribers to the queue if they are imported to an autoresponder type of list jNews_ListsSubs::subscribeARtoQueue($oneSubcriber, $listId); // } else { if (jNews_Lists::getListType($listId) == 1) { $arrayFollowUp = jNews_Subscribers::followInSelected($listId); if (!$arrayFollowUp) { continue; } foreach ($arrayFollowUp as $onefollow_id) { if (in_array($onefollow_id, $seleeected)) { continue; } $query .= ',(' . $onefollow_id . ',' . $oneSubcriber . ',' . $time . ')'; jNews_ListsSubs::subscribeARtoQueue($oneSubcriber, $onefollow_id); } } } } $db->setQuery($query); $db->query(); } } } else { //otherwise we get the value from dropdown box $listId = JRequest::getVar('opted_list', ''); if ($listId) { $query = 'INSERT IGNORE `#__jnews_listssubscribers` (`list_id`,`subscriber_id`,`subdate`) VALUES '; $firstTime = true; if (!empty($allSubscribersIDA)) { foreach ($allSubscribersIDA as $oneSubcriber) { if (!$firstTime) { $query .= ','; } $query .= '(' . $listId . ',' . $oneSubcriber . ',' . $time . ')'; $firstTime = false; if (jNews_Lists::getListType($listId) == 2) { //we add directly the imported subscribers to the queue if they are imported to an autoresponder type of list jNews_ListsSubs::subscribeARtoQueue($oneSubcriber, $listId); } else { if (jNews_Lists::getListType($listId) == 1) { $arrayFollowUp = jNews_Subscribers::followInSelected($listId); if (!$arrayFollowUp) { continue; } foreach ($arrayFollowUp as $onefollow_id) { if (in_array($onefollow_id, $seleeected)) { continue; } $query .= ',(' . $onefollow_id . ',' . $oneSubcriber . ',' . $time . ')'; jNews_ListsSubs::subscribeARtoQueue($oneSubcriber, $onefollow_id); } } } } $db->setQuery($query); $db->query(); } } } if ($saveSubsInRows) { //if adding subscribers in frontend through rows jnews::printM('green', count($allSubscribersIDA) . ' subscribers successfully added!'); } else { //otherwise we import subscribers jnews::printM('green', count($allSubscribersIDA) . ' subscribers successfully imported!'); } return _JNEWS_IMPORT_FINISHED; }
public static function showLists($subscriberId, $listId, $lisType, $action, $task) { $Itemid = JRequest::getInt('Itemid'); if (empty($Itemid)) { $Itemid = $GLOBALS[JNEWS . 'itemidAca']; } // we initialize the listType with one if (empty($lisType)) { $lisType = 1; } $mainframe = JFactory::getApplication(); $my = JFactory::getUser(); $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 (!empty($my->id)) { $ownedlists = jNews_Lists::getOwnedlists($my->id); //UPDATE321 $lists = jNews_Lists::getLists(0, 0, true); $access = false; foreach ($lists as $list) { $bit = jnews::checkPermissions($list->acc_level); if ($bit) { $access = true; break; } } if (!$access && empty($listsAddEdit) && empty($ownedlists) && !jnews::checkPermissions('admin') && !jnews::checkPermissions($gid)) { frontHTML::showPanel(); return true; } } //for popup window JHTML::_('behavior.modal'); switch ($task) { case 'new': case 'add': $access = 'admin'; $id = 0; if ($GLOBALS[JNEWS . 'enable_jsub']) { if (!empty($my->id)) { $ownedlists = jNews_Lists::getOwnedlists($my->id); } if (!empty($ownedlists)) { $access = strtolower($my->usertype); } $id = $my->id; } if (jnews::checkPermissions($access) || jnews::checkPermissions($gid)) { //traces $task = 'save'; $subscriber = jNews_Subscribers::getSubscriberInfoFromUserId($my->id); if (version_compare(JVERSION, '1.6.0', '<')) { //j15 $acl = JFactory::getACL(); $groups = $acl->get_group_children_tree(null, 'USERS', false); } else { //j16 $db = JFactory::getDBO(); $db->setQuery('SELECT a.*, a.title as text, a.id as value FROM #__usergroups AS a ORDER BY a.lft ASC'); $groups = $db->loadObjectList(); } $allGroupIds = array(); foreach ($groups as $oneGroup) { $allGroupIds[] = $oneGroup->value; } $newList = new stdClass(); $newList->id = ''; $newList->html = 1; $newList->new_letter = 1; $newList->list_name = ''; $newList->list_desc = ''; if (empty($subscriber)) { $newList->sendername = ''; $newList->senderemail = ''; $newList->bounceadres = ''; //$GLOBALS[JNEWS.'sendmail_from']; } else { $newList->sendername = $subscriber->name; $newList->senderemail = $subscriber->email; $newList->bounceadres = $subscriber->email; } $newList->hidden = 1; $newList->auto_add = 0; $newList->list_type = $lisType; $newList->delay_min = 1; $newList->delay_max = 7; $newList->user_choose = 0; $newList->cat_id = '0:0'; $newList->follow_up = ''; $newList->notify_id = 0; $newList->owner = $my->id; $newList->acc_level = '24,25,7,8'; $newList->acc_id = implode(',', $allGroupIds); $newList->published = 1; $newList->start_date = date('Y-m-d', jnews::getNow(0, true)); $newList->next_date = jnews::getNow(0, true); $newList->subscribemessage = _JNEWS_DEFAULT_SUBSCRIBE_MESS; $newList->unsubscribemessage = _JNEWS_DEFAULT_UNSUBSCRIBE_MESS; $newList->notifyadminmsg = _JNEWS_UNSUBSCRIBE_ADMIN_NOTIFICATION; $newList->subnotifymsg = _JNEWS_SUBSDEFAULT_NOTIFYMSG; $newList->subnotifysend = 1; $newList->unsubscribesend = 1; $newList->unsubscribenotifyadmin = 1; $newList->footer = 1; $linkForm = 'option=' . JNEWS_OPTION; $linkForm = jNews_Tools::completeLink($linkForm, false, 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\">"; $show = jNews_ListType::showType($lisType, 'editlist'); // menus for list edit // menu save $linkForm = jNews_Tools::completeLink($linkForm, true); $linkForm = '#'; $menuSave = new stdClass(); $menuSave->popup = new stdClass(); $menuSave->popup->isPop = false; $menuSave->link = $linkForm; $menuSave->action = 'save'; $menuSave->onclick = new stdClass(); $menuSave->onclick->custom = false; $menuSave->onclick->js = ''; $menuSave->title = _JNEWS_SAVE; // menu cancel $menuCancel = new stdClass(); $menuCancel->popup = new stdClass(); $menuCancel->popup->isPop = false; $menuCancel->link = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=list&Itemid=' . $Itemid, false); $menuCancel->action = 'cancel'; $menuCancel->onclick = new stdClass(); $menuCancel->onclick->custom = true; $menuCancel->onclick->js = ''; $menuCancel->title = _JNEWS_CANCEL; $link = 'option=' . JNEWS_OPTION; $link = jNews_Tools::completeLink($link, false); $menuCpanel = new stdClass(); $menuCpanel->popup = new stdClass(); $menuCpanel->popup->isPop = false; $menuCpanel->popup->isPop = false; $menuCpanel->link = $link; $menuCpanel->action = 'cpanel'; $menuCpanel->onclick = new stdClass(); $menuCpanel->onclick->custom = false; $menuCpanel->onclick->js = ''; $menuCpanel->title = _JNEWS_MENU_CPANEL; $menuA = array(); $menuA['save'] = $menuSave; $menuA['cancel'] = $menuCancel; $menuA['cpanel'] = $menuCpanel; frontHTML::formStart(_JNEWS_EDIT_A . @constant($GLOBALS[JNEWS . 'listname' . $lisType]) . ' ' . _JNEWS_LIST, $newList->html, 'listedit', $menuA); jNews_ListsHTML::editList($newList, $forms, $show, $lisType); $go[] = jnews::makeObj('list_id', $newList->id); $go[] = jnews::makeObj('act', $action); $go[] = jnews::makeObj('task', ''); $go[] = jnews::makeObj('listype', JRequest::getInt('listype')); frontHTML::formEndFN(null, $go); } break; case 'edit': $access = 'admin'; $id = 0; if ($GLOBALS[JNEWS . 'enable_jsub']) { if (!empty($my->id)) { $ownedlists = jNews_Lists::getOwnedlists($my->id); } if (!empty($ownedlists)) { $access = strtolower($my->usertype); } $id = $my->id; } if (jnews::checkPermissions($access) || jnews::checkPermissions($gid)) { //traces $task = 'update'; $list = jNews_Lists::getLists($listId, $lisType, $subscriberId, '', false, false, false); $listEdit = $list[0]; $listEdit->new_letter = 0; if (!empty($listEdit)) { $linkForm = 'option=' . JNEWS_OPTION; $linkForm = jNews_Tools::completeLink($linkForm, false, 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\">"; $show = jNews_ListType::showType($listEdit->list_type, 'editlist'); // menus for list edit // menu save $linkForm = 'option=' . JNEWS_OPTION . '&act=list&listid=' . $listId . '&listype=' . $lisType . '&siteend=1&Itemid=' . $Itemid; $linkForm = jNews_Tools::completeLink($linkForm, false); $menuSave = new stdClass(); $menuSave->popup = new stdClass(); $menuSave->popup->isPop = false; $menuSave->link = $linkForm; $menuSave->action = 'save'; $menuSave->onclick = new stdClass(); $menuSave->onclick->custom = false; $menuSave->onclick->js = ''; $menuSave->title = _JNEWS_SAVE; // menu cancel $menuCancel = new stdClass(); $menuCancel->popup = new stdClass(); $menuCancel->popup->isPop = false; $menuCancel->link = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=list&Itemid=' . $Itemid, false); $menuCancel->action = 'cancel'; $menuCancel->onclick = new stdClass(); $menuCancel->onclick->custom = true; $menuCancel->onclick->js = ''; $menuCancel->title = _JNEWS_CANCEL; $link = 'option=' . JNEWS_OPTION; $link = jNews_Tools::completeLink($link, false); $menuCpanel = new stdClass(); $menuCpanel->popup = new stdClass(); $menuCpanel->popup->isPop = false; $menuCpanel->popup->isPop = false; $menuCpanel->link = $link; $menuCpanel->action = 'cpanel'; $menuCpanel->onclick = new stdClass(); $menuCpanel->onclick->custom = false; $menuCpanel->onclick->js = ''; $menuCpanel->title = _JNEWS_MENU_CPANEL; $menuA = array(); if (@(include_once JNEWSPATH_ADMIN . 'social' . DS . 'class.social.php')) { if (class_exists('jNews_Social')) { $menuA['save'] = $menuSave; $menuA['cancel'] = $menuCancel; } } $menuA['cpanel'] = $menuCpanel; frontHTML::formStart(_JNEWS_EDIT_A . @constant($GLOBALS[JNEWS . 'listname' . $lisType]) . ' ' . _JNEWS_LIST, $listEdit->html, 'listedit', $menuA); jNews_ListsHTML::editList($listEdit, $forms, $show, $lisType); $go[] = jnews::makeObj('list_id', $listEdit->id); $go[] = jnews::makeObj('act', $action); $go[] = jnews::makeObj('task', 'update'); frontHTML::formEndFN(null, $go); } } break; case 'save': JRequest::checkToken() or die('Invalid Token'); if (empty($listId)) { if (@(include_once JNEWSPATH_ADMIN . 'social' . DS . 'class.social.php')) { if (class_exists('jNews_Social')) { $status = jNews_Social::createFrontendList($action, $task, $lisType); } } $msgtype = $status ? 'ok' : 'no'; $message = jnews::printYN($msgtype, _JNEWS_LIST_ADDED, _JNEWS_ERROR); if ($mainframe->isAdmin()) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=list&listype=' . $lisType . '&siteend=1'); } else { $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION . '&act=list&listype=' . $lisType . '&siteend=1'); jNews_Tools::redirect($mainLink); } echo $message; } else { $lisType = jNews_Lists::getListType($listId); $message = jnews::printYN(jNews_Lists::updateListFromEdit($listId, '', false, $lisType), _JNEWS_LIST_UPDATED, _JNEWS_ERROR); // jNews_Tools::redirect('index.php?option='.JNEWS_OPTION.'&act=list&listype='.$lisType.'&siteend=1'); if ($mainframe->isAdmin()) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=list&listype=' . $lisType . '&siteend=1'); } else { $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION . '&act=list&listype=' . $lisType . '&siteend=1'); jNews_Tools::redirect($mainLink); } echo $message; $listId = 0; } break; case 'ownerslists': $ownerid = JRequest::getVar('ownerid', 0); $item = JRequest::getInt('Itemid'); $ownerslists = jNews_Lists::getSpecifiedLists(0, '', $ownerid); $module = new jnews_module(); $module->lists = $ownerslists; $module->showListName = true; $module->defaultchecked = true; $module->dropdown = false; $module->shownamefield = true; $HTML = $module->create(); echo $HTML; break; case 'make': case 'forms': if (class_exists('jNews_CreateForm')) { jNews_CreateForm::taskOptions($task); $showLists = false; } else { $showLists = true; } break; case 'cpanel': jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION); break; default: $my = JFactory::getUser(); $show = jNews_ListType::showType($lisType, 'showListsFront'); $msgtype = JRequest::getVar('msg', ''); if (!empty($msgtype)) { if ($msgtype == 'no') { echo jnews::printM($msgtype, _JNEWS_ERROR); } else { echo jnews::printM($msgtype, _JNEWS_LIST_ADDED); } } $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION); $forms['main'] = '<form method="post" action="' . $mainLink . '" onsubmit="submitbutton();return false;" name="mosForm" >' . "\n\r"; //$link $forms['main'] .= '<input type="hidden" name="Itemid" value="' . $Itemid . '" />'; $order = 'listnameA'; $id = 0; if ($GLOBALS[JNEWS . 'enable_jsub']) { if (!empty($my->id)) { $ownedlists = jNews_Lists::getOwnedlists($my->id); } if (!empty($ownedlists)) { $id = $my->id; } } if (jnews::checkPermissions('admin') || jnews::checkPermissions($gid) || !empty($listsAddEdit)) { if ($mainframe->isAdmin()) { $lists = jNews_Lists::getLists($listId, $lisType, $subscriberId, $order, false, false, false); } else { $lists = jNews_Lists::getLists($listId, $lisType, $subscriberId, $order, false, true, false, false, true); } } else { if ($mainframe->isAdmin()) { if ($lisType == 0) { $lists1 = jNews_Lists::getLists($listId, 1, $subscriberId, $order, false, true, false); $lists2 = jNews_Lists::getLists($listId, 2, $subscriberId, $order, false, true, false); $lists7 = jNews_Lists::getLists($listId, 7, $subscriberId, $order, false, true, false); $lists = array_merge($lists1, $lists2, $lists7); } elseif ($lisType == 1 or $lisType == 2 or $lisType == 7) { $lists = jNews_Lists::getLists($listId, $lisType, $subscriberId, $order, false, true, false); } else { $lists = ''; } } else { if ($lisType == 0) { //get the owned list of the logged user $ownedlists = 0; if ($GLOBALS[JNEWS . 'enable_jsub']) { $my = JFactory::getUser(); if (!empty($my->id)) { $ownedlists = jNews_Lists::getOwnedlists($my->id); } if (!empty($ownedlists)) { $access = true; } } $lists1 = jNews_Lists::getLists($listId, 1, $subscriberId, $order, false, true, false, false, true, '', '', $ownedlists, $my->id); $lists2 = jNews_Lists::getLists($listId, 2, $subscriberId, $order, false, true, false, false, true); $lists7 = jNews_Lists::getLists($listId, 7, $subscriberId, $order, false, true, false, false, true); $lists = array_merge($lists1, $lists2, $lists7); } elseif ($lisType == 1 or $lisType == 2 or $lisType == 7) { $lists = jNews_Lists::getLists($listId, $lisType, $subscriberId, $order, false, true, false, false, true); } else { $lists = ''; } } } if (!empty($lists) || jnews::checkPermissions($gid)) { $menuA = null; if ($my->id > 0) { $link = 'option=' . JNEWS_OPTION; $link = jNews_Tools::completeLink($link, false); $menuCpanel = new stdClass(); $menuCpanel->popup = new stdClass(); $menuCpanel->popup->isPop = false; $menuCpanel->popup->isPop = false; $menuCpanel->link = $link; $menuCpanel->action = 'cpanel'; $menuCpanel->onclick = new stdClass(); $menuCpanel->onclick->custom = false; $menuCpanel->onclick->js = ''; $menuCpanel->title = _JNEWS_MENU_CPANEL; $menuShare = new stdClass(); $menuForms = new stdClass(); $menuNew = new stdClass(); $itemId = $GLOBALS[JNEWS . 'itemidAca']; if ($GLOBALS[JNEWS . 'enable_jsub'] && !empty($ownedlists) || jnews::checkPermissions('admin') || jnews::checkPermissions($gid)) { $linkShare = 'option=' . JNEWS_OPTION . '&act=list&task=ownerslists&ownerid=' . $my->id . '&Itemid=' . $itemId; $linkShare = jNews_Tools::completeLink($linkShare, false); $menuShare = new stdClass(); $menuShare->popup = new stdClass(); $menuShare->popup->isPop = false; $menuShare->link = $linkShare; $menuShare->action = 'share'; $menuShare->onclick = new stdClass(); $menuShare->onclick->custom = false; $menuShare->onclick->js = ''; $menuShare->title = 'Share'; $menuBack = new stdClass(); $menuBack->popup = new stdClass(); $menuBack->popup = new stdClass(); $menuBack->popup->isPop = false; $menuBack->link = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=list&Itemid=' . $Itemid, false); $menuBack->action = 'back'; $menuBack->onclick = new stdClass(); $menuBack->onclick->custom = true; $menuBack->onclick->js = ''; $menuBack->title = _JNEWS_MENU_BACK; $menuDelete = new stdClass(); $menuDelete->popup = new stdClass(); $menuDelete->popup->isPop = false; $menuDelete->link = '#'; $menuDelete->action = 'delete'; $menuDelete->onclick = new stdClass(); $menuDelete->onclick->custom = false; $menuDelete->onclick->js = ''; $menuDelete->title = _JNEWS_DELETE; $menuForms = new stdClass(); $menuNew = new stdClass(); if ($GLOBALS[JNEWS . 'enable_jsub'] && !empty($ownedlists)) { $linkForm = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=list&task=make', false, false, true); $menuForms->link = $linkForm; $menuForms->popup = new stdClass(); $menuForms->popup->isPop = true; $menuForms->popup->rel = true; $menuForms->popup->x = 750; $menuForms->popup->y = 500; $menuForms->action = 'form'; $menuForms->title = 'Create Form'; $linknew = 'option=com_jsubscription&view=jsubscription&task=listing&Itemid=' . $itemId; $menuNew = new stdClass(); $menuNew->popup = new stdClass(); $menuNew->popup->isPop = false; $menuNew->action = 'new'; $menuNew->onclick = new stdClass(); $menuNew->onclick->custom = true; $menuNew->onclick->js = ''; $menuNew->title = 'New'; $menuNew->link = $linknew; } else { if (@(include_once JNEWSPATH_ADMIN . 'social' . DS . 'class.social.php')) { if (class_exists('jNews_Social')) { // if($lisType == 1){ $linkForm = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=list&task=make', true, false, true); $menuForms->link = $linkForm; $menuForms->popup = new stdClass(); $menuForms->popup->isPop = true; $menuForms->popup->rel = true; $menuForms->popup->x = 750; $menuForms->popup->y = 500; $menuForms->action = 'form'; $menuForms->title = 'Create Form'; // $linknew = 'option='.JNEWS_OPTION.'&act=list&task=new&listype='.$lisType.'&siteend=1&Itemid='.$itemId; $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION); $menuNew = new stdClass(); $menuNew->popup = new stdClass(); $menuNew->popup->isPop = false; // $linknew = jNews_Tools::completeLink($linknew,false); $linknew = '#'; // # $menuNew->action = 'new'; $menuNew->onclick = new stdClass(); $menuNew->onclick->custom = true; $menuNew->onclick->js = "javascript: submitbutton('new')"; $menuNew->title = 'New'; $menuNew->link = $linknew; } // } } } $menuUnpub = new stdClass(); $menuUnpub->popup = new stdClass(); $menuUnpub->popup->isPop = false; $menuUnpub->link = '#'; $menuUnpub->action = 'unpublished'; $menuUnpub->onclick = new stdClass(); $menuUnpub->onclick->custom = true; $menuUnpub->onclick->js = 'javascript:history.go(-1)'; $menuUnpub->title = 'Unpublished'; $menuPub = new stdClass(); $menuPub->popup = new stdClass(); $menuPub->popup->isPop = false; $menuPub->link = '#'; $menuPub->action = 'published'; $menuPub->onclick = new stdClass(); $menuPub->onclick->custom = true; $menuPub->onclick->js = 'javascript:history.go(-1)'; $menuPub->title = 'Published'; $menuCopy = new stdClass(); $menuCopy->popup = new stdClass(); $menuCopy->popup->isPop = false; $menuCopy->link = '#'; $menuCopy->action = 'copy'; $menuCopy->onclick = new stdClass(); $menuCopy->onclick->custom = true; $menuCopy->onclick->js = 'javascript:history.go(-1)'; $menuCopy->title = 'Copy'; $menuDivider = new stdClass(); $menuDivider->divider = true; } $menuA = array(); if ($lisType == '2') { $menuA['new'] = $menuNew; $menuA['cpanel'] = $menuCpanel; } else { if ($GLOBALS[JNEWS . 'enable_jsub']) { $menuA['share'] = $menuShare; } $menuA['form'] = $menuForms; $menuA['new'] = $menuNew; $menuA['cpanel'] = $menuCpanel; } } if ($lisType == 1) { $title = _JNEWS_EMAIL_LISTS; } else { $title = 'Auto-responders'; } if (empty($my->id)) { $title = _JNEWS_SUBSCRIBE_LIST2; } if (empty($ownedlists) && !empty($my->id)) { $title = _JNEWS_SUBSCRIBE_LIST2; } $gid = !empty($GLOBALS[JNEWS . 'list_creatorfe']) ? $GLOBALS[JNEWS . 'list_creatorfe'] : 0; frontHTML::formStart($title, 0, '', $menuA); frontHTML::FEmenu(); if ($show['list_type']) { $show['list_type'] = jNews_ListType::checkOthers(); } $setSort = new stdClass(); $setSort->orderDir = ''; $setSort->orderValue = ''; if (class_exists('jNews_Pro')) { $id = 0; if ($GLOBALS[JNEWS . 'enable_jsub']) { if (!empty($my->id)) { $ownedlists = jNews_Lists::getOwnedlists($my->id); } if (!empty($ownedlists)) { $id = $my->id; } } $access = false; foreach ($lists as $list) { $bit = jnews::checkPermissions($list->acc_level); if ($bit) { $access = true; break; } } $my = JFactory::getUser(); //owner of the list to access the list if ($GLOBALS[JNEWS . 'enable_jsub']) { if (!empty($my->id)) { $ownedlists = jNews_Lists::getOwnedlists($my->id); } if (!empty($ownedlists)) { $access = true; $usertype = strtolower($my->usertype); } } if ($access) { jNews_Pro::showListingLists($lists, $action, 'edit', $forms, $show, $my->id); $go[] = jnews::makeObj('listype', JRequest::getInt('listype')); } else { jNews_ListsHTML::showListingLists($lists, $action, 'edit', $forms, $show, '', 0, null, null, $setSort); $go[] = jnews::makeObj('listype', JRequest::getInt('listype')); } } else { jNews_ListsHTML::showListingLists($lists, $action, 'edit', $forms, $show, '', 0, null, null, $setSort); } $go[] = jnews::makeObj('act', $action); frontHTML::formEnd('', $go); } else { frontHTML::FEmenu(); } break; } }
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; }
public static function getListMailingToDelete($listID) { if (empty($listID)) { return false; } $type = jNews_Lists::getListType($listID); $query = 'SELECT `mailing_id` FROM `#__jnews_listmailings` WHERE `list_id`=' . $listID; $db = JFactory::getDBO(); $db->setQuery($query); $loadResultArray = $db->loadObjectList(); $resultA = jnews::convertObjectList2Array($loadResultArray); return $resultA; }
function insertIntoQueue($queue) { static $alradyProceesed = array(); $db = JFactory::getDBO(); if ($queue->subscriber_id < 0) { return false; } //Added by Grace for the pending of queue $queue->published = $queue->send_date > time() ? 2 : 0; //Note: know what's the use of this line if (empty($queue->list_id)) { //this is for the smartnewsletter $queue->published = 2; } $confirmed = jNews_Subscribers::isConfirmed($queue->subscriber_id); $queue->suspend = $confirmed; $key = serialize($queue); if (isset($alradyProceesed[$key])) { return true; } $alradyProceesed[$key] = true; //if (!$exist){ $query = 'INSERT IGNORE INTO `#__jnews_queue` (`type` , `subscriber_id` , `mailing_id`, `issue_nb`,' . ' `send_date`, `suspend` , `delay`, `acc_level`, `published`, `priority`, `attempt`) VALUES (' . intval($queue->type) . ', ' . intval($queue->subscriber_id) . ' , ' . intval($queue->mailing_id) . ', ' . intval($queue->issue_nb) . ', \'' . $queue->send_date . '\', ' . $queue->suspend . ' , ' . $queue->delay . ' , ' . $queue->acc_level . ' , ' . $queue->published . ' , ' . $queue->priority . ' , ' . $queue->attempt . ')'; $db->setQuery($query); $db->query(); // ONLY FOR AUTO-RESPONDERS --- ONLY FOR AUTO-RESPONDERS --- ONLY FOR AUTO-RESPONDERS --- ONLY FOR AUTO-RESPONDERS --- ONLY FOR AUTO-RESPONDERS --- ONLY FOR AUTO-RESPONDERS --- if (!empty($queue->list_id)) { $type = jNews_Lists::getListType($queue->list_id); if ($type == 2) { $delays = jNews_Mailing::getMailingInfoz($queue->mailing_id, 'delay'); $newQueue->delay = $delays; $newQueue->send_date = time() + $delays * 60; // jnews::getNow( $delays ); $newQueue->published = 2; $arPRiority = empty($GLOBALS[JNEWS . 'ar_prior']) ? 1 : $GLOBALS[JNEWS . 'ar_prior']; $newQueue->priority = $arPRiority; $query = 'UPDATE `#__jnews_queue` SET `send_date`=' . $newQueue->send_date; $query .= ' , `delay`=' . $newQueue->delay; $query .= ' , `published`=' . $newQueue->published; $query .= ' , `priority`=' . $newQueue->priority; $query .= ' , `suspend`=' . $confirmed; $query .= ' WHERE `subscriber_id` = ' . $queue->subscriber_id; $query .= ' and `mailing_id` = ' . $queue->mailing_id; $db->setQuery($query); $db->query(); } return true; } //end if return true; //} }
public static function processTypeEightfromQueue() { $ARtoUnsubA = array(); $followupToSubscribeA = array(); //get entries in the queue where type =8 $typeEightinQueue = jNews_Queue::typeEight(); if (empty($typeEightinQueue)) { return false; } foreach ($typeEightinQueue as $oneTypeEight) { $subscriberId = $oneTypeEight->subscriber_id; $ARtoUnsubA[0] = $oneTypeEight->delay; //we use the delay column of the queue saving the AR id being subscribed of the subscriber $mailId = $oneTypeEight->mailing_id; //we get the followup of the listid saved in the delay column $followupid = jNews_Lists::getFollowup($ARtoUnsubA[0]); $followupToSubscribeA[0] = $followupid; //$subs=jNews_ListsSubs::getSubs($subscriberId); //we unsubscribe the user from the list using the data saved in the delay column in the queue jNews_ListsSubs::_applyChangedSubscription($subscriberId, '', $ARtoUnsubA); //we delete this type 8 entry in the queue $db = JFactory::getDBO(); $query = 'DELETE FROM `#__jnews_queue` WHERE `type`=8 AND `subscriber_id`=' . $subscriberId . ' AND `mailing_id`=' . $mailId; $db->setQuery($query); $db->query(); //we subscribe the user to the followup if ($followupToSubscribeA[0] != 0 && !empty($followupToSubscribeA[0])) { jNews_ListsSubs::_applyChangedSubscription($subscriberId, $followupToSubscribeA, ''); $followupType = jNews_Lists::getListType($followupid); if ($followupType == 2) { //we add entries in the queue if the type is equal 2 jNews_ListsSubs::subscribeARtoQueue($subscriberId, $followupToSubscribeA); } } //$subs=jNews_ListsSubs::getSubs($subscriberId); } return true; }