Пример #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();
 }
Пример #2
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;
}
Пример #3
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;
    }
}
Пример #4
0
 function mailingEdit($subscriberId, $mailingId, $listId, $listType, $action)
 {
     global $my, $Itemid;
     if (ACA_CMSTYPE) {
         // joomla 15
         $issue_nb = JRequest::getVar('issue_nb', '0');
         $my =& JFactory::getUser();
     } else {
         //joomla 1x
         $issue_nb = intval(mosGetParam($_REQUEST, 'issue_nb', 0));
         global $my;
     }
     //endif
     $accessGrant = false;
     $new = 0;
     if (class_exists('pro')) {
         if ($issue_nb == 0) {
             $issue_nb = xmailing::countMailings($listId, '');
             $issue_nb++;
         }
         if ($listId > 0) {
             $list = lists::getOneList($listId);
             $mailing = xmailing::getOneMailing($list, $mailingId, $issue_nb, $new);
             $acc_level = $list->acc_level;
         } else {
             return false;
         }
         if (acajoom::checkPermissions('hello', 0, $acc_level)) {
             $accessGrant = true;
         }
     } else {
         if ($subscriberId != 0 and ($my->usertype == 'Administrator' or $my->usertype == 'Super Administrator')) {
             $accessGrant = true;
         }
     }
     if ($accessGrant) {
         if ($issue_nb == 0) {
             $issue_nb = xmailing::countMailings($listId, '');
             $issue_nb++;
         }
         if (empty($mailing)) {
             if ($mailingId > 0) {
                 $mailing = xmailing::getOneMailing('', $mailingId, $issue_nb, $new);
             } else {
                 if ($listId > 0) {
                     $list = lists::getOneList($listId);
                     $mailing = xmailing::getOneMailing($list, $mailingId, $issue_nb, $new);
                 } else {
                     return false;
                 }
             }
         }
         $mainLink = '.php?option=com_acajoom&act=savemailing';
         compa::completeLink($mainLink, false);
         $forms['main'] = '<form method="post" enctype="multipart/form-data" action="' . $mainLink . '" onsubmit="submitbutton();return false;" name="adminForm" >' . "\n\r";
         $forms['main'] .= '<input type="hidden" name="Itemid" value="' . $Itemid . '" />';
         $show = lisType::showType($mailing->list_type, 'editmailing');
         frontHTML::formStart(_ACA_EDIT_A . @constant($GLOBALS[ACA . 'listname' . $mailing->list_type]), $mailing->html, 'edit_mailing');
         mailingsHTML::editMailing($mailing, $new, $listId, $forms, $show);
         $go[] = acajoom::makeObj('act', $action);
         frontHTML::formEnd(_CMN_SAVE . ' ' . @constant($GLOBALS[ACA . 'listname' . $mailing->list_type]), $go);
     } else {
         echo acajoom::printM('red', _NOT_AUTH);
     }
     return true;
 }