Esempio n. 1
0
 function showMailings($task, $action, $listId, $listType, $message, $showHeader, $title)
 {
     $start = mosGetParam($_REQUEST, 'start', 0);
     //ADRIEN
     //$limit = mosGetParam($_REQUEST, 'limit', $GLOBALS['mosConfig_list_limit']);
     $limit = -1;
     $emailsearch = mosGetParam($_REQUEST, 'emailsearch', '');
     $dropList = mosGetParam($_REQUEST, 'droplist', 'ZZZZ');
     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;
     }
     $orddef = 'idD';
     if ($listType == 2) {
         $orddef = 'idA';
     }
     $order = mosGetParam($_REQUEST, 'order', $orddef);
     if ($listId == 0) {
         $lists['title'] = lisType::chooseType($task, $action, $listType, 'titles', '', $title);
     } else {
         $listing = lists::getLists($listId, 0, 1, '', false, false, true);
         $lists['title'] = $title . "<span style='color: rgb(51, 51, 51);'>" . $listing[0]->list_name . "</span>";
     }
     $dropDownList = lisType::getMailingDropList($listId, $listType, $order);
     $lists['droplist'] = mosHTML::selectList($dropDownList, 'droplist', 'class="inputbox" size="1" onchange="document.AcajoomFilterForm.submit();"', 'id', 'name', $dropList);
     $mailings = xmailing::getMailings($listId, $listTypeM, $start, $limit, $emailsearch, $total, $order, false, false);
     $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n\r";
     $forms['select'] = " <form action='index2.php' method='post' name='AcajoomFilterForm'> \n\r";
     $show = lisType::showType($listType, 'showMailings');
     if ($showHeader) {
         xmailing::_header($task, $action, $listType, $message, '');
     }
     backHTML::formStart('show_mailing', 0, '');
     mailingsHTML::showMailingList($mailings, $lists, $start, $limit, $total, $emailsearch, $listId, $listType, $forms, $show, $action);
     backHTML::formEnd();
 }
Esempio n. 2
0
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;
}
Esempio n. 3
0
/**
* @copyright Copyright (C) 2009 Joobi Limited All rights reserved.
* @license This file is released under the GPL license (http://www.gnu.org/licenses )
* @link http://www.ijoobi.com
*/
function subscribers($action, $task, $userid, $listId, $cid)
{
    $erro = new xerr(__FILE__, __FUNCTION__);
    if (ACA_CMSTYPE) {
        // joomla 15
        $subscriberId = intval(JRequest::getVar('subscriber_id', ''));
        $message = JRequest::getVar('message', '');
    } else {
        //joomla 1x
        $subscriberId = intval(mosGetParam($_REQUEST, 'subscriber_id', ''));
        $message = mosGetParam($_REQUEST, 'message', '');
    }
    //endif
    $doShowSubscribers = true;
    subscribers::updateSubscribers();
    switch ($task) {
        case 'updateOneSub':
            $doShowSubscribers = true;
            $message = acajoom::printYN(subscribers::updateOneSubscriber(), _ACA_UPDATED_SUCCESSFULLY, _ACA_ERROR);
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            break;
        case 'deleteOneSub':
            $doShowSubscribers = true;
            $message = acajoom::printYN(subscribers::deleteOneSubscriber($subscriberId), _ACA_SUBSCRIBER_DELETED, _ACA_ERROR);
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            break;
        case 'cancelSub':
            $doShowSubscribers = true;
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            break;
        case 'edit':
            foreach ($cid as $id) {
                compa::redirect('index2.php?option=com_acajoom&act=subscribers&task=show&userid=' . $id);
            }
            break;
        case 'show':
            $doShowSubscribers = false;
            $qid[0] = $userid;
            $subscriber = subscribers::getSubscribersFromId($qid, false);
            $lists = lists::getLists(0, 0, 1, '', false, false);
            $queues = queue::getSubscriberLists($userid);
            $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n";
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            backHTML::formStart('', 0, '');
            echo subscribersHTML::editSubscriber($subscriber, $lists, $queues, $forms, acajoom::checkPermissions('admin'), false, false);
            $go[] = acajoom::makeObj('act', $action);
            $go[] = acajoom::makeObj('subscriber_id', $subscriber->id);
            $go[] = acajoom::makeObj('user_id', $subscriber->user_id);
            backHTML::formEnd($go);
            break;
        case 'new':
        case 'add':
            $doShowSubscribers = false;
            $newSubscriber->id = '';
            $newSubscriber->user_id = 0;
            $newSubscriber->name = '';
            $newSubscriber->email = '';
            $newSubscriber->receive_html = 1;
            $newSubscriber->confirmed = 1;
            $newSubscriber->blacklist = 0;
            $newSubscriber->timezone = '00:00:00';
            $newSubscriber->language_iso = 'eng';
            $newSubscriber->params = '';
            $newSubscriber->subscribe_date = acajoom::getNow();
            $lists = lists::getLists(0, 0, 1, '', false, false);
            $queues = '';
            $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n";
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            backHTML::formStart('', 0, '');
            echo subscribersHTML::editSubscriber($newSubscriber, $lists, $queues, $forms, acajoom::checkPermissions('admin'), false, false);
            $go[] = acajoom::makeObj('act', $action);
            $go[] = acajoom::makeObj('subscriber_id', $newSubscriber->id);
            $go[] = acajoom::makeObj('user_id', $newSubscriber->user_id);
            backHTML::formEnd($go);
            break;
        case 'doNew':
            $doShowSubscribers = true;
            $message = acajoom::printYN(subscribers::insertOneSubscriber(), _ACA_UPDATED_SUCCESSFULLY, _ACA_ERROR);
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            break;
        case 'delete':
            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) {
                    $erro->ck = subscribers::deleteOneSubscriber($id);
                    if (!$erro->ck) {
                        $status = false;
                    }
                }
                $message = acajoom::printYN($status, _ACA_SUBSCRIBER_DELETED, _ACA_ERROR);
                backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            }
            break;
        case 'update':
            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) {
                    if (ACA_CMSTYPE) {
                        // joomla 15
                        $changes = JRequest::getVar($id, array(0));
                    } else {
                        //joomla 1x
                        $changes = mosGetParam($_REQUEST, $id, array(0));
                    }
                    //endif
                    if (!isset($changes['receive_html'])) {
                        $changes['receive_html'] = 0;
                    }
                    if (!isset($changes['confirmed'])) {
                        $changes['confirmed'] = 0;
                    }
                }
            }
            $message = acajoom::print_message(_ACA_UPDATED_SUCCESSFULLY, 1);
            break;
        case 'export':
            $doShowSubscribers = false;
            subscribersHTML::export($action, $listId);
            break;
        case 'doExport':
            $message = acajoom::printYN(subscribers::export($listId), _EXPORT, _ACA_ERROR);
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            break;
        case 'import':
            $doShowSubscribers = false;
            $lists = lists::getLists(0, 0, 1, 'listnameA', false, false, true);
            subscribersHTML::import($action, $lists);
            break;
        case 'doImport':
            $message = acajoom::printYN(subscribers::import($listId), _ACA_IMPORT_FINISHED, _ACA_ERROR);
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            break;
            break;
        case 'subscribeAll':
            break;
        case 'unsubscribeAll':
            break;
        case 'cancel':
            if ($listId != 0) {
                $listId = 0;
            } else {
                compa::redirect('index2.php?option=com_acajoom');
            }
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            break;
        case 'cpanel':
            backHTML::controlPanel();
            $doShowSubscribers = 0;
            break;
        default:
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            break;
    }
    if ($doShowSubscribers) {
        if (ACA_CMSTYPE) {
            // joomla 15
            $start = intval(JRequest::getVar('start', 0));
            $conf =& JFactory::getConfig();
            $mail->Mailer = $conf->getValue('config.mailer');
            // $GLOBALS['mosConfig_mailer'];
            $limit = intval(JRequest::getVar('limit', $conf->getValue('config.list_limit')));
            $emailsearch = JRequest::getVar('emailsearch', '');
        } else {
            //joomla 1x
            $mail->Mailer = $GLOBALS['mosConfig_mailer'];
            $start = intval(mosGetParam($_REQUEST, 'start', 0));
            $limit = intval(mosGetParam($_REQUEST, 'limit', $GLOBALS['mosConfig_list_limit']));
            $emailsearch = mosGetParam($_REQUEST, 'emailsearch', '');
        }
        //endif
        $total = 0;
        $subscribers = subscribers::getSubscribers($start, $limit, $emailsearch, $total, $listId, '', '', '', 'sub_dateD');
        if ($listId != 0) {
            $showAdmin = true;
        } else {
            $showAdmin = false;
        }
        $dropDownList = lisType::getListsDropList(0, '', '');
        if (ACA_CMSTYPE) {
            // joomla 15
            $lists['listid'] = JHTML::_('select.genericlist', $dropDownList, 'listid', 'class="inputbox" size="1" onchange="document.AcajoomFilterForm.submit();"', 'id', 'list_name', $listId);
        } else {
            //joomla 1x
            $lists['listid'] = mosHTML::selectList($dropDownList, 'listid', 'class="inputbox" size="1" onchange="document.AcajoomFilterForm.submit();"', 'id', 'list_name', $listId);
        }
        //endif
        $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n";
        $forms['select'] = " <form action='index2.php' method='post' name='AcajoomFilterForm'> \n";
        backHTML::formStart('show_mailing', 0, '');
        subscribersHTML::showSubscribers($subscribers, $action, $listId, $lists, $start, $limit, $total, $showAdmin, $listId, $emailsearch, $forms);
    }
    return true;
}
Esempio n. 4
0
function lists($action, $task, $listId, $listType)
{
    global $database, $my;
    $message = '';
    $xf = new xonfig();
    $erro = new xerr(__FILE__, __FUNCTION__);
    $erro->show();
    $showLists = true;
    switch ($task) {
        case 'new':
            if ($listType < 1) {
                $listType = 1;
            }
            $filename = $GLOBALS['mosConfig_absolute_path'] . '/components/com_acajoom/templates/default/default.html';
            $handle = fopen($filename, "rb");
            $template = fread($handle, filesize($filename));
            fclose($handle);
            $template = str_replace('src="', 'src="' . $GLOBALS['mosConfig_live_site'] . '/', $template);
            $subscriber = subscribers::getSubscriberInfoFromUserId($my->id);
            $showLists = false;
            $newList->id = '';
            $newList->html = 1;
            $newList->new_letter = 1;
            $newList->list_name = '';
            $newList->list_desc = '';
            $newList->sendername = $subscriber->name;
            $newList->senderemail = $subscriber->email;
            $newList->bounceadres = $subscriber->email;
            $newList->layout = $template;
            $newList->template = 0;
            $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;
            $newList->follow_up = '';
            $newList->notify_id = 0;
            $newList->owner = $my->id;
            $newList->acc_level = 25;
            $newList->acc_id = 29;
            $newList->published = 0;
            $newList->start_date = date('Y-m-d', time());
            $newList->next_date = time();
            $newList->subscribemessage = _ACA_DEFAULT_SUBSCRIBE_MESS;
            $newList->unsubscribemessage = _ACA_DEFAULT_UNSUBSCRIBE_MESS;
            $newList->unsubscribesend = 1;
            $newList->footer = 1;
            $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n ";
            $show = lisType::showType($newList->list_type, 'editlist');
            backHTML::_header(_ACA_NEW . ' ' . _ACA_LIST, $GLOBALS[ACA . 'listlogo0'], $message, $task, $action);
            backHTML::formStart('listedit', $newList->html, '');
            listsHTML::editList($newList, $forms, $show);
            $go[] = acajoom::makeObj('act', $action);
            $go[] = acajoom::makeObj('listid', $newList->id);
            backHTML::formEnd($go);
            break;
        case 'doNew':
            $listname = mosGetParam($_REQUEST, 'list_name', '');
            $listType = mosGetParam($_REQUEST, 'list_type', 0);
            $now = acajoom::getNow();
            $query = "SELECT `id` FROM `#__acajoom_lists` WHERE `list_name`= '{$listname}' ";
            $database->setQuery($query);
            $lId = $database->loadResult();
            $erro->err = $database->getErrorMsg();
            $erro->E(__LINE__, '1091', $database);
            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 `#__acajoom_lists` (`list_name`,`createdate`) VALUES ( '" . addslashes($listname) . "'  , '{$now}' )";
                $database->setQuery($query);
                $database->query();
                $erro->err = $database->getErrorMsg();
            }
            if ($erro->E(__LINE__, '1001', $database)) {
                $query = "SELECT * FROM `#__acajoom_lists` WHERE `list_name`= '{$listname}' ";
                $database->setQuery($query);
                $database->loadObject($mynewlist);
                $mynewlist->list_name = stripslashes($mynewlist->list_name);
                $mynewlist->list_desc = stripslashes($mynewlist->list_desc);
                $mynewlist->layout = stripslashes($mynewlist->layout);
                $mynewlist->subscribemessage = stripslashes($mynewlist->subscribemessage);
                $mynewlist->unsubscribemessage = stripslashes($mynewlist->unsubscribemessage);
                $erro->err = $database->getErrorMsg();
                $erro->E(__LINE__, '1005');
                $listId = $mynewlist->id;
                $message = acajoom::printYN(lists::updateListFromEdit($listId, '', true), _ACA_LIST_ADDED, _ACA_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(_ACA_SELECT_LIST) . "'); window.history.go(-1);</script>\n";
                return false;
            } else {
                $showLists = false;
                $query = 'SELECT * FROM `#__acajoom_lists` WHERE `id` = ' . intval($listId);
                $database->setQuery($query);
                $database->loadObject($listEdit);
                $erro->err = $database->getErrorMsg();
                if (!$erro->E(__LINE__, '1002')) {
                    return false;
                } else {
                    $listEdit->list_name = stripslashes($listEdit->list_name);
                    $listEdit->list_desc = stripslashes($listEdit->list_desc);
                    $listEdit->layout = stripslashes($listEdit->layout);
                    $listEdit->subscribemessage = stripslashes($listEdit->subscribemessage);
                    $listEdit->unsubscribemessage = stripslashes($listEdit->unsubscribemessage);
                    $listEdit->new_letter = 0;
                    $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n ";
                    $show = lisType::showType($listEdit->list_type, 'editlist');
                    backHTML::_header(_ACA_EDIT_A . @constant($GLOBALS[ACA . 'listname' . $listEdit->list_type]) . ' ' . _ACA_LIST, $GLOBALS[ACA . 'listlogo0'], $message, $task, $action);
                    backHTML::formStart('listedit', $listEdit->html, '');
                    listsHTML::editList($listEdit, $forms, $show);
                    $go[] = acajoom::makeObj('act', $action);
                    $go[] = acajoom::makeObj('listid', $listEdit->id);
                    backHTML::formEnd($go);
                }
            }
            break;
        case 'update':
            $message = acajoom::printYN(lists::updateListFromEdit($listId, '', false), _ACA_LIST_UPDATED, _ACA_ERROR);
            break;
        case 'delete':
            $message = acajoom::printYN(lists::deleteList($listId), _ACA_LIST . _ACA_SUCCESS_DELETED, _ACA_ERROR);
            break;
        case 'copy':
            $message = acajoom::printYN(lists::copyList($listId), _ACA_LIST_COPY, _ACA_ERROR);
            break;
        case 'publish':
            $message = acajoom::printYN(lists::updateListFromList($listId, true, false), _ACA_PUBLISHED, _ACA_ERROR);
            break;
        case 'unpublish':
            $message = acajoom::printYN(lists::updateListFromList($listId, false, false), _ACA_UNPUBLISHED, _ACA_ERROR);
            break;
        case 'forms':
        case 'make':
            if (class_exists('createForm')) {
                createForm::taskOptions($task);
                $showLists = false;
            } else {
                $showLists = true;
            }
            break;
        case 'cpanel':
            backHTML::controlPanel();
            return true;
            break;
    }
    if ($showLists) {
        backHTML::_header(_ACA_MENU_LIST, $GLOBALS[ACA . 'listlogo0'], $message, $task, $action);
        $show = lisType::showType(0, 'showListsBack');
        $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n";
        backHTML::formStart('show_mailing', '', '');
        $listing = lists::getLists(0, 0, 1, '', false, false, false);
        if ($show['list_type']) {
            $show['list_type'] = lisType::checkOthers();
        }
        listsHTML::showListingLists($listing, $action, 'edit', $forms, $show);
        $go[] = acajoom::makeObj('act', $action);
        backHTML::formEnd($go);
        return true;
    }
}
Esempio n. 5
0
 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;
 }
