Ejemplo n.º 1
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;
}
Ejemplo n.º 2
0
 public static function mailingOptions($action, $task, $listId, $mailingId, $subscriberId, $listType, $artId, $contentType, $blogId, $blogType, $dealId, $dealType, $tmplid, $flexiid, $flexitype, $captchaWidth = 80, $captchaHeight = 25, $captchaBGColor = '', $captchaFTColor = '')
 {
     $Itemid = JRequest::getInt('Itemid');
     if (empty($Itemid)) {
         $Itemid = $GLOBALS[JNEWS . 'itemidAca'];
     }
     if (empty($lisType)) {
         $lisType = 1;
     }
     $acl = JFactory::getACL();
     $database = JFactory::getDBO();
     $my = JFactory::getUser();
     $new = false;
     $gid = !empty($GLOBALS[JNEWS . 'list_creatorfe']) ? $GLOBALS[JNEWS . 'list_creatorfe'] : 0;
     $gids = array();
     $gids = explode(',', $gid);
     if (empty($gids)) {
         $gids = $gid;
     }
     if (version_compare(JVERSION, '1.6.0', '<')) {
         $listsAddEdit = jNews_Lists::getIDswithacclevel($my->gid);
     } else {
         $groups = JAccess::getGroupsByUser($my->id);
         $listsAddEdit = jNews_Lists::getIDswithacclevel($groups);
     }
     //for popup window
     JHTML::_('behavior.modal');
     if ($listType < 1) {
         $dropLlistPost = JRequest::getVar('droplist');
         if (!empty($dropLlistPost)) {
             $maliste = explode('-', $dropLlistPost);
             $listType = $maliste[0];
             $listId = $maliste[1];
         } elseif ($listId > 0) {
             $maliste = jNews_Lists::getLists($listId, 0, null, 'listnameA', false, false, false, false);
             $listType = $maliste[0]->list_type;
         }
     }
     switch ($task) {
         case 'refreshcaptcha':
             $newcode = jNews_Captcha::generateCode('5');
             $_SESSION['captcha'] = $newcode;
             $newesc = jNews_Captcha::encryptData($newcode, crypt($GLOBALS[JNEWS . 'captcha_code'], $GLOBALS[JNEWS . 'captcha_code']));
             $newdecrypt = jNews_Captcha::decryptData($newesc, crypt($GLOBALS[JNEWS . 'captcha_code'], $GLOBALS[JNEWS . 'captcha_code']));
             $newpath = JNEWS_JPATH_LIVE_NO_HTTPS . '/index.php?option=' . JNEWS_OPTION . '&act=captcha&tmpl=component&width=' . $captchaWidth . '&height=' . $captchaHeight . '&bgcolor=' . $captchaBGColor . '&ftcolor=' . $captchaFTColor . '&characters=5&esc=' . $newesc . '&encpwd=' . crypt($GLOBALS[JNEWS . 'captcha_code'], $GLOBALS[JNEWS . 'captcha_code']);
             echo '<div id="newcode">' . $newdecrypt . '</div>';
             echo '<div id="newesc">' . $newesc . '</div>';
             echo '<div id="newdecrypt">' . $newdecrypt . '</div>';
             echo '<div id="newpath">' . $newpath . '</div>';
             exit;
             break;
         case 'blogContent':
             $artId = $blogId;
             $contentType = $blogType;
         case 'flexicontent':
             $session =& JFactory::getSession();
             if ($flexitype == 'country') {
                 $flexCategoriesCountries = $session->get('flexi_countries', array(), 'JNEWLSETTER');
                 if (isset($flexCategoriesCountries[$flexiid])) {
                     unset($flexCategoriesCountries[$flexiid]);
                 } else {
                     $flexCategoriesCountries[$flexiid] = $flexiid;
                 }
                 //we set this value in the session
                 $session->set('flexi_countries', $flexCategoriesCountries, 'JNEWLSETTER');
             } else {
                 $flexCategoriesIndustries = $session->get('flexi_industries', array(), 'JNEWLSETTER');
                 if (isset($flexCategoriesIndustries[$flexiid])) {
                     unset($flexCategoriesIndustries[$flexiid]);
                 } else {
                     $flexCategoriesIndustries[$flexiid] = $flexiid;
                 }
                 //we set this value in the session
                 $session->set('flexi_industries', $flexCategoriesIndustries, 'JNEWLSETTER');
             }
             break;
         case 'articleContent':
             jNews_Mailing::getContent($artId, $contentType, $task, $tmplid);
             break;
         case 'dealContent':
             jNews_Mailing::getDeal($dealId, $dealType, $tmplid);
             break;
         case 'listpanel':
             $listType = JRequest::getVar('listype');
             if ($listType == 1 || $listType == 7) {
                 frontHTML::showPanel('list');
             }
             break;
         case 'cancel':
             frontEnd::showMailingsFront($task, $action, $subscriberId, $listId, $listType, false, _JNEWS_MENU_MAILING);
             break;
         case 'delete':
             JRequest::checkToken() or die('Invalid Token');
             if (empty($mailingId)) {
                 echo '<script> javascript:alert("' . _JNEWS_DELETE_MAILING . '"); javascript:history.go(-1); </script>';
             } else {
                 $d['mailing'] = jNews_Mailing::getOneMailing('', $mailingId, '', $new);
                 echo jnews::printYN(jNews_Mailing::delete($d), @constant($GLOBALS[JNEWS . 'listname' . $d['mailing']->list_type]) . _JNEWS_SUCCESS_DELETED, _JNEWS_ERROR);
                 frontEnd::showMailingsFront($task, $action, $subscriberId, $listId, $listType, false, _JNEWS_MENU_MAILING);
             }
             break;
         case 'togle':
             // defined toggle for publish and unpublish of mailings
             $id = JRequest::getVar('mailingid');
             $col = JRequest::getVar('col');
             $mailingId = !empty($id) && !empty($col) ? $id : $mailingId;
             $task = !empty($mailingId) && !empty($col) ? $col : $task;
             switch ($task) {
                 case 'publishMailing':
                     $mailing = jNews_Mailing::getOneMailing('', $mailingId, '', $new);
                     jNews_Mailing::publishMailing($mailingId);
                     break;
                 case 'unpublishMailing':
                     $mailing = jNews_Mailing::getOneMailing('', $mailingId, '', $new);
                     jNews_Mailing::unpublishMailing($mailingId);
                     break;
                 default:
                     break;
             }
             echo '<script> javascript:history.go(-1); </script>';
             break;
         case 'edit':
             if ($GLOBALS[JNEWS . 'enable_jsub']) {
                 if (!empty($my->id)) {
                     $ownedlists = jNews_Lists::getOwnedlists($my->id);
                 }
                 if (!empty($ownedlists) || jnews::checkPermissions('admin')) {
                     if (empty($mailingId)) {
                         echo '<script> javascript:alert("' . _JNEWS_SELECT_MAILING . '"); javascript:history.go(-1); </script>';
                     } else {
                         frontEnd::mailingEdit($subscriberId, $mailingId, $listId, $listType, 'mailing');
                         //savemailing
                     }
                 }
             } else {
                 //edit a mailing
                 $canAccess = false;
                 if (class_exists('jNews_Pro') && !empty($listId)) {
                     $list = jNews_Lists::getOneList($listId);
                     $accessAuthorizedA = explode(',', $list->acc_id);
                     if (!is_array($accessAuthorizedA) || $accessAuthorizedA[0] != 'all') {
                         if (version_compare(JVERSION, '1.6.0', '<')) {
                             //j15
                             $usergid = $my->gid;
                         } else {
                             //j16
                             $usergid = JAccess::getGroupsByUser($my->id, false);
                         }
                         if (is_array($accessAuthorizedA)) {
                             if (is_array($usergid)) {
                                 $canAccess = array_intersect($usergid, $accessAuthorizedA);
                             } else {
                                 if (!in_array($usergid, $accessAuthorizedA)) {
                                     $canAccess = false;
                                 }
                             }
                         } else {
                             if (is_array($usergid)) {
                                 $canAccess = array_intersect($usergid, $accessAuthorizedA);
                             } else {
                                 if ($usergid != $accessAuthorizedA) {
                                     $canAccess = false;
                                 }
                             }
                         }
                     }
                 }
                 //cehck if I am the owner of the list
                 $archivemailing = jNews_Mailing::getOneMailing(0, $mailingId, 0, $new);
                 if ($archivemailing->author_id == $my->id) {
                     $canAccess = true;
                 }
                 if ($canAccess || jnews::checkPermissions('admin') || jnews::checkPermissions($gid) || !empty($listsAddEdit)) {
                     if (empty($mailingId)) {
                         echo '<script> javascript:alert("' . _JNEWS_SELECT_MAILING . '"); javascript:history.go(-1); </script>';
                     } else {
                         frontEnd::mailingEdit($subscriberId, $mailingId, $listId, $listType, 'mailing', $canAccess);
                         //savemailing
                     }
                 }
             }
             break;
         case 'new':
         case 'add':
             if ($GLOBALS[JNEWS . 'enable_jsub']) {
                 if (!empty($my->id)) {
                     $ownedlists = jNews_Lists::getOwnedlists($my->id);
                 }
                 if (!empty($ownedlists) || jnews::checkPermissions('admin')) {
                     frontEnd::mailingEdit($subscriberId, $mailingId, $listId, $listType, 'mailing');
                     //savemailing
                 }
             } else {
                 //$list = jNews_Lists::getOneList($listId);
                 $canAccess = false;
                 if (class_exists('jNews_Pro') && !empty($listId)) {
                     $list = jNews_Lists::getOneList($listId);
                     $accessAuthorizedA = explode(',', $list->acc_id);
                     if (!is_array($accessAuthorizedA) || $accessAuthorizedA[0] != 'all') {
                         if (version_compare(JVERSION, '1.6.0', '<')) {
                             //j15
                             $usergid = $my->gid;
                         } else {
                             //j16
                             $usergid = JAccess::getGroupsByUser($my->id, false);
                         }
                         if (is_array($accessAuthorizedA)) {
                             if (is_array($usergid)) {
                                 $canAccess = array_intersect($usergid, $accessAuthorizedA);
                             } else {
                                 if (!in_array($usergid, $accessAuthorizedA)) {
                                     $canAccess = false;
                                 }
                             }
                         } else {
                             if (is_array($usergid)) {
                                 $canAccess = array_intersect($usergid, $accessAuthorizedA);
                             } else {
                                 if ($usergid != $accessAuthorizedA) {
                                     $canAccess = false;
                                 }
                             }
                         }
                     }
                 }
                 if ($canAccess || jnews::checkPermissions('admin') || jnews::checkPermissions($gid) || !empty($listsAddEdit)) {
                     frontEnd::mailingEdit($subscriberId, $mailingId, $listId, $listType, 'mailing', true);
                     //savemailing
                 }
             }
             break;
         case 'archive':
             if (class_exists('jNews_Pro')) {
                 $list = jNews_Lists::getOneList($listId);
                 $listIds = explode(',', $list->acc_id);
                 if (!is_array($listIds) || $listIds[0] != 'all') {
                     if (version_compare(JVERSION, '1.6.0', '<')) {
                         //j15
                         $usergid = $my->gid;
                     } else {
                         if (version_compare(JVERSION, '3.0.0', '>')) {
                             //j3.0
                             $usergid = JAccess::getGroupsByUser($my->id, false);
                             //this is huck for joomla >3.0 because if you check this link http://joomla.dev/administrator/index.php?option=com_config&view=component&component=com_users&return=aHR0cDovL2pvb21sYS5kZXYvYWRtaW5pc3RyYXRvci9pbmRleC5waHA%2Fb3B0aW9uPWNvbV91c2VycyZ2aWV3PWdyb3Vwcw%3D%3D
                             //you will see  Guest User Group = Public by default and into db table #__extensions where element == com_users => params => you will see guest_usergroup == 13
                             // but if you try to change user group in brovser to registered for example => save=>save again as public => check again db=> you will see guest_usergroup = 1
                             //i think it is joomla bug because if jommla woks fine needs to be 13
                             // thants why i created this "if"
                             if ($usergid[0] === '13') {
                                 $usergid[0] = '1';
                             }
                         } else {
                             //j16
                             $usergid = JAccess::getGroupsByUser($my->id, false);
                         }
                     }
                     if (is_array($listIds)) {
                         if (is_array($usergid)) {
                             $canAccess = array_intersect($usergid, $listIds);
                             if (empty($canAccess)) {
                                 break;
                             }
                         } else {
                             if (!in_array($usergid, $listIds)) {
                                 break;
                             }
                         }
                     } else {
                         if (is_array($usergid)) {
                             $canAccess = array_intersect($usergid, $listIds);
                             if (empty($canAccess)) {
                                 break;
                             }
                         } else {
                             if ($usergid != $listIds) {
                                 break;
                             }
                         }
                     }
                 }
             }
             frontEnd::showMailingsFront($task, $action, $subscriberId, $listId, $listType, true, _JNEWS_MENU_VIEW_ARCHIVE . ' ');
             break;
         case 'save':
             JRequest::checkToken() or die('Invalid Token');
             $message = jnews::printYN(jNews_Mailing::saveMailing($mailingId, $listId), _JNEWS_MAILING_SAVED, _JNEWS_ERROR);
             frontEnd::showMailingsFront($task, $action, $subscriberId, $listId, $listType, false, _JNEWS_MENU_MAILING);
             break;
         case 'savepreview':
             JRequest::checkToken() or die('Invalid Token');
             $message = jnews::printYN(jNews_Mailing::saveMailing($mailingId, $listId), _JNEWS_MAILING_SAVED, _JNEWS_ERROR);
         case 'preview':
         case 'view':
             if ($mailingId != 0) {
                 if ($listId > 0) {
                     $archivemailing = jNews_Mailing::getMailingView($mailingId, $listId);
                 } else {
                     $archivemailing = jNews_Mailing::getMailingView($mailingId);
                 }
                 $list = jNews_Lists::getOneList($listId);
                 $acc_level = $list->acc_level;
                 jNews_ProcessMail::replaceClass($archivemailing->htmlcontent, $archivemailing->textonly);
                 if (!empty($archivemailing->template_id)) {
                     jNews_Templates::includeStyles($archivemailing->htmlcontent, $archivemailing->template_id);
                 }
                 $archivemailing->htmlcontent = str_replace('{tag:subscriptions}', '', $archivemailing->htmlcontent);
                 $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION);
                 $forms['main'] = '<form method="post" action="' . $mainLink . '" onsubmit="submitbutton();return false;" name="mosForm" >' . "\n\r";
                 $forms['main'] .= '<input type="hidden" name="Itemid" value="' . $Itemid . '" />';
                 //for view it online view
                 $currentUrl = JURI::current();
                 $gid = !empty($GLOBALS[JNEWS . 'list_creatorfe']) ? $GLOBALS[JNEWS . 'list_creatorfe'] : 0;
                 if (version_compare(JVERSION, '1.6.0', '<')) {
                     $listsAddEdit = jNews_Lists::getIDswithacclevel($my->gid);
                 } else {
                     $groups = JAccess::getGroupsByUser($my->id);
                     if (!$my->id) {
                         $listsAddEdit = array();
                     } else {
                         $listsAddEdit = jNews_Lists::getIDswithacclevel($groups);
                     }
                 }
                 if (jnews::checkPermissions('admin') || jnews::checkPermissions($gid) || !empty($listsAddEdit)) {
                     $menuA = array();
                     $onlyPreview = JRequest::getInt('onlypreview');
                     if (!$onlyPreview) {
                         //menu Preview
                         $menuNew = new stdClass();
                         $menuNew->popup = new stdClass();
                         $menuNew->popup->isPop = false;
                         $menuNew->action = 'view';
                         $linkBut = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=mailing&task=view&mailingid=' . $mailingId . '&onlypreview=1');
                         $menuNew->link = $linkBut;
                         $menuNew->onclick = new stdClass();
                         $menuNew->onclick->custom = true;
                         $menuNew->onclick->js = '';
                         $menuNew->title = _JNEWS_VIEW_BROWSER;
                         $menuA['view'] = $menuNew;
                         //menu edit
                         $menuNew = new stdClass();
                         $menuNew->popup = new stdClass();
                         $menuNew->popup->isPop = false;
                         $menuNew->action = 'edit';
                         $linkBut = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=mailing&task=edit&mailingid=' . $mailingId . '&listype=' . $listType);
                         $menuNew->link = $linkBut;
                         $menuNew->onclick = new stdClass();
                         $menuNew->onclick->custom = true;
                         $menuNew->onclick->js = '';
                         $menuNew->title = 'Edit';
                         $menuA['edit'] = $menuNew;
                         //menu send
                         $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;
                         $menuA['sendready'] = $menuSend;
                         // menu back
                         $menuBack = new stdClass();
                         $menuBack->popup = new stdClass();
                         $menuBack->popup = new stdClass();
                         $menuBack->popup->isPop = false;
                         $menuBack->link = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=mailing', false);
                         $menuBack->action = 'back';
                         $menuBack->onclick = new stdClass();
                         $menuBack->onclick->custom = true;
                         $menuBack->onclick->js = '';
                         $menuBack->title = _JNEWS_MENU_BACK;
                         $menuA['back'] = $menuBack;
                     }
                     frontHTML::formStart(_JNEWS_NEWSLETTER_ARCHIVE, 0, '', $menuA);
                 } else {
                     //can be improved where we check if user can edit
                     if (empty($archivemailing->visible) || empty($archivemailing->published) && $task == 'view') {
                         echo '<center>Access to this mailing is restricted!<center>';
                         break;
                     }
                     frontHTML::formStart(_JNEWS_NEWSLETTER_ARCHIVE, 0, '', null);
                 }
                 jNews_MailingsHTML::viewMailing($archivemailing, $forms);
                 $go[] = jnews::makeObj('act', 'mailing');
                 $go[] = jnews::makeObj('task', 'viewmailing');
                 $go[] = jnews::makeObj('listid', $archivemailing->list_id);
                 frontHTML::formEnd('', $go);
             } else {
                 frontHTML::FEmenu();
                 frontEnd::showMailingsFront($task, $action, $subscriberId, $listId, $listType, false, _JNEWS_MENU_MAILING);
             }
             break;
         case 'sendready':
             //we update the senddate of the newsletter
             jNews_Mailing::updatesenddate($mailingId);
             jNews_MailingsHTML::sendReady($mailingId, $listId, $listType);
             break;
         case 'send':
             if (!(require_once JNEWSPATH_CLASS . 'class.queue.php')) {
                 return false;
             }
             $queueC = new jNews_Queue();
             $queueC->checkForNewsletters($mailingId);
             $queueCount = jNews_Queue::getQueueCount($mailingId);
             $totalSub = JRequest::setVar('totalsend', $queueCount);
             $linkBut = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=mailing&task=continuesend&mailingid=' . $mailingId . '&totalsend=' . $totalSub, true, false, true);
             jNews_Tools::redirect($linkBut);
             //this line was commented out, we need this so that when we click the send button in the frontend the status of the sending will be displayed
             break;
         case 'continuesend':
             if (require_once JNEWSPATH_CLASS . 'class.queue.php') {
                 $queueC = new jNews_Queue();
                 $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 'unpublished':
             JRequest::checkToken() or die('Invalid Token');
             jNews_Mailing::unpublishMailing($mailingId);
             frontEnd::showMailingsFront($task, $action, $subscriberId, $listId, $listType, false, _JNEWS_MENU_MAILING);
             break;
         case 'copy':
             JRequest::checkToken() or die('Invalid Token');
             $message = jnews::printYN(jNews_Mailing::copyMailing($mailingId), _JNEWS_MAILING_COPY, _JNEWS_ERROR);
             if (empty($listId) or $listId == 0) {
                 $lsid = jNews_Mailing::getListId($mailingId);
             }
             jNews_Mailing::insertListMailings($listId);
             frontEnd::showMailingsFront($task, $action, $subscriberId, $listId, $listType, false, _JNEWS_MENU_MAILING);
             break;
         case 'cpanel':
             jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION);
             break;
         default:
             //alex archive
             //				$viewarchive = false;
             //				if(empty($my->id)) $viewarchive = true;
             $viewarchive = true;
             frontEnd::showMailingsFront($task, $action, $subscriberId, $listId, $listType, $viewarchive, _JNEWS_MENU_MAILING);
             break;
     }
     return true;
 }
