Example #1
0
 public static function showPanel($pageUsed = 'main')
 {
     $Itemid = JRequest::getInt('Itemid');
     if (empty($Itemid)) {
         $Itemid = $GLOBALS[JNEWS . 'itemidAca'];
     }
     $database = JFactory::getDBO();
     $acl = JFactory::getACL();
     $my = JFactory::getUser();
     $ex_groups = array();
     $gid = @$GLOBALS[JNEWS . 'list_creatorfe'];
     if (!empty($my->id)) {
         if (!empty($my->username)) {
             $greeting_message = _HI . ' ' . $my->username;
         } else {
             $greeting_message = '';
         }
         $doc6 = JFactory::getDocument();
         $doc6->addStyleSheet(JNEWS_JPATH_LIVE . '/components/' . JNEWS_OPTION . '/css/menu.css');
         $gid = !empty($GLOBALS[JNEWS . 'list_creatorfe']) ? $GLOBALS[JNEWS . 'list_creatorfe'] : 0;
         frontHTML::FEmenu();
         backHTML::controlPanelBottonStart(_JNEWS_UCP_USER_MENU, 'usermenu.png');
         switch ($pageUsed) {
             case 'list':
                 $listId = JRequest::getVar('listid');
                 // newsletter button
                 //			    	$link = 'option='.JNEWS_OPTION.'&act=mailing&listid='. $listId .'&listype=1&Itemid='.$Itemid;
                 //alex pagination
                 $link = 'option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listId . '&listype=1';
                 $link = jNews_Tools::completeLink($link, false);
                 backHTML::quickiconButton($link, 'newsletterFE.png', _JNEWS_NEWSLETTER, false, 'all', false);
                 // smart newsletter button
                 //			    	$link = 'option='.JNEWS_OPTION.'&act=mailing&listid='. $listId .'&listype=7&Itemid='.$Itemid;
                 //alex pagination
                 $link = 'option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listId . '&listype=7';
                 $link = jNews_Tools::completeLink($link, false);
                 backHTML::quickiconButton($link, 'smartnewsletterFE.png', _JNEWS_AUTONEWS, false, 'all', false);
                 break;
             default:
                 //					$link = 'option='.JNEWS_OPTION.'&act=show&Itemid='.$Itemid;
                 //alex pagination
                 $link = 'option=' . JNEWS_OPTION . '&act=show';
                 $link = jNews_Tools::completeLink($link, false);
                 backHTML::quickiconButton($link, 'my_subscriptions48.png', _JNEWS_UCP_USER_CONTACT, false, 'all', false);
                 //come back here
                 //$proceedToCheck = true;
                 break;
         }
         if (class_exists('jNews_Pro')) {
             $my = JFactory::getUser();
             $ownedlists = jNews_Lists::getOwnedlists($my->id);
             if (version_compare(JVERSION, '1.6.0', '<')) {
                 //j15
                 $usergid = $my->gid;
             } else {
                 //j16
                 $usergid = JAccess::getGroupsByUser($my->id, false);
             }
             $ex_groups = explode(',', $gid);
             if (is_array($usergid)) {
                 $canAccess = array_intersect($usergid, $ex_groups);
             }
             if (in_array($usergid, $ex_groups) || !empty($canAccess)) {
                 if ($GLOBALS[JNEWS . 'level'] > 2 && version_compare(JVERSION, '1.6.0', '>')) {
                     //					    $link = 'option='.JNEWS_OPTION.'&act=list&mid=1&listype=1&Itemid='.$Itemid;
                     //alex pagination
                     $link = 'option=' . JNEWS_OPTION . '&act=list&mid=1&listype=1';
                     $link = jNews_Tools::completeLink($link, false);
                     backHTML::quickiconButton($link, 'addedit.png', _JNEWS_MENU_LIST, false, 'all', false);
                 }
                 $listId = JRequest::getVar('listid');
                 $act = JRequest::getVar('act', '', '', 'WORD');
                 $task = JRequest::getVar('task');
                 if (empty($listId) || $act == 'mailing' && $task == 'save') {
                     // list button
                     $link = 'option=' . JNEWS_OPTION . '&act=list&listype=1&mid=1&Itemid=' . $Itemid;
                     $link = jNews_Tools::completeLink($link, false);
                     backHTML::quickiconButton($link, 'addedit.png', _JNEWS_MENU_LIST, false, $usergid, false);
                     if (empty($listId)) {
                         if ($GLOBALS[JNEWS . 'enable_jsub']) {
                             if (!empty($my->id)) {
                                 $ownedlists = jNews_Lists::getOwnedlists($my->id);
                             }
                             if (!empty($ownedlists)) {
                                 $listId = $ownedlists[0];
                             } else {
                                 $listId = jNews_Lists::getIDacclevel(18, $my->id);
                             }
                         } else {
                             $listId = jNews_Lists::getIDacclevel(18, $my->id);
                         }
                         frontHTML::cpanelHTML($listId, $Itemid);
                     }
                 }
             } else {
                 $lists = jNews_Lists::getLists(0, 0, true);
                 $access = false;
                 $id = 0;
                 if ($GLOBALS[JNEWS . 'enable_jsub']) {
                     if (!empty($my->id)) {
                         $ownedlists = jNews_Lists::getOwnedlists($my->id);
                     }
                     if (!empty($ownedlists)) {
                         $id = $my->id;
                     }
                 }
                 foreach ($lists as $list) {
                     $bit = jnews::checkPermissions($list->acc_level);
                     if ($bit) {
                         $access = true;
                         break;
                     }
                 }
                 $link = 'option=' . JNEWS_OPTION . '&act=list&mid=1&listype=1&Itemid=' . $Itemid;
                 $link = jNews_Tools::completeLink($link, false);
                 if (!empty($my->id)) {
                     $ownedlists = jNews_Lists::getOwnedlists($my->id);
                 }
                 if (empty($listId)) {
                     if ($GLOBALS[JNEWS . 'enable_jsub']) {
                         if (!empty($my->id)) {
                             $ownedlists = jNews_Lists::getOwnedlists($my->id);
                         }
                         if (!empty($ownedlists)) {
                             $listId = $ownedlists[0];
                         } else {
                             $listId = jNews_Lists::getIDacclevel(18, $my->id);
                         }
                     } else {
                         $listId = jNews_Lists::getIDacclevel(18, $my->id);
                     }
                 }
                 if ($GLOBALS[JNEWS . 'enable_jsub']) {
                     if ($access && !empty($ownedlists)) {
                         backHTML::quickiconButton($link, 'addedit.png', _JNEWS_MENU_LIST, false, 'all', false);
                         frontHTML::cpanelHTML($listId, $Itemid);
                     }
                 } else {
                     $creatorFe = jnews::checkPermissions($gid);
                     //traces
                     if ($access || $creatorFe) {
                         backHTML::quickiconButton($link, 'addedit.png', _JNEWS_MENU_LIST, false, 'all');
                         frontHTML::cpanelHTML($listId, $Itemid);
                     }
                 }
             }
         } else {
             if ($GLOBALS[JNEWS . 'level'] > 2) {
                 $link = 'option=' . JNEWS_OPTION . '&act=list&mid=1&listype=1&Itemid=' . $Itemid;
                 $link = jNews_Tools::completeLink($link, false);
                 backHTML::quickiconButton($link, 'addedit.png', _JNEWS_MENU_LIST, false, 'all', false);
             }
         }
         backHTML::controlPanelBottomEnd();
         if (class_exists('jNews_Auto')) {
             jNews_Auto::otherPanel();
         }
     } elseif ($GLOBALS[JNEWS . 'show_lists']) {
         $subscriberId = JRequest::getInt('subscriber');
         $subscriber = jNews_Subscribers::getSubscribersFromId(array($subscriberId), false);
         frontEnd::changeSubscriptions($subscriberId, md5($subscriber->email), '', 'save');
     }
 }