Esempio n. 6
0
/**
* <p>Templates controller</p>
* <p>This function is the controller to view the templates view</p>
* @author Joobi Limited <wwww.joobi.co>
*/
function templates($action, $task, $template_id)
{
    $my = JFactory::getUser();
    $css = '.icon-48-templates { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/templates.png)}';
    $doc = JFactory::getDocument();
    $doc->addStyleDeclaration($css, $type = 'text/css');
    $img = 'templates.png';
    $templatesearch = JRequest::getVar('templatesearch', '');
    $showTemplates = true;
    // defined toggle for publish and unpublish of mailings
    $willRedirect = false;
    $checkToggle = false;
    $cid = JRequest::getVar('cid');
    if (empty($template_id)) {
        if (!empty($cid) && is_array($cid)) {
            $template_id = $cid[key($cid)];
        }
    } else {
        if (empty($cid)) {
            $cid[] = $template_id;
        }
    }
    if (!empty($task) && $task == 'togle') {
        $checkToggle = true;
        //		$id = JRequest::getVar( 'templateid' );
        $id = $template_id;
        $col = JRequest::getVar('col');
        $template_id = !empty($id) && !empty($col) ? $id : $template_id;
        $task = !empty($template_id) && !empty($col) ? $col : $task;
        $willRedirect = true;
    }
    switch ($task) {
        case 'new':
        case 'add':
            $showTemplates = false;
            $template = null;
            $form['main'] = " <form action='index.php' method='post' name='adminForm' enctype='multipart/form-data' id=\"adminForm\"> \n";
            $message = isset($message) ? $message : '';
            backHTML::_header(_JNEWS_TEMPLATES, 'templates.png', $message, $task, $action);
            backHTML::formStart('template', 0, '');
            echo jNews_TemplatesHTML::createTemplate($template, $form);
            $go[] = jnews::makeObj('act', $action);
            backHTML::formEnd($go);
            break;
        case 'edit':
            $showTemplates = false;
            $template = jNews_Templates::loadOneTemplate('*', $template_id);
            $form['main'] = " <form action='index.php' method='post' name='adminForm' enctype='multipart/form-data' id=\"adminForm\">";
            $message = isset($message) ? $message : '';
            backHTML::_header(_JNEWS_TEMPLATES, 'templates.png', $message, $task, $action);
            backHTML::formStart('template', 0, '');
            echo jNews_TemplatesHTML::createTemplate($template, $form);
            $go[] = jnews::makeObj('act', $action);
            $go[] = jnews::makeObj('template_id', $template_id);
            backHTML::formEnd($go);
            break;
        case 'save':
            JRequest::checkToken() or die('Invalid Token');
            $message = jnews::printYN(jNews_Templates::saveTemplate($task, $template_id), _JNEWS_TEMPLATE_SAVED, _JNEWS_ERROR);
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message);
            break;
        case 'apply':
            JRequest::checkToken() or die('Invalid Token');
            $message = '';
            $message .= jnews::printYN(jNews_Templates::saveTemplate($task, $template_id), _JNEWS_TEMPLATE_SAVED, _JNEWS_ERROR);
            $id = empty($template_id) ? jNews_Templates::loadOneTemplate('template_id', '', 'template_id', 'DESC') : $template_id;
            $converMessage = JRequest::getVar('message', '', '', 'string', JREQUEST_ALLOWRAW);
            if (!empty($converMessage)) {
                $message .= '<br/>';
                $message .= implode("", $converMessage);
            }
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates&task=edit&template_id=' . $id, $message);
            break;
        case 'publish':
            if (!$checkToggle) {
                JRequest::checkToken() or die('Invalid Token');
            }
            $message = jnews::printYN(jNews_Templates::updateTemplate($cid, 'published', true), 'Successfully published template!', 'Error publishing the template!');
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message);
            break;
        case 'unpublish':
            if (!$checkToggle) {
                JRequest::checkToken() or die('Invalid Token');
            }
            $condition = jNews_Templates::updateTemplate($cid, 'published', false);
            if ($condition) {
                $message = jnews::printM('ok', 'Successfully unpublished template!');
            } else {
                $message = jnews::printM('defaulterror', 'Unable to unpublished default template!');
            }
            //	   		$message = jnews::defaultYN( jNews_Templates::updateTemplate($template_id,'published', false) ,  'Successfully unpublished template!' , 'Unable to unpublished default  template!' );
            if ($willRedirect) {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message);
            }
            break;
        case 'copy':
            JRequest::checkToken() or die('Invalid Token');
            $message = jnews::printYN(jNews_Templates::copyTemplate($template_id), _JNEWS_TEMPLATE . _JNEWS_SUCCESS_COPIED, _JNEWS_ERROR);
            $showTemplates = true;
            break;
        case 'default':
            $success = false;
            //set all the templates to premium = 0
            if (jNews_Templates::updateTemplate($template_id, 'default', false, false)) {
                $success = true;
            }
            //set the template published and premium
            if ($success) {
                jNews_Templates::updateTemplate($template_id, 'default', true, true);
            }
            $message = jnews::printYN($success, 'Successfully set the template to default!', 'Unable to set template to default!');
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message);
            break;
        case 'delete':
            JRequest::checkToken() or die('Invalid Token');
            $showTemplates = true;
            $isDefault = jNews_Templates::loadOneTemplate('premium', $template_id);
            if (!$isDefault) {
                $message = jnews::printYN(jNews_Templates::deleteTemplate($cid), _JNEWS_TEMPLATE . _JNEWS_SUCCESS_DELETED, _JNEWS_ERROR);
            } else {
                $message = jnews::printM('red', _JNEWS_TEMPLATE_DEFAULT_NODEL);
            }
            break;
        case 'cpanel':
            backHTML::controlPanel();
            return true;
            break;
        case 'toggle':
            JRequest::checkToken() or die('Invalid Token');
            // main toggle for all usage
            $listid = JRequest::getVar('listid');
            $column = JRequest::getVar('col');
            if (!empty($listid) && !empty($column)) {
                $passObj = new stdClass();
                $passObj->tableName = '#__jnews_lists';
                $passObj->columnName = $column;
                $passObj->whereColumn = 'id';
                $passObj->whereColumnValue = $listid;
                jnews::toggle($passObj);
            }
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates');
            break;
        case 'tempupload':
            // HTML for upload template
            //			JRequest::checkToken() or die( 'Invalid Token' );
            $html = '<form action="index.php?option=' . JNEWS_OPTION . '&act=templates&task=upload" method="post" name="adminForm" enctype="multipart/form-data" id="adminForm">';
            $html .= '<table style="width:100%;padding:100px;">';
            $html .= '<tr>';
            $html .= '<td style="text-align:center;"> <input type="FILE" name="tempupload"> </td>';
            $html .= '</tr><tr">';
            $html .= '<td style="text-align:center;padding:20px;"> <input type="submit" value="Upload Template" style="width:130px;height:25px;"> </td>';
            $html .= '</tr>';
            $html .= '</table>';
            if (version_compare(JVERSION, '3.0.0', '<')) {
                $html .= JHTML::_('form.token');
            } else {
                $html .= JHtml::_('form.token');
            }
            $html .= '</form><br/><br/>';
            echo $html;
            $showTemplates = false;
            break;
        case 'sendtest':
            JRequest::checkToken() or die('Invalid Token');
            //we save first the template
            $saveStatus = jNews_Templates::saveTemplate($task, $template_id);
            //then we send it if the template is successfully saved
            if ($saveStatus) {
                $message = jnews::printM('ok', _JNEWS_TEMPLATE_SAVED);
                $my = JFactory::getUser();
                $mailing = new stdClass();
                $receiver = new stdClass();
                $status = false;
                $mailing->id = 1;
                $mailing->html = 1;
                $mailing->images = '';
                $mailing->attachments = '';
                $mailing->subject = jNews_Templates::loadOneTemplate('name', $template_id);
                $mailing->htmlcontent = jNews_Templates::loadOneTemplate('body', $template_id);
                $mailing->template_id = $template_id;
                $receiver->name = $my->name;
                $receiver->email = $my->email;
                $receiver->receive_html = 1;
                $receiver->user_id = $my->id;
                $mailerC = new jNews_ProcessMail();
                $sendStatus = $mailerC->send($mailing, $receiver);
                $success = 'Template ' . $mailing->subject . ' successfully sent to ' . $receiver->email;
                $error = 'There is a problem in sending the template ' . $mailing->subject . ' <br/>' . _JNEWS_SENDTEST_CONFIGERROR;
                $message = $sendStatus ? jnews::printM('ok', $success) : jnews::printM('error', $error);
            } else {
                //otherwise we give an error message
                $message = jnews::printM('error', _JNEWS_ERROR);
            }
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates&task=edit&template_id=' . $template_id, $message);
            break;
        case 'upload':
            JRequest::checkToken() or die('Invalid Token');
            $db = JFactory::getDBO();
            $fileName = $_FILES['tempupload']['name'];
            $folderName = substr($fileName, 0, -4);
            // explode to array to compare and check if the uploaded file is a zip file
            $type = $_FILES['tempupload']['type'];
            // if zip is not found then return to previous upload page
            if (strtolower($type) != 'application/zip') {
                if (strtolower(substr($fileName, -4)) != '.zip') {
                    if (version_compare(JVERSION, '1.6.0', '<')) {
                        //j15
                        echo "<script> alert('" . addslashes(_JNEWS_UPLOAD_ZIP_INVALID) . "'); document.location.href='index.php?option='.JNEWS_OPTION.'&act=templates';</script>";
                    } else {
                        if (version_compare(JVERSION, '3.0.0', '<')) {
                            echo "<script> alert('" . addslashes(_JNEWS_UPLOAD_ZIP_INVALID) . "'); window.parent.SqueezeBox.close();</script>";
                        } else {
                            echo "<script> alert('" . addslashes(_JNEWS_UPLOAD_ZIP_INVALID) . "');   jQuery(window.top.document).find(\"div.modal-backdrop\").click(); </script>";
                        }
                    }
                    break;
                }
            }
            $result = jNews_Templates::uploadTemplate();
            if ($result) {
                // if success
                // read index.html of file for template body content
                $tempPath = JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'media' . DS . JNEWS_OPTION . DS . 'templates' . DS;
                $file = fopen($tempPath . $folderName . DS . 'index.html', "r") or exit("Unable to open file!");
                $tempbody = array();
                while (!feof($file)) {
                    $tempbody[] = fgets($file);
                }
                //endwhile
                fclose($file);
                $tempbody = implode(' ', $tempbody);
                $standardCSSA = array();
                $extraCSSStyles = '';
                if (is_file($tempPath . $folderName . DS . 'css' . DS . 'style.css')) {
                    //new template package with style.css file
                    //we get here the css codes from the uploaded template
                    $cssfile = fopen($tempPath . $folderName . DS . 'css' . DS . 'style.css', "r") or exit("Unable to open file!");
                    $cssstyle = array();
                    while (!feof($cssfile)) {
                        $cssstyle[] = fgets($cssfile);
                    }
                    //endwhile
                    fclose($cssfile);
                    $cssstyle = implode(' ', $cssstyle);
                    $cleanCSSstyle = jNews_Templates::cleanCSSComments($cssstyle);
                    //cleancsscomments
                    @(require_once JNEWSPATH_CLASS . 'class.cssinlinestyles.php');
                    if (class_exists('CSSToInlineStyles')) {
                        $newCSSProcess = new CSSToInlineStyles();
                        $newCSSProcess->setCSS($cleanCSSstyle);
                        $newCSSProcess->processCSS();
                        //we define the predefined selectors for the css
                        $standardSelectorsA = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'a', 'ul', 'li', '.unsubscribe', '.subscriptions', '.content', '.title', '.readmore', '.online', '.aca_content', '.aca_title', '.aca_readmore', '.aca_online', '.aca_subscribe', '.aca_unsubscribe', '.aca_subscriptions');
                        $standardCSSA = $newCSSProcess->getStandardCSSTag($newCSSProcess->cssRules, $standardSelectorsA);
                        $extraCSSStyles = $newCSSProcess->getExtraCSSTag($newCSSProcess->cssRules, $standardSelectorsA);
                    }
                }
                // replace source image paths from 'images/' to 'media/.../templates/$FOLDERNAME/'
                $bodyImgA = JRequest::getVar('bodyImg');
                if (is_file($tempPath . $folderName . DS . 'css' . DS . 'style.css')) {
                    //new template package
                    //					$body = preg_replace('#images\/#', JNEWS_JPATH_LIVE . '/media/'. JNEWS_OPTION . '/templates/' . $folderName .'/images/', $tempbody);
                    $origin = '"images/';
                    $destination = '"' . JNEWS_JPATH_LIVE . '/media/' . JNEWS_OPTION . '/templates/' . $folderName . '/images/';
                    $body = str_replace($origin, $destination, $tempbody);
                } else {
                    //					$body = preg_replace('#images\/#', JNEWS_JPATH_LIVE . '/media/'. JNEWS_OPTION . '/templates/'. $folderName.'/' , $tempbody);
                    $origin = 'media/' . JNEWS_OPTION . '/templates/' . $folderName . '/';
                    $destination = JNEWS_JPATH_LIVE . '/media/' . JNEWS_OPTION . '/templates/' . $folderName . '/';
                    $body = str_replace($origin, $destination, $tempbody);
                }
                $template = null;
                $template->name = ucfirst($folderName);
                $template->description = '';
                $template->created = time();
                $template->body = addslashes($body);
                $template->altbody = '';
                $template->premium = 0;
                $template->namekey = $folderName;
                $template->published = 1;
                $template->styles = addslashes(serialize($standardCSSA));
                $template->csstyle = addslashes($extraCSSStyles);
                $template->thumbnail = '';
                $templateA = (array) $template;
                $query = 'SELECT * FROM `#__jnews_templates` WHERE `namekey` = \'' . $template->namekey . '\' ';
                $db->setQuery($query);
                $findresult = $db->loadObject();
                if (empty($findresult)) {
                    // store template
                    $status = jNews_Templates::storeTemplate($templateA);
                } else {
                    //update template
                    $query = 'UPDATE `#__jnews_templates` SET `body` = \'' . $template->body . '\' , `availability` = 1 WHERE `namekey`= \'' . $template->namekey . '\'  AND `template_id`=' . $findresult->template_id;
                    $db->setQuery($query);
                    $status = $db->query();
                }
                // upload success
                // display success message
                if ($status) {
                    if (version_compare(JVERSION, '1.6.0', '<')) {
                        //j15
                        echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_SUCCESS) . "'); document.location.href='index.php?option=" . JNEWS_OPTION . "&act=templates';</script>";
                    } else {
                        //j16
                        echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_SUCCESS) . "'); window.parent.location.reload();</script>";
                    }
                }
            } else {
                // failed uploading
                // display an error message
                if (version_compare(JVERSION, '1.6.0', '<')) {
                    //j15
                    echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_FAIL) . "'); document.location.href='index.php?option=" . JNEWS_OPTION . "&act=templates';</script>";
                } else {
                    if (version_compare(JVERSION, '3.0.0', '<')) {
                        echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_FAIL) . "'); window.parent.SqueezeBox.close();</script>";
                    } else {
                        echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_FAIL) . "');   jQuery(window.top.document).find(\"div.modal-backdrop\").click(); </script>";
                    }
                }
            }
            $showTemplates = false;
            break;
        case 'preview':
            $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">";
            $forms['filter'] = " <form name='jnewsFilterForm' method='POST' action='index.php'> \n";
            $id = JRequest::getInt('template_id', 0, 'request');
            $body = jNews_Templates::loadOneTemplate('body', $id);
            jNews_Templates::includeStyles($body, $id);
            jNews_TemplatesHTML::previewTemplate($body, $forms);
            $showTemplates = false;
            break;
        case 'assign':
            $templatesearch = JRequest::getVar('templatesearch', '');
            $linkTh = jNews_Tools::completeLink('option=' . JNEWS_OPTION, true, false, true);
            $forms['main'] = "<form action=" . $linkTh . " method='post' name='adminForm' id=\"adminForm\">";
            $paginationStart = JRequest::getVar('pg');
            if (!empty($paginationStart)) {
                $limitstart = 0;
                $limitend = $paginationStart;
            } else {
                $app = JFactory::getApplication();
                $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int');
                $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int');
            }
            $limittotal = jNews_Templates::countTemplates(1, 1);
            $setLimit = new stdClass();
            $setLimit->total = !empty($limittotal) ? $limittotal : 0;
            $setLimit->start = !empty($limitstart) ? $limitstart : 0;
            $setLimit->end = !empty($limitend) ? $limitend : 20;
            $templates = jNews_Templates::getTemplates(true, false, $templatesearch, $setLimit->start, $setLimit->end, null, 1);
            //first param to true to show only the published
            jNews_TemplatesHTML::assignTemplate($templates, $forms, $setLimit, $templatesearch);
            $showTemplates = false;
            break;
    }
    if ($showTemplates) {
        $start = JRequest::getVar('start', '0');
        $templatesearch = JRequest::getVar('templatesearch', '');
        $limit = -1;
        $message = isset($message) ? $message : '';
        backHTML::_header(_JNEWS_TEMPLATES, $img, $message, $task, $action);
        $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">";
        $forms['filter'] = " <form name='jnewsFilterForm' method='POST' action='index.php'> \n";
        backHTML::formStart('show_template', '', '');
        // added this code for pagination ===========================
        $paginationStart = JRequest::getVar('pg');
        $app = JFactory::getApplication();
        if (!empty($paginationStart)) {
            $limitstart = 0;
            $limitend = $paginationStart;
        } else {
            $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int');
            $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int');
        }
        $setSort = new stdClass();
        $setSort->orderValue = $app->getUserStateFromRequest(JNEWS_OPTION . '.templates.filter_order', 'filter_order', 'premium', 'cmd');
        $setSort->orderDir = $app->getUserStateFromRequest(JNEWS_OPTION . '.templates.filter_order_Dir', 'filter_order_Dir', 'desc', 'word');
        $limittotal = jNews_Templates::countTemplates();
        $setLimit = new stdClass();
        $setLimit->total = !empty($limittotal) ? $limittotal : 0;
        $setLimit->start = !empty($limitstart) ? $limitstart : 0;
        $setLimit->end = !empty($limitend) ? $limitend : $limittotal;
        // recheck start
        if ($setLimit->total == $setLimit->end) {
            $setLimit->start = 0;
        }
        $templates = jNews_Templates::getTemplates(false, false, $templatesearch, $setLimit->start, $setLimit->end, $setSort);
        //recheck limit total [pagination]
        if (isset($setLimit->total) && !empty($templatesearch)) {
            $setLimit->total = !empty($temps) ? count($templates) : $setLimit->total;
        }
        jNews_TemplatesHTML::displayTemplateList($templates, $forms, $setLimit->start, $setLimit->end, $templatesearch, $action, $setLimit, $setSort);
        $go[] = jnews::makeObj('act', 'templates');
        $go[] = jnews::makeObj('filter_order', $setSort->orderValue);
        $go[] = jnews::makeObj('filter_order_Dir', $setSort->orderDir);
        backHTML::formEnd($go);
    }
    return true;
}
Esempio n. 7
0
function update($action, $task)
{
    require_once JNEWSPATH_CLASS . 'class.update.php';
    $update = new jNews_Update();
    $showListing = true;
    $showComplete = false;
    $message = JRequest::getVar('message', '');
    if (!ini_get('safe_mode')) {
        @set_time_limit(60 * $GLOBALS[JNEWS . 'script_timeout']);
    }
    //css injection for the images
    $doc = JFactory::getDocument();
    $css = '.icon-48-import { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/import.png)}';
    $doc->addStyleDeclaration($css, $type = 'text/css');
    switch ($task) {
        case 'doUpdate':
            backHTML::_header(_JNEWS_MENU_UPDATE, 'update', $message, $task, $action);
            $update->doUpdate();
            $showListing = false;
            $showComplete = false;
            break;
        case 'version':
            $update->getVersion();
            break;
        case 'complete':
            $showComplete = true;
            $showListing = false;
            break;
        case 'cancel':
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=update');
            $showListing = false;
            break;
        case 'cpanel':
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION);
            $showListing = false;
            break;
        case 'new1':
            backHTML::_header(_JNEWS_MENU_UPDATE, 'import.png', $message, $task, $action);
            $message = jnews::printYN(jnews::upgrade_News1(), '<br />' . _JNEWS_IMPORT_SUCCESS . ' Anjel data', _JNEWS_ERROR);
            jnews::resetUpgrade(1);
            echo '<br />' . $message;
            break;
        case 'new2':
            backHTML::_header(_JNEWS_MENU_UPDATE, 'import.png', $message, $task, $action);
            $message = jnews::printYN(jnews::upgrade_News2(), '<br />' . _JNEWS_IMPORT_SUCCESS . ' Letterman data', _JNEWS_ERROR);
            jnews::resetUpgrade(2);
            echo '<br />' . $message;
            break;
        case 'new3':
            backHTML::_header(_JNEWS_MENU_UPDATE, 'import.png', $message, $task, $action);
            $message = jnews::printYN(jnews::upgrade_News3(), '<br />' . _JNEWS_IMPORT_SUCCESS . ' YaNC data', _JNEWS_ERROR);
            jnews::resetUpgrade(3);
            echo '<br />' . $message;
            break;
    }
    if ($showListing) {
        backHTML::_header(_JNEWS_MENU_UPDATE, 'import.png', $message, $task, $action);
        backHTML::_upgrade();
        $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">";
        echo $forms['main'];
        backHTML::formStart('', '', '');
        backHTML::showCompsList($update);
        $go[] = jnews::makeObj('act', $action);
        backHTML::formEnd($go);
    } elseif ($showComplete) {
        backHTML::_header(_JNEWS_MENU_UPDATE, 'import.png', $message, $task, $action);
        $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">";
        echo $forms['main'];
        backHTML::formStart('', '', '');
        backHTML::showUpdateOptions($update);
        $go[] = jnews::makeObj('act', $action);
        backHTML::formEnd($go);
    }
}
Esempio n. 8
0
/**
* @copyright Copyright (C) 2009 Joobi Limited All rights reserved.
* @license This file is released under the GPL license (http://www.gnu.org/licenses )
* @link http://www.ijoobi.com
*/
function mailing($action, $task, $listId, $listType, $mailingId, $message)
{
    $showMailings = false;
    switch ($task) {
        case 'edit':
            if (ACA_CMSTYPE) {
                // joomla 15
                $issue_nb = intval(JRequest::getVar('issue_nb', 1));
            } else {
                //joomla 1x
                $issue_nb = intval(mosGetParam($_REQUEST, 'issue_nb', 1));
            }
            //endif
            $list = lists::getOneList($listId);
            $mailing = xmailing::getOneMailing($list, $mailingId, $issue_nb, $new);
            $show = lisType::showType($mailing->list_type, 'editmailing');
            if ($mailing->published != 1 or $mailing->list_type != 1 or isset($show['admin']) and $show['admin']) {
                $forms['main'] = " <form action='index2.php' method='post' enctype='multipart/form-data' name='adminForm'> \n ";
                xmailing::_header($task, $action, $mailing->list_type, $message, 'edit');
                mailingsHTML::editMailing($mailing, $new, $listId, $forms, $show);
                $go[] = acajoom::makeObj('act', $action);
                backHTML::formEnd($go);
            } else {
                $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n\r";
                xmailing::_header($task, $action, $mailing->list_type, $message);
                //backHTML::formStart();
                mailingsHTML::viewMailing($mailing, $forms);
                $go[] = acajoom::makeObj('act', 'mailing');
                $go[] = acajoom::makeObj('task', 'viewmailing');
                $go[] = acajoom::makeObj('listid', $mailing->list_id);
                backHTML::formEnd($go);
            }
            break;
        case 'new':
        case 'add':
            if ($listId == 0) {
                echo "<script> alert('" . addslashes(_ACA_SELCT_MAILING) . "'); window.history.go(-1);</script>\n";
                return false;
            } else {
                $total = xmailing::countMailings($listId, '');
                $total++;
                compa::redirect('index2.php?option=com_acajoom&act=mailing&task=edit&mailingid=0&issue_nb=' . $total . '&listid=' . $listId);
            }
            break;
        case 'saveSend':
            xmailing::saveMailing($mailingId, $listId);
        case 'sendNewsletter':
            if ($listId < 1 or $listType < 0) {
                $mailing = xmailing::getOneMailing('', $mailingId, '', $new, true);
                $listId = $mailing->list_id;
                $listType = $mailing->list_type;
            }
            if (lisType::sendType($listType)) {
                $checkStatus = lists::checkStatus($listId);
                if ($checkStatus == false) {
                    $message = acajoom::printYN(0, _ACA_MESSAGE_SENT_SUCCESSFULLY, _ACA_NOT_PUBLISHED);
                    $showMailings = true;
                } else {
                    $receivers = subscribers::getSubscribers(-1, -1, '', $total, $listId, '', 1, 1, 'sub_emailA');
                    if (empty($receivers)) {
                        $message = acajoom::printYN(0, _ACA_MESSAGE_SENT_SUCCESSFULLY, _ACA_NO_SUSCRIBERS);
                        $showMailings = true;
                    } else {
                        $status = queue::sendNewsletter(true, $mailingId, $listId, $receivers, $message);
                        $message = acajoom::printYN($status, _ACA_MESSAGE_SENT_SUCCESSFULLY, $message);
                        $showMailings = true;
                        flush();
                        sleep(5);
                        compa::redirect('index2.php?option=com_acajoom&act=mailing&listype=' . $listType, $message);
                    }
                }
            } else {
                if (class_exists('auto')) {
                    $message = acajoom::printYN(auto::processQueue(true), _ACA_QUEUE_SENT_SUCCESS, _ACA_ERROR);
                }
                $showMailings = true;
            }
            break;
        case 'savePreview':
            xmailing::saveMailing($mailingId, $listId);
        case 'preview':
            if (ACA_CMSTYPE) {
                // joomla 15
                $emailaddress = JRequest::getVar('emailaddress', '');
            } else {
                //joomla 1x
                $emailaddress = mosGetParam($_REQUEST, 'emailaddress', '');
            }
            //endif
            if (!empty($emailaddress)) {
                $status = xmailing::preview($mailingId, $listId, $message);
                $message = acajoom::printYN($status, _ACA_MESSAGE_SENT_SUCCESSFULLY, $message);
            }
            backHTML::_header(_ACA_PREVIEW_TITLE, 'preview_f2.png', $message, $task, $action);
            mailingsHTML::previewMailingHTML($mailingId, $listId, $listType);
            if ($listId > 0) {
                $archivemailing = xmailing::getMailingView($mailingId, $listId);
            } else {
                $archivemailing = xmailing::getMailingView($mailingId);
            }
            $forms['main'] = '';
            $list = lists::getOneList($archivemailing->list_id);
            $textonly = '';
            acajoom_mail::getContent($archivemailing->images, $list->layout, $archivemailing->htmlcontent, $textonly);
            acajoom_mail::replaceClass($archivemailing->htmlcontent, $textonly);
            mailingsHTML::viewMailing($archivemailing, $forms);
            break;
        case 'view':
            if ($mailingId != 0) {
                if ($listId > 0) {
                    $archivemailing = xmailing::getMailingView($mailingId, $listId);
                } else {
                    $archivemailing = xmailing::getMailingView($mailingId);
                }
                $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n\r";
                xmailing::_header($task, $action, $listType, $message);
                backHTML::formStart('', 0, '');
                mailingsHTML::viewMailing($archivemailing, $forms);
                $go[] = acajoom::makeObj('act', 'mailing');
                $go[] = acajoom::makeObj('task', 'viewmailing');
                $go[] = acajoom::makeObj('listid', $archivemailing->list_id);
                backHTML::formEnd($go);
            }
            break;
        case 'deleteMailing':
            $d['mailing'] = xmailing::getOneMailing('', $mailingId, '', $new);
            $message = acajoom::printYN(xmailing::delete($d), @constant($GLOBALS[ACA . 'listname' . $d['mailing']->list_type]) . _ACA_SUCCESS_DELETED, _ACA_ERROR);
            $showMailings = true;
            break;
        case 'cancel':
            compa::redirect('index2.php?option=com_acajoom');
            break;
        case 'copy':
            $message = acajoom::printYN(xmailing::copyMailing($mailingId), _ACA_MAILING_COPY, _ACA_ERROR);
            $showMailings = true;
            break;
        case 'cancelMailing':
            $showMailings = true;
            break;
        case 'publishMailing':
            $mailing = xmailing::getOneMailing('', $mailingId, '', $new);
            $message = acajoom::printYN(xmailing::publishMailing($mailingId), @constant($GLOBALS[ACA . 'listname' . $mailing->list_type]) . ' ' . _ACA_PUBLISHED, _ACA_ERROR);
            $showMailings = true;
            break;
        case 'unpublishMailing':
            $mailing = xmailing::getOneMailing('', $mailingId, '', $new);
            $message = acajoom::printYN(xmailing::unpublishMailing($mailingId), @constant($GLOBALS[ACA . 'listname' . $mailing->list_type]) . ' ' . _ACA_UNPUBLISHED, _ACA_ERROR);
            $showMailings = true;
            break;
        case 'cpanel':
            backHTML::controlPanel();
            break;
        case 'save':
            $message = acajoom::printYN(xmailing::saveMailing($mailingId, $listId), _ACA_MAILING_SAVED, _ACA_ERROR);
            $showMailings = true;
            unset($GLOBALS["task"]);
            unset($_REQUEST["task"]);
            break;
        case 'show':
        default:
            $showMailings = true;
            break;
    }
    if ($showMailings) {
        xmailing::showMailings($task, $action, $listId, $listType, $message, true, _ACA_MENU_MAILING);
    }
    return true;
}
 function about()
 {
     echo '<table width="100%" align="left"><tr>';
     echo '<td>';
     echo '<form action="index2.php" method="post" name="adminForm">';
     acajoom::beginingOfTable('acajoomtable');
     acajoom::miseEnPage('Description', '', constant('_ACA_DESC_' . strtoupper($GLOBALS[ACA . 'type'])));
     acajoom::miseEnPage('Project Manager', '', 'Adrien Baborier');
     acajoom::miseEnPage('Contributor', '', 'Christelle Gesset');
     acajoom::miseEnPage('Logo design', '', '<a href="http://www.gaboink.com" target="_blank">George Jones</a>');
     acajoom::miseEnPage('Template design', '', '<a href="http://www.72dpi.net.au" target="_blank">Ryan Scott</a>');
     acajoom::miseEnPage('Video tutorials', '', '<a href="http://www.wisewomengroup.com" target="_blank">Lisa Egan</a>');
     acajoom::miseEnPage('CB Integration', '', 'Mikko R&ouml;nkk&ouml;');
     acajoom::miseEnPage('Add-ons', '', 'Kyle Witt');
     acajoom::miseEnPage('Language Translation', '', '');
     acajoom::miseEnPage('Danish', '', 'Joergen Floes');
     acajoom::miseEnPage('Dutch', '', 'Tromp Wezelman & Bart Bevers');
     acajoom::miseEnPage('French', '', 'Christelle Gesset');
     acajoom::miseEnPage('German', '', 'David Freund & Frank Jansen');
     acajoom::miseEnPage('Hungarian', '', 'Zolt&aacute;n Varanka');
     acajoom::miseEnPage('Italian', '', 'Maria Luisa Rossari');
     acajoom::miseEnPage('Norwegian', '', '<a href="http://www.timeoffice.com" target="_blank">Irma Rustad</a>');
     acajoom::miseEnPage('Polish', '', 'Andrzej Herzberg');
     acajoom::miseEnPage('Portuguese', '', 'Ricardo Sim&otilde;es');
     acajoom::miseEnPage('Russian', '', 'Salikhov Ilyas');
     acajoom::miseEnPage('Simplified Chinese', '', '<a href="http://www.joomlagate.com" target="_blank">Baijianpeng</a>');
     acajoom::miseEnPage('Spanish', '', '<a href="http://www.eaid.org" target="_blank">Jorge Pasco</a>');
     acajoom::miseEnPage('Swedish', '', 'Janne Karlsson');
     acajoom::miseEnPage(' ', '', '   ');
     acajoom::miseEnPage(_ACA_VERSION, '', acajoom::version());
     acajoom::miseEnPage(' ', '', '   ');
     acajoom::miseEnPage(_ACA_DESC_HOME, '', '<a href="' . $GLOBALS[ACA . 'homesite'] . '" target="_blank">www.Acajoom.com</a>');
     acajoom::miseEnPage(_ACA_MENU_HELP, '', '<a href="http://www.acajoom.com/content/blogcategory/29/93/" target="_blank">Documentation</a>');
     acajoom::miseEnPage(_ACA_MENU_HELP, '', '<a href="http://www.acajoom.com/index.php?option=com_joomlaboard&Itemid=26&task=listcat&catid=22" target="_blank">Forum</a>');
     acajoom::miseEnPage(_ACA_MENU_LEARN, '', '<a href="' . $GLOBALS[ACA . 'homesite'] . 'index.php?option=com_content&task=blogsection&id=5&Itemid=68" target="_blank">Education Center</a>');
     acajoom::miseEnPage('Copyrights', '', 'Acajoom <i>Your Communciation Partner</i>, &copy; Acajoom Services');
     ### http://www.acajoom.com/license.php
     ### http://www.acajoom.com/license.php
     acajoom::miseEnPage(_ACA_LICENSE, '', '<a href="http://www.acajoom.com/index.php?option=com_content&task=view&id=2282&Itemid=84" target="_blank">&copy; Acajoom Services</a>');
     acajoom::endOfTable();
     backHTML::formEnd();
     echo '</td>';
     echo '<td width="380px">';
     $logo = 'acajoom_slog_' . strtolower($GLOBALS[ACA . 'type']) . '.png';
     echo '<a href="http://www.acajoom.com" target="_blank"><img src="components/com_acajoom/images/' . $logo . '" alt="Acajoom Logo" border="0" align="center" /></a>';
     echo '</td>';
     echo '</tr></table>';
 }
