예제 #1
0
 public static function ReadImages($imagePath, $folderPath, &$folders, &$images)
 {
     jimport('joomla.filesystem.folder');
     $imgFiles = JFolder::files($imagePath);
     if (!empty($imgFiles)) {
         foreach ($imgFiles as $file) {
             $ff_ = $folderPath . DS . $file;
             $ff = $folderPath . DS . $file;
             $i_f = $imagePath . '/' . $file;
             if (is_dir($i_f) && $file != 'CVS' && $file != '.svn') {
                 $folders[] = jnews::HTML_SelectOption($ff_);
                 jNews_MailingsHTML::ReadImages($i_f, $ff_, $folders, $images);
             } else {
                 if (preg_match("/bmp|gif|jpg|jpeg|png/i", $file) && is_file($i_f)) {
                     // leading / we don't need
                     $imageFile = substr($ff, 1);
                     $images[$folderPath][] = jnews::HTML_SelectOption($imageFile, $file);
                 }
             }
         }
     }
 }
예제 #2
0
파일: frontend.php 프로젝트: naka211/kkvn
 public static function mailingEdit($subscriberId, $mailingId, $listId, $listType = '', $action, $grantCAnAccess = false)
 {
     global $my, $Itemid;
     $issue_nb = JRequest::getVar('issue_nb', '0');
     $my = JFactory::getUser();
     if (version_compare(JVERSION, '1.6.0', '>=')) {
         //j16
         $usergid = JAccess::getGroupsByUser($my->id, false);
         $my->gid = $usergid[0];
     }
     $accessGrant = false;
     if (!empty($my->id)) {
         $ownedlists = jNews_Lists::getOwnedlists($my->id);
     }
     $new = 0;
     if (class_exists('jNews_Pro')) {
         if ($issue_nb == 0) {
             $issue_nb = jNews_Mailing::countMailings($listId, '');
             $issue_nb++;
         }
         if ($listId > 0) {
             $list = jNews_Lists::getOneList($listId);
             $mailing = jNews_Mailing::getOneMailing($list, $mailingId, $issue_nb, $new);
             $acc_level = $list->acc_level;
         } else {
             if (!empty($ownedlists)) {
                 $list = jNews_Lists::getOneList($listId);
                 $mailing = jNews_Mailing::getOneMailing($list, $mailingId, $issue_nb, $new);
                 $acc_level = $list->acc_level;
             } else {
                 $listId = jNews_Lists::getIDacclevel($my->gid);
                 $list = jNews_Lists::getOneList($listId);
                 $mailing = jNews_Mailing::getOneMailing($list, $mailingId, $issue_nb, $new);
                 $acc_level = $list->acc_level;
             }
         }
         $id = 0;
         if ($GLOBALS[JNEWS . 'enable_jsub']) {
             if (!empty($my->id)) {
                 $ownedlists = jNews_Lists::getOwnedlists($my->id);
             }
             if (!empty($ownedlists)) {
                 $id = $my->id;
             }
         }
         if (jnews::checkPermissions($acc_level)) {
             $accessGrant = true;
         }
     } else {
         if ($subscriberId != 0 && jnews::checkPermissions('admin')) {
             $accessGrant = true;
         }
     }
     if (@(include_once JNEWSPATH_ADMIN . 'social' . DS . 'class.social.php')) {
         if (class_exists('jNews_Social') && !$GLOBALS[JNEWS . 'enable_jsub']) {
             $accessGrant = true;
         }
     }
     if ($accessGrant || $grantCAnAccess) {
         if ($issue_nb == 0) {
             $issue_nb = jNews_Mailing::countMailings($listId, '');
             $issue_nb++;
         }
         if (empty($mailing)) {
             if ($mailingId > 0) {
                 $mailing = jNews_Mailing::getOneMailing('', $mailingId, $issue_nb, $new);
             } else {
                 if ($listId > 0) {
                     $list = jNews_Lists::getOneList($listId);
                     $mailing = jNews_Mailing::getOneMailing($list, $mailingId, $issue_nb, $new);
                 } else {
                     return false;
                 }
             }
         }
         $mainLink = 'option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listId . '&listype=' . $listType . '&Itemid=' . $Itemid;
         $mainLink = jNews_Tools::completeLink($mainLink, false, false);
         $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION);
         //$forms['main'] = '<form method="post" enctype="multipart/form-data" action="'. $mainLink . '" onsubmit="submitbutton();return false;" name="adminForm" id="adminForm">'."\n\r";
         $forms['main'] = '<form method="post" enctype="multipart/form-data" action="' . $mainLink . '" name="adminForm" id="adminForm">' . "\n\r";
         $forms['main'] .= '<input type="hidden" name="Itemid" value="' . $Itemid . '" />';
         $show = jNews_ListType::showType($mailing->mailing_type, 'editmailing');
         $menuA = null;
         if ($GLOBALS[JNEWS . 'level'] > 1) {
             //menu object start here
             //to create the template menu
             $listype = JRequest::getInt('listype', 0, 'request');
             $menuTag = new stdClass();
             $menuTag->link = 'administrator/' . jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=tags', true, false, true);
             if ($listype == 7) {
                 $delaymax = JRequest::getInt('delay_max', 0, 'request');
                 $notifyID = JRequest::getInt('notify_id', 0, 'request');
                 $catid = JRequest::getVar('cat_id', 0, 'request');
                 $menuTag->link = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=tags&listype=' . $listype . '&cat_id=' . $catid . '&delay_max=' . $delaymax . '&notify_id=' . $notifyID, false, false, true);
             } else {
                 $menuTag->link = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=tags', false, false, true);
             }
             $menuTag->popup = new stdClass();
             $menuTag->popup->isPop = true;
             $menuTag->popup->rel = true;
             $menuTag->popup->x = 750;
             $menuTag->popup->y = 500;
             $menuTag->action = 'tags';
             $menuTag->title = _JNEWS_MAILING_TAG;
             //to create the template menu
             $menuTemplate = new stdClass();
             $menuTemplate->link = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=templates&task=assign', false, false, true);
             $menuTemplate->popup = new stdClass();
             $menuTemplate->popup->isPop = true;
             $menuTemplate->popup->rel = true;
             $menuTemplate->popup->x = 640;
             $menuTemplate->popup->y = 480;
             $menuTemplate->action = 'template';
             $menuTemplate->title = _JNEWS_LIST_T_TEMPLATE;
             //to create cancel menu
             $menuCancel = new stdClass();
             $menuCancel->popup = new stdClass();
             $menuCancel->popup->isPop = false;
             $menuCancel->link = '#';
             $menuCancel->action = 'cancel';
             $menuCancel->onclick = new stdClass();
             $menuCancel->onclick->custom = false;
             $menuCancel->onclick->js = '';
             $menuCancel->title = _JNEWS_CANCEL;
             //to create save menu
             $linksave = 'option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listId . '&listype=' . $listType . '&Itemid=' . $Itemid;
             if ($listId == 0) {
                 $linksave = 'option=' . JNEWS_OPTION . '&act=mailing&listype=' . $listType . '&Itemid=' . $Itemid;
             }
             $linksave = jNews_Tools::completeLink($linksave, false);
             $menuSave = new stdClass();
             $menuSave->popup = new stdClass();
             $menuSave->popup->isPop = false;
             $menuSave->link = '#';
             $menuSave->action = 'save';
             $menuSave->onclick = new stdClass();
             $menuSave->onclick->custom = false;
             $menuSave->onclick->js = '';
             $menuSave->title = _JNEWS_SAVE;
             //to create preview menu
             $menuPreview = new stdClass();
             $menuPreview->popup = new stdClass();
             $menuPreview->popup->isPop = false;
             $menuPreview->link = '#';
             $menuPreview->action = 'savepreview';
             $menuPreview->onclick = new stdClass();
             $menuPreview->onclick->custom = false;
             $menuPreview->onclick->js = '';
             $menuPreview->title = 'Preview';
             //to create send menu
             $menuSend = new stdClass();
             $menuSend->popup = new stdClass();
             $menuSend->popup->isPop = true;
             $menuSend->popup->rel = true;
             $menuSend->popup->x = 750;
             $menuSend->popup->y = 500;
             $linkBut = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=mailing&task=sendready&mailingid=' . $mailingId . '&listype=' . $listType, true, false, true);
             $menuSend->link = $linkBut;
             $menuSend->action = 'sendready';
             $menuSend->onclick = new stdClass();
             $menuSend->onclick->custom = false;
             $menuSend->onclick->js = "";
             $menuSend->title = _JNEWS_MENU_SEND;
             //to create the divider
             $menuDivider = new stdClass();
             $menuDivider->divider = true;
             $menuA = array();
             if (empty($mailingId)) {
                 $menuA['template'] = $menuTemplate;
             }
             $menuA['tags'] = $menuTag;
             $menuA['divider1'] = $menuDivider;
             $menuA['preview'] = $menuPreview;
             $menuA['save'] = $menuSave;
             if ($listType == 1 && $mailingId != 0) {
                 $menuA['send'] = $menuSend;
             }
             $menuA['divider'] = $menuDivider;
             $menuA['cancel'] = $menuCancel;
         }
         frontHTML::formStart(_JNEWS_EDIT_A . @constant($GLOBALS[JNEWS . 'listname' . $mailing->mailing_type]), $mailing->html, 'edit_mailing', $menuA);
         jNews_MailingsHTML::editMailing($mailing, $new, $listId, $forms, $show, $listType);
         $go[] = jnews::makeObj('act', $action);
         $go[] = jnews::makeObj('listype', $listType);
         frontHTML::formEnd(_CMN_SAVE . ' ' . @constant($GLOBALS[JNEWS . 'listname' . $mailing->mailing_type]), $go);
     } else {
         echo jnews::printM('red', _NOT_AUTH);
     }
     return true;
 }
