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 getMailingDropList($listId, $listType, $order) { $lists = ''; $i = 0; $flag = array(); $lists[0] = new stdClass(); $lists[0]->name = _JNEWS_SEL_ALL; $lists[0]->id = '0-0'; $nb = explode(',', $GLOBALS[JNEWS . 'activelist']); $size = sizeof($nb); for ($k = 0; $k < $size; $k++) { $index = $nb[$k]; if ($listType == $index or $GLOBALS[JNEWS . 'listype' . $index] == 1 and $GLOBALS[JNEWS . 'totallist' . $index] > 0) { $i++; $lists[$i] = new stdClass(); $lists[$i]->name = _JNEWS_ALL . ' ' . @constant($GLOBALS[JNEWS . 'listnames' . $index]); $lists[$i]->id = $index . '-0'; $flag[$index] = 0; } } if ($listId > 0) { $i++; $getList = jNews_Lists::getLists($listId, 0, 1, $order, false, false, true); if (empty($getList)) { return; } if (!isset($lists[$i])) { $lists[$i] = new stdClass(); } $lists[$i]->name = $getList[0]->list_name; $lists[$i]->id = $getList[0]->list_type . '-' . $getList[0]->id; } else { if ($listType == 0) { $getLists = jNews_Lists::getLists(0, 0, 1, 'listype_name', false, false, false); } else { $getLists = jNews_Lists::getLists(0, $listType, 1, $order, false, false, false); } foreach ($getLists as $getList) { $size = sizeof($nb); for ($k = 0; $k < $size; $k++) { $index = $nb[$k]; if ($getList->list_type == $index && empty($flag[$index]) && @$GLOBALS[JNEWS . 'listype' . $index] == 1 && @$GLOBALS[JNEWS . 'totallist' . $index] > 0) { $i++; $lists[$i] = new stdClass(); $lists[$i]->name = '-- ' . @constant($GLOBALS[JNEWS . 'listnames' . $index]) . ' --'; $lists[$i]->id = $index . '-0'; $flag[$index] = true; } } if ($GLOBALS[JNEWS . 'listype' . $getList->list_type]) { $i++; $lists[$i] = new stdClass(); $lists[$i]->name = $getList->list_name; $lists[$i]->id = $getList->list_type . '-' . $getList->id; } } } return $lists; }
public static function showPanel($pageUsed = 'main') { $Itemid = JRequest::getInt('Itemid'); if (empty($Itemid)) { $Itemid = $GLOBALS[JNEWS . 'itemidAca']; } $database = JFactory::getDBO(); $acl = JFactory::getACL(); $my = JFactory::getUser(); $ex_groups = array(); $gid = @$GLOBALS[JNEWS . 'list_creatorfe']; if (!empty($my->id)) { if (!empty($my->username)) { $greeting_message = _HI . ' ' . $my->username; } else { $greeting_message = ''; } $doc6 = JFactory::getDocument(); $doc6->addStyleSheet(JNEWS_JPATH_LIVE . '/components/' . JNEWS_OPTION . '/css/menu.css'); $gid = !empty($GLOBALS[JNEWS . 'list_creatorfe']) ? $GLOBALS[JNEWS . 'list_creatorfe'] : 0; frontHTML::FEmenu(); backHTML::controlPanelBottonStart(_JNEWS_UCP_USER_MENU, 'usermenu.png'); switch ($pageUsed) { case 'list': $listId = JRequest::getVar('listid'); // newsletter button // $link = 'option='.JNEWS_OPTION.'&act=mailing&listid='. $listId .'&listype=1&Itemid='.$Itemid; //alex pagination $link = 'option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listId . '&listype=1'; $link = jNews_Tools::completeLink($link, false); backHTML::quickiconButton($link, 'newsletterFE.png', _JNEWS_NEWSLETTER, false, 'all', false); // smart newsletter button // $link = 'option='.JNEWS_OPTION.'&act=mailing&listid='. $listId .'&listype=7&Itemid='.$Itemid; //alex pagination $link = 'option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listId . '&listype=7'; $link = jNews_Tools::completeLink($link, false); backHTML::quickiconButton($link, 'smartnewsletterFE.png', _JNEWS_AUTONEWS, false, 'all', false); break; default: // $link = 'option='.JNEWS_OPTION.'&act=show&Itemid='.$Itemid; //alex pagination $link = 'option=' . JNEWS_OPTION . '&act=show'; $link = jNews_Tools::completeLink($link, false); backHTML::quickiconButton($link, 'my_subscriptions48.png', _JNEWS_UCP_USER_CONTACT, false, 'all', false); //come back here //$proceedToCheck = true; break; } if (class_exists('jNews_Pro')) { $my = JFactory::getUser(); $ownedlists = jNews_Lists::getOwnedlists($my->id); if (version_compare(JVERSION, '1.6.0', '<')) { //j15 $usergid = $my->gid; } else { //j16 $usergid = JAccess::getGroupsByUser($my->id, false); } $ex_groups = explode(',', $gid); if (is_array($usergid)) { $canAccess = array_intersect($usergid, $ex_groups); } if (in_array($usergid, $ex_groups) || !empty($canAccess)) { if ($GLOBALS[JNEWS . 'level'] > 2 && version_compare(JVERSION, '1.6.0', '>')) { // $link = 'option='.JNEWS_OPTION.'&act=list&mid=1&listype=1&Itemid='.$Itemid; //alex pagination $link = 'option=' . JNEWS_OPTION . '&act=list&mid=1&listype=1'; $link = jNews_Tools::completeLink($link, false); backHTML::quickiconButton($link, 'addedit.png', _JNEWS_MENU_LIST, false, 'all', false); } $listId = JRequest::getVar('listid'); $act = JRequest::getVar('act', '', '', 'WORD'); $task = JRequest::getVar('task'); if (empty($listId) || $act == 'mailing' && $task == 'save') { // list button $link = 'option=' . JNEWS_OPTION . '&act=list&listype=1&mid=1&Itemid=' . $Itemid; $link = jNews_Tools::completeLink($link, false); backHTML::quickiconButton($link, 'addedit.png', _JNEWS_MENU_LIST, false, $usergid, false); if (empty($listId)) { if ($GLOBALS[JNEWS . 'enable_jsub']) { if (!empty($my->id)) { $ownedlists = jNews_Lists::getOwnedlists($my->id); } if (!empty($ownedlists)) { $listId = $ownedlists[0]; } else { $listId = jNews_Lists::getIDacclevel(18, $my->id); } } else { $listId = jNews_Lists::getIDacclevel(18, $my->id); } frontHTML::cpanelHTML($listId, $Itemid); } } } else { $lists = jNews_Lists::getLists(0, 0, true); $access = false; $id = 0; if ($GLOBALS[JNEWS . 'enable_jsub']) { if (!empty($my->id)) { $ownedlists = jNews_Lists::getOwnedlists($my->id); } if (!empty($ownedlists)) { $id = $my->id; } } foreach ($lists as $list) { $bit = jnews::checkPermissions($list->acc_level); if ($bit) { $access = true; break; } } $link = 'option=' . JNEWS_OPTION . '&act=list&mid=1&listype=1&Itemid=' . $Itemid; $link = jNews_Tools::completeLink($link, false); if (!empty($my->id)) { $ownedlists = jNews_Lists::getOwnedlists($my->id); } if (empty($listId)) { if ($GLOBALS[JNEWS . 'enable_jsub']) { if (!empty($my->id)) { $ownedlists = jNews_Lists::getOwnedlists($my->id); } if (!empty($ownedlists)) { $listId = $ownedlists[0]; } else { $listId = jNews_Lists::getIDacclevel(18, $my->id); } } else { $listId = jNews_Lists::getIDacclevel(18, $my->id); } } if ($GLOBALS[JNEWS . 'enable_jsub']) { if ($access && !empty($ownedlists)) { backHTML::quickiconButton($link, 'addedit.png', _JNEWS_MENU_LIST, false, 'all', false); frontHTML::cpanelHTML($listId, $Itemid); } } else { $creatorFe = jnews::checkPermissions($gid); //traces if ($access || $creatorFe) { backHTML::quickiconButton($link, 'addedit.png', _JNEWS_MENU_LIST, false, 'all'); frontHTML::cpanelHTML($listId, $Itemid); } } } } else { if ($GLOBALS[JNEWS . 'level'] > 2) { $link = 'option=' . JNEWS_OPTION . '&act=list&mid=1&listype=1&Itemid=' . $Itemid; $link = jNews_Tools::completeLink($link, false); backHTML::quickiconButton($link, 'addedit.png', _JNEWS_MENU_LIST, false, 'all', false); } } backHTML::controlPanelBottomEnd(); if (class_exists('jNews_Auto')) { jNews_Auto::otherPanel(); } } elseif ($GLOBALS[JNEWS . 'show_lists']) { $subscriberId = JRequest::getInt('subscriber'); $subscriber = jNews_Subscribers::getSubscribersFromId(array($subscriberId), false); frontEnd::changeSubscriptions($subscriberId, md5($subscriber->email), '', 'save'); } }
public static function lists($mailingEdit, $list, $show, $lType, $arId, $indicate = false, $isEdit = false) { $mainframe = JFactory::getApplication(); if (!isset($mailingEdit)) { $mailingEdit = new stdClass(); } $listType = JRequest::getVar('listype'); if (!isset($mailingEdit->list_type)) { $mySess = JFactory::getSession(); if (!empty($mySess)) { $mailingEdit->list_type = $mySess->get('listype', '', 'LType'); } } $listType = !empty($listType) ? $listType : $mailingEdit->list_type; $typeList = !empty($listType) && $listType == 2 ? 2 : 1; ?> <div style="padding: 2px;"><span style="font-size: 12px;"><?php if ($lType != 2) { //echo _JNEWS_SUBS_LIST; //}else{ if ($typeList == 2) { echo _JNEWS_SUBS_LIST_CAMPAIGN; } else { echo _JNEWS_SUBS_LIST_LABEL; } //edif } ?> </span></div> <table class="<?php echo jnews::myTheme(); ?> "> <thead> <tr> <th class="title"> # </th> <th class="title"> <?php echo _JNEWS_LIST_NAME; ?> </th> <th class="title" style="min-width:200px;"> <?php echo _JNEWS_SUBS_LIST_RECEIVE; ?> </th> </tr> </thead> <tbody> <?php $my = JFactory::getUser(); $ownedlists = 0; if ($GLOBALS[JNEWS . 'enable_jsub']) { $ownedlists = jNews_Lists::getOwnedlists($my->id); } if (jnews::checkPermissions('admin')) { if ($lType == 2) { $lists = jNews_Lists::getLists('', 1, '', '', false, true, true, false, false); } else { $lists = jNews_Lists::getLists('', $typeList, '', '', false, true, true, false, false); } } else { if ($lType == 2) { $lists = jNews_Lists::getLists('', 1, '', '', false, true, true, false, false, '', '', $ownedlists, $my->id); } else { $lists = jNews_Lists::getLists('', $typeList, '', '', false, true, true, false, false, '', '', $ownedlists, $my->id); } } $k = 0; $i = 0; //$listId=JRequest::getVar('listId'); if (empty($listId)) { $listId = JRequest::getVar('listid'); } $ls = array(); $myKey = null; foreach ($lists as $key => $list) { if ($list->id == $listId) { $myKey = $key; break; } } if (isset($myKey)) { $ls[] = $lists[$myKey]; unset($lists[$myKey]); $lists = array_merge($ls, $lists); } $listsA = array(); if (!$mainframe->isAdmin()) { foreach ($lists as $list) { if (empty($list->params)) { $listsA[] = $list; } } } else { $listsA = $lists; } foreach ($listsA as $list) { ?> <tr class="<?php echo "row{$k}"; ?> "> <td width="5%"> <center> <?php echo $i + 1; ?> </center> </td> <td> <?php $getMailingId = !empty($mailingEdit->id) ? $mailingEdit->id : JRequest::getVar('mailingid'); $result = jNews_Mailing::mailingListFound($getMailingId, $list->id); $result = $result ? 1 : 0; if ($result == 0) { $lstID = JRequest::getVar('listid'); $result = $lstID == $list->id ? 1 : 0; } //check if this view will be displayed upon the creation of new list if ($lType == 2) { $result = jNews_Lists::followupListFound($arId, $list->id); } //public static function booleanlist( $name, $attribs = null, $selected = null, $yes='yes', $no='no', $id=false ) $text = '<b>List ID: </b>' . $list->id; $text .= '<br/>' . str_replace(array("'", '"'), array("'", '"'), $list->list_desc); $title = str_replace(array("'", '"'), array("'", '"'), $list->list_name); //echo jNews_Tools::toolTip( $tip, '', 280, 'tooltip.png', $title, '', 0 ); echo JHTML::_('tooltip', $text, $title, 'tooltip.png', $title); ?> </td> <td width="100px" nowrap="nowrap"> <center> <?php //if the listid in the request is equal to this listid the default value of the radio button should be yes if ($listId == $list->id) { echo jnews::HTML_BooleanList("aca_mailing_addto[" . $list->id . "]", 'class="inputbox"', 1, 'Yes', 'No'); } else { echo jnews::HTML_BooleanList("aca_mailing_addto[" . $list->id . "]", 'class="inputbox"', $result, 'Yes', 'No'); } ?> </center> </td> </tr> <?php $k = 1 - $k; $i++; } if (count($lists > 3)) { ?> <tr> <td colspan="3" align="center" nowrap="nowrap"> <script language="javascript" type="text/javascript"> function updateStatus(statusval){ <?php foreach ($lists as $row) { ?> window.document.getElementById('aca_mailing_addto[<?php echo $row->id; ?> ]'+statusval).checked = true; <?php } ?> } </script> <div style="float:right; font-size: 12px;"><a title="Click to select all list" href="#" onclick="updateStatus(1);"><?php echo _JNEWS_SUBS_LIST_TOALL; ?> </a> | <a href="#" onclick="updateStatus(0);"><?php echo _JNEWS_SUBS_LIST_TONONE; ?> </a></div> </td> </tr> <?php } ?> </tbody> </table> <?php }
/** * This public static function is used by jnews_cb plugin */ public static function updateCBSubscribers($force = false, $install = false) { $db = JFactory::getDBO(); $time = isset($GLOBALS[JNEWS . 'last_sub_update']) && $GLOBALS[JNEWS . 'last_sub_update'] > 0 ? $GLOBALS[JNEWS . 'last_sub_update'] : 200000; $newTask = mktime(date("H") - 1, date("i"), date("s"), date("m"), date("d"), date("Y")); if ($force or $newTask > $GLOBALS[JNEWS . 'last_sub_update']) { $query = 'UPDATE IGNORE `#__jnews_subscribers` as S LEFT JOIN `#__users` AS U ON U.`id` = S.`user_id` SET S.`name` = U.`name`, S.`email` = U.`email`, S.`confirmed` = 1 - U.`block` WHERE U.`id` > 0 AND S.`user_id` > 0'; $db->setQuery($query); $db->query(); $xf = new jNews_Config(); $newtime = mktime(date("H", $time), date("i", $time), date("s", $time), date("m", $time), date("d", $time) - 2, date("Y", $time)); if ($install) { $newtime = 0; } $oneDay = date('Y-m-d H:i:s', $newtime); $query = 'SELECT M.* FROM `#__users` AS M ' . ' LEFT JOIN `#__jnews_subscribers` AS N ON M.email = N.email '; $query .= ' WHERE M.registerDate > \'' . $oneDay . '\''; $query .= ' AND N.id IS NULL AND M.block=0 '; $db->setQuery($query); $rows = $db->loadObjectList(); if (!empty($rows)) { foreach ($rows as $row) { $query = "INSERT INTO `#__jnews_subscribers` (`user_id`,`subscribe_date`, `name`,`email`,`confirmed`)"; $query .= " VALUES ( {$row->id} , '{$row->registerDate}', '" . addslashes($row->name) . "', '" . addslashes($row->email) . "' , 1 ) "; $db->setQuery($query); $db->query(); $xf->plus('totalsubcribers0', 1); $xf->plus('act_totalsubcribers0', 1); $lists = jNews_Lists::getLists(0, 0, null, '', true, false, false); if (!empty($lists)) { foreach ($lists as $list) { $qid[0] = jNews_Subscribers::getSubscriberId($row->registerDate); $subscriber = jNews_Subscribers::getSubscribersFromId($qid, false); $subId = array(); //if ( isset($subscriber->id) ) { //$subId[0] = $subscriber->id; // jNews_Queue::insertQueuesForNews($subId, $list->id, 29 ); ////$subscriberInfo=jNews_ListsSubs::getListidsSubscribedInfo($subscriber->id); //jNews_Queue::updateQueues($subId, '', $list->id, @$list->acc_id, true); // } } } } } $query = 'SELECT M.* FROM `#__jnews_subscribers` AS M ' . ' LEFT JOIN `#__users` AS N ON N.id = M.user_id '; $query .= ' WHERE N.registerDate > \'' . $oneDay . '\''; $query .= ' AND M.subscribe_date > \'' . $oneDay . '\''; $query .= ' AND N.id IS NULL AND M.user_id>0 ORDER BY N.id '; $db->setQuery($query); $rows = $db->loadObjectList(); if (!empty($rows)) { foreach ($rows as $row) { $query = 'DELETE FROM `#__jnews_subscribers` WHERE `id` = ' . $row->id; $db->setQuery($query); $db->query(); $xf->plus('act_totalsubcribers0', -1); jNews_ListsSubs::removeSubscription($row->id, ''); } } $query = 'SELECT N.id, N.name , N.email , N.block FROM `#__users` AS N ' . ' LEFT JOIN `#__jnews_subscribers` AS M ON N.id = M.user_id '; $query .= ' WHERE N.registerDate > \'' . $oneDay . '\''; $query .= ' AND M.subscribe_date > \'' . $oneDay . '\''; $query .= ' AND M.name != N.name OR M.email != N.email OR N.block = M.confirmed '; $db->setQuery($query); $rows = $db->loadObjectList(); if (!empty($rows)) { foreach ($rows as $row) { if ($row->block == 1) { $status = 0; } else { $status = 1; } $query = "UPDATE IGNORE `#__jnews_subscribers` SET `name` ='" . addslashes($row->name) . "' " . ", `email` = '" . addslashes($row->email) . "' " . ", `confirmed` ='" . $status . "' WHERE `user_id` = " . $row->id; $db->setQuery($query); $db->query(); } } $query = 'SELECT N.id , N.email FROM `#__users` AS N '; $query .= 'LEFT JOIN `#__jnews_subscribers` AS M ON N.email = M.email '; $query .= ' WHERE N.registerDate > \'' . $oneDay . '\''; $query .= ' AND M.subscribe_date > \'' . $oneDay . '\''; $query .= ' AND M.user_id = 0 AND N.block = 0 '; $db->setQuery($query); $rows = $db->loadObjectList(); if (!empty($rows)) { foreach ($rows as $row) { $query = "UPDATE `#__jnews_subscribers` AS S SET `user_id` = " . $row->id; $query .= " WHERE S.email = '{$row->email}'"; $db->setQuery($query); } } $xf->update('last_sub_update', time()); return true; } }
public static function showSubscribers($subscribers, $action, $listId, &$lists, $start, $limit, $total, $showAdmin, $theLetterId, $emailsearch, $forms, $setLimit = null, $front = false, $setSort = null) { $my = JFactory::getUser(); $mainframe = JFactory::getApplication(); ?> <script language="javascript" type="text/javascript"> //<!-- function jnewsletterselectall(){ var i = 0; allcheck = document.getElementById("selectallcheck"); if(allcheck.checked) checkedvalue = 1; else checkedvalue = 0; while(myelement = document.getElementById("cid["+i+"]")){ myelement.checked = checkedvalue; i++; } if(checkedvalue){ document.getElementById("boxcount").value = i; }else{ document.getElementById("boxcount").value = 0; } } //--> </script> <?php if ($listId == 0) { $message = _JNEWS_SUSCRIB_LIST; } else { $lt_name = jNews_Lists::getLists($listId, 0, null, '', false, false, true); $message = _JNEWS_SUSCRIB_LIST_UNIQUE . "<span style='color: rgb(51, 51, 51);'>" . @$lt_name[0]->list_name . "</span>"; } $filter = _JNEWS_SEL_LIST . ' ' . $lists['listid'] . ' ' . $lists['subscirberType']; $hidden = '<input type="hidden" name="listid" value="' . $listId . '" />'; $hidden .= '<input type="hidden" name="limit" value="' . $limit . '" />'; $pos = strpos($forms['main'], "<form"); if ($pos !== false) { $forms['select'] = ""; } echo $forms['main']; // top portion before the table list // for search $toSearch = new stdClass(); $toSearch->forms = $forms['select']; $toSearch->hidden = $hidden; $toSearch->listsearch = $emailsearch; $toSearch->id = 'emailsearch'; echo jnews::setTop($toSearch, $message, $setLimit, $filter); ?> <table class="<?php echo jnews::myTheme(); ?> "> <thead> <tr> <th class="title">#</th> <th class="title"><input type="checkbox" id="selectallcheck" name="allchecked" onclick="jnewsletterselectall();"/></th> <th class="title"><?php echo jnews::HTML_GridSort(_JNEWS_INPUT_NAME, 'name', $setSort->orderDir, $setSort->orderValue); ?> </th> <?php if ($mainframe->isAdmin()) { ?> <th class="title"><?php echo jnews::HTML_GridSort(_JNEWS_INPUT_EMAIL, 'email', $setSort->orderDir, $setSort->orderValue); ?> </th> <?php } else { if ($GLOBALS[JNEWS . 'show_sub_email']) { ?> <th class="title"><?php echo jnews::HTML_GridSort(_JNEWS_INPUT_EMAIL, 'email', $setSort->orderDir, $setSort->orderValue); ?> </th> <?php } } //endelse if ($mainframe->isAdmin()) { ?> <th class="title"><?php echo jnews::HTML_GridSort(_JNEWS_SIGNUP_DATE, 'subscribe_date', $setSort->orderDir, $setSort->orderValue); ?> </th> <?php } ?> <th class="title"><center><?php echo jnews::HTML_GridSort(_JNEWS_REGISTERED, 'user_id', $setSort->orderDir, $setSort->orderValue); ?> </center></th> <th class="title"><center><?php echo jnews::HTML_GridSort(_JNEWS_CONFIRMED, 'confirmed', $setSort->orderDir, $setSort->orderValue); ?> </center></th> <th class="title"><center><?php echo jnews::HTML_GridSort(_JNEWS_HTML, 'receive_html', $setSort->orderDir, $setSort->orderValue); ?> </center></th> <?php if ($GLOBALS[JNEWS . 'level'] > 2) { //check if the version of jnewsletter is pro if ($GLOBALS[JNEWS . 'show_column1'] == 1) { ?> <th class="title"><center><?php echo $GLOBALS[JNEWS . 'column1_name']; } //<!--/center></th><!--column 1 in the subscribers list-BE--> if ($GLOBALS[JNEWS . 'show_column2'] == 1) { ?> <th class="title"><center><?php echo $GLOBALS[JNEWS . 'column2_name']; } if ($GLOBALS[JNEWS . 'show_column3'] == 1) { ?> <th class="title"><center><?php echo $GLOBALS[JNEWS . 'column3_name']; } if ($GLOBALS[JNEWS . 'show_column4'] == 1) { ?> <th class="title"><center><?php echo $GLOBALS[JNEWS . 'column4_name']; } if ($GLOBALS[JNEWS . 'show_column5'] == 1) { ?> <th class="title"><center><?php echo $GLOBALS[JNEWS . 'column5_name']; } } if (jnews::checkPermissions('admin')) { ?> <th class="title"><?php echo jnews::HTML_GridSort('ID', 'id', $setSort->orderDir, $setSort->orderValue); ?> </th> <?php } ?> </tr> </thead> <?php $i = 0; if (!empty($subscribers)) { if (version_compare(JVERSION, '3.0.0', '<')) { $onClickFct = ''; } else { $onClickFct = 'Joomla.'; } foreach ($subscribers as $subscriber) { $subscriber->email = trim($subscriber->email); if (!jNews_Subscribers::validEmail($subscriber->email)) { continue; } if ($subscriber->user_id != 0) { $img = '16/status_g.png'; $alt = 'Registered'; jnews::getLegend('status_g.png', _JNEWS_REGISTERED . '/' . _JNEWS_CONFIRMED); } else { $img = '16/status_r.png'; $alt = 'Unregistered'; jnews::getLegend('status_r.png', _JNEWS_SUBSCRIBERS_UNREGISTERED . '/' . _JNEWS_PIE_UNCONFIRMED); } //endelse if ($subscriber->confirmed == 1) { $imgC = '16/status_g.png'; $altC = 'Confirmed'; jnews::getLegend('status_g.png', _JNEWS_REGISTERED . '/' . _JNEWS_CONFIRMED); } else { $imgC = '16/status_r.png'; $altC = 'Not confirmed'; jnews::getLegend('status_r.png', _JNEWS_SUBSCRIBERS_UNREGISTERED . '/' . _JNEWS_PIE_UNCONFIRMED); } //endelse if ($subscriber->receive_html == 1) { $imgH = '16/status_g.png'; $altH = 'HTML'; jnews::getLegend('status_g.png', _JNEWS_REGISTERED . '/' . _JNEWS_CONFIRMED); } else { $imgH = '16/status_r.png'; $altH = 'TEXT'; jnews::getLegend('status_r.png', _JNEWS_SUBSCRIBERS_UNREGISTERED . '/' . _JNEWS_PIE_UNCONFIRMED); } //endelse ?> <tr class="row<?php echo ($i + 1) % 2; ?> "> <td><center><?php echo $i + 1 + $start; ?> </center></td> <td> <center><input type="checkbox" id="cid[<?php echo $i; ?> ]" name="cid[<?php echo $i; ?> ]" value="<?php echo $subscriber->id; ?> " onclick="<?php echo $onClickFct; ?> isChecked(this.checked);" /></center> </td> <td> <?php if (!$front) { $href = "index.php?option=" . JNEWS_OPTION . "&act=" . $action . "&task=show&userid=" . $subscriber->id; } else { $link = "option=" . JNEWS_OPTION . "&act=" . $action . "&task=show&userid=" . $subscriber->id; $href = jNews_Tools::completeLink($link, false, true); } ?> <a href=<?php echo $href; ?> > <?php echo $subscriber->name; ?> </a> </td> <?php if (!jNews_Subscribers::validEmail($subscriber->email)) { $subscriber->email = ''; } if ($mainframe->isAdmin()) { ?> <td><?php echo $subscriber->email; ?> </td> <?php } else { if ($GLOBALS[JNEWS . 'show_sub_email']) { ?> <td><?php echo $subscriber->email; ?> </td> <?php } } //endelse if ($mainframe->isAdmin()) { ?> <td><div align="center"> <?php echo date('D, d M Y H:i:s', jnews::getNow(0, true, $subscriber->subscribe_date)); } ?> </div></td> <td align="center"> <img src="<?php echo JNEWS_PATH_ADMIN_IMAGES2 . $img; ?> " width="12" height="12" border="0" alt="<?php echo $alt; ?> " /> </td> <td align="center"> <a href="<?php echo jnews::createToggleLink('subscribers', 'confirmed', 'subid', $subscriber->id, 'toggle', $listId); ?> "> <img src="<?php echo JNEWS_PATH_ADMIN_IMAGES2 . $imgC; ?> " width="12" height="12" border="0" alt="<?php echo $altC; ?> " /> </a> </td> <td align="center"> <a href="<?php echo jnews::createToggleLink('subscribers', 'receive_html', 'subid', $subscriber->id, 'toggle', $listId); ?> "> <img src="<?php echo JNEWS_PATH_ADMIN_IMAGES2 . $imgH; ?> " width="12" height="12" border="0" alt="<?php echo $altH; ?> " /> </a> </td> <?php $i++; ?> <?php if ($GLOBALS[JNEWS . 'level'] > 2) { //check if the version of jnewsletter is 5.0.2 if ($GLOBALS[JNEWS . 'show_column1'] == 1) { ?> <!--check to show/hide column 1 data in the subscribers list--> <td align="center"> <!--data for column1--> <?php echo $subscriber->column1; } ?> </td> <?php if ($GLOBALS[JNEWS . 'show_column2'] == 1) { ?> <!--check to show/hide column 2 data in the subscribers list--> <td align="center"> <!--data for column1--> <?php echo $subscriber->column2; } ?> </td> <?php if ($GLOBALS[JNEWS . 'show_column3'] == 1) { ?> <!--check to show/hide column 3 data in the subscribers list--> <td align="center"> <!--data for column3--> <?php echo $subscriber->column3; } ?> </td> <?php if ($GLOBALS[JNEWS . 'show_column4'] == 1) { ?> <!--check to show/hide column 4 data in the subscribers list--> <td align="center"> <!--data for column4--> <?php echo $subscriber->column4; } ?> </td> <?php if ($GLOBALS[JNEWS . 'show_column5'] == 1) { ?> <!--check to show/hide column 5 data in the subscribers list--> <td align="center"> <!--data for column5--> <?php echo $subscriber->column5; } } //end check of version if (jnews::checkPermissions('admin')) { echo '<td align="center">' . $subscriber->id . '</td>'; } ?> </td> <?php } } ?> </tr> </table> <input type="hidden" name="option" value="<?php echo JNEWS_OPTION; ?> " /> <input type="hidden" name="act" value="<?php echo $action; ?> " /> <input type="hidden" name="task" value="" /> <input type="hidden" name="userid" value="" /> <input type="hidden" name="filter_order" value="<?php echo $setSort->orderValue; ?> " /> <input type="hidden" name="filter_order_Dir" value="<?php echo $setSort->orderDir; ?> " /> <input type="hidden" id="boxcount" name="boxchecked" value="0" /> <?php if (version_compare(JVERSION, '3.0.0', '<')) { echo JHTML::_('form.token'); } else { echo JHtml::_('form.token'); } ?> </form> <?php echo '<br />'; echo jnews::setLegend(); }
public static function showMailingsFront($task, $action, $subscriberId, $listId, $listType = '', $viewArchive, $pageTile) { $Itemid = JRequest::getInt('Itemid'); if (empty($Itemid)) { $Itemid = $GLOBALS[JNEWS . 'itemidAca']; } $gidAdmins = array(24, 25, 7, 8); $my = JFactory::getUser(); if (version_compare(JVERSION, '1.6.0', '>=')) { //j16 $usergid = JAccess::getGroupsByUser($my->id, false); $my->gid = $usergid[0]; } $start = JRequest::getVar('start', '0'); if (!$start) { $start = JRequest::getVar('limitstart', '0'); } JRequest::setVar('limitstart', $start); $emailsearch = JRequest::getVar('emailsearch', '', '', 'STRING'); $emailsearch = htmlentities($emailsearch, ENT_COMPAT, "UTF-8"); $obj_for_order = new stdClass(); if (version_compare(JVERSION, '3.0.0', '>=')) { //j16 //alex filter if ($action === 'mailing') { $order = JRequest::getVar('filter_order', 'send_date'); $obj_for_order->orderValue = $order; $obj_for_order->orderDir = JRequest::getVar('filter_order_Dir', 'desc'); } else { $order = JRequest::getVar('filter_order', 'id'); $obj_for_order->orderValue = $order; $obj_for_order->orderDir = JRequest::getVar('filter_order_Dir', 'asc'); } } else { $order = JRequest::getVar('order', 'sendDateD'); } $dropList = JRequest::getVar('droplist', 'ZZZZ'); $my = JFactory::getUser(); $accessGrant = false; $limit = JRequest::getInt('limit'); if (empty($limit) || $limit > 100) { $limit = 20; } $total = 0; if ($dropList == 'ZZZZ') { $dropList = $listType . '-' . $listId; } $total = 0; $dropListValues = explode('-', $dropList); $listType = $dropListValues[0]; $listId = $dropListValues[1]; $id = 0; if ($GLOBALS[JNEWS . 'enable_jsub']) { if (!empty($my->id)) { $ownedlists = jNews_Lists::getOwnedlists($my->id); } if (!empty($ownedlists)) { $id = $my->id; } } $allowed = false; if (class_exists('jNews_Pro') && $listId > 0) { $list = jNews_Lists::getOneList($listId); $allowed = jnews::checkPermissions($list->acc_level); } elseif (class_exists('jNews_Pro') && empty($listId)) { //check all list $myQ = 'SELECT `acc_level` FROM `#__jnews_lists` '; $db = JFactory::getDBO(); $db->setQuery($myQ); $listsAccessHere = $db->loadObjectList(); $allowed = false; if (!empty($listsAccessHere)) { foreach ($listsAccessHere as $oneAcessL) { if (jnews::checkPermissions($oneAcessL->acc_level)) { $allowed = true; break; } } //endfoerach } } else { $allowed = in_array($my->gid, $gidAdmins); } if (!empty($my->id)) { $ownedlists = jNews_Lists::getOwnedlists($my->id); } $accessGrant = !empty($ownedlists) ? true : $allowed; if ($accessGrant || $GLOBALS[JNEWS . 'level'] > 2) { //we don't filter the newsletters by lists yet - 8889955 if ($task === "archive") { $listType_old = $listType; $listType = 1; } if (empty($listType)) { $listType = 1; } $mailings = jNews_Mailing::getMailings($listId, $listType, $start, $limit, $emailsearch, $order, false, $viewArchive, $obj_for_order); $total = count(jNews_Mailing::getMailings($listId, $listType, '0', '100000000', $emailsearch, $order, false, $viewArchive, $obj_for_order)); if ($task === "archive") { $listType = $listType_old; } } else { if ($listType == 1 || $listType == 2 || $listType == 7) { $mailings = jNews_Mailing::getMailings($listId, $listType, $start, $limit, $emailsearch, $order, true, $viewArchive, $obj_for_order); $total = count(jNews_Mailing::getMailings($listId, $listType, '0', '100000000', $emailsearch, $order, true, $viewArchive, $obj_for_order)); } elseif ($listType == 0) { $mailings1 = jNews_Mailing::getMailings($listId, 1, $start, $limit, $emailsearch, $order, true, $viewArchive, $obj_for_order); $mailings2 = jNews_Mailing::getMailings($listId, 2, $start, $limit, $emailsearch, $order, true, $viewArchive, $obj_for_order); $mailings7 = jNews_Mailing::getMailings($listId, 7, $start, $limit, $emailsearch, $order, true, $viewArchive, $obj_for_order); $mailings = array_merge($mailings1, $mailings2, $mailings7); $totalmailings1 = jNews_Mailing::getMailings($listId, 1, '0', '100000000', $emailsearch, $order, true, $viewArchive, $obj_for_order); $totalmailings2 = jNews_Mailing::getMailings($listId, 2, '0', '100000000', $emailsearch, $order, true, $viewArchive, $obj_for_order); $totalmailings7 = jNews_Mailing::getMailings($listId, 7, '0', '100000000', $emailsearch, $order, true, $viewArchive, $obj_for_order); $totalmailings = array_merge($totalmailings1, $totalmailings2, $totalmailings7); $total = count($totalmailings); } else { $mailings = ''; } } if ($listId == 0) { $lists['title'] = jNews_ListType::chooseType($task, $action, $listType, 'titles', '', _JNEWS_MENU_MAILING); } else { $listing = jNews_Lists::getLists($listId, 0, $subscriberId, '', false, false, true); $listType = $listType > 0 ? $listType : '0'; $lists['title'] = _JNEWS_NEWSLETTER_ARCHIVE; } //we check if the user has access to addedit mailing to a list if (version_compare(JVERSION, '1.6.0', '<')) { $listsAddEdit = jNews_Lists::getIDswithacclevel($my->gid, $listId); } else { $groups = JAccess::getGroupsByUser($my->id); $listsAddEdit = jNews_Lists::getIDswithacclevel($groups, $listId); } $haveaccesstoList = true; $gid = !empty($GLOBALS[JNEWS . 'list_creatorfe']) ? $GLOBALS[JNEWS . 'list_creatorfe'] : 0; if (!$allowed && empty($listsAddEdit) && !empty($my->id) && !jnews::checkPermissions('admin') && !jnews::checkPermissions($gid)) { $haveaccesstoList = false; } if ($haveaccesstoList) { $dropDownList = jNews_ListType::getMailingDropList($listId, $listType, 'idA'); // $order if (!empty($dropDownList)) { $lists['droplist'] = jnews::HTML_GenericList($dropDownList, 'droplist', 'class="inputbox" size="1" onchange="document.jNewsFilterForm.submit();"', 'id', 'name', $dropList); } } $linkMain = 'index.php?option=' . JNEWS_OPTION . '&act=' . $action; $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION); //alex pagination if (!empty($task)) { $mainLink .= '&task=' . $task; } if (!empty($action)) { $mainLink .= '&act=' . $action; } if (!empty($listType)) { $mainLink .= '&listype=' . $listType; } if (!empty($listId)) { $mainLink .= '&listid=' . $listId; } $forms['main'] = '<form method="post" action="' . $mainLink . '" enctype="multipart/form-data" onsubmit="submitbutton();return false;" name="adminForm" id="adminForm">' . "\n\r"; $forms['select'] = '<form method="post" action="' . $linkMain . '" name="jNewsFilterForm">' . "\n\r"; $forms['main'] .= '<input type="hidden" name="Itemid" value="' . $Itemid . '" />'; $forms['select'] .= '<input type="hidden" name="Itemid" value="' . $Itemid . '" />'; $show = jNews_ListType::showType($listType, 'showMailings'); $show['index'] = 'index'; $show['select'] = false; $show['send'] = false; $show['buttons'] = true; if (class_exists('jNews_Pro') && !$viewArchive) { $show['admin'] = true; $show['status'] = true; } $mailingType = $listType == 7 ? 1 : $listType; $db = JFactory::getDBO(); $query = 'SELECT * FROM `#__jnews_lists` WHERE `hidden` = 1 AND `published` = 1 AND '; if (is_array($mailingType)) { $query .= ' `list_type` IN (' . jnews::implode(',', $mailingType) . ') '; } else { $query .= ' `list_type`=' . intval($mailingType); } $db->setQuery($query); $lists = $db->loadObjectList(); $access = false; foreach ($lists as $list) { $bit = jnews::checkPermissions($list->acc_level); if ($bit) { $access = true; break; } } $menuA = null; if ($my->id > 0 && jnews::checkPermissions('all') && $haveaccesstoList) { if ($GLOBALS[JNEWS . 'level'] > 2) { if ((empty($ownedlists) || !in_array($my->gid, $gidAdmins)) && !$access) { $accessGrant = false; } else { $accessGrant = true; } if ($accessGrant) { $show['select'] = true; $show['send'] = true; // menu new $link = 'option=' . JNEWS_OPTION . '&act=mailing&task=new&listid=' . $listId . '&listype=' . $listType . '&Itemid=' . $Itemid; $link = jNews_Tools::completeLink($link, false); $menuNew = new stdClass(); $menuNew->popup = new stdClass(); $menuNew->popup->isPop = false; $menuNew->link = '#'; $menuNew->action = 'new'; $menuNew->onclick = new stdClass(); $menuNew->onclick->custom = false; $menuNew->onclick->js = ''; $menuNew->title = _JNEWS_NEW; //menu edit $menuEdit = new stdClass(); $menuEdit->popup = new stdClass(); $menuEdit->popup->isPop = false; $menuEdit->link = '#'; $menuEdit->action = 'edit'; $menuEdit->onclick = new stdClass(); $menuEdit->onclick->custom = false; $menuEdit->onclick->js = ''; $menuEdit->title = _JNEWS_MENU_EDIT; //menu delete $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; $menuPreview = new stdClass(); $menuPreview->popup = new stdClass(); $menuPreview->popup->isPop = false; $menuPreview->link = '#'; $menuPreview->action = 'preview'; $menuPreview->onclick = new stdClass(); $menuPreview->onclick->custom = true; $menuPreview->onclick->js = 'javascript:if(document.adminForm.boxchecked.value==0){alert(\'Please make a selection from the mailings to preview\');}else{ submitbutton(\'preview\')}'; $menuPreview->title = 'Preview'; $menuCopy = new stdClass(); $menuCopy->popup = new stdClass(); $menuCopy->popup->isPop = false; $menuCopy->link = '#'; $menuCopy->action = 'copy'; $menuCopy->onclick = new stdClass(); $menuCopy->onclick->custom = false; $menuCopy->onclick->js = ''; $menuCopy->title = 'Copy'; $menuUnpub = new stdClass(); $menuUnpub->popup = new stdClass(); $menuUnpub->popup->isPop = false; $menuUnpub->link = '#'; $menuUnpub->action = 'unpublished'; $menuUnpub->onclick = new stdClass(); $menuCopy->onclick->custom = false; $menuUnpub->onclick->js = ''; $menuUnpub->title = 'Unpublished'; $menuDivider = new stdClass(); $menuDivider->divider = true; } else { $menuNew = new stdClass(); $menuEdit = new stdClass(); $menuDelete = new stdClass(); $menuCopy = new stdClass(); $menuUnpub = new stdClass(); $menuSend = new stdClass(); $menuPreview = new stdClass(); $menuDivider = new stdClass(); } } else { $menuNew = new stdClass(); $menuEdit = new stdClass(); $menuDelete = new stdClass(); $menuCopy = new stdClass(); $menuUnpub = new stdClass(); $menuSend = new stdClass(); $menuPreview = new stdClass(); $menuDivider = new stdClass(); } // menu cpanel $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 = true; $menuCpanel->onclick->js = "javascript: submitbutton('cpanel')"; $menuCpanel->title = _JNEWS_MENU_CPANEL; $menuA = array(); if ($listType != 7) { $menuA['unpublished'] = $menuUnpub; } $menuA['preview'] = $menuPreview; $menuA['new'] = $menuNew; $menuA['edit'] = $menuEdit; if ($listType != 7) { $menuA['copy'] = $menuCopy; } $menuA['delete'] = $menuDelete; // $menuA['divider1'] = $menuDivider; } //menu back if ($listType == 2) { $link = 'option=' . JNEWS_OPTION . '&act=list&Itemid=' . $Itemid; } $link = 'option=' . JNEWS_OPTION . '&Itemid=' . $Itemid; $link = jNews_Tools::completeLink($link, false, false); $menuBack = new stdClass(); $menuBack->popup = new stdClass(); $menuBack->popup = new stdClass(); $menuBack->popup->isPop = false; $menuBack->link = $link; $menuBack->action = 'back'; $menuBack->onclick = new stdClass(); $menuBack->onclick->custom = false; $menuBack->onclick->js = ''; $menuBack->title = _JNEWS_MENU_BACK; $menuBack = new stdClass(); $menuA['cpanel'] = $menuBack; $title = !empty($lists['title']) ? $lists['title'] : ''; if (in_array($my->gid, $gidAdmins) or !empty($ownedlists) or $accessGrant) { if ($listType == 1) { $title = 'Newsletters'; } if ($listType == 7) { $title = 'Smart-Newsletters'; } if ($listType == 2) { $title = 'Auto-responders'; } } $app = JFactory::getApplication(); $setSort = new stdClass(); if ($listType == '2') { //autoresponder $key = JNEWS_OPTION . '.mailing2'; $column = 'delay'; $direction = 'asc'; } elseif ($listType == '7') { //smartnewsletter $key = JNEWS_OPTION . '.mailing7'; $column = 'id'; $direction = 'desc'; } else { //newsletter $key = JNEWS_OPTION . '.mailing1'; $column = 'send_date'; $direction = 'desc'; } $setSort->orderValue = $app->getUserStateFromRequest($key . 'filter_order', 'filter_order', $column, 'cmd'); $setSort->orderDir = $app->getUserStateFromRequest($key . 'filter_order_Dir', 'filter_order_Dir', $direction, 'word'); $setLimit = new stdClass(); $setLimit->start = $start; $setLimit->end = $limit; $setLimit->total = $total; frontHTML::formStart($title, 0, 'show_mailing', $menuA); frontHTML::FEmenu(); jNews_MailingsHTML::showMailingList($mailings, $lists, $start, $limit, $total, $emailsearch, $listId, $listType, $forms, $show, $action, $setLimit, $setSort); $go[] = jnews::makeObj('filter_order', $setSort->orderValue); $go[] = jnews::makeObj('filter_order_Dir', $setSort->orderDir); backHTML::formEnd($go); return true; }
public static function NEWMAILING() { JToolBarHelper::custom('apply', 'apply.png', 'apply.png', 'JTOOLBAR_APPLY', false); JToolBarHelper::custom('save', 'save.png', 'save.png', 'JTOOLBAR_SAVE', false); JToolBarHelper::custom('show', 'cancel.png', 'cancel.png', _JNEWS_MENU_CANCEL, false); JToolBarHelper::divider(); $mailingID = JRequest::getInt('mailingid', '', 'request'); $bar = JToolBar::getInstance('toolbar'); $doc = JFactory::getDocument(); if (empty($mailingID) || $mailingID < 1) { $css = 'span.icon-32-acatemplate {background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'toolbar/templates.png)}'; $doc->addStyleDeclaration($css, $type = 'text/css'); $bar->appendButton('Popup', 'acatemplate', _JNEWS_TEMPLATE, jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=templates&task=assign', true, false, true)); JToolBarHelper::divider(); } $listype = JRequest::getInt('listype', 0); $css = 'span.icon-32-acatags {background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'toolbar/tag.png)}'; $doc->addStyleDeclaration($css, $type = 'text/css'); if ($listype == 7) { $catid = JRequest::getVar('cat_id', 0, 'request'); if (empty($mailingID) || $mailingID < 1) { $link = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=tags&listype=' . $listype . '&cat_id=' . $catid . '&new=1', true, false, true); } else { $delaymax = JRequest::getInt('delay_max', 0, 'request'); $notifyID = JRequest::getInt('notify_id', 0, 'request'); $link = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=tags&listype=' . $listype . '&cat_id=' . $catid . '&delay_max=' . $delaymax . '¬ify_id=' . $notifyID, true, false, true); } } else { $link = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=tags&listype=' . $listype, true, false, true); } $bar->appendButton('Popup', 'acatags', _JNEWS_MENU_TAG, $link); JToolBarHelper::divider(); JToolBarHelper::custom('savePreview', 'share.png', 'share.png', _JNEWS_MENU_PREVIEW, false); if (empty($listype)) { $droplistW = JRequest::getVar('droplist', ''); $maliste = explode('-', $droplistW); if (!empty($maliste[0])) { $listype = $maliste[0]; } else { $listidW = JRequest::getVar('listid', 0); $maliste = jNews_Lists::getLists($listidW, 0, null, 'listnameA', false, false, false, false); $listype = $maliste[0]->list_type; } } JToolBarHelper::divider(); $docLink = $listype == '7' ? 'edit-smart-newsletter' : 'edit-newsletter'; jNews_Menu::_wizardBtn($docLink); }
public static function showMailings($task, $action, $listId, $listType, $message, $showHeader, $title, $setLimit = null) { $start = JRequest::getVar('start', '0'); $emailsearch = JRequest::getVar('emailsearch', '', '', 'STRING'); $emailsearch = htmlentities($emailsearch, ENT_COMPAT, "UTF-8"); $dropList = JRequest::getVar('droplist', 'ZZZZ'); $limit = -1; if ($dropList == 'ZZZZ') { $dropList = $listType . '-' . $listId; } $total = 0; $dropListValues = explode('-', $dropList); $listType = $dropListValues[0]; $listId = $dropListValues[1]; // if ( $listId>0 ) $listTypeM = 0; // else $listTypeM = $listType; $listTypeM = $listType; $orddef = 'idD'; if ($listType == 2) { $orddef = 'idA'; } $order = JRequest::getVar('order', $orddef); if ($listId == 0) { $lists['title'] = jNews_ListType::chooseType($task, $action, $listType, 'titles', '', $title); } else { $listing = jNews_Lists::getLists($listId, 0, 1, '', false, false, true); $lists['title'] = $title . "<span style='color: rgb(51, 51, 51);'>" . $listing[0]->list_name . "</span>"; } $app = JFactory::getApplication(); if ($listType == '2') { //autoresponder $key = JNEWS_OPTION . '.mailing2'; $column = 'id'; $direction = 'desc'; } elseif ($listType == '7') { //smartnewsletter $key = JNEWS_OPTION . '.mailing7'; $column = 'id'; $direction = 'desc'; } else { //newsletter $key = JNEWS_OPTION . '.mailing1'; $column = 'id'; $direction = 'desc'; } $setSort = new stdClass(); $setSort->orderValue = $app->getUserStateFromRequest($key . 'filter_order', 'filter_order', $column, 'cmd'); $setSort->orderDir = $app->getUserStateFromRequest($key . 'filter_order_Dir', 'filter_order_Dir', $direction, 'word'); $dropDownList = jNews_ListType::getMailingDropList($listId, $listType, $order); if (!empty($dropDownList)) { $lists['droplist'] = jnews::HTML_GenericList($dropDownList, 'droplist', 'class="inputbox" size="1" onchange="document.jNewsFilterForm.submit();"', 'id', 'name', $dropList); } $mailings = jNews_Mailing::getMailings($listId, $listTypeM, $setLimit->start, $setLimit->end, $emailsearch, $order, false, false, $setSort); //recheck limit total [pagination] if (isset($setLimit->total) && !empty($emailsearch)) { $mails = jNews_Mailing::getMailings($listId, $listTypeM, 0, 0, $emailsearch, $order, false, false); $setLimit->total = !empty($mails) ? count($mails) : $setLimit->total; } $forms['main'] = "<form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; $forms['select'] = "<form action='index.php' method='post' name='jNewsFilterForm'>"; $show = jNews_ListType::showType($listType, 'showMailings'); if ($showHeader) { jNews_Mailing::_header($task, $action, $listType, $message, ''); } backHTML::formStart('show_mailing', 0, ''); jNews_MailingsHTML::showMailingList($mailings, $lists, $setLimit->start, $setLimit->end, $setLimit->total, $emailsearch, $listId, $listType, $forms, $show, $action, $setLimit, $setSort); $go[] = jnews::makeObj('act', 'mailing'); $go[] = jnews::makeObj('filter_order', $setSort->orderValue); $go[] = jnews::makeObj('filter_order_Dir', $setSort->orderDir); backHTML::formEnd($go); }
public static function controlPanel() { unset($GLOBALS["task"]); unset($_REQUEST["task"]); $doc = JFactory::getDocument(); $doc->addStyleSheet(JNEWS_URL_ADMIN . 'cssadmin/jnews.css'); ?> <div align="center" class="centermain"> <div id="jnews"> <table class=""> <tr> <td width="58%" valign="top"> <?php echo backHTML::iconsPanel(); ?> </td> <td width="42%" valign="top"> <div style="width=100%;"> <script type="text/javascript"> function checkcid(myField) { myField.checked = true; isChecked(true); } </script> <form action="index.php" method="post" name="adminForm" id="adminForm"> <input type="hidden" name="option" value="<?php echo JNEWS_OPTION; ?> " /> <input type="hidden" name="act" value="jnews" /> <input type="hidden" name="task" value="" /> <input type="hidden" name="userid" value="" /> <input type="hidden" name="boxchecked" value="0" /> <?php $tabs = new MosTabsjNews(1); $tabs->startPane('acaControlPanel'); $tabs->startTab(_JNEWS_MENU_TAB_SUM, "acaControlPanel.Summary"); ?> <table class="<?php echo jnews::myTheme(); ?> "> <tbody> <thead> <tr> <th class="title" style="text-align: center;"><?php echo '#'; ?> </th> <th class="title" style="text-align: center;"><?php echo _JNEWS_MENU_TAB_LIST; ?> </th> <th class="title" style="text-align: center;"><?php echo _JNEWS_MENU_MAILING_TITLE; ?> </th> </tr> </thead> <?php $html = ''; $totalist = 0; $totalmail = 0; $totalsub = $GLOBALS[JNEWS . 'act_totalsubcribers0']; $totalsent = 0; $nb = explode(',', $GLOBALS[JNEWS . 'activelist']); $size = sizeof($nb); $countOfLists[1] = jNews_Lists::countLists(1); $countOfLists[2] = jNews_Lists::countLists(2); $countOfLists[7] = jNews_Mailing::countMails(7, true); $countOfMailings[1] = jNews_Mailing::countMails(1); $countOfMailings[2] = jNews_Mailing::countMails(2); $countOfMailings[7] = jNews_Mailing::countMails(7); for ($i = 0; $i < $size; $i++) { $index = $nb[$i]; if ($GLOBALS[JNEWS . 'listshow' . $index] > 0 and $GLOBALS[JNEWS . 'listype' . $index] == 1) { $row = ($i + 1) % 2; $html .= '<tr class="row' . $row . '">'; $html .= '<td><b>' . @constant($GLOBALS[JNEWS . 'listnames' . $index]) . '</b></td>'; // $html .= '<td style="text-align: center; ">' .$GLOBALS[JNEWS.'act_totallist'.$index].'1 </td>'; $html .= '<td style="text-align: center; ">' . $countOfLists[$index] . ' </td>'; //if the value to be is less than 0 we will display 0 if ($GLOBALS[JNEWS . 'act_totalmailing' . $index] > 0) { // $html .= '<td style="text-align: center; ">' .$GLOBALS[JNEWS.'act_totalmailing'.$index].' </td>'; $html .= '<td style="text-align: center; ">' . $countOfMailings[$index] . ' </td>'; } else { $html .= '<td style="text-align: center; ">0</td>'; } // $html .= '<td style="text-align: center; ">' .$GLOBALS[JNEWS.'totalmailingsent'.$index].' </td>'; $html .= '</tr>'; // $totalist = $totalist + $GLOBALS[JNEWS.'act_totallist'.$index]; $totalist = array_sum($countOfLists); // $totalmail = $totalmail + $GLOBALS[JNEWS.'act_totalmailing'.$index]; $totalmail = array_sum($countOfMailings); $totalsent = $totalsent + $GLOBALS[JNEWS . 'totalmailingsent' . $index]; if ($GLOBALS[JNEWS . 'act_totalsubcribers' . $index] > $totalsub) { $totalsub = $GLOBALS[JNEWS . 'act_totalsubcribers' . $index]; } } } $html .= '<tr>'; $html .= '<td style="background-color: #CCFFFF;"><b>' . _JNEWS_CP_TOTAL . '</b></td>'; $html .= '<td style="text-align: center; text-decoration: bold; background-color: #CCFFFF; border-top: 1px solid #000; ">' . $totalist . ' </td>'; $html .= '<td style="text-align: center; text-decoration: bold; background-color: #CCFFFF; border-top: 1px solid #000; ">' . $totalmail . ' </td>'; // $html .= '<td style="text-align: center; text-decoration: bold; background-color: #CCFFFF; border-top: 1px solid #000; ">' .$totalsent.' </td>'; //$html .= '<td style="text-align: center; ">' .$totalsub.' </td>'; $html .= '</tr>'; echo $html; ?> </tbody></table> <br /> <?php if (class_exists('jNews_Auto')) { echo jNews_Auto::showQueue(); } $tabs->endTab(); $tabs->startTab(_JNEWS_MENU_SUBSCRIBERS, "acaControlPanel.Subscribers"); $emailsearch = ''; $listId = 0; $limittotal = jNews_Subscribers::getSubscribersCount($listId); $setLimitSubs = jnews::setLimitPagination($limittotal); ?> <input type="hidden" name="listid" value="<?php echo $listId; ?> " /> <input type="hidden" name="start" value="<?php echo $setLimitSubs->start; ?> " /> <input type="hidden" name="limit" value="<?php echo $setLimitSubs->end; ?> " /> <input type="hidden" name="listsearch" value="<?php echo $emailsearch; ?> " /> <div style="margin-top: 10px;"><?php echo jnews::setTop('', '', $setLimitSubs); ?> </div> <table class="<?php echo jnews::myTheme(); ?> "> <thead> <tr> <th class="title">#</th> <th class="title" style="text-align: left;"><?php echo _JNEWS_INPUT_NAME; ?> </th> <th class="title" style="text-align: left;"><?php echo _JNEWS_INPUT_EMAIL; ?> </th> <th class="title" style="text-align: center;"><?php echo _JNEWS_SIGNUP_DATE; ?> </th> </tr> </thead> <?php $subscribers = jNews_Subscribers::getSubscribers($setLimitSubs->start, $setLimitSubs->end, $emailsearch, $setLimitSubs->total, $listId, '', 0, 0, 'sub_dateD', 0, 0, null, 0); $i = 0; foreach ($subscribers as $subscriber) { $i++; if (!jNews_Subscribers::validEmail($subscriber->email)) { continue; } ?> <tr class="row<?php echo ($i + 2) % 2; ?> "> <td><center><?php echo $i + $setLimitSubs->start; ?> </center></td> <td style="text-align: left;"> <a href="index.php?option=<?php echo JNEWS_OPTION; ?> &act=subscribers&task=show&userid=<?php echo $subscriber->id; ?> " > <?php echo $subscriber->name; ?> </a></td> <td style="text-align: left;"><?php echo $subscriber->email; ?> </td> <td style="text-align: center;"> <?php echo date('l, jS F Y h:i:s A', jnews::getNow(0, true, $subscriber->subscribe_date)); ?> </td> </tr> <?php } ?> </table> <?php $tabs->endTab(); $tabs->startTab(_JNEWS_MENU_TAB_LIST, "acaControlPanel.Lists"); $listsearch = ''; $lists = jNews_Lists::getLists(0, 0, 1, '', false, false, false); $limittotal = count($lists); $setLimitLists = jnews::setLimitPagination($limittotal); ?> <input type="hidden" name="listid" value="<?php echo $listId; ?> " /> <input type="hidden" name="start" value="<?php echo $setLimitLists->start; ?> " /> <input type="hidden" name="limit" value="<?php echo $setLimitLists->end; ?> " /> <input type="hidden" name="listsearch" value="<?php echo $listsearch; ?> " /> <div style="margin-top: 10px;"><?php echo jnews::setTop('', '', $setLimitLists); ?> </div> <table class="<?php echo jnews::myTheme(); ?> "> <thead> <tr> <th class="title">#</th> <th class="title" width="65%" style="text-align: left;"><?php echo _JNEWS_LIST_NAME; ?> </th> <th class="title" width="25%" style="text-align: left;"><?php echo _JNEWS_LIST_TYPE; ?> </th> <th class="title" style="text-align: center;">ID</th> </tr> </thead> <?php $lists = jNews_Lists::getLists(0, 0, 1, 'listtypeA', false, false, false, false, false, $listsearch, $setLimitLists, 0, 0); $i = 0; foreach ($lists as $list) { $i++; $link = 'index.php?option=' . JNEWS_OPTION . '&act=mailing&task=show&listid=' . $list->id; ?> <tr class="row<?php echo ($i + 2) % 2; ?> "> <td><?php echo $i + $setLimitLists->start; ?> </td> <td style="text-align: left;"> <a href="<?php echo $link; ?> "> <?php echo $list->list_name; ?> </a> </td> <td style="text-align: left;"><?php if ($list->list_type == 1) { echo _JNEWS_LIST; } else { echo _JNEWS_AR; } ?> </td> <td style="text-align: center;"><?php echo $list->id; ?> </td> </tr> <?php } ?> <tr> <th colspan="4"> </th> </tr> </table> <?php $tabs->endTab(); ?> <?php $tabs->endPane(); ?> </form> </div> <div style="clear:both; float:left; margin-top: 10px;"> <?php echo jnews::printM('ok', _JNEWS_SERVER_LOCAL_TIME . ' : ' . date('l, j F Y H:i:s', jnews::getNow(0, true))); // - date('Z') ?> </div> <td> </tr> </table> </div> </div> <?php }
function lists($action, $task, $listId, $listType) { $db = JFactory::getDBO(); $my = JFactory::getUser(); $css = '.icon-48-lists { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/lists.png)}'; $doc = JFactory::getDocument(); $doc->addStyleDeclaration($css, $type = 'text/css'); $img = 'lists.png'; $listsearch = JRequest::getVar('listsearch', ''); $message = ''; $xf = new jNews_Config(); $showLists = true; $checkToggle = false; // defined toggle for publish and unpublish of mailings if (!empty($task) && $task == 'togle') { $checkToggle = true; $id = JRequest::getVar('listid'); $col = JRequest::getVar('col'); $listId = !empty($id) && !empty($col) ? $id : $listId; $task = !empty($listId) && !empty($col) ? $col : $task; } switch ($task) { case 'new': case 'add': $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(); $showLists = false; $newList->id = ''; $newList->html = 1; $newList->new_letter = 1; $newList->list_name = ''; $newList->list_desc = ''; $newList->template = ''; if (empty($subscriber)) { $newList->sendername = ''; $newList->senderemail = ''; $newList->bounceadres = ''; } else { $newList->sendername = ''; $newList->senderemail = ''; $newList->bounceadres = ''; } $newList->hidden = 1; $newList->auto_add = 0; $newList->list_type = $listType; $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', time()); $newList->next_date = jnews::getNow(); $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; $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; $show = jNews_ListType::showType($newList->list_type, 'editlist'); if ($listType == 1) { backHTML::_header(_JNEWS_NEW . ' ' . _JNEWS_LIST, $img, $message, $task, $action); } else { backHTML::_header(_JNEWS_NEW . ' ' . _JNEWS_AUTORESP . ' ' . _JNEWS_LIST, $img, $message, $task, $action); } backHTML::formStart('editlist', $newList->html, ''); jNews_ListsHTML::editList($newList, $forms, $show, $listType); $go[] = jnews::makeObj('act', $action); $go[] = jnews::makeObj('listid', $newList->id); backHTML::formEnd($go); break; case 'doNew': JRequest::checkToken() or die('Invalid Token'); $listname = JRequest::getVar('list_name', ''); if (empty($listname)) { echo "<script> alert(' List name must be filled out. '); window.history.go(-1);</script>\n"; return false; } $now = jnews::getNow(); $query = "SELECT `id` FROM `#__jnews_lists` WHERE `list_name`= '" . addslashes($listname) . "' "; $db->setQuery($query); $lId = $db->loadResult(); if ($lId > 0) { echo "<script> alert(' This list already exist, please choose another name. '); window.history.go(-1);</script>\n"; return false; } else { $query = "INSERT INTO `#__jnews_lists` (`list_name`,`createdate`) VALUES ( '" . addslashes($listname) . "' , '{$now}' )"; $db->setQuery($query); $db->query(); } $query = "SELECT * FROM `#__jnews_lists` WHERE `list_name`= '" . addslashes($listname) . "' "; $db->setQuery($query); $mynewlist = $db->loadObject(); $mynewlist->list_name = stripslashes($mynewlist->list_name); $mynewlist->list_desc = stripslashes($mynewlist->list_desc); $mynewlist->template = $mynewlist->template; $mynewlist->layout = stripslashes($mynewlist->layout); $mynewlist->subscribemessage = stripslashes($mynewlist->subscribemessage); $mynewlist->unsubscribemessage = stripslashes($mynewlist->unsubscribemessage); $mynewlist->notifyadminmsg = stripslashes($mynewlist->notifyadminmsg); $mynewlist->subnotifysend = stripslashes($mynewlist->subnotifysend); $mynewlist->subnotifymsg = stripslashes($mynewlist->subnotifymsg); $listId = $mynewlist->id; $message = jnews::printYN(jNews_Lists::updateListFromEdit($listId, '', true, $listType), _JNEWS_LIST_ADDED, _JNEWS_ERROR); $xf->plus('totallist0', 1); $xf->plus('act_totallist0', 1); $xf->plus('totallist' . $listType, 1); $xf->plus('act_totallist' . $listType, 1); break; case 'edit': if ($listId == 0) { echo "<script> alert('" . addslashes(_JNEWS_SELECT_LIST) . "'); window.history.go(-1);</script>\n"; return false; } else { $showLists = false; $query = 'SELECT * FROM `#__jnews_lists` WHERE `id` = ' . intval($listId); $db->setQuery($query); $listEdit = $db->loadObject(); if ($listEdit->acc_id == 'all') { 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; } $listEdit->acc_id = implode(',', $allGroupIds); } $listEdit->list_name = stripslashes($listEdit->list_name); $listEdit->list_desc = stripslashes($listEdit->list_desc); $listEdit->template = $listEdit->template; $listEdit->layout = stripslashes($listEdit->layout); $listEdit->subscribemessage = stripslashes($listEdit->subscribemessage); $listEdit->unsubscribemessage = stripslashes($listEdit->unsubscribemessage); $listEdit->notifyadminmsg = stripslashes($listEdit->notifyadminmsg); $listEdit->subnotifysend = stripslashes($listEdit->subnotifysend); $listEdit->subnotifymsg = stripslashes($listEdit->subnotifymsg); $listEdit->new_letter = 0; $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; $show = jNews_ListType::showType($listEdit->list_type, 'editlist'); backHTML::_header(_JNEWS_EDIT_A . @constant($GLOBALS[JNEWS . 'listname' . $listEdit->list_type]) . ' ' . _JNEWS_LIST, $img, $message, $task, $action); backHTML::formStart('listedit', $listEdit->html, ''); jNews_ListsHTML::editList($listEdit, $forms, $show, $listType); $go[] = jnews::makeObj('act', $action); $go[] = jnews::makeObj('listid', $listEdit->id); backHTML::formEnd($go); } break; case 'update': JRequest::checkToken() or die('Invalid Token'); $message = jnews::printYN(jNews_Lists::updateListFromEdit($listId, '', false, $listType), _JNEWS_LIST_UPDATED, _JNEWS_ERROR); break; case 'delete': JRequest::checkToken() or die('Invalid Token'); $query = "SELECT list_name FROM #__jnews_lists WHERE id = {$listId}"; $db->setQuery($query); $listName = $db->loadResult(); $message = jnews::printYN(jNews_Lists::deleteList($listId), '"' . $listName . '"' . _JNEWS_LIST . _JNEWS_SUCCESS_DELETED, _JNEWS_ERROR); break; case 'copy': JRequest::checkToken() or die('Invalid Token'); $message = jnews::printYN(jNews_Lists::copyList($listId), _JNEWS_LIST_COPY, _JNEWS_ERROR); break; case 'publish': if (!$checkToggle) { JRequest::checkToken() or die('Invalid Token'); } $message = jnews::printYN(jNews_Lists::updateListFromList($listId, true, false), _JNEWS_PUBLISHED, _JNEWS_ERROR); if ($listType == 1) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=list&listype=' . $listType); } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=arlist&listype=' . $listType); } break; case 'unpublish': if (!$checkToggle) { JRequest::checkToken() or die('Invalid Token'); } $message = jnews::printYN(jNews_Lists::updateListFromList($listId, false, false), _JNEWS_UNPUBLISHED, _JNEWS_ERROR); if ($listType == 1) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=list&listype=' . $listType . '&listid=' . $listId); } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=arlist&listype=' . $listType . '&listid=' . $listId); } break; case 'forms': case 'make': if (class_exists('jNews_CreateForm')) { jNews_CreateForm::taskOptions($task); $showLists = false; } else { $showLists = true; } break; case 'cpanel': backHTML::controlPanel(); return true; break; case 'toggle': $listid = JRequest::getVar('listid'); $column = JRequest::getVar('col'); if (!empty($listid) && !empty($column)) { $passObj = new stdClass(); $passObj->tableName = '#__jnews_lists'; $passObj->columnName = $column; $passObj->whereColumn = 'id'; $passObj->whereColumnValue = $listid; jnews::toggle($passObj); } if ($listType == 1) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=list&listype=1'); } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=arlist&listype=2'); } break; } if ($showLists) { $limit = -1; //Title header if ($listType == 1) { backHTML::_header(_JNEWS_MENU_LIST, $img, $message, $task, $action); } else { backHTML::_header(_JNEWS_ARLIST, $img, $message, $task, $action); } $show = jNews_ListType::showType(0, 'showListsBack'); $forms['main'] = "<form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; backHTML::formStart('show_mailing', '', ''); $paginationStart = JRequest::getVar('pg'); $app = JFactory::getApplication(); if (!empty($paginationStart)) { $limitstart = 0; $limitend = $paginationStart; } else { $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int'); $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int'); } $limittotal = jNews_Lists::getListCount($listType); $limittotal = $limittotal[0]; $setLimit = new stdClass(); $setLimit->total = !empty($limittotal) ? $limittotal : 0; $setLimit->start = !empty($limitstart) ? $limitstart : 0; $setLimit->end = !empty($limitend) ? $limitend : $limittotal; // recheck start if ($setLimit->total == $setLimit->end) { $setLimit->start = 0; } $setSort = new stdClass(); if ($listType == '2') { //autoresponder $key = JNEWS_OPTION . '.arlist'; $column = 'id'; $direction = 'desc'; } else { //newsletter $key = JNEWS_OPTION . '.list'; $column = 'list_name'; $direction = 'asc'; } $setSort->orderValue = $app->getUserStateFromRequest($key . 'filter_order', 'filter_order', $column, 'cmd'); $setSort->orderDir = $app->getUserStateFromRequest($key . 'filter_order_Dir', 'filter_order_Dir', $direction, 'word'); if ($listType == 2) { ?> <script language="javascript" type="text/javascript"> function submitbutton(pressbutton) { var form = document.adminForm; if (pressbutton == 'delete') { var $ok = confirm('Are you sure you want to delete?\r\nAll of the mailings attached in this auto-responder will be deleted as well.'); if ( $ok == true ){ form.action = 'index.php?option=<?php echo JNEWS_OPTION; ?> &act=arlist&task=delete'; }else{ return; } } submitform( pressbutton ); } </script> <?php } $listing = jNews_Lists::getLists(0, $listType, 1, '', false, false, false, false, false, $listsearch, $setLimit, $setSort); if (isset($setLimit->total) && !empty($listsearch)) { $lists = jNews_Lists::getLists(0, $listType, 1, '', false, false, false, false, false, $listsearch, $setSort); $setLimit->total = !empty($lists) ? count($lists) : $setLimit->total; } $totalSubs = array(); $totalUnSubs = array(); $db = JFactory::getDBO(); if (!empty($listing)) { foreach ($listing as $list) { $totalSubs[] = jNews_Subscribers::getSubscribersCount($list->id, true); $totalUnSubs[] = jNews_Subscribers::getSubscribersCount($list->id, 2); } } jNews_ListsHTML::showListingLists($listing, $action, 'edit', $forms, $show, $listsearch, $setLimit->end, $setLimit, $totalSubs, $setSort, $totalUnSubs); $go[] = jnews::makeObj('act', $action); $go[] = jnews::makeObj('filter_order', $setSort->orderValue); $go[] = jnews::makeObj('filter_order_Dir', $setSort->orderDir); backHTML::formEnd($go); return true; } }
public static function showMailingQueue($mailingq = null, $lists = null, $form, $start, $limit, $mailingsearch, $setLimit = null, $setSort = null) { $listId = null; ?> <script language="javascript" type="text/javascript"> <!-- function jnewsselectall(){ var i = 0; allcheck = document.getElementById("selectallcheck"); if(allcheck.checked) checkedvalue = 1; else checkedvalue = 0; while(myelement = document.getElementById("cid["+i+"]")){ myelement.checked = checkedvalue; i++; } if(checkedvalue){ document.getElementById("boxcount").value = i; }else{ document.getElementById("boxcount").value = 0; } } //--> </script> <?php if (empty($mailingq)) { echo '<center>' . jnews::printYN(true, _JNEWS_Q_M1, _JNEWS_ERROR) . '</center>'; } if ($listId == 0) { $message = _JNEWS_MESSAGE_QUEUE; } else { $lt_name = jNews_Lists::getLists($listId, 0, null, '', false, false, true, false, false, ''); $message = _JNEWS_SUSCRIB_LIST_UNIQUE . "<span style='color: rgb(51, 51, 51);'>" . @$lt_name[0]->list_name . "</span>"; } if (!isset($action)) { $action = JRequest::getVar('act', '', '', 'WORD'); } $mySepList = array(); $mySepList[0] = new stdClass(); $mySepList[0]->subject = 'All Mailings'; $mySepList[0]->id = 0; $myMailingQueA = jNews_Mailing::getMailingsForQueue(); if (empty($myMailingQueA) || !is_array($myMailingQueA)) { $myMailingQueA = array(); } $lt = array_merge($mySepList, $myMailingQueA); $mailingId = JREquest::getVar('mailingid', ''); $dropDown = jnews::HTML_GenericList($lt, 'mailingid', '' . 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'id', 'subject', $mailingId); $filter = _JNEWS_FILTER_MAILING . $dropDown; $hidden = '<input type="hidden" name="option" value="' . JNEWS_OPTION . '" />'; $hidden .= '<input type="hidden" name="act" value="' . $action . '" />'; $hidden .= '<input type="hidden" name="limit" value="' . $limit . '" />'; ?> <?php echo $form['main']; if ($form['main'] !== "") { $form['select'] = ""; } // top portion before the table list // for search $toSearch = new stdClass(); $toSearch->forms = $form['select']; $toSearch->hidden = $hidden; $toSearch->listsearch = $mailingsearch; $toSearch->id = 'mailingsearch'; echo jnews::setTop($toSearch, $message, $setLimit, $filter); ?> <table class="<?php echo jnews::myTheme(); ?> "> <thead><tr> <th width="2%" class="title">#</th> <th width="2%" class="title"><input type="checkbox" id="selectallcheck" name="allchecked" onclick="jnewsselectall();"></th> <th width="22%" class="title"><?php echo jnews::HTML_GridSort(_JNEWS_QUEUE_SUBJECT, 'm.subject', $setSort->orderDir, $setSort->orderValue); ?> </th> <th width="22%" class="title"><?php echo jnews::HTML_GridSort(_JNEWS_QUEUE_EMAIL, 's.email', $setSort->orderDir, $setSort->orderValue); ?> </th> <th width="22%" class="title"><?php echo jnews::HTML_GridSort(_JNEWS_SENDDATE, 'q.send_date', $setSort->orderDir, $setSort->orderValue); ?> </th> <th width="3%" class="title"><center><?php echo jnews::HTML_GridSort(_JNEWS_QUEUE_PRIOR, 'q.priority', $setSort->orderDir, $setSort->orderValue); ?> </center></th> <th width="2%" class="title"><center><?php echo jnews::HTML_GridSort(_JNEWS_QUEUE_ATT, 'q.attempt', $setSort->orderDir, $setSort->orderValue); ?> </center></th> <th width="3%" class="title"><?php echo jnews::HTML_GridSort('Suspend', 'q.suspend', $setSort->orderDir, $setSort->orderValue); ?> </th> <th width="3%" class="title"><?php echo jnews::HTML_GridSort('Blocked', 'q.block', $setSort->orderDir, $setSort->orderValue); ?> </th> <th width="3%" class="title"><?php echo jnews::HTML_GridSort('ID', 'q.qid', $setSort->orderDir, $setSort->orderValue); ?> </th> </thead></tr> <?php $i = $start; jNews_QueueHTML::_displayQueue($mailingq, $i); ?> </table> <?php echo '<br />'; echo jnews::setLegend(); }