Esempio n. 10
0
function mailing($action, $task, $listId, $listType, $mailingId, $message)
{
    $showMailings = false;
    $db = JFactory::getDBO();
    switch ($task) {
        case 'edit':
            $issue_nb = JRequest::getInt('issue_nb', 1);
            $mailingType = JRequest::getVar('listype');
            $isEdit = JRequest::getVar('isEdit', true);
            $mySess = JFactory::getSession();
            $mySess->set('listype', $mailingType, 'LType');
            if (!empty($listId)) {
                $list = jNews_Lists::getOneList($listId);
            } else {
                $list = jNews_Lists::getListFirstEntry();
            }
            $new = empty($mailingId) || $mailingId == 0 ? true : false;
            $mailing = jNews_Mailing::getOneMailing($list, $mailingId, $issue_nb, $new, false, true);
            $mailing->mailing_type = $mailingType;
            //			if(empty($isEdit)) $isEdit = true;
            // set default mailing parameters
            $my = JFactory::getUser();
            $subscribers = jNews_Subscribers::getSubscriberInfoFromUserId($my->id);
            if (!isset($subscribers)) {
                $subscribers = new stdClass();
            }
            $subscribers->name = isset($subscribers->name) ? $subscribers->name : '';
            $subscribers->email = isset($subscribers->email) ? $subscribers->email : '';
            //			$mailing->fromname = ( !isset( $mailing->fromname ) || empty( $mailing->fromname ) ) ? $subscribers->name : $mailing->fromname;
            //			$mailing->fromemail = ( !isset( $mailing->fromemail ) || empty( $mailing->fromemail ) ) ? $subscribers->email : $mailing->fromemail;
            //			$mailing->frombounce = ( !isset( $mailing->frombounce ) || empty( $mailing->frombounce ) ) ? $GLOBALS[JNEWS.'sendmail_from'] : $mailing->frombounce;
            $show = jNews_ListType::showType($mailing->mailing_type, 'editmailing');
            if ($mailing->published != 1 or $mailing->mailing_type != 1 or isset($show['admin']) and $show['admin']) {
                $forms['main'] = " <form action='index.php' method='post' enctype='multipart/form-data' name='adminForm' id=\"adminForm\">";
                jNews_Mailing::_header($task, $action, $mailing->mailing_type, $message, 'edit');
                jNews_MailingsHTML::editMailing($mailing, $new, $listId, $forms, $show, $isEdit);
                $go[] = jnews::makeObj('act', $action);
                backHTML::formEnd($go);
            } else {
                $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">";
                jNews_Mailing::_header($task, $action, $mailing->mailing_type, $message);
                //backHTML::formStart();
                jNews_MailingsHTML::viewMailing($mailing, $forms);
                $go[] = jnews::makeObj('act', 'mailing');
                $go[] = jnews::makeObj('task', 'viewmailing');
                $go[] = jnews::makeObj('mailingid', $mailing->id);
                backHTML::formEnd($go);
            }
            break;
        case 'new':
        case 'add':
            // check if atleast one list exist and published
            // if false then restrict entry
            $mailingType = JRequest::getVar('listype');
            $type = $mailingType == 2 ? 2 : 1;
            $result = jNews_Lists::checkListNotEmpty($type);
            if (!$result) {
                if ($type == 2) {
                    $disp = addslashes(_JNEWS_CHECKCAMPAIGNFOUND);
                } else {
                    $disp = addslashes(_JNEWS_CHECKLISTFOUND);
                }
                echo "<script> alert('" . $disp . "'); window.history.go(-1);</script>\n";
                break;
            }
            $mailingType = JRequest::getVar('listype');
            if (empty($listId)) {
                $listId = JRequest::getVar('listid');
            }
            if (!empty($listId)) {
                $mailingType = jNews_Lists::getListType($listId) == 2 ? 2 : 1;
            }
            JRequest::setVar('listype', $mailingType);
            $total = jNews_Mailing::countMailings($listId, $mailingType);
            $total++;
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&task=edit&mailingid=0&issue_nb=' . $total . '&listype=' . $mailingType . '&listid=' . $listId . '&isEdit=0');
            //mariap
            break;
        case 'saveSend':
            JRequest::checkToken() or die('Invalid Token');
            $mySess = JFactory::getSession();
            $mailingType = $mySess->get('listype', '', 'LType');
            $status = checkMailingSave($mailingType);
            if (!$status) {
                return false;
            }
            jNews_Mailing::saveMailing($mailingId, $listId);
        case 'sendready':
            //we update the senddate of the newsletter
            jNews_Mailing::updatesenddate($mailingId);
            jNews_MailingsHTML::sendReady($mailingId, $listId, $listType);
            break;
        case 'generate':
            if (class_exists('jNews_Auto')) {
                $still = false;
                $message = jnews::printYN(jNews_Auto::processQueue(true, true, $still, true), 'Queue processed', _JNEWS_ERROR);
                jNews_Auto::displayStatus();
            }
            return;
            break;
        case 'send':
            $queueC = new jNews_Queue();
            $queueC->checkForNewsletters($mailingId);
            $queueCount = jNews_Queue::getQueueCount($mailingId);
            $totalSub = JRequest::setVar('totalsend', $queueCount);
            $linkURL = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=mailing&task=continuesend&mailingid=' . $mailingId . '&totalsend=' . $totalSub, true, false, true);
            jNews_Tools::redirect($linkURL);
            break;
        case 'continuesend':
            $queueC = new jNews_Queue();
            //we update the senddate of the mailing to be now to be able to continue the sending and send it after we click continue
            //			$queueC->updateSenddateToNow($mailingId);
            $totalSend = JRequest::getVar('totalsend', 0, '', 'int');
            $alreadySent = JRequest::getVar('alreadysent', 0, '', 'int');
            $queueC->start = $alreadySent;
            $queueC->total = $totalSend;
            $queueC->pause = $GLOBALS[JNEWS . 'pause_time'];
            $queueC->sendQueue(false, $mailingId, false, true);
            ob_start();
            exit;
            break;
        case 'testspam':
            if (empty($message)) {
                $message = _JNEWS_MESSAGE_NOT;
            }
            $mailingId = $mailingId == 0 ? jNews_Mailing::getLastMailingId() : $mailingId;
            $my = JFactory::getUser();
            if ($listId > 0) {
                $archivemailing = jNews_Mailing::getMailingView($mailingId, $listId);
            } else {
                $archivemailing = jNews_Mailing::getMailingView($mailingId);
            }
            $mailing = new stdClass();
            $receivers = new stdClass();
            $receivers->email = '*****@*****.**';
            $receivers->name = $archivemailing->fromname;
            $receivers->receive_html = 1;
            $receivers->id = jNews_Subscribers::getSubscriberIdFromUserId($my->id);
            //if email are different we dont replace because we want to make sure the spam cehck count the fact that
            //sender and bounce back are different
            if ($archivemailing->fromemail == $archivemailing->frombounce) {
                $archivemailing->frombounce = $my->email;
            }
            $archivemailing->fromemail = $my->email;
            $mailerC = new jNews_ProcessMail();
            $status = $mailerC->send($archivemailing, $receivers);
            $message = jnews::printYN($status, _JNEWS_SPAMTEXT_MESSAGE_SENT_SUCCESSFULLY, $message);
            $link = 'http://www.joobi.co/index.php?option=com_jlinks&controller=redirect&link=SpamCheck&alt=jnewsdoc_glossary';
            $iFrame = '<iframe src="' . $link . '" width="100%" height="680px" scrolling="auto"></iframe>';
            echo $iFrame;
            break;
        case 'savePreview':
            JRequest::checkToken() or die('Invalid Token');
            $status = checkMailingSave($mailingType);
            if (!$status) {
                return false;
            }
            if ($mailingType == 7) {
                $mailing = JRequest::getVar('mailing', '');
                $ContentStatus = checkTag();
                if (!$ContentStatus) {
                    return false;
                }
            }
            jNews_Mailing::saveMailing($mailingId, $listId);
        case 'preview':
            $emailaddress = JRequest::getVar('emailaddress', '');
            $mailingId = $mailingId == 0 ? jNews_Mailing::getLastMailingId() : $mailingId;
            if (!empty($emailaddress)) {
                $status = jNews_Mailing::sendTestEmail($mailingId, $listId);
                if (empty($message)) {
                    $message = _JNEWS_MESSAGE_NOT;
                }
                $message = jnews::printYN($status, _JNEWS_MESSAGE_SENT_SUCCESSFULLY, $message);
            }
            if ($listId > 0) {
                $archivemailing = jNews_Mailing::getMailingView($mailingId, $listId);
            } else {
                $archivemailing = jNews_Mailing::getMailingView($mailingId);
            }
            $doc = JFactory::getDocument();
            $css = '.icon-48-preview{ background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/preview.png)}';
            $doc->addStyleDeclaration($css, $type = 'text/css');
            $title = _JNEWS_PREVIEW_TITLE . ': ' . $archivemailing->subject;
            backHTML::_header(_JNEWS_PREVIEW_TITLE, 'preview.png', $message, $task, $action);
            //new view for the preview mailing
            echo '<table cellpadding="0" cellspacing="2" border="0" width="100%"><tr><td width="40%">';
            jNews_MailingsHTML::previewMailingHTML($mailingId, $listId, $listType, $archivemailing->html);
            echo '</td><td width="60%">';
            $forms['main'] = '';
            $list = jNews_Lists::getOneList($archivemailing->list_id);
            $textonly = '';
            $mailerC = new jNews_ProcessMail();
            $queueInfo = new stdClass();
            $queueInfo->mailingid = $mailingId;
            $queueInfo->listid = @$listId;
            $mailerC->getContent($archivemailing->images, $archivemailing->html, $archivemailing->textonly, $archivemailing->subject, false, true, $queueInfo);
            //new $archivemailing->subject
            if ($archivemailing->html == 1) {
                if (empty($template_id)) {
                    $template_id = $archivemailing->template_id;
                }
                if (!empty($template_id)) {
                    jNews_Templates::includeStyles($archivemailing->htmlcontent, $template_id);
                }
            } else {
                $archivemailing->textonly = jNews_ProcessMail::htmlToText($archivemailing->textonly);
            }
            //new view for the preview mailing
            jNews_MailingsHTML::viewHeading($archivemailing);
            echo '</td></tr><tr><td colspan="2">';
            jNews_MailingsHTML::viewMailing($archivemailing, $forms);
            echo '</td></tr></tbody></table>';
            if ($mailingId == 0) {
                JRequest::setVar('mailingid', $mailingId);
            }
            break;
        case 'view':
            $mailingType = JRequest::getVar('listype');
            if (!empty($mailingType)) {
                $mySess = JFactory::getSession();
                $mySess->set('listype', $mailingType, 'LType');
            }
            if ($mailingId != 0) {
                if ($listId > 0) {
                    $archivemailing = jNews_Mailing::getMailingView($mailingId, $listId);
                } else {
                    $archivemailing = jNews_Mailing::getMailingView($mailingId);
                }
                if (empty($template_id)) {
                    $template_id = $archivemailing->template_id;
                }
                if (!empty($template_id)) {
                    jNews_Templates::includeStyles($archivemailing->htmlcontent, $template_id);
                }
                $forms['main'] = "<form action='index.php?option=" . JNEWS_OPTION . "&act=mailing&listype=" . $listType . "&listid=" . $listId . "' method='post' name='adminForm' id=\"adminForm\">";
                jNews_Mailing::_header($task, $action, $listType, $message);
                backHTML::formStart('show_mailing', 0, '');
                jNews_MailingsHTML::viewMailing($archivemailing, $forms);
                $go[] = jnews::makeObj('act', 'mailing');
                $go[] = jnews::makeObj('task', 'viewmailing');
                $go[] = jnews::makeObj('listId', $archivemailing->list_id);
                //listid to listId--original
                backHTML::formEnd($go);
            }
            break;
        case 'deletequeue':
            //implement here what are we going to do with the delete queueu column on the mailing
            $mailingID = JRequest::getVar('mailingid');
            $mailingType = JRequest::getVar('listype');
            if (!empty($mailingID)) {
                $db = JFactory::getDBO();
                $db->setQuery('DELETE FROM `#__jnews_queue` WHERE `mailing_id` = ' . $mailingID);
                $db->query();
                $message = jnews::printYN(true, _JNEWS_MAILING_QUEUE_DELETED, _JNEWS_ERROR);
            } else {
                $message = jnews::printYN(false, _JNEWS_MAILING_QUEUE_DELETED, _JNEWS_ERROR);
            }
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType, $message);
            break;
        case 'deleteMailing':
            JRequest::checkToken() or die('Invalid Token');
            $d['mailing'] = jNews_Mailing::getOneMailing('', $mailingId, '', $new);
            $message = jnews::printYN(jNews_Mailing::delete($d), @constant($GLOBALS[JNEWS . 'listname' . $d['mailing']->list_type]) . '"' . $d['mailing']->subject . '"' . _JNEWS_SUCCESS_DELETED, _JNEWS_ERROR);
            $showMailings = true;
            break;
        case 'cancel':
            $url = 'index.php?option=' . JNEWS_OPTION . '&act=mailing&mailingid=' . $mailingId;
            $url .= (!empty($listId) ? '&listid=' . $listId : '') . '&listype=' . $mailingType;
            jNews_Tools::redirect($url);
            break;
        case 'copy':
            JRequest::checkToken() or die('Invalid Token');
            $message = jnews::printYN(jNews_Mailing::copyMailing($mailingId), _JNEWS_MAILING_COPY, _JNEWS_ERROR);
            $showMailings = true;
            break;
        case 'cancelMailing':
            $showMailings = true;
            break;
        case 'publishMailing':
            JRequest::checkToken() or die('Invalid Token');
            $mailing = jNews_Mailing::getOneMailing('', $mailingId, '', $new);
            $message = jnews::printYN(jNews_Mailing::publishMailing($mailingId), @constant($GLOBALS[JNEWS . 'listname' . $mailing->mailing_type]) . ' ' . _JNEWS_PUBLISHED, _JNEWS_ERROR);
            $mailingType = jNews_Mailing::getMailingInfoz($mailingId);
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType);
            break;
        case 'unpublishMailing':
            JRequest::checkToken() or die('Invalid Token');
            $mailing = jNews_Mailing::getOneMailing('', $mailingId, '', $new);
            $message = jnews::printYN(jNews_Mailing::unpublishMailing($mailingId), @constant($GLOBALS[JNEWS . 'listname' . $mailing->mailing_type]) . ' ' . _JNEWS_UNPUBLISHED, _JNEWS_ERROR);
            $mailingType = jNews_Mailing::getMailingInfoz($mailingId);
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId);
            break;
        case 'cpanel':
            backHTML::controlPanel();
            break;
        case 'save':
            JRequest::checkToken() or die('Invalid Token');
            $subject = JRequest::getVar('subject', '');
            if (empty($subject)) {
                echo "<script> alert('subject needs to be not empty'); window.history.go(-1);</script>\n";
                return false;
            }
            if (!isset($mailingType)) {
                $mySess = JFactory::getSession();
                $mailingType = $mySess->get('listype', '', 'LType');
            }
            $status = checkMailingSave($mailingType);
            if ($mailingType == 7) {
                $mailing = JRequest::getVar('mailing', '');
                $ContentStatus = checkTag();
                if (!$ContentStatus) {
                    return false;
                }
            }
            if (!$status) {
                return false;
            }
            $message = jnews::printYN(jNews_Mailing::saveMailing($mailingId, $listId), _JNEWS_MAILING_SAVED, _JNEWS_ERROR);
            if (!empty($mailingtype)) {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId);
            } else {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId);
                $showMailings = true;
                unset($GLOBALS["task"]);
                unset($_REQUEST["task"]);
            }
            break;
        case 'apply':
            JRequest::checkToken() or die('Invalid Token');
            $mailingid = JRequest::getVar('mailingid', '0');
            if (!isset($mailingType)) {
                $mySess = JFactory::getSession();
                $mailingType = $mySess->get('listype', '', 'LType');
            }
            $status = checkMailingSave($mailingType);
            if ($mailingType == 7) {
                $mailing = JRequest::getVar('mailing', '');
                $ContentStatus = checkTag();
                if (!$ContentStatus) {
                    return false;
                }
            }
            if (!$status) {
                return false;
            }
            $message = jnews::printYN(jNews_Mailing::saveMailing($mailingId, $listId), _JNEWS_MAILING_SAVED, _JNEWS_ERROR);
            $mailingid = $mailingid == 0 ? jNews_Mailing::getLastMailingId() : $mailingid;
            if (!empty($mailingtype)) {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&task=edit&listype=' . $mailingType . '&mailingid=' . $mailingid . '&listid=' . $listId);
            } else {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&task=edit&listype=' . $mailingType . '&mailingid=' . $mailingid . '&listid=' . $listId);
                $showMailings = true;
                unset($GLOBALS["task"]);
                unset($_REQUEST["task"]);
            }
            break;
        case 'show':
            $id = JRequest::getVar('mailingid');
            $mySess = JFactory::getSession();
            $mailingType = JRequest::getVar('listype', 0);
            $listId = JRequest::getVar('listid', 0);
            $link = 'index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId;
            jNews_Tools::redirect($link);
            $showMailings = true;
            break;
        case 'toggle':
            $listid = JRequest::getVar('listid');
            $column = JRequest::getVar('col');
            $mailingid = JRequest::getVar('mailingid');
            if (!empty($mailingid) && !empty($column)) {
                $passObj = new stdClass();
                $passObj->tableName = '#__jnews_mailings';
                $passObj->columnName = $column;
                $passObj->whereColumn = 'id';
                $passObj->whereColumnValue = $mailingid;
                jnews::toggle($passObj);
            }
            if ($listType == 1) {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listid . '&listype=1');
            } else {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listid . '&listype=2');
            }
            break;
        default:
            $showMailings = true;
            break;
    }
    if ($showMailings) {
        if (empty($listType)) {
            $listType = JRequest::getVar('listype', 0);
        }
        if (empty($listId)) {
            $listId = JRequest::getVar('listid', 0);
        }
        $paginationStart = JRequest::getVar('pg');
        if (!empty($paginationStart)) {
            $limitstart = 0;
            $limitend = $paginationStart;
        } else {
            $app = JFactory::getApplication();
            $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int');
            $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int');
        }
        $limittotal = jNews_Mailing::countMailings(0, $listType);
        $setLimit = new stdClass();
        $setLimit->total = !empty($limittotal) ? $limittotal : 0;
        $setLimit->start = !empty($limitstart) ? $limitstart : 0;
        $setLimit->end = !empty($limitend) ? $limitend : $limittotal;
        if ($setLimit->total == $setLimit->end) {
            $setLimit->start = 0;
        }
        jNews_Mailing::showMailings($task, $action, $listId, $listType, $message, true, _JNEWS_MENU_MAILING, $setLimit);
    }
    return true;
}
Esempio n. 11
0
/**
* @copyright Copyright (C) 2009 Joobi Limited All rights reserved.
* @license This file is released under the GPL license (http://www.gnu.org/licenses )
* @link http://www.ijoobi.com
*/
function update($action, $task)
{
    $update = new wupdate();
    $showListing = true;
    $showComplete = false;
    if (ACA_CMSTYPE) {
        // joomla 15
        $message = JRequest::getVar('message', '');
    } else {
        //joomla 1x
        $message = mosGetParam($_REQUEST, 'message', '');
    }
    //endif
    if (ini_get('safe_mode')) {
    } else {
        @set_time_limit(60 * $GLOBALS[ACA . 'script_timeout']);
    }
    /*if ((ini_get('allow_url_fopen') == false && !in_array('curl', get_loaded_extensions())) || ini_get('safe_mode') == true) {
    		 echo _ACA_WARNING_1011;
    		 return;
    	 }*/
    switch ($task) {
        case 'doUpdate':
            backHTML::_header(_ACA_MENU_UPDATE, 'update', $message, $task, $action);
            $update->doUpdate();
            $showListing = false;
            $showComplete = false;
            break;
        case 'version':
            $update->getVersion();
            break;
        case 'complete':
            $showComplete = true;
            $showListing = false;
            break;
        case 'cancel':
            compa::redirect('index2.php?option=com_acajoom&act=update');
            $showListing = false;
            break;
        case 'cpanel':
            compa::redirect('index2.php?option=com_acajoom');
            $showListing = false;
            break;
        case 'new1':
            backHTML::_header(_ACA_MENU_UPDATE, 'backup.png', $message, $task, $action);
            $message = acajoom::printYN(acajoom::upgrade_News1(), '<br />' . _ACA_IMPORT_SUCCESS . ' Anjel data', _ACA_ERROR);
            acajoom::resetUpgrade(1);
            echo '<br />' . $message;
            break;
        case 'new2':
            backHTML::_header(_ACA_MENU_UPDATE, 'backup.png', $message, $task, $action);
            $message = acajoom::printYN(acajoom::upgrade_News2(), '<br />' . _ACA_IMPORT_SUCCESS . ' Letterman data', _ACA_ERROR);
            acajoom::resetUpgrade(2);
            echo '<br />' . $message;
            break;
        case 'new3':
            backHTML::_header(_ACA_MENU_UPDATE, 'backup.png', $message, $task, $action);
            $message = acajoom::printYN(acajoom::upgrade_News3(), '<br />' . _ACA_IMPORT_SUCCESS . ' YaNC data', _ACA_ERROR);
            acajoom::resetUpgrade(3);
            echo '<br />' . $message;
            break;
    }
    if ($showListing) {
        backHTML::_header(_ACA_MENU_UPDATE, 'backup.png', $message, $task, $action);
        backHTML::_upgrade();
        $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n";
        echo $forms['main'];
        backHTML::formStart('', '', '');
        backHTML::showCompsList($update);
        $go[] = acajoom::makeObj('act', $action);
        backHTML::formEnd($go);
    } elseif ($showComplete) {
        backHTML::_header(_ACA_MENU_UPDATE, 'backup.png', $message, $task, $action);
        $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n";
        echo $forms['main'];
        backHTML::formStart('', '', '');
        backHTML::showUpdateOptions($update);
        $go[] = acajoom::makeObj('act', $action);
        backHTML::formEnd($go);
    }
}
Esempio n. 12
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);
 }