예제 #3
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;
}
예제 #4
0
    public static function description($listEdit, $lists, $show, $html, $listType)
    {
        $editor = JFactory::getEditor();
        static $db = null;
        if (!isset($db)) {
            $db = JFactory::getDBO();
        }
        ?>
	<fieldset class="jnewscss">
	<table class="jnewstable" width="100%"  cellspacing="1">
		<tbody>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
        $tip = _JNEWS_INFO_LIST_PUB;
        $title = _JNEWS_PUBLISHED;
        echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
        ?>
				</span>
			</td>
			<td><?php 
        echo $lists['published'];
        ?>
</td>
		</tr>
	<?php 
        if ($show['hide']) {
            ?>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_MAILING_VISIBLE;
            $title = _JNEWS_VISIBLE_FRONT;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			<td><?php 
            echo $lists['hidden'];
            ?>
</td>
			</tr>

	<?php 
        } else {
            echo '<input type="hidden" name="hidden" value="' . $listEdit->hidden . '" />';
        }
        ?>
	 		<?php 
        if ($listType == 2) {
            ?>
	 	<tr>
	 		<td width="185%" class="key">
	 			<span class="editlinktip">
	 			<?php 
            $tip = _JNEWS_SUBS_LIST_TIPS;
            $title = _JNEWS_SUBS_LIST2;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
	 			</span>
	 		</td>

			<td width="90%">
			<table width = "50%"><tr><td>
			<?php 
            require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'views' . DS . 'mailings.jnews.html.php';
            jNews_MailingsHTML::lists(null, $lists, $show, $listType, $listEdit->id, true);
            ?>
			 </td></tr></table>
			</td>	 	</tr>
			<?php 
        }
        ?>

		</tbody>
	</table>
	</fieldset>
	<fieldset class="jnewscss">
	<legend><?php 
        echo _JNEWS_LIST_T_GENERAL;
        ?>
</legend>
	<table class="jnewstable" width="100%" cellspacing="1">
		<tbody>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
        $tip = _JNEWS_INFO_LIST_NAME;
        $title = _JNEWS_LIST_NAME;
        echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
        ?>
				</span>
			</td>
			<td>
			<?php 
        $text = str_replace('"', '&quot;', $listEdit->list_name);
        if (function_exists('htmlspecialchars_decode')) {
            $text = htmlspecialchars_decode($text, ENT_NOQUOTES);
        } elseif (function_exists('html_entity_decode')) {
            $text = html_entity_decode($text, ENT_NOQUOTES);
        }
        echo ' <input type="text" name="list_name" class="inputbox requiredd" size="50" maxlength="64" value="' . $text . '" />';
        ?>
			</td>
		</tr>
		<?php 
        if ($GLOBALS[JNEWS . 'listHTMLeditor'] == '1') {
            ?>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_DESC;
            $title = _JNEWS_LIST_DESC;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
			<?php 
            echo $editor->display('list_desc', $listEdit->list_desc, '100%', '200', '75', '10');
            ?>
			</td>
		</tr>
		<?php 
        } else {
            echo jnews::printM('notice', _JNEWS__LIST_HTML_EDITOR);
        }
        ?>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
        $tip = _JNEWS_ASSIGN_LIS_TEMPLATE_TIPS;
        $title = _JNEWS_ASSIGN_LIS_TEMPLATE;
        echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
        ?>
				</span>
			</td>
			<td>
			<?php 
        echo $lists['list_templates'];
        ?>
			</td>
		</tr>
		</tbody>
	</table>
	</fieldset>
<?php 
        if ($show['sender_info']) {
            ?>
	<fieldset class="jnewscss">
	<legend><?php 
            echo _JNEWS_LIST_T_SENDER;
            ?>
</legend>
	<table class="jnewstable" width="100%" cellspacing="1">
		<tbody>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_SENDER_NAME;
            $title = _JNEWS_SENDER_NAME;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
			<?php 
            //if empty sender name and sender email
            //				$userSender=jNews_Subscribers::getUsers( 'gid', '50',$listEdit->owner );
            //				if(empty($listEdit->sendername)) $listEdit->sendername=$userSender[0]->name;
            //				if(empty($listEdit->senderemail)) $listEdit->senderemail=$userSender[0]->email;
            $text = str_replace('"', '&quot;', $listEdit->sendername);
            if (function_exists('htmlspecialchars_decode')) {
                $text = htmlspecialchars_decode($text, ENT_NOQUOTES);
            } elseif (function_exists('html_entity_decode')) {
                $text = html_entity_decode($text, ENT_NOQUOTES);
            }
            echo ' <input type="text" name="sendername" class="inputbox" size="40" maxlength="64" value="' . $text . '" />';
            ?>

				&nbsp;<img src="components/<?php 
            echo JNEWS_OPTION;
            ?>
/images/16/profile.png" id="popbtn" name="popbtn" onClick="document.getElementById('poplist').style.display = 'inline'; document.getElementById('popbtn').style.display = 'none';" title="<?php 
            echo _JNEWS_SENDER_LIST_INFO;
            ?>
" style="position:absolute;">
				<select id="poplist" name="poplist" style="display:none;position:relative;" onChange="document.getElementById('poplist').style.display = 'none'; document.getElementById('popbtn').style.display = 'inline';">
				<option value="0" onClick="document.adminForm.sendername.value=''; document.adminForm.senderemail.value='';"> </option>
			<?php 
            // 2nd parameter of this public static function should be a preference
            // we need to limit it so that it wouldnt cause any problems when loading a bunch of datas e.g hundreds or thousands of users
            $usersA = jNews_Subscribers::getUsers('gid', '50');
            // create options for list
            if (!empty($usersA)) {
                foreach ($usersA as $user) {
                    $name = $user->name;
                    $email = $user->email;
                    $selected = isset($listEdit->sendername) && $listEdit->sendername == $name && (isset($listEdit->senderemail) && $listEdit->senderemail == $email) ? true : false;
                    ?>
						<option value="<?php 
                    echo $user->name;
                    ?>
" onClick="document.adminForm.sendername.value='<?php 
                    echo $name;
                    ?>
'; document.adminForm.senderemail.value='<?php 
                    echo $email;
                    ?>
';" <?php 
                    if ($selected) {
                        echo 'selected';
                    }
                    ?>
> <?php 
                    echo $user->name . ' (' . $user->email . ')';
                    ?>
 </option>
				<?php 
                }
            }
            ?>
			 	</select>
			</td>
		</tr>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_SENDER_EMAIL;
            $title = _JNEWS_SENDER_EMAIL;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
				<input type="text" name="senderemail" class="inputbox" size="40" maxlength="64" value="<?php 
            echo $listEdit->senderemail;
            ?>
" />
			</td>
		</tr>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_SENDER_BOUNCED;
            $title = _JNEWS_SENDER_BOUNCE;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
				<input type="text" name="bounceadres" class="inputbox" size="40" maxlength="64" value="<?php 
            echo $listEdit->bounceadres;
            ?>
" />
			</td>
		</tr>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_JNEWS_OWNER;
            $title = _JNEWS_OWNER;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
				<?php 
            echo $listEdit->owner;
            ?>
			</td>
		</tr>
		</tbody>
	</table>
	</fieldset>
	<?php 
        } else {
            echo '<input type="hidden" name="sendername" value="' . $listEdit->sendername . '" />';
            echo '<input type="hidden" name="senderemail" value="' . $listEdit->senderemail . '" />';
            echo '<input type="hidden" name="bounceadres" value="' . $listEdit->bounceadres . '" />';
        }
    }
예제 #5
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);
 }