Example #2
0
function subscribers($action, $task, $userid, $listId, $cid, $front = false)
{
    $Itemid = JRequest::getInt('Itemid');
    $mainframe = JFactory::getApplication();
    $newSubscriber = null;
    $subscriberId = JRequest::getInt('subscriber_id');
    $message = JRequest::getVar('message', '');
    $css = '.icon-48-subscribers { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/subscribers.png)}';
    $doc = JFactory::getDocument();
    $doc->addStyleDeclaration($css, $type = 'text/css');
    $img = 'subscribers.png';
    $emailField = JRequest::getVar('email', '');
    $new = true;
    //new subscriber
    $my = JFactory::getUser();
    //START OF DATA FROM REQUEST
    $subscriber = new stdClass();
    $subscriber->user_id = JRequest::getInt('user_id');
    $subscriber->name = JRequest::getVar('name', '');
    $subscriber->email = JRequest::getVar('email', '', '', 'STRING');
    if (!jNews_Subscribers::validEmail($subscriber->email)) {
        $subscriber->email = '';
    }
    $subscriber->receive_html = JRequest::getInt('receive_html', 0);
    if (empty($subscriberId)) {
        //if it is a new user the confirmed depends if the require confirmation is turned on
        if ($GLOBALS[JNEWS . 'require_confirmation'] == '1') {
            $subscriber->confirmed = 0;
        } else {
            $subscriber->confirmed = JRequest::getInt('confirmed');
        }
    } else {
        $subscriber->confirmed = JRequest::getInt('confirmed');
    }
    $subscriber->blacklist = JRequest::getVar('blacklist', 0);
    $subscriber->timezone = JRequest::getVar('timezone', '');
    $subscriber->language_iso = JRequest::getVar('language_iso', '');
    if (empty($subscriber->ip)) {
        $subscriber->ip = jNews_Subscribers::getIP();
    }
    if ($subscriber->ip == '0.0.0.0') {
        $subscriber->ip = '0';
    }
    $subscriber->subscribe_date = time();
    $subscriber->params = JRequest::getVar('params', '');
    //column
    if ($GLOBALS[JNEWS . 'level'] > 2) {
        $subscriber->column1 = JRequest::getVar('column1', '');
        $subscriber->column2 = JRequest::getVar('column2', '');
        $subscriber->column3 = JRequest::getVar('column3', '');
        $subscriber->column4 = JRequest::getVar('column4', '');
        $subscriber->column5 = JRequest::getVar('column5', '');
    }
    //end check of version pro
    //END OF DATA FROM REQUEST
    $doShowSubscribers = true;
    switch ($task) {
        case 'updateOneSub':
            JRequest::checkToken() or die('Invalid Token');
            $doShowSubscribers = true;
            $new = false;
            //we addslashes the name incase an ' is entered in the name
            $subscriber->name = addslashes($subscriber->name);
            $message = jnews::printYN(jNews_Subscribers::saveSubscriber($subscriber, $subscriberId, $new), _JNEWS_UPDATED_SUCCESSFULLY, _JNEWS_ERROR);
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            break;
        case 'deleteOneSub':
            JRequest::checkToken() or die('Invalid Token');
            $doShowSubscribers = true;
            $message = jnews::printYN(jNews_Subscribers::deleteSubscriber($subscriberId), _JNEWS_SUBSCRIBER_DELETED, _JNEWS_ERROR);
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            break;
        case 'cancelSub':
            $doShowSubscribers = true;
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            break;
        case 'edit':
            foreach ($cid as $id) {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=subscribers&task=show&userid=' . $id);
            }
            break;
        case 'show':
            $doShowSubscribers = false;
            $qid[0] = $userid;
            $subscriber = jNews_Subscribers::getSubscribersFromId($qid, false);
            $lists = jNews_Lists::getLists(0, 0, 1, '', false, false);
            $queues = jNews_ListsSubs::getSubscriberLists($userid);
            $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">";
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            backHTML::formStart('', 0, '');
            echo jNews_SubscribersHTML::editSubscriber($subscriber, $lists, $queues, $forms, jnews::checkPermissions('admin'), false, false);
            $go[] = jnews::makeObj('act', $action);
            $go[] = jnews::makeObj('subscriber_id', $subscriber->id);
            $go[] = jnews::makeObj('user_id', $subscriber->user_id);
            backHTML::formEnd($go);
            break;
        case 'new':
        case 'add':
            $doShowSubscribers = false;
            $newSubscriber = new stdClass();
            $newSubscriber->id = '';
            $newSubscriber->user_id = 0;
            $newSubscriber->name = '';
            $newSubscriber->email = '';
            $newSubscriber->ip = jNews_Subscribers::getIP();
            $newSubscriber->receive_html = 1;
            $newSubscriber->confirmed = 1;
            $newSubscriber->blacklist = 0;
            $newSubscriber->timezone = '00:00:00';
            $newSubscriber->language_iso = 'eng';
            $newSubscriber->params = '';
            $newSubscriber->subscribe_date = time();
            //column
            if ($GLOBALS[JNEWS . 'level'] > 2) {
                //check if the version of jnews is pro
                $newSubscriber->column1 = '';
                $newSubscriber->column2 = '';
                $newSubscriber->column3 = '';
                $newSubscriber->column4 = '';
                $newSubscriber->column5 = '';
            }
            $lists = jNews_Lists::getLists(0, 0, 1, '', false, false);
            $queues = '';
            $forms['main'] = " <form action='index.php' method='post' name=\"adminForm\" id=\"adminForm\">";
            if ($mainframe->isAdmin() || $GLOBALS[JNEWS . 'use_backendview']) {
                backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
                backHTML::formStart('addsubsback', 0, '');
                echo jNews_SubscribersHTML::editSubscriber($newSubscriber, $lists, $queues, $forms, jnews::checkPermissions('admin'), false, false);
            } else {
                backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
                backHTML::formStart('addsubsfront', 0, '');
                echo jNews_SubscribersHTML::editSubscriberFE($newSubscriber, $lists, $queues, $forms, jnews::checkPermissions('admin'), false, false);
            }
            $go[] = jnews::makeObj('act', $action);
            $go[] = jnews::makeObj('subscriber_id', $newSubscriber->id);
            $go[] = jnews::makeObj('user_id', $newSubscriber->user_id);
            backHTML::formEnd($go);
            break;
        case 'doNew':
            JRequest::checkToken() or die('Invalid Token');
            $doShowSubscribers = true;
            if ($mainframe->isAdmin() || $GLOBALS[JNEWS . 'use_backendview']) {
                $message = jnews::printYN(jNews_Subscribers::saveSubscriber($subscriber, $subscriberId, $new), _JNEWS_NEW_SUBSCRIBER, _JNEWS_ERROR);
                backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            } else {
                $status = jNews_Subscribers::importBis();
                if ($mainframe->isAdmin()) {
                    jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=subscribers&mid=2');
                } else {
                    $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION . '&act=subscribers&mid=2');
                    jNews_Tools::redirect($mainLink);
                }
            }
            break;
        case 'delete':
            JRequest::checkToken() or die('Invalid Token');
            if (!is_array($cid) || count($cid) < 1) {
                echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n";
                return false;
            } else {
                $status = true;
                foreach ($cid as $id) {
                    if (!jNews_Subscribers::deleteSubscriber($id)) {
                        $status = false;
                    }
                }
                $message = jnews::printYN($status, _JNEWS_SUBSCRIBER_DELETED, _JNEWS_ERROR);
                backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            }
            break;
        case 'update':
            JRequest::checkToken() or die('Invalid Token');
            if (!is_array($cid) || count($cid) < 1) {
                echo "<script> alert('Select an item to update'); window.history.go(-1);</script>\n";
                return false;
            } else {
                foreach ($cid as $id) {
                    $changes = JRequest::getVar($id, array(0));
                    if (!isset($changes['receive_html'])) {
                        $changes['receive_html'] = 0;
                    }
                    if (!isset($changes['confirmed'])) {
                        $changes['confirmed'] = 0;
                    }
                }
            }
            $message = jnews::print_message(_JNEWS_UPDATED_SUCCESSFULLY, 1);
            break;
        case 'export':
            $doShowSubscribers = false;
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            jNews_SubscribersHTML::export($action, $listId);
            break;
        case 'doExport':
            $message = jnews::printYN(jNews_Subscribers::export($listId), _EXPORT, _JNEWS_ERROR);
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            break;
        case 'import':
            $doShowSubscribers = false;
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            $lists = jNews_Lists::getLists('', 0, '', '', false, true, true, false, false);
            jNews_SubscribersHTML::import($action, $lists, $listId);
            break;
        case 'doImport':
            JRequest::checkToken() or die('Invalid Token');
            $message = jNews_Subscribers::importBis();
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            $message = !empty($message) && $message !== true ? $message : ($message === false ? 'Import failed' : _JNEWS_IMPORT_FINISHED);
            if ($mainframe->isAdmin()) {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=subscribers', $message);
            } else {
                $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION . '&act=subscribers&mid=2');
                jNews_Tools::redirect($mainLink);
            }
            break;
        case 'subscribeAll':
        case 'unsubscribeAll':
            JRequest::checkToken() or die('Invalid Token');
            break;
        case 'cancel':
            if ($listId != 0) {
                $listId = 0;
            } else {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION);
            }
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            break;
        case 'cpanel':
            $mainframe = JFactory::getApplication();
            if ($mainframe->isAdmin()) {
                backHTML::controlPanel();
            } else {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION);
            }
            $doShowSubscribers = 0;
            break;
        case 'toggle':
            $subid = JRequest::getVar('subid');
            $column = JRequest::getVar('col');
            if (!empty($subid) && !empty($column)) {
                $passObj = new stdClass();
                $passObj->tableName = '#__jnews_subscribers';
                $passObj->columnName = $column;
                $passObj->whereColumn = 'id';
                $passObj->whereColumnValue = $subid;
                jnews::toggle($passObj);
                // change suspend status if column toggled is confirmed
                if ($column == 'confirmed') {
                    $passObj = new stdClass();
                    $passObj->tableName = '#__jnews_queue';
                    $passObj->columnName = 'suspend';
                    $passObj->whereColumn = 'subscriber_id';
                    $passObj->whereColumnValue = $subid;
                    jnews::toggle($passObj);
                }
            }
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=subscribers&listid=' . $listId);
            break;
        default:
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            break;
    }
    if ($doShowSubscribers) {
        $limit = -1;
        $emailsearch = JRequest::getVar('emailsearch', '', '', 'STRING');
        $emailsearch = htmlentities($emailsearch, ENT_COMPAT, "UTF-8");
        $paginationStart = JRequest::getVar('pg');
        $lll = JRequest::getVar('limitstart');
        if (empty($lll)) {
            JRequest::setVar('limitstart', 0, 'int');
        }
        $app = JFactory::getApplication();
        $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int');
        $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int');
        $subscirberTypeID = JRequest::getVar('subtype', 1);
        if (empty($listId) && in_array($subscirberTypeID, array(1, 2))) {
            $subscirberTypeID = 0;
        }
        if (!empty($listId) && in_array($subscirberTypeID, array(3, 4))) {
            $subscirberTypeID = 0;
        }
        if (!empty($my->id)) {
            $ownedlists = jNews_Lists::getOwnedlists($my->id);
        }
        $ztozto = null;
        $limittotal = jNews_Subscribers::getSubscribers(0, 0, $emailsearch, $ztozto, $listId, '', '', '', 'sub_dateD', '', $ownedlists, '', $subscirberTypeID, true);
        //added one parameter for mailid
        $setLimit = new stdClass();
        $setLimit->total = !empty($limittotal) ? $limittotal : 0;
        $setLimit->start = !empty($limitstart) ? $limitstart : 0;
        $setLimit->end = !empty($limitend) ? $limitend : 20;
        $setSort = new stdClass();
        $setSort->orderValue = $app->getUserStateFromRequest(JNEWS_OPTION . '.subscribers.filter_order', 'filter_order', 'subscribe_date', 'cmd');
        $setSort->orderDir = $app->getUserStateFromRequest(JNEWS_OPTION . '.subscribers.filter_order_Dir', 'filter_order_Dir', 'desc', 'word');
        if (empty($limitstart)) {
            $limitstart = 0;
        }
        if ($setLimit->end > 200) {
            $setLimit->end = 200;
        }
        if ($setLimit->total == $setLimit->end) {
            $setLimit->start = 0;
        }
        $subscribers = jNews_Subscribers::getSubscribers($setLimit->start, $setLimit->end, $emailsearch, $setLimit->total, $listId, '', '', '', 'sub_dateD', '', $ownedlists, $setSort, $subscirberTypeID);
        //added one parameter for mailid
        if ($listId != 0) {
            $showAdmin = true;
        } else {
            $showAdmin = false;
        }
        $dropDownList = jNews_ListType::getListsDropList(0, '', '');
        $subTypeA = array();
        $subTypeA[0] = new stdClass();
        $subTypeA[0]->id = 0;
        $subTypeA[0]->subtype = _JNEWS_SUB_LISTTYPE_ALL;
        if ($listId != 0) {
            $subTypeA[1] = new stdClass();
            $subTypeA[1]->id = 1;
            $subTypeA[1]->subtype = _JNEWS_SUB_LISTTYPE_ONLY_SUBCRIBED;
            $subTypeA[2] = new stdClass();
            $subTypeA[2]->id = 2;
            $subTypeA[2]->subtype = _JNEWS_SUB_LISTTYPE_ONLY_UNSUBCRIBED;
        } else {
            $subTypeA[3] = new stdClass();
            $subTypeA[3]->id = 3;
            $subTypeA[3]->subtype = _JNEWS_SUB_LISTTYPE_ONLY_WAITINGCONF;
            $subTypeA[4] = new stdClass();
            $subTypeA[4]->id = 4;
            $subTypeA[4]->subtype = _JNEWS_SUB_LISTTYPE_ONLY_BLOCKED;
        }
        $lists['listid'] = jnews::HTML_GenericList($dropDownList, 'listid', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'id', 'list_name', $listId);
        $lists['subscirberType'] = jnews::HTML_GenericList($subTypeA, 'subtype', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'id', 'subtype', $subscirberTypeID);
        if ($mainframe->isAdmin()) {
            $forms['main'] = " <form action='index.php' method='post' name=\"adminForm\" id=\"adminForm\">";
        } else {
            if (empty($setLimit->start)) {
                $setLimit->start = 0;
            }
            $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION);
            $forms['main'] = "<form action='" . $mainLink . "' method='post' name=\"adminForm\" id=\"adminForm\">";
        }
        $forms['select'] = " <form method='post' name='jNewsFilterForm'> \n";
        backHTML::formStart('show_mailing', 0, '');
        jNews_SubscribersHTML::showSubscribers($subscribers, $action, $listId, $lists, $setLimit->start, $setLimit->end, $setLimit->total, $showAdmin, $listId, $emailsearch, $forms, $setLimit, $front, $setSort);
    }
    return true;
}
Example #3
0
 /**
  * This public static function is used by jnews_cb plugin
  */
 public static function updateCBSubscribers($force = false, $install = false)
 {
     $db = JFactory::getDBO();
     $time = isset($GLOBALS[JNEWS . 'last_sub_update']) && $GLOBALS[JNEWS . 'last_sub_update'] > 0 ? $GLOBALS[JNEWS . 'last_sub_update'] : 200000;
     $newTask = mktime(date("H") - 1, date("i"), date("s"), date("m"), date("d"), date("Y"));
     if ($force or $newTask > $GLOBALS[JNEWS . 'last_sub_update']) {
         $query = 'UPDATE IGNORE `#__jnews_subscribers` as S LEFT JOIN `#__users` AS U ON U.`id` = S.`user_id` SET S.`name` = U.`name`, S.`email` = U.`email`, S.`confirmed` = 1 - U.`block`  WHERE U.`id` > 0 AND S.`user_id` > 0';
         $db->setQuery($query);
         $db->query();
         $xf = new jNews_Config();
         $newtime = mktime(date("H", $time), date("i", $time), date("s", $time), date("m", $time), date("d", $time) - 2, date("Y", $time));
         if ($install) {
             $newtime = 0;
         }
         $oneDay = date('Y-m-d H:i:s', $newtime);
         $query = 'SELECT M.* FROM `#__users` AS M ' . ' LEFT JOIN `#__jnews_subscribers` AS N ON M.email = N.email ';
         $query .= ' WHERE M.registerDate > \'' . $oneDay . '\'';
         $query .= ' AND  N.id IS NULL AND M.block=0 ';
         $db->setQuery($query);
         $rows = $db->loadObjectList();
         if (!empty($rows)) {
             foreach ($rows as $row) {
                 $query = "INSERT INTO `#__jnews_subscribers` (`user_id`,`subscribe_date`, `name`,`email`,`confirmed`)";
                 $query .= " VALUES ( {$row->id} , '{$row->registerDate}', '" . addslashes($row->name) . "', '" . addslashes($row->email) . "' , 1 ) ";
                 $db->setQuery($query);
                 $db->query();
                 $xf->plus('totalsubcribers0', 1);
                 $xf->plus('act_totalsubcribers0', 1);
                 $lists = jNews_Lists::getLists(0, 0, null, '', true, false, false);
                 if (!empty($lists)) {
                     foreach ($lists as $list) {
                         $qid[0] = jNews_Subscribers::getSubscriberId($row->registerDate);
                         $subscriber = jNews_Subscribers::getSubscribersFromId($qid, false);
                         $subId = array();
                         //if ( isset($subscriber->id) ) {
                         //$subId[0] =  $subscriber->id;
                         // jNews_Queue::insertQueuesForNews($subId, $list->id, 29 );
                         ////$subscriberInfo=jNews_ListsSubs::getListidsSubscribedInfo($subscriber->id);
                         //jNews_Queue::updateQueues($subId, '', $list->id, @$list->acc_id, true);
                         // }
                     }
                 }
             }
         }
         $query = 'SELECT M.* FROM `#__jnews_subscribers` AS M ' . ' LEFT JOIN `#__users` AS N ON N.id = M.user_id ';
         $query .= ' WHERE N.registerDate > \'' . $oneDay . '\'';
         $query .= ' AND M.subscribe_date > \'' . $oneDay . '\'';
         $query .= ' AND  N.id IS NULL  AND M.user_id>0 ORDER BY N.id ';
         $db->setQuery($query);
         $rows = $db->loadObjectList();
         if (!empty($rows)) {
             foreach ($rows as $row) {
                 $query = 'DELETE FROM `#__jnews_subscribers` WHERE `id` = ' . $row->id;
                 $db->setQuery($query);
                 $db->query();
                 $xf->plus('act_totalsubcribers0', -1);
                 jNews_ListsSubs::removeSubscription($row->id, '');
             }
         }
         $query = 'SELECT N.id, N.name , N.email , N.block  FROM `#__users` AS N ' . ' LEFT JOIN `#__jnews_subscribers` AS M ON N.id = M.user_id ';
         $query .= ' WHERE  N.registerDate > \'' . $oneDay . '\'';
         $query .= ' AND M.subscribe_date > \'' . $oneDay . '\'';
         $query .= ' AND M.name != N.name  OR M.email != N.email OR N.block = M.confirmed ';
         $db->setQuery($query);
         $rows = $db->loadObjectList();
         if (!empty($rows)) {
             foreach ($rows as $row) {
                 if ($row->block == 1) {
                     $status = 0;
                 } else {
                     $status = 1;
                 }
                 $query = "UPDATE IGNORE `#__jnews_subscribers` SET `name` ='" . addslashes($row->name) . "' " . ", `email` = '" . addslashes($row->email) . "' " . ", `confirmed` ='" . $status . "'  WHERE `user_id` = " . $row->id;
                 $db->setQuery($query);
                 $db->query();
             }
         }
         $query = 'SELECT N.id , N.email FROM `#__users` AS N ';
         $query .= 'LEFT JOIN `#__jnews_subscribers` AS M ON N.email = M.email ';
         $query .= ' WHERE N.registerDate > \'' . $oneDay . '\'';
         $query .= ' AND M.subscribe_date > \'' . $oneDay . '\'';
         $query .= ' AND M.user_id = 0 AND N.block = 0 ';
         $db->setQuery($query);
         $rows = $db->loadObjectList();
         if (!empty($rows)) {
             foreach ($rows as $row) {
                 $query = "UPDATE `#__jnews_subscribers` AS S SET `user_id` = " . $row->id;
                 $query .= " WHERE S.email = '{$row->email}'";
                 $db->setQuery($query);
             }
         }
         $xf->update('last_sub_update', time());
         return true;
     }
 }