Esempio n. 13
0
 public static function about()
 {
     echo '<table width="100%" align="left"><tr>';
     echo '<td>';
     echo '<form action="index.php" method="post" name="adminForm" id="adminForm">';
     jnews::beginingOfTable('jnewstable');
     jnews::miseEnPage('Description', '', constant('_JNEWS_DESC_' . strtoupper($GLOBALS[JNEWS . 'type'])));
     jnews::miseEnPage('Developers', '', 'Evelyn Lopez, Mary Michelle Piquero, Gerald R. Zalsos, Ebony Grace Ursua, Mary Grace Arabis, Gino Tayo, <br/>Glenn Jaime Chan, Adel Fomar Dulanas, Lalene Cababat, Jhen Bontilao');
     jnews::miseEnPage('Contributor', '', 'Amir Ben Avraham, Christelle Gesset & Adrien Baborier');
     jnews::miseEnPage('Captcha Contributor', '', 'Sorin Rosen');
     jnews::miseEnPage('Designer', '', 'Rochel Abrasaldo');
     jnews::miseEnPage('CB Integration', '', 'Mikko R&ouml;nkk&ouml;');
     jnews::miseEnPage('Add-ons', '', 'Kyle Witt');
     jnews::miseEnPage('Language Translation', '', '');
     jnews::miseEnPage('Brazilian_portuguese', '', 'Navsoft');
     jnews::miseEnPage('Danish', '', 'Joergen Floes');
     jnews::miseEnPage('Dutch', '', 'Tromp Wezelman & Bart Bevers');
     jnews::miseEnPage('Finnish', '', 'Tero Kankaanperä');
     jnews::miseEnPage('French', '', 'Christelle Gesset');
     jnews::miseEnPage('German', '', 'David Freund & Frank Jansen');
     jnews::miseEnPage('Hebrew', '', 'Eszter Somos & Adam Segev');
     jnews::miseEnPage('Hungarian', '', 'Zolt&aacute;n Varanka');
     jnews::miseEnPage('Italian', '', 'Maria Luisa Rossari');
     jnews::miseEnPage('Norwegian', '', '<a href="http://www.timeoffice.com" target="_blank">Irma Rustad</a>');
     jnews::miseEnPage('Polish', '', 'Andrzej Herzberg');
     jnews::miseEnPage('Portuguese', '', 'Ricardo Sim&otilde;es');
     jnews::miseEnPage('Simplified Chinese', '', '<a href="http://www.joomlagate.com" target="_blank">Baijianpeng</a>');
     jnews::miseEnPage('Spanish', '', '<a href="http://www.eaid.org" target="_blank">Jorge Pasco</a>');
     jnews::miseEnPage('Swedish', '', 'Janne Karlsson');
     jnews::miseEnPage('Turkish', '', 'Anonymous');
     jnews::miseEnPage('CSS class to style attribute', '', '<a href="http://classes.verkoyen.eu/css_to_inline_styles" target="_NEW">http://classes.verkoyen.eu/css_to_inline_styles</a>');
     jnews::miseEnPage(' ', '', '   ');
     jnews::miseEnPage(_JNEWS_VERSION, '', jnews::version());
     jnews::miseEnPage(' ', '', '   ');
     jnews::miseEnPage(_JNEWS_DESC_HOME, '', '<a href="' . $GLOBALS[JNEWS . 'homesite'] . '" target="_blank">' . JNEWS_HOME_SITE . '</a>');
     jnews::miseEnPage(_JNEWS_MENU_HELP, '', '<a href="' . JNEWS_HOME_SITE . '/index.php?option=com_content&Itemid=67&catid=93&id=8241&lang=en&view=article" target="_blank">Documentation</a>');
     jnews::miseEnPage(_JNEWS_MENU_LIVE_SUPPORT, '', '<a href="' . JNEWS_HOME_SITE . '/live-support" target="_blank">Help</a>');
     jnews::miseEnPage(_JNEWS_MENU_LEARN, '', '<a href="http://demo.joobi.co/" target="_blank">Education Center</a>');
     jnews::miseEnPage('Copyrights', '', 'jNews <i>Your Communciation Partner</i>, &copy; Joobi Limited');
     jnews::miseEnPage(_JNEWS_LICENSE, '', '<a href="http://www.joobi.co/index.php?option=com_jlinks&controller=redirect&link=single-license" target="_blank">&copy; Joobi Limited</a>');
     jnews::endOfTable();
     backHTML::formEnd();
     echo '</td>';
     echo '<td width="380px">';
     $logo = 'jnews_logo' . (!empty($GLOBALS[JNEWS . 'type']) ? '_' . strtolower($GLOBALS[JNEWS . 'type']) : '') . '.png';
     echo '<a href="http://www.joobi.co" target="_blank"><img src="http://www.joobi.co/images/' . $logo . '" alt="jNews Logo" border="0" align="center" /></a>';
     echo '</td>';
     echo '</tr></table>';
 }