Ejemplo n.º 3
0
 /** send emails
  * @param bool $showHTML show report on the screen
  * @param object $mailing contain the information of mailing
  * @param objectlist $receivers all receivers
  * @params $type (1-all types of mailings, 2-confirmation email)
  */
 function send($oneQueue, $receiver)
 {
     // we should verify that the data we get is teh proper value
     if (!is_object($oneQueue)) {
         return false;
     }
     $tags = null;
     ### create the mail
     $mail = jNews_ProcessMail::getMailer($oneQueue);
     //$frompreview param is to determine if the sending is called by 'Send Test Email'
     if (empty($mail)) {
         return false;
     }
     $tags['issuenb'] = $oneQueue->issue_nb;
     ### create content
     $this->getContent($oneQueue->images, $oneQueue->htmlcontent, $oneQueue->textonly, $oneQueue->subject, true, false, $oneQueue);
     //new $oneQueue->subject
     if ($this->cancelMailing) {
         $this->cancelMailing = false;
         return true;
         // we return true even though the mail was not sent because empty. Need improvement...
     }
     if (!empty($receiver->user_id)) {
         $tags['user_id'] = $receiver->user_id;
     }
     //Forced HTML Mailing Only?
     if ($GLOBALS[JNEWS . 'forced_html']) {
         $receiver->receive_html = 1;
     }
     $tname = explode(" ", $receiver->name);
     $firstname = $tname[0];
     $toUser = $GLOBALS[JNEWS . 'minisendmail'] ? '' : $receiver->name;
     $mail->AddAddress($receiver->email, $toUser);
     $username = empty($receiver->username) ? $firstname : $receiver->username;
     if (version_compare(JVERSION, '3.0.0', '<')) {
         $date = JHTML::_('date', jnews::getNow(), JText::_('DATE_FORMAT_LC1'), JNEWS_TIME_OFFSET);
     } else {
         $date = JHtml::_('date', jnews::getNow(), JText::_('DATE_FORMAT_LC1'), JNEWS_TIME_OFFSET);
     }
     $replaceWhat = array('{tag:name}', '{tag:firstname}', '{tag:username}', '{tag:date}');
     $replaceBy = array($receiver->name, $firstname, $username, $date);
     $sujetReplaced = str_replace($replaceWhat, $replaceBy, $oneQueue->subject);
     if (class_exists('jNews_Auto')) {
         jNews_Auto::tags($sujetReplaced, $tags);
     }
     $mail->Subject = $sujetReplaced;
     if (!empty($oneQueue->html) && $receiver->receive_html) {
         $this->html = true;
         $mail->IsHTML(true);
         $ashtml = 1;
         $mail->Body = jNews_ProcessMail::replaceTags($oneQueue->htmlcontent, $receiver, $oneQueue, $ashtml, $tags);
         $mail->AltBody = jNews_ProcessMail::replaceTags($oneQueue->textonly, $receiver, $oneQueue, $ashtml, $tags);
         //this line is added when jLinks is integrated with jNews
         //variables used in integration of jLinks
         static $mailCatID = null;
         static $convertedLinks = null;
         if (empty($oneQueue->mailing_type)) {
             $oneQueue->mailing_type = 1;
         }
         $mainframe = JFactory::getApplication();
         JPluginHelper::importPlugin('jnews');
         $jomsocial = $mainframe->triggerEvent('jnewsbot_jomsocial_members', array(&$mail->Body, &$mail->AltBody, $receiver));
         $this->_linkReplacement($oneQueue->mailing_type, $oneQueue->id, $oneQueue->subject, $mail, $mailCatID, $convertedLinks, $receiver->id);
         jNews_ProcessMail::replaceClass($mail->Body, $mail->AltBody, $receiver);
         if (!empty($oneQueue->template_id)) {
             jNews_Templates::includeStyles($mail->Body, $oneQueue->template_id);
         }
     } else {
         //text only email
         $this->html = false;
         $mail->IsHTML(false);
         $mail->AltBody = '';
         $ashtml = 0;
         $mail->Body = jNews_ProcessMail::replaceTags($oneQueue->textonly, $receiver, $oneQueue, $ashtml, $tags);
         $mail->AltBody = $this->_safe_utf8_encode($mail->Body, $mail->CharSet);
         $simpleText = '';
         jNews_ProcessMail::replaceClass($mail->Body, $simpleText, $receiver);
         if (version_compare(JVERSION, '1.6.0', '<')) {
             //j15
             $imgfolders = DS . 'images' . DS . 'stories';
         } else {
             //j16
             $imgfolders = DS . 'images' . DS . 'sampledata';
         }
         if (!empty($oneQueue->images)) {
             foreach ($oneQueue->images as $image) {
                 $img = explode('|', $image);
                 $attrib = explode("/", $img[0]);
                 $path = JNEWS_JPATH_ROOT . $imgfolders;
                 if (count($img) == 1) {
                     $imageName = $img[0];
                 } else {
                     $imageName = $attrib[count($attrib) - 1];
                     for ($index = 0; $index < sizeof($attrib) - 1; $index++) {
                         $path .= $attrib[$index] . '/';
                     }
                 }
                 $mail->AddAttachment($path . $imageName);
             }
             //endofreach
         }
     }
     jNews_ProcessMail::normalizeURL($mail->Body);
     if (!empty($oneQueue->html) && $receiver->receive_html) {
         $this->_addHTMLTagToBody($mail->Body, $sujetReplaced);
     }
     if ($GLOBALS[JNEWS . 'embed_images']) {
         $this->_embedImages($mail);
     }
     $mail->addCustomHeader("X-SubscriberID: " . base64_encode($receiver->email));
     // DKIM code addition by Amod begins
     $mail = $this->_addDKIM2($mail);
     // DKIM code addition by Amod ends
     $status = $mail->Send();
     if (version_compare(JVERSION, '1.6.0', '<')) {
         //j15
         $mailErrorCount = $mail->error_count;
     } else {
         //j16
         $mailErrorCount = !empty($mail->ErrorInfo) ? 1 : 0;
     }
     //we prompt message regarding the status of the sending if there is an error
     if (!empty($mail->ErrorInfo)) {
         echo '<br><span style="color:red;">' . $mail->ErrorInfo . '</span>';
     }
     if ($status && $mailErrorCount < 1) {
         return true;
     } else {
         jNews_ProcessMail::failMailReason($mail);
         return false;
     }
 }
