示例#1
0
文件: frontend.php 项目: naka211/kkvn
 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;
 }
示例#2
0
 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);
 }