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; }
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; }
function _showSubcriptionListOld($subscriber, $loggedin = true, $item) { $HTML = ''; //We create the dropdown if ($this->dropdown) { $dropdown = '<input type="hidden" value="1" name="subscribed[1]" />'; $dropdown .= '<select class="aca_list_drop" name="sub_list_id[1]" id="sub_list_id[1]">'; } $i = 0; $accessLevel = 0; $queues = $loggedin ? jNews_ListsSubs::getSubscriberLists($subscriber->id) : ''; //we retrieve the listIds set in the module if (!empty($this->hiddenlistIds)) { $hiddenListIds = explode(',', $this->hiddenlistIds); } if ($this->showListName) { foreach ($this->lists as $list) { $i++; $subscribed = 0; $accessLevel = 0; if ($loggedin) { if (!empty($queues)) { foreach ($queues as $queue) { if ($list->id == $queue->list_id) { $subscribed = 1; $accessLevel = $queue->acc_level; } } } } if ($list->html == 1) { $htmlOK = true; } $checked = 0; if ($loggedin) { $checked = $subscribed; } else { if ($this->defaultchecked) { $checked = 1; } $subscriber->blacklist = 0; } $checkedPrint = $checked != 0 ? 'checked="checked"' : ''; if ($list->hidden == 1) { if ($this->dropdown) { $extraselect = $list->id == $this->selecteddrop ? 'selected' : ''; $dropdown .= '<option value="' . $list->id . '" ' . $extraselect . '>' . $list->list_name . '</option>'; } else { //889 if ($subscriber->blacklist == 0) { if ($loggedin) { $text = "\n" . '<input id="wz_3' . $i . '" type="checkbox" class="inputbox" value="1" name="subscribed[' . $i . ']" ' . $checkedPrint . ' />'; } else { if (!$this->red_subscription) { $text = "\n" . '<input id="wz_3' . $i . '" type="checkbox" class="inputbox" value="' . $list->id . '" name="subscribed[' . $i . ']" ' . $checkedPrint . ' />'; } else { $text = "\n" . '<input id="wz_3' . $i . '" type="checkbox" class="inputbox" value="1" name="subscribed[' . $i . ']" ' . $checkedPrint . ' />'; } } } else { if (!$this->red_subscription) { $text = "\n" . '<input type="checkbox" class="inputbox" value="' . $list->id . '" name="subscribedfake[' . $i . ']" ' . $checkedPrint . ' />'; } else { $text = "\n" . '<input type="checkbox" class="inputbox" value="1" name="subscribedfake[' . $i . ']" ' . $checkedPrint . ' />'; } $text .= "\n" . '<input type="hidden" value="0" name="subscribed[' . $i . ']" />'; } $text .= "\n" . '<input type="hidden" name="sub_list_id[' . $i . ']" value="' . $list->id . '" />'; $link = ($list->list_type == '1' or $list->list_type == '7') && $GLOBALS[JNEWS . 'show_archive'] ? 'index.php?option=' . JNEWS_OPTION . $item . '&act=mailing&task=archive&listid=' . $list->id . '&listype=' . $list->list_type : '#'; $text .= "\n" . '<span class="aca_list_name"'; if ($link == "#") { $text .= " onclick='return false;' "; } $text .= '>' . jNews_Tools::toolTip($list->list_desc, $list->list_name, '', '', $list->list_name, $link, 1) . '</span>'; $HTML .= jnews::printLine($this->linear, $text); $HTML .= "\n" . '<input type="hidden" name="acc_level[' . $i . ']" value="' . $accessLevel . '" />' . "\n\r"; } } else { if (!$loggedin) { $HTML .= '<input type="hidden" value="1" name="subscribed[' . $i . ']" />'; $HTML .= "\n" . '<input type="hidden" name="sub_list_id[' . $i . ']" value="' . $list->id . '" id="hidden_sub_lists"/>'; } } } } else { foreach ($this->lists as $list) { $i++; $subscribed = 0; $accessLevel = 0; if ($loggedin) { if (!empty($queues)) { foreach ($queues as $queue) { if ($list->id == $queue->list_id) { $subscribed = 1; $accessLevel = $queue->acc_level; } } } } if ($list->html == 1) { $htmlOK = true; } $checked = 0; if ($loggedin) { $checked = $subscribed; } else { if ($this->defaultchecked) { $checked = 1; } } $HTML .= '<input type="hidden" value="' . $checked . '" name="subscribed[' . $i . ']" />'; $HTML .= "\n" . '<input type="hidden" name="sub_list_id[' . $i . ']" value="' . $list->id . '" id="hidden_sub_lists"/>'; $HTML .= "\n" . '<input type="hidden" name="acc_level[' . $i . ']" value="' . $accessLevel . '" />'; if ($list->html == 1) { $htmlOK = true; } } } if ($this->dropdown) { $dropdown .= '</select><br/>'; $HTML .= $dropdown; } return $HTML; }
public static function changeSubscriptions($subscriber, $subscriberId, $cle = '', $action) { $Itemid = JRequest::getInt('Itemid'); $db = JFactory::getDBO(); if (!empty($subscriberId) and !empty($cle)) { $confirmed = false; if (md5($subscriber->email) == $cle) { $subsListsA = jNews_ListsSubs::getSubscriberLists($subscriberId); $confirmed = true; if ($subscriber->user_id > 0) { $access = jnews::checkPermissions('admin'); } else { $access = false; } if ($subscriberId > 0) { $author = 0; } //we get the lists subscribed by the subscriberId $query = 'SELECT L.`list_name`, L.`list_desc`, L.`acc_level`, L.`id`,L.`list_type` FROM `#__jnews_lists` AS L ' . 'LEFT JOIN `#__jnews_listssubscribers` AS LS ON L.`id` = LS.`list_id` '; $query .= 'WHERE LS.`subscriber_id`=' . $subscriberId . ' AND L.`hidden`!=0 AND L.`published`!=0'; $query .= jnews::orderBy('list_idA'); $db->setQuery($query); $lists = $db->loadObjectList(); $doShowSubscribers = false; $mainLink = 'option=' . JNEWS_OPTION; $selectLink = 'option=' . JNEWS_OPTION . '&act=' . $action; $mainLink = jNews_Tools::completeLink($mainLink, false); $selectLink = jNews_Tools::completeLink($selectLink, false); $forms['main'] = '<form method="post" action="' . $mainLink . '" onsubmit="submitbutton();return false;" name="mosForm" >' . "\n\r"; $forms['select'] = '<form method="post" action="' . $selectLink . '" name="jNewsFilterForm">' . "\n\r"; $forms['main'] .= '<input type="hidden" name="Itemid" value="' . $Itemid . '" />'; $forms['select'] .= '<input type="hidden" name="Itemid" value="' . $Itemid . '" />'; $forms['main'] .= '<input type="hidden" name="confirmed" value="' . $confirmed . '" />'; frontHTML::formStart(_JNEWS_SUBSCRIPTIONS, 0, 'name_email'); echo jNews_SubscribersHTML::editSubscriber($subscriber, $lists, $subsListsA, $forms, $access, true, false); $go[] = jnews::makeObj('act', $action); $go[] = jnews::makeObj('subscriber_id', $subscriber->id); $go[] = jnews::makeObj('user_id', $subscriber->user_id); frontHTML::formEnd(_JNEWS_CHANGE_SUBSCRIPTIONS, $go); return true; } else { return false; } } else { return false; } }
function onAfterRoute() { $redirectlink = trim(JRequest::getString('redirectlink')); $fromSubscribe = JRequest::getVar('fromSubscribe', ''); // this is either we have a redirect setup or we come from the module if (empty($fromSubscribe) || empty($redirectlink)) { return ''; } 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_CLASS . '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'); $db = JFactory::getDBO(); $plugin = JPluginHelper::getPlugin('system', 'vmjnewssubs'); $registry = new JRegistry(); if (!method_exists($registry, 'loadString')) { $data = trim($plugin->params); $options = array('processSections' => false); if (substr($data, 0, 1) != '{' && substr($data, -1, 1) != '}') { $ini = JRegistryFormat::getInstance('INI'); $obj = $ini->stringToObject($data, $options); } else { $obj = json_decode($data); } $registry->loadObject($obj); } else { $registry->loadString($plugin->params); } $params = $registry; $reqfield = $params->get('reqfield', 'user_email'); $email = JRequest::getString('email'); $reqvalue = $reqfield == 'user_email' ? $email : JRequest::get($reqfield); if (is_array($reqvalue)) { //if we find any no we do no if (empty($reqvalue)) { return ''; } foreach ($reqvalue as $resultArVal) { if (empty($resultArVal)) { return ''; } } } else { if (empty($reqvalue) || empty($email) || in_array(strtolower($reqvalue), array('', '0', 'n', 'no', 'none', 'nein', 'non'))) { return; } } $user_id = JRequest::getInt('user_id'); $email = trim(strip_tags($email)); $fname = JRequest::getString('first_name', ''); $mname = JRequest::getString('middle_name', ''); $lname = JRequest::getString('last_name', ''); $name = ''; if (!empty($fname)) { $name .= $fname . ' '; } if (!empty($mname)) { $name .= $mname . ' '; } if (!empty($lname)) { $name .= $lname; } $name = trim($name); if (empty($name)) { $name = JRequest::getVar('username'); } $subscriber = new stdClass(); $subscriber->user_id = $user_id; $subscriber->name = $name; $subscriber->email = $email; $subscriber->ip = jNews_Subscribers::getIP(); $subscriber->receive_html = 1; $subscriber->confirmed = $GLOBALS[JNEWS . 'require_confirmation'] == '1' ? 0 : 1; $subscriber->subscribe_date = time(); $subscriber->language_iso = 'eng'; $subscriber->timezone = '00:00:00'; $subscriber->blacklist = 0; $subscriber->params = ''; $subscriber->admin_id = 62; $status = jNews_Subscribers::saveSubscriber($subscriber, $user_id, true); if (!$status) { return; } $listsToSubscribe = $params->get('lists', ''); $listsToSubscribe = str_replace(' ', '', $listsToSubscribe); if (!empty($listsToSubscribe)) { $condition = ' WHERE `id` IN (' . $listsToSubscribe . ')'; } else { $condition = ''; } $query = 'SELECT `id`, `list_type`,`params` from `#__jnews_lists`' . $condition; $db->setQuery($query); $lsidstoinsert = $db->loadObjectList(); $error = $db->getErrorMsg(); if (!empty($error)) { echo $error; return false; } else { //use for masterlists $listsA = array(); foreach ($lsidstoinsert as $lsid) { $d['email'] = $subscriber->email; //get the subscriber id which is newly inserted jNews_Subscribers::getSubscriberIdFromEmail($d); //subscriber_id from the inserted subscriber if ($d['subscriberId'] > 0) { $subscriber->id = $d['subscriberId']; } else { $subscriber->id = $subscriber->user_id; } if (!empty($lsid->params)) { //use for masterlists $listsA[] = $lsid->id; } else { //for non-masterlists $subscriber->list_id = $lsid->id; jNews_ListsSubs::saveToListSubscribers($subscriber); } if ($lsid->list_type == 2) { $subscribe = array(); $subscribe[] = $lsid->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('jNews_Social')) { $listidSubsA = array(); $masterListSubscriber = new stdClass(); //we check if configuration for master lists is enabled if ($GLOBALS[JNEWS . 'use_masterlists']) { if ($GLOBALS[JNEWS . 'level'] > 1) { //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 . 'level'] > 2) { //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); } } //we check first if $listidSubsA and if not empty we do the subscription to the lists if (!empty($listidSubsA)) { $masterListSubscriber->id = $subscriber->id; $masterListSubscriber->list_id = $listidSubsA; jNews_ListsSubs::saveToListSubscribers($masterListSubscriber); } } } } } }
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; }
} //end if check if the version is pro //jNews_Subscribers::insertSubscriber($subscriber, $subscriberId); jNews_Subscribers::saveSubscriber($subscriber, $subscriberId, true, $listid); //get subscriber info by passing the user id $userInfo = jNews_Subscribers::getSubscriberInfoFromUserId($user->id); } else { } //end if //save the subscriber id and list to listssubscribers table $subscriber->id = $userInfo->id; $subscriber->list_id = $listid; $subscriber->flexicontentFlag = true; //a flag that the subscription is from a tenders subscription from the flexicontent module $subscriber->params = $params; jNews_ListsSubs::saveToListSubscribers($subscriber); } //clear jnews session $mySess->clear('flexi_countries', 'JNEWLSETTER'); $mySess->clear('flexi_industries', 'JNEWLSETTER'); $mySess->clear('modjnewsflexi_listid', 'JNEWLSETTER'); echo '<div id=mod_message><span style="color:green;">You have been successfully subscribed to smartflexi articles.</span></div>'; //echo jnews::printM('green','Successfully subscribed to smartflexi articles.'); // break; //echo jnews::printM('green','Successfully subscribed to smartflexi articles.'); // break; default: if (class_exists('jNews_Auto')) { $showPanel = false; switch ($action) { case 'cron':
public static function upgrade_News3() { $my = JFactory::getUser(); $db = JFactory::getDBO(); $xf = new jNews_Config(); $newLists = array(); $idImportedList = array(); $i = 0; $db->setQuery("SELECT * FROM #__yanc_letters"); $newsletters = $db->loadObjectList(); $error = $db->getErrorMsg(); $newSubscriber = null; $list = null; $mailings = null; $subscriberId = 0; $total = 0; if (!empty($error)) { echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error getting newsletters. Database error: <br />' . $error . '</p>'; return false; } else { foreach ($newsletters as $newsletter) { $list->list_name = $newsletter->list_name; $list->list_desc = $newsletter->list_desc; $list->sendername = $newsletter->sendername; $list->senderemail = $newsletter->senderemail; $list->bounceadres = $newsletter->bounceadres; $list->layout = $newsletter->layout; $list->template = 0; $list->subscribemessage = $newsletter->subscribemessage; $list->unsubscribemessage = $newsletter->unsubscribemessage; $list->notifyadminmsg = $newsletter->notifyadminmsg; $list->html = $newsletter->html; $list->hidden = !$newsletter->hidden; $list->unsubscribesend = 1; $list->unsubscribenotifyadmin = 1; $list->list_type = '1'; $list->auto_add = 0; $list->user_choose = 0; $list->cat_id = '0:0'; $list->delay_min = 0; $list->delay_max = 0; $list->follow_up = 0; $list->owner = $my->id; $list->acc_level = $newsletter->aid; $list->acc_id = 29; $list->published = 1; $list->createdate = time(); $list->footer = 1; $list->notify_id = 0; $list->notification = 0; $query = 'INSERT INTO `#__jnews_lists` (`list_name`) VALUES (\'' . $list->list_name . '\' )'; $db->setQuery($query); $db->query(); $error = $db->getErrorMsg(); if (!empty($error)) { echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error adding list to database. Database error: <br />' . $error . '</p><br /><br />Are you trying to insert a list name which is already in use? The list name has to be different for each list! <br /><br />'; } else { $query = 'SELECT * FROM `#__jnews_lists` WHERE `list_name`= \'' . $list->list_name . '\''; $db->setQuery($query); $mynewlist = $db->loadObject(); $error = $db->getErrorMsg(); $xf->plus('totallist0', 1); $xf->plus('act_totallist0', 1); $xf->plus('totallist1', 1); $xf->plus('act_totallist1', 1); if (!empty($error)) { echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting listname. Database error: <br />' . $error . '</p>'; return false; } else { $idImportedList[$newsletter->id] = $mynewlist->list_id; $newLists[$i] = $mynewlist->list_id; $i++; $list->id = $mynewlist->list_id; $error = jNews_Lists::updateListData($list); if (!$error) { echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error inserting list. Database error: <br />' . $error . '</p>'; } else { echo '<br /><b>' . @constant($GLOBALS[JNEWS . 'listnames1']) . ': </b>' . $list->list_name . ': ' . jnews::printM('green', _JNEWS_IMPORT_SUCCESS); $db->setQuery("SELECT * FROM #__yanc_letters WHERE `list_id`=" . $newsletter->id); $mailingsImports = $db->loadObjectList(); $error = $db->getErrorMsg(); if (!empty($error)) { echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting mailings. Database error: <br />' . $error . '</p>'; return false; } else { $issue_nb = 1; foreach ($mailingsImports as $mailingsImport) { $mailings->list_id = $mynewlist->list_id; $mailings->list_type = '1'; $mailings->send_date = $mailingsImport->send_date; $mailings->subject = $mailingsImport->subject; $mailings->htmlcontent = $mailingsImport->htmlcontent; $mailings->textonly = $mailingsImport->textonly; $mailings->attachments = $mailingsImport->attachments; $mailings->images = $mailingsImport->images; $mailings->published = $mailingsImport->published; $mailings->visible = $mailingsImport->visible; $mailings->html = $mynewlist->html; $mailings->fromname = $list->sendername; $mailings->fromemail = $list->senderemail; $mailings->frombounce = $list->bounceadres; $mailings->author_id = $my->id; $mailings->delay = 0; $mailings->issue_nb = $issue_nb; $mailings->acc_level = 25; $mailings->createdate = $list->createdate; $issue_nb++; $error = jNews_Mailing::insertMailingData($mailings); if (!$error) { echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error inserting mailing. Database error: <br />' . $error . '</p>'; } else { echo '<br /><b>' . _JNEWS_MENU_MAILING_TITLE . ': </b>' . $mailingsImport->subject . ': ' . jnews::printM('green', _JNEWS_IMPORT_SUCCESS); } } } } } } } $db->setQuery("SELECT * FROM #__yanc_subscribers"); $subscribers = $db->loadObjectList(); $error = $db->getErrorMsg(); if (!empty($error)) { echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting subscribers. Database error: <br />' . $error . '</p>'; return false; } else { foreach ($subscribers as $subscriber) { $newSubs = true; $jnewssubscribers = jNews_Subscribers::getSubscribers(-1, -1, '', $total, 0, '', '', '', '', ''); //added one parameter for mailid foreach ($jnewssubscribers as $jnewssubscriber) { if ($subscriber->subscriber_email == $jnewssubscriber->email) { $newSubs = false; $subId[0] = $jnewssubscriber->id; } } if ($newSubs) { $newSubscriber->user_id = $subscriber->userid; $newSubscriber->name = $subscriber->subscriber_name; $newSubscriber->email = $subscriber->subscriber_email; $newSubscriber->ip = $subscriber->ip; $newSubscriber->receive_html = $subscriber->receive_html; $newSubscriber->confirmed = $subscriber->confirmed; $newSubscriber->subscribe_date = $subscriber->subscribe_date; $newSubscriber->blacklist = 0; $newSubscriber->timezone = '00:00:00'; $newSubscriber->language_iso = 'eng'; $newSubscriber->params = ''; if ($GLOBALS[JNEWS . 'level'] > 2) { //check if the version of jnews is pro $newSubscriber->column1 = $newSubscriber->column1; $newSubscriber->column2 = $newSubscriber->column2; $newSubscriber->column3 = $newSubscriber->column3; $newSubscriber->column4 = $newSubscriber->column4; $newSubscriber->column5 = $newSubscriber->column5; } //end if for check version pro $error = jNews_Subscribers::saveSubscriber($newSubscriber, $subscriberId, true); if (!empty($error)) { if ($subscriberId < 1) { echo ' Error inserting subscriber:' . $newSubscriber->name; } $error = ''; $subId[0] = $subscriberId; } else { echo '<br /><b>' . _JNEWS_MENU_SUBSCRIBERS . ': </b>' . $newSubscriber->name . ': ' . jnews::printM('green', _JNEWS_IMPORT_SUCCESS); $d['email'] = $subscriber->email; jNews_Subscribers::getSubscriberIdFromEmail($d); $subId[0] = $d['subscriberId']; } } else { echo '<br /><b>' . _JNEWS_MENU_SUBSCRIBERS . ': </b>' . $subscriber->subscriber_name . ': ' . jnews::printM('red', _JNEWS_IMPORT_EXIST); } $j = 0; $queue = jNews_ListsSubs::getListSubscriberInfo($subId[0], $idImportedList[$subscriber->list_id]); if (empty($queue)) { $error = jNews_Queue::insertQueuesForNews($subId, $idImportedList[$subscriber->list_id], 29); if (!$error) { echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error inserting queue. Database error: <br />' . $error . '</p>'; } } } } } return true; }
static function insertQueuesForNews($subId, $listId, $acc_level) { $mailing_ids = array(); $mailing_ids = jNews_Mailing::getListMailing($listId); $status = true; if (is_array($subId)) { for ($k = 0; $k < count($subId); $k++) { if (is_array($mailing_ids)) { for ($i = 0; $i < sizeOf($mailing_ids); $i++) { // check subscribers confirmed status $result = jNews_Subscribers::isSubConfirmed($subId[$k]); $queue = new stdClass(); $queue->id = 0; $queue->subscriber_id = $subId[$k]; $queue->list_id = $listId; $queue->type = 1; $queue->mailing_id = $mailing_ids[$i]; $queue->send_date = jNews_Mailing::getSendDate($mailing_ids[$i]); $queue->suspend = !empty($result) ? 1 : 0; $queue->delay = 0; $queue->acc_level = $acc_level; $queue->issue_nb = 0; $queue->published = 0; $queue->priority = 0; $queue->attempt = 0; jNews_Queue::insertIntoQueue($queue); } $subscriber = new stdClass(); $subscriber->list_id = $listId; $subscriber->id = $subId[$k]; jNews_ListsSubs::saveToListSubscribers($subscriber); } else { // check subscribers confirmed status $result = jNews_Subscribers::isSubConfirmed($subId[$k]); $queue = new stdClass(); $queue->id = 0; $queue->subscriber_id = $subId[$k]; $queue->list_id = $listId; $queue->type = 1; $queue->mailing_id = $mailing_ids; $queue->send_date = jNews_Mailing::getSendDate($mailing_ids); $queue->suspend = !empty($result) ? 1 : 0; $queue->delay = 0; $queue->acc_level = $acc_level; $queue->issue_nb = 0; $queue->published = 0; $queue->priority = 0; $queue->attempt = 0; $subscriber = new stdClass(); $subscriber->list_id = $listId; $subscriber->id = $subId[$k]; jNews_ListsSubs::saveToListSubscribers($subscriber); jNews_Queue::insertIntoQueue($queue); } } } else { if (is_array($mailing_ids)) { // check subscribers confirmed status $result = jNews_Subscribers::isSubConfirmed($subId); for ($i = 0; $i < sizeOf($mailing_ids); $i++) { $queue = new stdClass(); $queue->id = 0; $queue->subscriber_id = $subId; $queue->list_id = $listId; $queue->type = 1; $queue->mailing_id = $mailing_ids[$i]; $queue->send_date = jNews_Mailing::getSendDate($mailing_ids[$i]); $queue->suspend = !empty($result) ? 1 : 0; if ($GLOBALS[JNEWS . 'require_confirmation']) { $queue->suspend = 1; } else { $queue->suspend = 0; } $queue->delay = 0; $queue->acc_level = $acc_level; $queue->issue_nb = 0; $queue->published = 0; $queue->priority = 0; $queue->attempt = 0; jNews_Queue::insertIntoQueue($queue); } $subscriber = new stdClass(); $subscriber->list_id = $listId; $subscriber->id = $subId; jNews_ListsSubs::saveToListSubscribers($subscriber); } else { // check subscribers confirmed status $result = jNews_Subscribers::isSubConfirmed($subId); $queue = new stdClass(); $queue->id = 0; $queue->subscriber_id = $subId; $queue->list_id = $listId; $queue->type = 1; $queue->mailing_id = $mailing_ids; $queue->send_date = jNews_Mailing::getSendDate($mailing_ids); $queue->suspend = !empty($result) ? 1 : 0; $queue->delay = 0; $queue->acc_level = $acc_level; $queue->issue_nb = 0; $queue->published = 0; $queue->priority = 0; $queue->attempt = 0; $subscriber = new stdClass(); $subscriber->list_id = $listId; $subscriber->id = $subId; jNews_ListsSubs::saveToListSubscribers($subscriber); jNews_Queue::insertIntoQueue($queue); } } return $status; }
function getEditTab($tab, $user, $ui) { $Itemid = JRequest::getInt('Itemid'); $my = JFactory::getUser(); if ($my->get('id') < 1) { echo JText::_('ALERTNOTAUTH'); echo "<br />" . JText::_('You need to login.'); return false; } if (!getjNewsTab::checkInstalled()) { return _UE_NEWSLETTERNOTINSTALLED; } $html = ''; require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . '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'; require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . 'class.lists.php'; require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'views' . DS . 'subscribers.jnews.html.php'; if (!empty($my->id)) { $subscriberId = jNews_Subscribers::getSubscriberIdFromUserId($my->id); $qid[0] = $subscriberId; $subscriber = jNews_Subscribers::getSubscribersFromId($qid, false); $queues = jNews_ListsSubs::getSubscriberLists($subscriberId); $access = jnews::checkPermissions('admin', $my->id); } else { $userId = 0; $queues = ''; $access = false; $subscriberId = 0; $subscriber = new stdClass(); $subscriber->id = ''; $subscriber->user_id = 0; $subscriber->name = ''; $subscriber->email = ''; $subscriber->ip = jNews_Subscribers::getIP(); $subscriber->receive_html = 1; $subscriber->confirmed = 1; $subscriber->blacklist = 0; $subscriber->timezone = '00:00:00'; $subscriber->language_iso = 'eng'; $subscriber->params = ''; $subscriber->subscribe_date = time(); if ($GLOBALS[JNEWS . 'level'] > 2) { //check if the version of jnews is pro $subscriber->column1 = ''; $subscriber->column2 = ''; $subscriber->column3 = ''; $subscriber->column4 = ''; $subscriber->column5 = ''; } } if (!empty($my->user_id)) { if ($my->user_id > 0) { $access = jnews::checkPermissions('admin'); } else { $access = false; } } $query = 'SELECT * FROM `#__jnews_lists` WHERE `published`=1 AND `hidden`=1 '; $db = JFactory::getDBO(); $db->setQuery($query); $lists = $db->loadObjectList(); $doShowSubscribers = false; $mainLink = 'option=' . JNEWS_OPTION; $selectLink = 'option=' . JNEWS_OPTION . '&act=subscriber'; $mainLink = jNews_Tools::completeLink($mainLink, false); $selectLink = jNews_Tools::completeLink($selectLink, false); $forms['main'] = '<form method="post" action="' . $mainLink . '" onsubmit="submitbutton();return false;" name="mosForm" >' . "\n\r"; $forms['select'] = '<form method="post" action="' . $selectLink . '" name="jNewsFilterForm">'; if (empty($access)) { $access = 29; } $html .= jNews_SubscribersHTML::editSubscriber($subscriber, $lists, $queues, $forms, $access, true, true); $html .= '<input type="hidden" name="subscriber_id" value="' . $subscriber->id . '" />'; return $html; }
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; }
public static function _displayQueue($mailingq, $i) { if (empty($mailingq)) { return true; } if (version_compare(JVERSION, '3.0.0', '<')) { $onClickFct = ''; } else { $onClickFct = 'Joomla.'; } foreach ($mailingq as $mailingQ) { ?> <tr class="row<?php echo ($i + 1) % 2; ?> "> <td><center><?php echo $i + 1; ?> </center></td> <td><center><input type="checkbox" id="cid[<?php echo $i; ?> ]" name="cid[<?php echo $i; ?> ]" value="<?php echo $mailingQ->qid; ?> " onclick="<?php echo $onClickFct; ?> isChecked(this.checked);"></center></td> <td><?php $subject = jNews_Mailing::getMailingsSubject($mailingQ->mailing_id); echo $subject; ?> </td> <td><?php $email = jNews_ListsSubs::getSubscriberMail($mailingQ->subscriber_id); echo $email; ?> </td> <td ><div align="center"><?php if ($mailingQ->send_date == 0) { echo '0000-00-00 00:00:00'; } else { echo date('D, d M Y H:i:s', jnews::getNow(0, true, $mailingQ->send_date)); } ?> </div></td> <td><center><?php echo $mailingQ->priority; ?> </center></td> <td><center><?php echo $mailingQ->attempt; ?> </center></td> <td><center><?php echo $mailingQ->suspend; ?> </center></td> <td><center><?php if ($mailingQ->block) { $img = '16/block.png'; ?> <img src="<?php echo JNEWS_PATH_ADMIN_IMAGES2 . $img; ?> " border="0" alt="" /> <?php jnews::getLegend('block.png', _JNEWS_QUEUE_BLOCK); } else { $img = '16/unblock.png'; ?> <img src="<?php echo JNEWS_PATH_ADMIN_IMAGES2 . $img; ?> " border="0" alt="" /> <?php jnews::getLegend('unblock.png', _JNEWS_QUEUE_UNBLOCK); } ?> </center></td> <td><center><?php echo $mailingQ->qid; ?> </center></td> </tr> <?php $i = $i + 1; } }