Ejemplo n.º 4
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;
}
Ejemplo n.º 5
0
 /** we call this public static function to get the content of the articles via ajax
  * we directly insert the article in the newsletter without the tags
  * */
 public static function getContent($artId = 0, $contentType = 0, $task = '', $template_id = '')
 {
     $mainframe = JFactory::getApplication();
     ob_clean();
     //j15
     if (version_compare(JVERSION, '1.6.0', '<')) {
         $Itemid = $mainframe->getItemId($artId);
     }
     if (empty($Itemid)) {
         $Itemid = $GLOBALS[JNEWS . 'itemidAca'];
     }
     if ($task == 'articleContent') {
         $content = jNews_Mailing::getContentDetail($artId);
     } elseif ($task == 'blogContent') {
         $content = jNews_Mailing::getBlogDetail($artId);
     }
     if ($GLOBALS[JNEWS . 'show_author'] == 1) {
         $author = '<br />' . $content->created_by_alias;
     } else {
         $author = '';
     }
     //we get the details of the article
     //if show only the title
     if ($contentType == 2) {
         $link = 'option=com_content&view=article&id=' . $artId . '&Itemid=' . $Itemid;
         $link = jNews_Tools::completeLink($link, false, $GLOBALS[JNEWS . 'use_sef']);
         $contentD = '<a href="' . $link . '"><span class="aca_title">' . $content->title . '</span></a>';
     } elseif ($contentType == 0) {
         //to show the  full article
         $contentD = '<div class="aca_content"><span class="aca_title">' . $content->title . '</span>' . "\r\n" . $author . '<br />' . $content->introtext . '<br />' . "\r\n" . $content->fulltext . "\r\n" . '</div>';
         //TO DO: images
     } else {
         //title, intro and readmore
         if ($task == 'articleContent') {
             $link = 'option=com_content&view=article&id=' . $artId . '&Itemid=' . $Itemid;
         } elseif ($task == 'blogContent') {
             $link = 'option=com_lyftenbloggie&view=lyftenbloggie&view=entry&id=' . $artId . '&Itemid=' . $Itemid;
         }
         $link = jNews_Tools::completeLink($link, false, $GLOBALS[JNEWS . 'use_sef']);
         $wordwrap = $GLOBALS[JNEWS . 'word_wrap'];
         if (empty($content->fulltext) and !empty($wordwrap)) {
             //Limit the number of words
             if (strlen($content->introtext) > $wordwrap) {
                 //$fulltext = $content->introtext;
                 $fulltext = strip_tags($content->introtext, '<br><img>');
                 if (strlen($fulltext) > $wordwrap) {
                     //We make sure we won't cut any html tag :
                     $open = 0;
                     $limitText = strlen($fulltext) - 1;
                     for ($i = 0; $i < strlen($fulltext); $i++) {
                         if ($content->introtext[$i] == '<') {
                             $open++;
                         }
                         continue;
                         if ($content->introtext[$i] == '>') {
                             $open--;
                         }
                         continue;
                         if ($content->introtext[$i] == " " and $i > $wordwrap and $open == 0) {
                             $limitText = $i - 1;
                             break;
                         }
                     }
                     $content->introtext = substr($fulltext, 0, $limitText) . '...';
                 }
             }
             if (empty($content->fulltext) and !empty($GLOBALS[JNEWS . 'word_wrap'])) {
                 if (strlen($content->introtext) > $GLOBALS[JNEWS . 'word_wrap']) {
                     //$content->introtext = substr(strip_tags($content->introtext),0,$GLOBALS[JNEWS.'word_wrap']).'...';
                     $content->introtext = substr($content->introtext, 0, $GLOBALS[JNEWS . 'word_wrap']) . '...';
                 }
             }
         }
         $images = jNews_Mailing::getimage($content->images);
         foreach ($images as $image) {
             $image_string = '<img src="' . JNEWS_JPATH_LIVE_NO_HTTPS . '/images/stories/' . $image['image'] . '" align="' . $image['align'] . '" alt="' . $image['alttext'] . '" border="' . $image['border'] . '" />';
             $contentD = preg_replace('/{mosimage}/', $image_string, $contentD, 1);
         }
         $contentD = str_replace('{mosimage}', '', $contentD);
         $contentD = '<div class="aca_content"><span class="aca_title">' . $content->title . '</span>' . "\r\n" . $author . '<br />' . $content->introtext . '<br />' . "\r\n" . '<a href="' . $link . '"><span class="aca_readmore">' . _JNEWS_READMORE . '</span></a>' . "\r\n" . '</div>';
         //$contentD = '<div class="aca_content"><span class="aca_title" style="display:block; text-indent:5px; font-weight: bold; width: 100%; font-size: 1.2em; text-decoration: none; color: rgb(255, 255, 255); border: 1px solid rgb(50, 154, 167); background-color: rgb(2, 91, 135);">' . $content->title . '</span>' . "\r\n" . $author . '<br />' . $content->introtext . '<br />' . "\r\n" . '<a href="' . $link . '"><span class="aca_readmore" style="font-weight:bold; color:#ffffff; font-size:11px; float: right; border: 1px solid rgb(50, 154, 167); background-color: rgb(2, 91, 135); padding: 2px 8px;">' . _JNEWS_READMORE . '</span></a>' . "\r\n".'</div>';
         //}
     }
     //insert the styles of this template
     if (!empty($template_id)) {
         jNews_Templates::includeStyles($contentD, $template_id);
     }
     if ($task == 'articleContent') {
         echo "<div id=artcontent_{$artId}>{$contentD}</div>";
     } elseif ($task == 'blogContent') {
         echo "<div id=blogcontent_{$artId}>{$contentD}</div>";
     }
     return true;
 }