Esempio n. 14
0
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;
    }
}
Esempio n. 15
0
function queue($action, $task, $listid, $mailingid, $lists, $cid)
{
    $db = JFactory::getDBO();
    $my = JFactory::getUser();
    $start = JRequest::getInt('start');
    $css = '.icon-48-queue { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/queue.png)}';
    $doc = JFactory::getDocument();
    $doc->addStyleDeclaration($css, $type = 'text/css');
    $img = 'queue.png';
    $message = '';
    $xf = new jNews_Config();
    $conf = JFactory::getConfig();
    $mail = new stdClass();
    $mail->Mailer = $conf->get('config.mailer');
    $mailingsearch = JRequest::getVar('mailingsearch', '');
    $start = JRequest::getInt('start');
    $limit = JRequest::getInt('limit', $conf->get('config.list_limit'));
    ?>

<script language="javascript" type="text/javascript">
function submitbutton(pressbutton) {
	var form = document.adminForm;
	if (pressbutton == 'cpanel') {
		form.action = 'index.php?option=<?php 
    echo JNEWS_OPTION;
    ?>
&act=queue&task=cpanel';
	}else if (pressbutton == 'pqueue') {
		var $ok = confirm('Are you sure you want to process queue?');
		if ( $ok == true ){
			form.action = 'index.php?option=<?php 
    echo JNEWS_OPTION;
    ?>
&act=queue&task=pqueue';
		}else{
			return;
		}
	}else if (pressbutton == 'stopqueue') {
		var $ok = confirm('Are you sure you want to stop the queue?');
		if ( $ok == true ){
			form.action = 'index.php?option=<?php 
    echo JNEWS_OPTION;
    ?>
&act=queue&task=stopqueue';
		}else{
			return;
		}
	}else if (pressbutton == 'startqueue') {
		var $ok = confirm('Are you sure you want to start the queue?');
		if ( $ok == true ){
			form.action = 'index.php?option=<?php 
    echo JNEWS_OPTION;
    ?>
&act=queue&task=startqueue';
		}else{
			return;
		}
	}else if (pressbutton == 'delq') {
		var $ok = confirm('Are you sure you want to delete?');
		if ( $ok == true ){
			form.action = 'index.php?option=<?php 
    echo JNEWS_OPTION;
    ?>
&act=queue&task=delq';
		}else{
			return;
		}
	}else if (pressbutton == 'cleanq') {
		var $ok = confirm('Are you sure you want to clear the queue?');
		if ( $ok == true ){
			form.action = 'index.php?option=<?php 
    echo JNEWS_OPTION;
    ?>
&act=queue&task=cleanq';
		}else{
			return;
		}
	}else if (pressbutton == 'block') {
		var $ok = confirm('Are you sure you want to block selected entries?');
		if ( $ok == true ){
			form.action = 'index.php?option=<?php 
    echo JNEWS_OPTION;
    ?>
&act=queue&task=block';
		}else{
			return;
		}
	}else if (pressbutton == 'unblock') {
		var $ok = confirm('Are you sure you want to unblock selected entries?');
		if ( $ok == true ){
			form.action = 'index.php?option=<?php 
    echo JNEWS_OPTION;
    ?>
&act=queue&task=unblock';
		}else{
			return;
		}
	}
	submitform( pressbutton );
}
</script>
	<?php 
    $message = JRequest::getVar('message', '');
    $showqueue = true;
    switch ($task) {
        case 'pqueue':
            if (!$GLOBALS[JNEWS . 'queue_status']) {
                //we start the processing of queue
                $xf->update('queue_status', 1);
                $GLOBALS[JNEWS . 'queue_status'] = 1;
            }
            //create smart-newsletter if necessary
            if (class_exists('jNews_Autonews')) {
                $SmartNewsMessageHTML = jNews_Autonews::createSmartNewsletters();
            } else {
                $SmartNewsMessageHTML = '';
            }
            $queueC = new jNews_Queue();
            $queuedMails = $queueC->queueStatus($mailingid);
            $nextQueuedMails = $queueC->queueStatus($mailingid);
            // , true
            if ($GLOBALS[JNEWS . 'level'] > 1) {
                $scheduledMails = $queueC->getScheduled();
            } else {
                $scheduledMails = null;
            }
            jNews_QueueHTML::processQueueHTML($queuedMails, $nextQueuedMails, $scheduledMails, $mailingid, false, $SmartNewsMessageHTML);
            return;
            break;
        case 'stopqueue':
            //we need to implement here how we can stop the queue
            $xf->update('queue_status', 0);
            //we start the processing of queue
            $GLOBALS[JNEWS . 'queue_status'] = 0;
            //we turn off the queue_process to make sure we only have one process going on
            //$xf->update('queue_process', 0);
            //$GLOBALS[JNEWS.'queue_process']=0;
            JToolBarHelper::custom('startqueue', 'start-queue.png', 'start-queue.png', _JNEWS_MENU_STARTQ, false);
            JToolBarHelper::spacer();
            $message = jnews::printYN(true, _JNEWS_MENU_STOPQ_MSG, $message);
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=queue' . $message);
            break;
        case 'startqueue':
            //we need to implement here how we can start back the queue
            $xf->update('queue_status', 1);
            //we stop the processing of queue
            $GLOBALS[JNEWS . 'queue_status'] = 1;
            //we turn off the queue_process to make sure we only have one process going on
            //$xf->update('queue_process', 0);
            //$GLOBALS[JNEWS.'queue_process']=0;
            JToolBarHelper::custom('stopqueue', 'stop-queue.png', 'stop-queue.png', _JNEWS_MENU_STOPQ, false);
            JToolBarHelper::spacer();
            $message = jnews::printYN(true, _JNEWS_MENU_STARTQ_MSG, $message);
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=queue' . $message);
            break;
        case 'cpanel':
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION);
            break;
        case 'delq':
            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;
                if (!empty($cid)) {
                    $db = JFactory::getDBO();
                    $query = 'DELETE from `#__jnews_queue` where `qid` IN (' . implode(',', $cid) . ')';
                    $db->setQuery($query);
                    $db->query();
                }
                $message = jnews::printYN(true, 'Successfully deleted the mailing(s) in the queue.', _JNEWS_ERROR);
            }
            break;
        case 'block':
            JRequest::checkToken() or die('Invalid Token');
            if (!is_array($cid) || count($cid) < 1) {
                echo "<script> alert('Select an item to block'); window.history.go(-1);</script>\n";
                return false;
            } else {
                $status = true;
                if (!empty($cid)) {
                    $message = jnews::printYN(jNews_Queue::updateQueueBlock($cid, 1), 'Successfully blocked the mailing(s) in the queue.', _JNEWS_ERROR);
                }
            }
            break;
        case 'unblock':
            JRequest::checkToken() or die('Invalid Token');
            if (!is_array($cid) || count($cid) < 1) {
                echo "<script> alert('Select an item to unblock'); window.history.go(-1);</script>\n";
                return false;
            } else {
                $status = true;
                if (!empty($cid)) {
                    $message = jnews::printYN(jNews_Queue::updateQueueBlock($cid, 0), 'Successfully blocked the mailing(s) in the queue.', _JNEWS_ERROR);
                }
            }
            break;
        case 'cleanq':
            JRequest::checkToken() or die('Invalid Token');
            $db = JFactory::getDBO();
            $query = 'DELETE from `#__jnews_queue` WHERE `type` < 7';
            //do not delete the smartnewsletter type 7 and type 8
            $db->setQuery($query);
            $db->query();
            $message = jnews::printYN(true, ' Successfully cleared the mailings in the queue! ', _JNEWS_ERROR);
            break;
        default:
            if ($GLOBALS[JNEWS . 'queue_status'] == 1) {
                JToolBarHelper::custom('stopqueue', 'stop-queue.png', 'stop-queue.png', _JNEWS_MENU_STOPQ, false);
            } else {
                JToolBarHelper::custom('startqueue', 'start-queue.png', 'start-queue.png', _JNEWS_MENU_STARTQ, false);
            }
            JToolBarHelper::spacer();
    }
    if ($showqueue) {
        $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_Queue::getQueueCount($mailingid);
        $setLimit = new stdClass();
        $setLimit->total = !empty($limittotal) ? $limittotal : 0;
        $setLimit->start = !empty($limitstart) ? $limitstart : 0;
        $setLimit->end = !empty($limitend) ? $limitend : $limittotal;
        $setSort = new stdClass();
        $setSort->orderValue = $app->getUserStateFromRequest(JNEWS_OPTION . '.queue.filter_order', 'filter_order', 'q.send_date', 'cmd');
        $setSort->orderDir = $app->getUserStateFromRequest(JNEWS_OPTION . '.queue.filter_order_Dir', 'filter_order_Dir', 'asc', 'word');
        //count only the search result
        if (!empty($mailingsearch)) {
            $mailingq = jNews_Queue::getMailingqueue($mailingsearch, $mailingid, 0, 0, $setSort);
            $setLimit->total = count($mailingq);
        }
        // recheck start
        if ($setLimit->total <= $setLimit->start) {
            $setLimit->start = 0;
        }
        //perform query for all or specific search
        $mailingq = jNews_Queue::getMailingqueue($mailingsearch, $mailingid, $setLimit->start, $setLimit->end, $setSort);
        $form['main'] = " <form  name='adminForm' method='POST' action='index.php'  id=\"adminForm\">";
        $form['select'] = " <form name='jnewsFilterForm' method='POST' action='index.php'> \n";
        backHTML::_header('Mailing Queue', $img, $message, $task, $action);
        jNews_QueueHTML::showMailingQueue($mailingq, $lists, $form, $setLimit->start, $setLimit->end, $mailingsearch, $setLimit, $setSort);
        $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;
}