Example #4
0
 public static function confirmRegistration($d)
 {
     if (!empty($d['subscriberId']) and !empty($d['cle'])) {
         $qid[0] = $d['subscriberId'];
         $subscriber = jNews_Subscribers::getSubscribersFromId($qid, false);
         if (md5($subscriber->email) == $d['cle']) {
             $subscriber->confirmed = 1;
             $subscriber->name = addslashes($subscriber->name);
             jNews_Subscribers::saveSubscriber($subscriber, $subscriber->id, false);
             //&$subscriberId
         }
         if (!(require_once JNEWSPATH_CLASS . 'class.queue.php')) {
             return false;
         }
         jNews_Queue::updateSuspendedQueue($subscriber->id);
     }
     return true;
 }
Example #5
0
require_once JNEWSPATH_ADMIN . 'views' . DS . 'lists.jnews.html.php';
require_once JNEWSPATH_ADMIN . 'views' . DS . 'mailings.jnews.html.php';
require_once JNEWSPATH_ADMIN . 'views' . DS . 'templates.jnews.html.php';
require_once JNEWSPATH_ADMIN . 'views' . DS . 'tags.jnews.html.php';
if (JNEWS_DEBUG) {
    ini_set('display_errors', true);
    error_reporting(E_ALL);
}
$my = JFactory::getUser();
$subscriber = new stdClass();
$userId = $my->id;
$validated = false;
//we get the subscriber Info
$qid[0] = $subscriberId;
if ($subscriberId > 0) {
    $subscriber = jNews_Subscribers::getSubscribersFromId($qid, false);
}
if ($subscriberId > 0 && !empty($cle) && $userId < 1) {
    if (md5($subscriber->email) == $cle) {
        $userId = $subscriberId;
        $validated = true;
    } else {
        echo jnews::printM('red', _NOT_AUTH);
        $subscriberId = 0;
    }
}
$document = JFactory::getDocument();
$d['subscriberId'] = $subscriberId;
$d['cle'] = $cle;
if ($userId > 0 && empty($cle)) {
    $validated = true;
Example #6
0
 public static function sendTestEmail($mailingId, $listId)
 {
     $list = new stdClass();
     $new = null;
     $mailing = jNews_Mailing::getOneMailing($list, $mailingId, '', $new);
     if ($listId > 0) {
         $list = jNews_Lists::getOneList($listId);
     } else {
         $list = jNews_Lists::getOneList($mailing->list_id);
     }
     $previewemailaddress = JRequest::getVar('emailaddress', '');
     $previewname = JRequest::getVar('name', '');
     $previewhtml = JRequest::getVar('html', '0');
     $receivers = new stdClass();
     $my = JFactory::getUser();
     $d['email'] = trim($previewemailaddress);
     $infos = jNews_Subscribers::getSubscriberIdFromEmail($d);
     if (empty($infos['subscriberId'])) {
         $d['email'] = $my->email;
         $infos = jNews_Subscribers::getSubscriberIdFromEmail($d);
     }
     if (!empty($infos['subscriberId'])) {
         $receivers = jNews_Subscribers::getSubscribersFromId(array($infos['subscriberId']));
     } else {
         $receivers->id = 0;
     }
     $receivers->email = $previewemailaddress;
     $receivers->name = $previewname;
     $receivers->receive_html = $previewhtml;
     $mailerC = new jNews_ProcessMail();
     return $mailerC->send($mailing, $receivers);
 }
Example #7
0
 function getEditTab($tab, $user, $ui)
 {
     $Itemid = JRequest::getInt('Itemid');
     $my = JFactory::getUser();
     if ($my->get('id') < 1) {
         echo JText::_('ALERTNOTAUTH');
         echo "<br />" . JText::_('You need to login.');
         return false;
     }
     if (!getjNewsTab::checkInstalled()) {
         return _UE_NEWSLETTERNOTINSTALLED;
     }
     $html = '';
     require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . 'class.jnews.php';
     require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . 'class.subscribers.php';
     require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . 'class.listssubscribers.php';
     require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . 'class.lists.php';
     require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'views' . DS . 'subscribers.jnews.html.php';
     if (!empty($my->id)) {
         $subscriberId = jNews_Subscribers::getSubscriberIdFromUserId($my->id);
         $qid[0] = $subscriberId;
         $subscriber = jNews_Subscribers::getSubscribersFromId($qid, false);
         $queues = jNews_ListsSubs::getSubscriberLists($subscriberId);
         $access = jnews::checkPermissions('admin', $my->id);
     } else {
         $userId = 0;
         $queues = '';
         $access = false;
         $subscriberId = 0;
         $subscriber = new stdClass();
         $subscriber->id = '';
         $subscriber->user_id = 0;
         $subscriber->name = '';
         $subscriber->email = '';
         $subscriber->ip = jNews_Subscribers::getIP();
         $subscriber->receive_html = 1;
         $subscriber->confirmed = 1;
         $subscriber->blacklist = 0;
         $subscriber->timezone = '00:00:00';
         $subscriber->language_iso = 'eng';
         $subscriber->params = '';
         $subscriber->subscribe_date = time();
         if ($GLOBALS[JNEWS . 'level'] > 2) {
             //check if the version of jnews is pro
             $subscriber->column1 = '';
             $subscriber->column2 = '';
             $subscriber->column3 = '';
             $subscriber->column4 = '';
             $subscriber->column5 = '';
         }
     }
     if (!empty($my->user_id)) {
         if ($my->user_id > 0) {
             $access = jnews::checkPermissions('admin');
         } else {
             $access = false;
         }
     }
     $query = 'SELECT * FROM `#__jnews_lists` WHERE `published`=1 AND `hidden`=1 ';
     $db = JFactory::getDBO();
     $db->setQuery($query);
     $lists = $db->loadObjectList();
     $doShowSubscribers = false;
     $mainLink = 'option=' . JNEWS_OPTION;
     $selectLink = 'option=' . JNEWS_OPTION . '&act=subscriber';
     $mainLink = jNews_Tools::completeLink($mainLink, false);
     $selectLink = jNews_Tools::completeLink($selectLink, false);
     $forms['main'] = '<form method="post" action="' . $mainLink . '" onsubmit="submitbutton();return false;" name="mosForm" >' . "\n\r";
     $forms['select'] = '<form method="post" action="' . $selectLink . '"  name="jNewsFilterForm">';
     if (empty($access)) {
         $access = 29;
     }
     $html .= jNews_SubscribersHTML::editSubscriber($subscriber, $lists, $queues, $forms, $access, true, true);
     $html .= '<input type="hidden" name="subscriber_id" value="' . $subscriber->id . '" />';
     return $html;
 }