Exemple #1
0
 public function Process()
 {
     // Newsletter component disabled or not found. Aborting.
     if (!$this->enabled) {
         return true;
     }
     $config = new jNews_Config();
     // Build subscriber object
     $subscriber = new stdClass();
     // Lists
     $cumulative = $this->JInput->post->get("jnews_subscribe_cumulative", NULL, "int");
     $checkboxes = $this->JInput->post->get("jnews_subscribe", array(), "array");
     $subscriber->list_id = $cumulative ? $checkboxes : array();
     // No lists selected. Skip here to avoid annoying the user with email confirmation. It is useless to confirm a subscription to no lists.
     if (empty($subscriber->list_id)) {
         return true;
     }
     // Name field may be absent. JNews will assign an empty name to the user.
     $subscriber->name = isset($this->FieldsBuilder->Fields['sender0']) ? $this->FieldsBuilder->Fields['sender0']['Value'] : "";
     $subscriber->email = empty($this->FieldsBuilder->Fields['sender1']['Value']) ? NULL : JMailHelper::cleanAddress($this->FieldsBuilder->Fields['sender1']['Value']);
     // JNews saves users with empty email address, so we have to check it
     if (empty($subscriber->email)) {
         $this->logger->Write(get_class($this) . " Process(): Email address empty. User save aborted.");
         return true;
     }
     // It seems that $subscriber->confirmed defaults to unconfirmed if unset, so we need to read and pass the actual value from the configuration
     $subscriber->confirmed = !(bool) $config->get('require_confirmation');
     $subscriber->receive_html = 1;
     // Avoid Notice: Undefined property while JNews libraries access undefined properties
     $subscriber->ip = jNews_Subscribers::getIP();
     $subscriber->subscribe_date = jnews::getNow();
     $subscriber->language_iso = "eng";
     $subscriber->timezone = "00:00:00";
     $subscriber->blacklist = 0;
     $subscriber->user_id = JFactory::getUser()->id;
     // Subscription
     $sub_id = null;
     jNews_Subscribers::saveSubscriber($subscriber, $sub_id, true);
     if (empty($sub_id)) {
         // User save failed. Probably email address is empty or invalid
         $this->logger->Write(get_class($this) . " Process(): User save failed");
         return true;
     }
     // Subscribe $subscriber to $subscriber->list_id
     //$subscriber->id = $sub_id;
     // jNews_ListsSubs::saveToListSubscribers() doesn't work well. When only one list is passed to, it reads the value $listids[0],
     // but the element 0 is not always the first element of the array. In our case is $listids[1]
     //jNews_ListsSubs::saveToListSubscribers($subscriber);
     $this->SaveSubscription($subscriber);
     // Log
     $this->logger->Write(get_class($this) . " Process(): subscribed " . $this->FieldsBuilder->Fields['sender0']['Value'] . " (" . $this->FieldsBuilder->Fields['sender1']['Value'] . ") to lists " . implode(",", $subscriber->list_id));
     return true;
 }
Exemple #2
0
    public static function description($listEdit, $lists, $show, $html, $listType)
    {
        $editor = JFactory::getEditor();
        static $db = null;
        if (!isset($db)) {
            $db = JFactory::getDBO();
        }
        ?>
	<fieldset class="jnewscss">
	<table class="jnewstable" width="100%"  cellspacing="1">
		<tbody>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
        $tip = _JNEWS_INFO_LIST_PUB;
        $title = _JNEWS_PUBLISHED;
        echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
        ?>
				</span>
			</td>
			<td><?php 
        echo $lists['published'];
        ?>
</td>
		</tr>
	<?php 
        if ($show['hide']) {
            ?>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_MAILING_VISIBLE;
            $title = _JNEWS_VISIBLE_FRONT;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			<td><?php 
            echo $lists['hidden'];
            ?>
</td>
			</tr>

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

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

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

				&nbsp;<img src="components/<?php 
            echo JNEWS_OPTION;
            ?>
/images/16/profile.png" id="popbtn" name="popbtn" onClick="document.getElementById('poplist').style.display = 'inline'; document.getElementById('popbtn').style.display = 'none';" title="<?php 
            echo _JNEWS_SENDER_LIST_INFO;
            ?>
" style="position:absolute;">
				<select id="poplist" name="poplist" style="display:none;position:relative;" onChange="document.getElementById('poplist').style.display = 'none'; document.getElementById('popbtn').style.display = 'inline';">
				<option value="0" onClick="document.adminForm.sendername.value=''; document.adminForm.senderemail.value='';"> </option>
			<?php 
            // 2nd parameter of this public static function should be a preference
            // we need to limit it so that it wouldnt cause any problems when loading a bunch of datas e.g hundreds or thousands of users
            $usersA = jNews_Subscribers::getUsers('gid', '50');
            // create options for list
            if (!empty($usersA)) {
                foreach ($usersA as $user) {
                    $name = $user->name;
                    $email = $user->email;
                    $selected = isset($listEdit->sendername) && $listEdit->sendername == $name && (isset($listEdit->senderemail) && $listEdit->senderemail == $email) ? true : false;
                    ?>
						<option value="<?php 
                    echo $user->name;
                    ?>
" onClick="document.adminForm.sendername.value='<?php 
                    echo $name;
                    ?>
'; document.adminForm.senderemail.value='<?php 
                    echo $email;
                    ?>
';" <?php 
                    if ($selected) {
                        echo 'selected';
                    }
                    ?>
> <?php 
                    echo $user->name . ' (' . $user->email . ')';
                    ?>
 </option>
				<?php 
                }
            }
            ?>
			 	</select>
			</td>
		</tr>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_SENDER_EMAIL;
            $title = _JNEWS_SENDER_EMAIL;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
				<input type="text" name="senderemail" class="inputbox" size="40" maxlength="64" value="<?php 
            echo $listEdit->senderemail;
            ?>
" />
			</td>
		</tr>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_SENDER_BOUNCED;
            $title = _JNEWS_SENDER_BOUNCE;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
				<input type="text" name="bounceadres" class="inputbox" size="40" maxlength="64" value="<?php 
            echo $listEdit->bounceadres;
            ?>
" />
			</td>
		</tr>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_JNEWS_OWNER;
            $title = _JNEWS_OWNER;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
				<?php 
            echo $listEdit->owner;
            ?>
			</td>
		</tr>
		</tbody>
	</table>
	</fieldset>
	<?php 
        } else {
            echo '<input type="hidden" name="sendername" value="' . $listEdit->sendername . '" />';
            echo '<input type="hidden" name="senderemail" value="' . $listEdit->senderemail . '" />';
            echo '<input type="hidden" name="bounceadres" value="' . $listEdit->bounceadres . '" />';
        }
    }
Exemple #3
0
function mailing($action, $task, $listId, $listType, $mailingId, $message)
{
    $showMailings = false;
    $db = JFactory::getDBO();
    switch ($task) {
        case 'edit':
            $issue_nb = JRequest::getInt('issue_nb', 1);
            $mailingType = JRequest::getVar('listype');
            $isEdit = JRequest::getVar('isEdit', true);
            $mySess = JFactory::getSession();
            $mySess->set('listype', $mailingType, 'LType');
            if (!empty($listId)) {
                $list = jNews_Lists::getOneList($listId);
            } else {
                $list = jNews_Lists::getListFirstEntry();
            }
            $new = empty($mailingId) || $mailingId == 0 ? true : false;
            $mailing = jNews_Mailing::getOneMailing($list, $mailingId, $issue_nb, $new, false, true);
            $mailing->mailing_type = $mailingType;
            //			if(empty($isEdit)) $isEdit = true;
            // set default mailing parameters
            $my = JFactory::getUser();
            $subscribers = jNews_Subscribers::getSubscriberInfoFromUserId($my->id);
            if (!isset($subscribers)) {
                $subscribers = new stdClass();
            }
            $subscribers->name = isset($subscribers->name) ? $subscribers->name : '';
            $subscribers->email = isset($subscribers->email) ? $subscribers->email : '';
            //			$mailing->fromname = ( !isset( $mailing->fromname ) || empty( $mailing->fromname ) ) ? $subscribers->name : $mailing->fromname;
            //			$mailing->fromemail = ( !isset( $mailing->fromemail ) || empty( $mailing->fromemail ) ) ? $subscribers->email : $mailing->fromemail;
            //			$mailing->frombounce = ( !isset( $mailing->frombounce ) || empty( $mailing->frombounce ) ) ? $GLOBALS[JNEWS.'sendmail_from'] : $mailing->frombounce;
            $show = jNews_ListType::showType($mailing->mailing_type, 'editmailing');
            if ($mailing->published != 1 or $mailing->mailing_type != 1 or isset($show['admin']) and $show['admin']) {
                $forms['main'] = " <form action='index.php' method='post' enctype='multipart/form-data' name='adminForm' id=\"adminForm\">";
                jNews_Mailing::_header($task, $action, $mailing->mailing_type, $message, 'edit');
                jNews_MailingsHTML::editMailing($mailing, $new, $listId, $forms, $show, $isEdit);
                $go[] = jnews::makeObj('act', $action);
                backHTML::formEnd($go);
            } else {
                $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">";
                jNews_Mailing::_header($task, $action, $mailing->mailing_type, $message);
                //backHTML::formStart();
                jNews_MailingsHTML::viewMailing($mailing, $forms);
                $go[] = jnews::makeObj('act', 'mailing');
                $go[] = jnews::makeObj('task', 'viewmailing');
                $go[] = jnews::makeObj('mailingid', $mailing->id);
                backHTML::formEnd($go);
            }
            break;
        case 'new':
        case 'add':
            // check if atleast one list exist and published
            // if false then restrict entry
            $mailingType = JRequest::getVar('listype');
            $type = $mailingType == 2 ? 2 : 1;
            $result = jNews_Lists::checkListNotEmpty($type);
            if (!$result) {
                if ($type == 2) {
                    $disp = addslashes(_JNEWS_CHECKCAMPAIGNFOUND);
                } else {
                    $disp = addslashes(_JNEWS_CHECKLISTFOUND);
                }
                echo "<script> alert('" . $disp . "'); window.history.go(-1);</script>\n";
                break;
            }
            $mailingType = JRequest::getVar('listype');
            if (empty($listId)) {
                $listId = JRequest::getVar('listid');
            }
            if (!empty($listId)) {
                $mailingType = jNews_Lists::getListType($listId) == 2 ? 2 : 1;
            }
            JRequest::setVar('listype', $mailingType);
            $total = jNews_Mailing::countMailings($listId, $mailingType);
            $total++;
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&task=edit&mailingid=0&issue_nb=' . $total . '&listype=' . $mailingType . '&listid=' . $listId . '&isEdit=0');
            //mariap
            break;
        case 'saveSend':
            JRequest::checkToken() or die('Invalid Token');
            $mySess = JFactory::getSession();
            $mailingType = $mySess->get('listype', '', 'LType');
            $status = checkMailingSave($mailingType);
            if (!$status) {
                return false;
            }
            jNews_Mailing::saveMailing($mailingId, $listId);
        case 'sendready':
            //we update the senddate of the newsletter
            jNews_Mailing::updatesenddate($mailingId);
            jNews_MailingsHTML::sendReady($mailingId, $listId, $listType);
            break;
        case 'generate':
            if (class_exists('jNews_Auto')) {
                $still = false;
                $message = jnews::printYN(jNews_Auto::processQueue(true, true, $still, true), 'Queue processed', _JNEWS_ERROR);
                jNews_Auto::displayStatus();
            }
            return;
            break;
        case 'send':
            $queueC = new jNews_Queue();
            $queueC->checkForNewsletters($mailingId);
            $queueCount = jNews_Queue::getQueueCount($mailingId);
            $totalSub = JRequest::setVar('totalsend', $queueCount);
            $linkURL = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=mailing&task=continuesend&mailingid=' . $mailingId . '&totalsend=' . $totalSub, true, false, true);
            jNews_Tools::redirect($linkURL);
            break;
        case 'continuesend':
            $queueC = new jNews_Queue();
            //we update the senddate of the mailing to be now to be able to continue the sending and send it after we click continue
            //			$queueC->updateSenddateToNow($mailingId);
            $totalSend = JRequest::getVar('totalsend', 0, '', 'int');
            $alreadySent = JRequest::getVar('alreadysent', 0, '', 'int');
            $queueC->start = $alreadySent;
            $queueC->total = $totalSend;
            $queueC->pause = $GLOBALS[JNEWS . 'pause_time'];
            $queueC->sendQueue(false, $mailingId, false, true);
            ob_start();
            exit;
            break;
        case 'testspam':
            if (empty($message)) {
                $message = _JNEWS_MESSAGE_NOT;
            }
            $mailingId = $mailingId == 0 ? jNews_Mailing::getLastMailingId() : $mailingId;
            $my = JFactory::getUser();
            if ($listId > 0) {
                $archivemailing = jNews_Mailing::getMailingView($mailingId, $listId);
            } else {
                $archivemailing = jNews_Mailing::getMailingView($mailingId);
            }
            $mailing = new stdClass();
            $receivers = new stdClass();
            $receivers->email = '*****@*****.**';
            $receivers->name = $archivemailing->fromname;
            $receivers->receive_html = 1;
            $receivers->id = jNews_Subscribers::getSubscriberIdFromUserId($my->id);
            //if email are different we dont replace because we want to make sure the spam cehck count the fact that
            //sender and bounce back are different
            if ($archivemailing->fromemail == $archivemailing->frombounce) {
                $archivemailing->frombounce = $my->email;
            }
            $archivemailing->fromemail = $my->email;
            $mailerC = new jNews_ProcessMail();
            $status = $mailerC->send($archivemailing, $receivers);
            $message = jnews::printYN($status, _JNEWS_SPAMTEXT_MESSAGE_SENT_SUCCESSFULLY, $message);
            $link = 'http://www.joobi.co/index.php?option=com_jlinks&controller=redirect&link=SpamCheck&alt=jnewsdoc_glossary';
            $iFrame = '<iframe src="' . $link . '" width="100%" height="680px" scrolling="auto"></iframe>';
            echo $iFrame;
            break;
        case 'savePreview':
            JRequest::checkToken() or die('Invalid Token');
            $status = checkMailingSave($mailingType);
            if (!$status) {
                return false;
            }
            if ($mailingType == 7) {
                $mailing = JRequest::getVar('mailing', '');
                $ContentStatus = checkTag();
                if (!$ContentStatus) {
                    return false;
                }
            }
            jNews_Mailing::saveMailing($mailingId, $listId);
        case 'preview':
            $emailaddress = JRequest::getVar('emailaddress', '');
            $mailingId = $mailingId == 0 ? jNews_Mailing::getLastMailingId() : $mailingId;
            if (!empty($emailaddress)) {
                $status = jNews_Mailing::sendTestEmail($mailingId, $listId);
                if (empty($message)) {
                    $message = _JNEWS_MESSAGE_NOT;
                }
                $message = jnews::printYN($status, _JNEWS_MESSAGE_SENT_SUCCESSFULLY, $message);
            }
            if ($listId > 0) {
                $archivemailing = jNews_Mailing::getMailingView($mailingId, $listId);
            } else {
                $archivemailing = jNews_Mailing::getMailingView($mailingId);
            }
            $doc = JFactory::getDocument();
            $css = '.icon-48-preview{ background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/preview.png)}';
            $doc->addStyleDeclaration($css, $type = 'text/css');
            $title = _JNEWS_PREVIEW_TITLE . ': ' . $archivemailing->subject;
            backHTML::_header(_JNEWS_PREVIEW_TITLE, 'preview.png', $message, $task, $action);
            //new view for the preview mailing
            echo '<table cellpadding="0" cellspacing="2" border="0" width="100%"><tr><td width="40%">';
            jNews_MailingsHTML::previewMailingHTML($mailingId, $listId, $listType, $archivemailing->html);
            echo '</td><td width="60%">';
            $forms['main'] = '';
            $list = jNews_Lists::getOneList($archivemailing->list_id);
            $textonly = '';
            $mailerC = new jNews_ProcessMail();
            $queueInfo = new stdClass();
            $queueInfo->mailingid = $mailingId;
            $queueInfo->listid = @$listId;
            $mailerC->getContent($archivemailing->images, $archivemailing->html, $archivemailing->textonly, $archivemailing->subject, false, true, $queueInfo);
            //new $archivemailing->subject
            if ($archivemailing->html == 1) {
                if (empty($template_id)) {
                    $template_id = $archivemailing->template_id;
                }
                if (!empty($template_id)) {
                    jNews_Templates::includeStyles($archivemailing->htmlcontent, $template_id);
                }
            } else {
                $archivemailing->textonly = jNews_ProcessMail::htmlToText($archivemailing->textonly);
            }
            //new view for the preview mailing
            jNews_MailingsHTML::viewHeading($archivemailing);
            echo '</td></tr><tr><td colspan="2">';
            jNews_MailingsHTML::viewMailing($archivemailing, $forms);
            echo '</td></tr></tbody></table>';
            if ($mailingId == 0) {
                JRequest::setVar('mailingid', $mailingId);
            }
            break;
        case 'view':
            $mailingType = JRequest::getVar('listype');
            if (!empty($mailingType)) {
                $mySess = JFactory::getSession();
                $mySess->set('listype', $mailingType, 'LType');
            }
            if ($mailingId != 0) {
                if ($listId > 0) {
                    $archivemailing = jNews_Mailing::getMailingView($mailingId, $listId);
                } else {
                    $archivemailing = jNews_Mailing::getMailingView($mailingId);
                }
                if (empty($template_id)) {
                    $template_id = $archivemailing->template_id;
                }
                if (!empty($template_id)) {
                    jNews_Templates::includeStyles($archivemailing->htmlcontent, $template_id);
                }
                $forms['main'] = "<form action='index.php?option=" . JNEWS_OPTION . "&act=mailing&listype=" . $listType . "&listid=" . $listId . "' method='post' name='adminForm' id=\"adminForm\">";
                jNews_Mailing::_header($task, $action, $listType, $message);
                backHTML::formStart('show_mailing', 0, '');
                jNews_MailingsHTML::viewMailing($archivemailing, $forms);
                $go[] = jnews::makeObj('act', 'mailing');
                $go[] = jnews::makeObj('task', 'viewmailing');
                $go[] = jnews::makeObj('listId', $archivemailing->list_id);
                //listid to listId--original
                backHTML::formEnd($go);
            }
            break;
        case 'deletequeue':
            //implement here what are we going to do with the delete queueu column on the mailing
            $mailingID = JRequest::getVar('mailingid');
            $mailingType = JRequest::getVar('listype');
            if (!empty($mailingID)) {
                $db = JFactory::getDBO();
                $db->setQuery('DELETE FROM `#__jnews_queue` WHERE `mailing_id` = ' . $mailingID);
                $db->query();
                $message = jnews::printYN(true, _JNEWS_MAILING_QUEUE_DELETED, _JNEWS_ERROR);
            } else {
                $message = jnews::printYN(false, _JNEWS_MAILING_QUEUE_DELETED, _JNEWS_ERROR);
            }
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType, $message);
            break;
        case 'deleteMailing':
            JRequest::checkToken() or die('Invalid Token');
            $d['mailing'] = jNews_Mailing::getOneMailing('', $mailingId, '', $new);
            $message = jnews::printYN(jNews_Mailing::delete($d), @constant($GLOBALS[JNEWS . 'listname' . $d['mailing']->list_type]) . '"' . $d['mailing']->subject . '"' . _JNEWS_SUCCESS_DELETED, _JNEWS_ERROR);
            $showMailings = true;
            break;
        case 'cancel':
            $url = 'index.php?option=' . JNEWS_OPTION . '&act=mailing&mailingid=' . $mailingId;
            $url .= (!empty($listId) ? '&listid=' . $listId : '') . '&listype=' . $mailingType;
            jNews_Tools::redirect($url);
            break;
        case 'copy':
            JRequest::checkToken() or die('Invalid Token');
            $message = jnews::printYN(jNews_Mailing::copyMailing($mailingId), _JNEWS_MAILING_COPY, _JNEWS_ERROR);
            $showMailings = true;
            break;
        case 'cancelMailing':
            $showMailings = true;
            break;
        case 'publishMailing':
            JRequest::checkToken() or die('Invalid Token');
            $mailing = jNews_Mailing::getOneMailing('', $mailingId, '', $new);
            $message = jnews::printYN(jNews_Mailing::publishMailing($mailingId), @constant($GLOBALS[JNEWS . 'listname' . $mailing->mailing_type]) . ' ' . _JNEWS_PUBLISHED, _JNEWS_ERROR);
            $mailingType = jNews_Mailing::getMailingInfoz($mailingId);
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType);
            break;
        case 'unpublishMailing':
            JRequest::checkToken() or die('Invalid Token');
            $mailing = jNews_Mailing::getOneMailing('', $mailingId, '', $new);
            $message = jnews::printYN(jNews_Mailing::unpublishMailing($mailingId), @constant($GLOBALS[JNEWS . 'listname' . $mailing->mailing_type]) . ' ' . _JNEWS_UNPUBLISHED, _JNEWS_ERROR);
            $mailingType = jNews_Mailing::getMailingInfoz($mailingId);
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId);
            break;
        case 'cpanel':
            backHTML::controlPanel();
            break;
        case 'save':
            JRequest::checkToken() or die('Invalid Token');
            $subject = JRequest::getVar('subject', '');
            if (empty($subject)) {
                echo "<script> alert('subject needs to be not empty'); window.history.go(-1);</script>\n";
                return false;
            }
            if (!isset($mailingType)) {
                $mySess = JFactory::getSession();
                $mailingType = $mySess->get('listype', '', 'LType');
            }
            $status = checkMailingSave($mailingType);
            if ($mailingType == 7) {
                $mailing = JRequest::getVar('mailing', '');
                $ContentStatus = checkTag();
                if (!$ContentStatus) {
                    return false;
                }
            }
            if (!$status) {
                return false;
            }
            $message = jnews::printYN(jNews_Mailing::saveMailing($mailingId, $listId), _JNEWS_MAILING_SAVED, _JNEWS_ERROR);
            if (!empty($mailingtype)) {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId);
            } else {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId);
                $showMailings = true;
                unset($GLOBALS["task"]);
                unset($_REQUEST["task"]);
            }
            break;
        case 'apply':
            JRequest::checkToken() or die('Invalid Token');
            $mailingid = JRequest::getVar('mailingid', '0');
            if (!isset($mailingType)) {
                $mySess = JFactory::getSession();
                $mailingType = $mySess->get('listype', '', 'LType');
            }
            $status = checkMailingSave($mailingType);
            if ($mailingType == 7) {
                $mailing = JRequest::getVar('mailing', '');
                $ContentStatus = checkTag();
                if (!$ContentStatus) {
                    return false;
                }
            }
            if (!$status) {
                return false;
            }
            $message = jnews::printYN(jNews_Mailing::saveMailing($mailingId, $listId), _JNEWS_MAILING_SAVED, _JNEWS_ERROR);
            $mailingid = $mailingid == 0 ? jNews_Mailing::getLastMailingId() : $mailingid;
            if (!empty($mailingtype)) {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&task=edit&listype=' . $mailingType . '&mailingid=' . $mailingid . '&listid=' . $listId);
            } else {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&task=edit&listype=' . $mailingType . '&mailingid=' . $mailingid . '&listid=' . $listId);
                $showMailings = true;
                unset($GLOBALS["task"]);
                unset($_REQUEST["task"]);
            }
            break;
        case 'show':
            $id = JRequest::getVar('mailingid');
            $mySess = JFactory::getSession();
            $mailingType = JRequest::getVar('listype', 0);
            $listId = JRequest::getVar('listid', 0);
            $link = 'index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId;
            jNews_Tools::redirect($link);
            $showMailings = true;
            break;
        case 'toggle':
            $listid = JRequest::getVar('listid');
            $column = JRequest::getVar('col');
            $mailingid = JRequest::getVar('mailingid');
            if (!empty($mailingid) && !empty($column)) {
                $passObj = new stdClass();
                $passObj->tableName = '#__jnews_mailings';
                $passObj->columnName = $column;
                $passObj->whereColumn = 'id';
                $passObj->whereColumnValue = $mailingid;
                jnews::toggle($passObj);
            }
            if ($listType == 1) {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listid . '&listype=1');
            } else {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listid . '&listype=2');
            }
            break;
        default:
            $showMailings = true;
            break;
    }
    if ($showMailings) {
        if (empty($listType)) {
            $listType = JRequest::getVar('listype', 0);
        }
        if (empty($listId)) {
            $listId = JRequest::getVar('listid', 0);
        }
        $paginationStart = JRequest::getVar('pg');
        if (!empty($paginationStart)) {
            $limitstart = 0;
            $limitend = $paginationStart;
        } else {
            $app = JFactory::getApplication();
            $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int');
            $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int');
        }
        $limittotal = jNews_Mailing::countMailings(0, $listType);
        $setLimit = new stdClass();
        $setLimit->total = !empty($limittotal) ? $limittotal : 0;
        $setLimit->start = !empty($limitstart) ? $limitstart : 0;
        $setLimit->end = !empty($limitend) ? $limitend : $limittotal;
        if ($setLimit->total == $setLimit->end) {
            $setLimit->start = 0;
        }
        jNews_Mailing::showMailings($task, $action, $listId, $listType, $message, true, _JNEWS_MENU_MAILING, $setLimit);
    }
    return true;
}
    public static function showSubscribers($subscribers, $action, $listId, &$lists, $start, $limit, $total, $showAdmin, $theLetterId, $emailsearch, $forms, $setLimit = null, $front = false, $setSort = null)
    {
        $my = JFactory::getUser();
        $mainframe = JFactory::getApplication();
        ?>

	<script language="javascript" type="text/javascript">
	//<!--
	function jnewsletterselectall(){
		var i = 0;
		allcheck = document.getElementById("selectallcheck");
		if(allcheck.checked) checkedvalue = 1;
		else checkedvalue = 0;

		while(myelement = document.getElementById("cid["+i+"]")){
			myelement.checked = checkedvalue;
			i++;
		}

		if(checkedvalue){
			document.getElementById("boxcount").value = i;
		}else{
			document.getElementById("boxcount").value = 0;
		}
	}
	 //-->
	</script>

	<?php 
        if ($listId == 0) {
            $message = _JNEWS_SUSCRIB_LIST;
        } else {
            $lt_name = jNews_Lists::getLists($listId, 0, null, '', false, false, true);
            $message = _JNEWS_SUSCRIB_LIST_UNIQUE . "<span style='color: rgb(51, 51, 51);'>" . @$lt_name[0]->list_name . "</span>";
        }
        $filter = _JNEWS_SEL_LIST . '  ' . $lists['listid'] . ' ' . $lists['subscirberType'];
        $hidden = '<input type="hidden" name="listid" value="' . $listId . '" />';
        $hidden .= '<input type="hidden" name="limit" value="' . $limit . '" />';
        $pos = strpos($forms['main'], "<form");
        if ($pos !== false) {
            $forms['select'] = "";
        }
        echo $forms['main'];
        // top portion before the table list
        // for search
        $toSearch = new stdClass();
        $toSearch->forms = $forms['select'];
        $toSearch->hidden = $hidden;
        $toSearch->listsearch = $emailsearch;
        $toSearch->id = 'emailsearch';
        echo jnews::setTop($toSearch, $message, $setLimit, $filter);
        ?>

		<table class="<?php 
        echo jnews::myTheme();
        ?>
">
		<thead>
		<tr>
			<th class="title">#</th>
			<th class="title"><input type="checkbox" id="selectallcheck" name="allchecked" onclick="jnewsletterselectall();"/></th>
			<th class="title"><?php 
        echo jnews::HTML_GridSort(_JNEWS_INPUT_NAME, 'name', $setSort->orderDir, $setSort->orderValue);
        ?>
</th>
		<?php 
        if ($mainframe->isAdmin()) {
            ?>
			<th class="title"><?php 
            echo jnews::HTML_GridSort(_JNEWS_INPUT_EMAIL, 'email', $setSort->orderDir, $setSort->orderValue);
            ?>
</th>
		<?php 
        } else {
            if ($GLOBALS[JNEWS . 'show_sub_email']) {
                ?>
				<th class="title"><?php 
                echo jnews::HTML_GridSort(_JNEWS_INPUT_EMAIL, 'email', $setSort->orderDir, $setSort->orderValue);
                ?>
</th>
		<?php 
            }
        }
        //endelse
        if ($mainframe->isAdmin()) {
            ?>
			<th class="title"><?php 
            echo jnews::HTML_GridSort(_JNEWS_SIGNUP_DATE, 'subscribe_date', $setSort->orderDir, $setSort->orderValue);
            ?>
</th>
		<?php 
        }
        ?>
			<th class="title"><center><?php 
        echo jnews::HTML_GridSort(_JNEWS_REGISTERED, 'user_id', $setSort->orderDir, $setSort->orderValue);
        ?>
</center></th>
			<th class="title"><center><?php 
        echo jnews::HTML_GridSort(_JNEWS_CONFIRMED, 'confirmed', $setSort->orderDir, $setSort->orderValue);
        ?>
</center></th>
			<th class="title"><center><?php 
        echo jnews::HTML_GridSort(_JNEWS_HTML, 'receive_html', $setSort->orderDir, $setSort->orderValue);
        ?>
</center></th>
		<?php 
        if ($GLOBALS[JNEWS . 'level'] > 2) {
            //check if the version of jnewsletter is pro
            if ($GLOBALS[JNEWS . 'show_column1'] == 1) {
                ?>
				<th class="title"><center><?php 
                echo $GLOBALS[JNEWS . 'column1_name'];
            }
            //<!--/center></th><!--column 1 in the subscribers list-BE-->
            if ($GLOBALS[JNEWS . 'show_column2'] == 1) {
                ?>
				<th class="title"><center><?php 
                echo $GLOBALS[JNEWS . 'column2_name'];
            }
            if ($GLOBALS[JNEWS . 'show_column3'] == 1) {
                ?>
				<th class="title"><center><?php 
                echo $GLOBALS[JNEWS . 'column3_name'];
            }
            if ($GLOBALS[JNEWS . 'show_column4'] == 1) {
                ?>
				<th class="title"><center><?php 
                echo $GLOBALS[JNEWS . 'column4_name'];
            }
            if ($GLOBALS[JNEWS . 'show_column5'] == 1) {
                ?>
				<th class="title"><center><?php 
                echo $GLOBALS[JNEWS . 'column5_name'];
            }
        }
        if (jnews::checkPermissions('admin')) {
            ?>
			<th class="title"><?php 
            echo jnews::HTML_GridSort('ID', 'id', $setSort->orderDir, $setSort->orderValue);
            ?>
</th>
		<?php 
        }
        ?>
		</tr>
		</thead>
		<?php 
        $i = 0;
        if (!empty($subscribers)) {
            if (version_compare(JVERSION, '3.0.0', '<')) {
                $onClickFct = '';
            } else {
                $onClickFct = 'Joomla.';
            }
            foreach ($subscribers as $subscriber) {
                $subscriber->email = trim($subscriber->email);
                if (!jNews_Subscribers::validEmail($subscriber->email)) {
                    continue;
                }
                if ($subscriber->user_id != 0) {
                    $img = '16/status_g.png';
                    $alt = 'Registered';
                    jnews::getLegend('status_g.png', _JNEWS_REGISTERED . '/' . _JNEWS_CONFIRMED);
                } else {
                    $img = '16/status_r.png';
                    $alt = 'Unregistered';
                    jnews::getLegend('status_r.png', _JNEWS_SUBSCRIBERS_UNREGISTERED . '/' . _JNEWS_PIE_UNCONFIRMED);
                }
                //endelse
                if ($subscriber->confirmed == 1) {
                    $imgC = '16/status_g.png';
                    $altC = 'Confirmed';
                    jnews::getLegend('status_g.png', _JNEWS_REGISTERED . '/' . _JNEWS_CONFIRMED);
                } else {
                    $imgC = '16/status_r.png';
                    $altC = 'Not confirmed';
                    jnews::getLegend('status_r.png', _JNEWS_SUBSCRIBERS_UNREGISTERED . '/' . _JNEWS_PIE_UNCONFIRMED);
                }
                //endelse
                if ($subscriber->receive_html == 1) {
                    $imgH = '16/status_g.png';
                    $altH = 'HTML';
                    jnews::getLegend('status_g.png', _JNEWS_REGISTERED . '/' . _JNEWS_CONFIRMED);
                } else {
                    $imgH = '16/status_r.png';
                    $altH = 'TEXT';
                    jnews::getLegend('status_r.png', _JNEWS_SUBSCRIBERS_UNREGISTERED . '/' . _JNEWS_PIE_UNCONFIRMED);
                }
                //endelse
                ?>
					<tr class="row<?php 
                echo ($i + 1) % 2;
                ?>
">
						<td><center><?php 
                echo $i + 1 + $start;
                ?>
</center></td>

						<td>
							<center><input type="checkbox" id="cid[<?php 
                echo $i;
                ?>
]" name="cid[<?php 
                echo $i;
                ?>
]" value="<?php 
                echo $subscriber->id;
                ?>
" onclick="<?php 
                echo $onClickFct;
                ?>
isChecked(this.checked);" /></center>
						</td>
						<td>

			<?php 
                if (!$front) {
                    $href = "index.php?option=" . JNEWS_OPTION . "&act=" . $action . "&task=show&userid=" . $subscriber->id;
                } else {
                    $link = "option=" . JNEWS_OPTION . "&act=" . $action . "&task=show&userid=" . $subscriber->id;
                    $href = jNews_Tools::completeLink($link, false, true);
                }
                ?>

						<a href=<?php 
                echo $href;
                ?>
 >
						<?php 
                echo $subscriber->name;
                ?>
</a>
						</td>
					<?php 
                if (!jNews_Subscribers::validEmail($subscriber->email)) {
                    $subscriber->email = '';
                }
                if ($mainframe->isAdmin()) {
                    ?>
						<td><?php 
                    echo $subscriber->email;
                    ?>
</td>
					<?php 
                } else {
                    if ($GLOBALS[JNEWS . 'show_sub_email']) {
                        ?>
							<td><?php 
                        echo $subscriber->email;
                        ?>
</td>
					<?php 
                    }
                }
                //endelse
                if ($mainframe->isAdmin()) {
                    ?>
						<td><div align="center">
						<?php 
                    echo date('D, d M Y H:i:s', jnews::getNow(0, true, $subscriber->subscribe_date));
                }
                ?>
					</div></td>
						<td align="center">
							<img src="<?php 
                echo JNEWS_PATH_ADMIN_IMAGES2 . $img;
                ?>
" width="12" height="12" border="0" alt="<?php 
                echo $alt;
                ?>
" />
						</td>

						<td align="center">
							<a href="<?php 
                echo jnews::createToggleLink('subscribers', 'confirmed', 'subid', $subscriber->id, 'toggle', $listId);
                ?>
"> <img src="<?php 
                echo JNEWS_PATH_ADMIN_IMAGES2 . $imgC;
                ?>
" width="12" height="12" border="0" alt="<?php 
                echo $altC;
                ?>
" /> </a>
						</td>
						<td align="center">
							<a href="<?php 
                echo jnews::createToggleLink('subscribers', 'receive_html', 'subid', $subscriber->id, 'toggle', $listId);
                ?>
"> <img src="<?php 
                echo JNEWS_PATH_ADMIN_IMAGES2 . $imgH;
                ?>
" width="12" height="12" border="0" alt="<?php 
                echo $altH;
                ?>
" /> </a>
						</td>
						<?php 
                $i++;
                ?>
						<?php 
                if ($GLOBALS[JNEWS . 'level'] > 2) {
                    //check if the version of jnewsletter is 5.0.2
                    if ($GLOBALS[JNEWS . 'show_column1'] == 1) {
                        ?>
 <!--check to show/hide column 1 data in the subscribers list-->
							<td align="center"> <!--data for column1-->
								<?php 
                        echo $subscriber->column1;
                    }
                    ?>
							</td>
							<?php 
                    if ($GLOBALS[JNEWS . 'show_column2'] == 1) {
                        ?>
 <!--check to show/hide column 2 data in the subscribers list-->
							<td align="center"> <!--data for column1-->
								<?php 
                        echo $subscriber->column2;
                    }
                    ?>
							</td>
							<?php 
                    if ($GLOBALS[JNEWS . 'show_column3'] == 1) {
                        ?>
 <!--check to show/hide column 3 data in the subscribers list-->
							<td align="center"> <!--data for column3-->
								<?php 
                        echo $subscriber->column3;
                    }
                    ?>
							</td>
							<?php 
                    if ($GLOBALS[JNEWS . 'show_column4'] == 1) {
                        ?>
 <!--check to show/hide column 4 data in the subscribers list-->
							<td align="center"> <!--data for column4-->
								<?php 
                        echo $subscriber->column4;
                    }
                    ?>
							</td>
							<?php 
                    if ($GLOBALS[JNEWS . 'show_column5'] == 1) {
                        ?>
 <!--check to show/hide column 5 data in the subscribers list-->
							<td align="center"> <!--data for column5-->
								<?php 
                        echo $subscriber->column5;
                    }
                }
                //end check of version
                if (jnews::checkPermissions('admin')) {
                    echo '<td align="center">' . $subscriber->id . '</td>';
                }
                ?>
						</td>
					<?php 
            }
        }
        ?>
			</tr>
		</table>
		<input type="hidden" name="option" value="<?php 
        echo JNEWS_OPTION;
        ?>
" />
		<input type="hidden" name="act" value="<?php 
        echo $action;
        ?>
" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="userid" value="" />
		<input type="hidden" name="filter_order" value="<?php 
        echo $setSort->orderValue;
        ?>
" />
		<input type="hidden" name="filter_order_Dir" value="<?php 
        echo $setSort->orderDir;
        ?>
" />
		<input type="hidden" id="boxcount" name="boxchecked" value="0" />
		<?php 
        if (version_compare(JVERSION, '3.0.0', '<')) {
            echo JHTML::_('form.token');
        } else {
            echo JHtml::_('form.token');
        }
        ?>
		</form>
		<?php 
        echo '<br />';
        echo jnews::setLegend();
    }
Exemple #5
0
 function userDeleted($user, $success)
 {
     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';
     if (!empty($user->user_id)) {
         $subscriberId = jNews_Subscribers::getSubscriberIdFromUserId($user->user_id);
         if (!empty($subscriberId)) {
             jNews_Subscribers::deleteSubscriber($subscriberId);
         }
     }
     jNews_Subscribers::updateCBSubscribers();
     return true;
 }
Exemple #6
0
 /**
  * we get the subscribers info using the the id of the user.
  * @param int $id id of the user
  * @retrun object $subscriber info of the subscriber
  */
 function _getSubscriberInfo($id)
 {
     $subscriber = '';
     $subscriber = jNews_Subscribers::getSubscriberInfoFromUserId($id);
     //we get subscriber info if this user is a subscriber of jnews
     if (empty($subscriber)) {
         //if there is no record for the user
         jNews_Subscribers::syncSubscribers(true);
         //we sync the user as subscriber
         $subscriber = jNews_Subscribers::getSubscriberInfoFromUserId($id);
         //we get the subscriber info
     }
     return $subscriber;
 }
Exemple #7
0
 public static function export($listId)
 {
     $total = 0;
     $doShowSubscribers = false;
     @set_time_limit(0);
     $subtype = JRequest::getVar('subtype', 0);
     //If memory_limit less than 128M
     $limit = jnews::convertToBytes(@ini_get('memory_limit'));
     if ($limit < jnews::convertToBytes('128M')) {
         @ini_set('memory_limit', '128M');
     }
     if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $HTTP_USER_AGENT)) {
         $UserBrowser = 'Opera';
     } elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT)) {
         $UserBrowser = 'IE';
     } else {
         $UserBrowser = '';
     }
     $mime_type = $UserBrowser == 'IE' || $UserBrowser == 'Opera' ? 'application/octetstream' : 'application/octet-stream';
     $filename = "subscribers_list_" . $listId . "_" . date("Y.d.m");
     ob_end_clean();
     ob_start();
     // header of the imported file
     $export = '';
     //confirmed is set to 2 so that it will also take those unconfirmed subscribers
     $subscribers = jNews_Subscribers::getSubscribers(-1, -1, '', $total, $listId, '', 1, 2, 'name', '', 0, null, $subtype);
     //added one parameter for mailid
     foreach ($subscribers as $subscriber) {
         if (get_magic_quotes_runtime()) {
             $subscriber->name = stripslashes($subscriber->name);
             $subscriber->email = stripslashes($subscriber->email);
         }
         $export .= $subscriber->name . '';
         $export .= ',' . $subscriber->email . '';
         $export .= ',' . $subscriber->receive_html . '';
         $export .= ',' . $subscriber->confirmed . '';
         //export column1 - column5
         if ($GLOBALS[JNEWS . 'level'] > 2) {
             if (!empty($subscriber->column1)) {
                 $export .= ',' . $subscriber->column1 . '';
             }
             if (!empty($subscriber->column2)) {
                 $export .= ',' . $subscriber->column2 . '';
             }
             if (!empty($subscriber->column3)) {
                 $export .= ',' . $subscriber->column3 . '';
             }
             if (!empty($subscriber->column4)) {
                 $export .= ',' . $subscriber->column4 . '';
             }
             if (!empty($subscriber->column5)) {
                 $export .= ',' . $subscriber->column5 . '';
             }
         }
         if (!empty($subscriber->ip)) {
             $export .= ',' . $subscriber->ip;
         }
         $export .= "\r\n";
     }
     header('Content-Type: ' . $mime_type);
     header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     if ($UserBrowser == 'IE') {
         header('Content-Disposition: inline; filename="' . $filename . '.csv"');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
     } else {
         header('Content-Disposition: attachment; filename="' . $filename . '.csv"');
         header('Pragma: no-cache');
     }
     print $export;
     exit;
     return true;
 }
Exemple #8
0
    public static function senderinfo($mailingEdit, $lists, $show)
    {
        ?>
	<?php 
        if ($show['sender_info']) {
            ?>

	<table class="jnewstable" cellspacing="1">
		<tbody>
		<tr>
			<td width="150px" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_SENDER_NAME;
            $title = _JNEWS_SENDER_NAME;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
			<?php 
            //				$userSender=jNews_Subscribers::getUsers( 'gid', '50',$mailingEdit->author_id ); //if empty sender name and sender email
            //				if(empty($mailingEdit->fromname)) $mailingEdit->fromname=$userSender[0]->name;
            //				if(empty($mailingEdit->fromemail)) $mailingEdit->fromemail=$userSender[0]->email;
            $text = str_replace('"', '&quot;', $mailingEdit->fromname);
            if (function_exists('htmlspecialchars_decode')) {
                $text = htmlspecialchars_decode($text, ENT_NOQUOTES);
            } elseif (function_exists('html_entity_decode')) {
                $text = html_entity_decode($text, ENT_NOQUOTES);
            }
            echo '<input type="text" name="fromname" class="inputbox" size="20" maxlength="64" value="' . $text . '" />';
            ?>
				<?php 
            // clickable image for sender list
            ?>
				&nbsp;<img src="components/<?php 
            echo JNEWS_OPTION;
            ?>
/images/16/profile.png" id="popbtn" name="popbtn" onClick="document.getElementById('poplist').style.display = 'inline'; document.getElementById('popbtn').style.display = 'none';" title="<?php 
            echo _JNEWS_SENDER_LIST_INFO;
            ?>
" style="position:absolute;">

				<?php 
            //Select tag with script
            ?>
				<select id="poplist" name="poplist" style="display:none;position:absolute;" onChange="document.getElementById('poplist').style.display = 'none'; document.getElementById('popbtn').style.display = 'inline';">

				<?php 
            //create a default sender value for NONE/NULL
            ?>
				<option value="1" onClick="document.adminForm.fromname.value=''; document.adminForm.fromemail.value='';"> </option>
			<?php 
            // 2nd parameter of this public static function should be a preference
            // we need to limit it so that it wouldnt cause any problems when loading a bunch of datas e.g hundreds or thousands of users
            $usersA = jNews_Subscribers::getUsers('gid', '50');
            // create options for list
            if (!empty($usersA)) {
                foreach ($usersA as $user) {
                    $name = $user->name;
                    $email = $user->email;
                    $selected = isset($mailingEdit->fromname) && $mailingEdit->fromname == $name && (isset($mailingEdit->fromemail) && $mailingEdit->fromemail == $email) ? true : false;
                    ?>
						<option value="<?php 
                    echo $user->name;
                    ?>
" onClick="document.adminForm.fromname.value='<?php 
                    echo $name;
                    ?>
'; document.adminForm.fromemail.value='<?php 
                    echo $email;
                    ?>
';" <?php 
                    if ($selected) {
                        echo 'selected';
                    }
                    ?>
> <?php 
                    echo $user->name . ' (' . $user->email . ')';
                    ?>
 </option>
				<?php 
                }
            }
            ?>
			 	</select>
			</td>
		</tr>
		<tr>
			<td width="150px" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_SENDER_EMAIL;
            $title = _JNEWS_SENDER_EMAIL;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
				<input type="text" name="fromemail" class="inputbox" size="20" maxlength="64" value="<?php 
            echo $mailingEdit->fromemail;
            ?>
" />
			</td>
		</tr>
		<tr>
			<td width="150px" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_SENDER_BOUNCED;
            $title = _JNEWS_SENDER_BOUNCE;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
				<input type="text" name="frombounce" class="inputbox" size="20" maxlength="64" value="<?php 
            echo $mailingEdit->frombounce;
            ?>
" />
			</td>
		</tr>
		<tr>
			<td width="150px" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_JNEWS_OWNER;
            $title = _JNEWS_OWNER;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
				<?php 
            echo $mailingEdit->author_id;
            ?>
			</td>
		</tr>
		</tbody>
	</table>
	<?php 
        }
    }
Exemple #9
0
 public static function updateList($listId, $listUpdated, $status, $new)
 {
     $total = 0;
     @set_time_limit(0);
     //If memory_limit less than 128M
     $limit = jnews::convertToBytes(@ini_get('memory_limit'));
     if ($limit < jnews::convertToBytes('128M')) {
         @ini_set('memory_limit', '128M');
     }
     if ($listUpdated->list_type != '7' and $listUpdated->delay_min > $listUpdated->delay_max) {
         $listUpdated->delay_min = $listUpdated->delay_max;
     }
     if (!jNews_Lists::updateListData($listUpdated)) {
         return false;
     } else {
         if ($listUpdated->auto_add == 2) {
             $subscribers = jNews_Subscribers::getSubscribers(-1, -1, '', $total, 0, '', 1, 1, '', '');
             //added one parameter for mailid
             $subId = jnews::convertObjectToIdList($subscribers, 'id');
             if (!empty($subId)) {
                 jNews_Queue::insertQueuesForNews($subId, $listId, $listUpdated->acc_id);
             }
         } elseif ($status == '' and $listUpdated->list_type == 2) {
             $queues = jNews_Queue::getAllOneList($listId);
             $qid = jnews::convertObjectToIdList($queues, 'qid');
             if (!jNews_Queue::updatePublished($qid, $status)) {
                 return false;
             }
         } else {
             if (class_exists('jNews_Auto')) {
                 jNews_Auto::updateListNb($listUpdated->list_type, $listUpdated->id);
             }
         }
     }
     if ($listUpdated->published == 0) {
         jnews::printM('blue', _JNEWS_LIST_UNPUBMSG);
     }
     if ($listUpdated->hidden == 0) {
         jnews::printM('blue', _JNEWS_LIST_INVIMSG);
     }
     return true;
 }
Exemple #10
0
 /**
  * This function is used to override the send function in Joomla
  */
 public static function getMailer($mailing, $html = 0)
 {
     $fromname = empty($mailing->fromname) ? trim($GLOBALS[JNEWS . 'sendmail_name']) : trim($mailing->fromname);
     $fromemail = empty($mailing->fromemail) ? trim($GLOBALS[JNEWS . 'sendmail_email']) : trim($mailing->fromemail);
     $frombounce = empty($mailing->frombounce) ? trim($GLOBALS[JNEWS . 'sendmail_from']) : trim($mailing->frombounce);
     if (empty($fromemail)) {
         $my = JFactory::getUser();
         $userSender = jNews_Subscribers::getUsers('gid', '50', $my->id);
         $fromemail = $userSender[0]->email;
         if (empty($fromemail)) {
             jnews::printM('no', 'The sender email needs to be specified in the configuration.');
             return false;
         }
     }
     if (empty($frombounce)) {
         $frombounce = $fromemail;
     }
     $attachments = $mailing->attachments;
     $images = $mailing->images;
     $conf = JFactory::getConfig();
     $frombounceName = $fromname ? $fromname : $conf->get('config.fromname');
     if (empty($fromemail)) {
         $fromemail = trim($conf->get('config.mailfrom'));
     }
     if (empty($fromname)) {
         $fromname = trim($conf->get('config.fromname'));
     }
     jimport('joomla.mail.mail');
     $phpmailerPath = JPATH_LIBRARIES . DS . 'phpmailer' . DS;
     $mail = new JMail();
     $mail->PluginDir = $phpmailerPath;
     $mail->SetLanguage('en', $phpmailerPath . 'language' . DS);
     $mail->WordWrap = 150;
     //      	$mail->addCustomHeader("X-Mailer: ".JNEWS_JPATH_LIVE);
     //      	$mail->addCustomHeader("X-MessageID: $mailing->id");
     if ($GLOBALS[JNEWS . 'mail_format'] == '1') {
         $mail->Encoding = 'base64';
     }
     if ($GLOBALS[JNEWS . 'minisendmail']) {
         $frombounceName = '';
     }
     if (!empty($frombounce)) {
         if (version_compare(JVERSION, '3.0.0', '<')) {
             $mail->addReplyTo(array($frombounce, $frombounceName));
         } else {
             $mail->addReplyTo(array($frombounce));
         }
         JRequest::setVar('bounceBackEmail', $frombounce);
     }
     $mail->From = trim($fromemail);
     if ($GLOBALS[JNEWS . 'minisendmail']) {
         $mail->FromName = '';
     } else {
         $mail->FromName = $fromname;
     }
     $mail->Sender = trim($GLOBALS[JNEWS . 'sendmail_from']);
     if (empty($mail->Sender)) {
         $mail->Sender = '';
     }
     switch ($GLOBALS[JNEWS . 'emailmethod']) {
         case 'mail':
             $mail->IsMail();
             break;
         case 'sendmail':
             $mail->IsSendmail();
             $mail->Sendmail = $GLOBALS[JNEWS . 'sendmail_path'] ? $GLOBALS[JNEWS . 'sendmail_path'] : $conf->get('config.sendmail');
             break;
         case 'smtp':
             $mail->IsSMTP();
             $mail->Host = $GLOBALS[JNEWS . 'smtp_host'] ? $GLOBALS[JNEWS . 'smtp_host'] : $conf->get('config.smtphost');
             $mail->Port = $GLOBALS[JNEWS . 'smtp_port'] ? $GLOBALS[JNEWS . 'smtp_port'] : $conf->get('config.smtpport');
             $mail->SMTPSecure = $GLOBALS[JNEWS . 'smtp_secure'] ? $GLOBALS[JNEWS . 'smtp_secure'] : '';
             if ((bool) $GLOBALS[JNEWS . 'smtp_auth_required']) {
                 $mail->SMTPAuth = $GLOBALS[JNEWS . 'smtp_auth_required'];
                 $mail->Password = $GLOBALS[JNEWS . 'smtp_password'];
                 $mail->Username = $GLOBALS[JNEWS . 'smtp_username'];
             }
             break;
         default:
             $mail->Mailer = $conf->get('config.mailer');
             break;
     }
     if (!empty($attachments)) {
         foreach ($attachments as $attachment) {
             if (basename($attachment) !== 'index.html') {
                 $mail->AddAttachment(JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'upload_url'] . DS . basename($attachment));
             }
         }
     }
     switch (substr(strtoupper(PHP_OS), 0, 3)) {
         case "WIN":
             $mail->LE = "\r\n";
             break;
         case "MAC":
         case "DAR":
             $mail->LE = "\r";
         default:
             break;
     }
     return $mail;
 }
Exemple #11
0
function configuration($action, $task)
{
    $db = JFactory::getDBO();
    $config = array();
    $redirect = true;
    $xf = new jNews_Config();
    $message = JRequest::getVar('message', '');
    $clear_log = JRequest::getVar('clear_log', '0');
    switch ($task) {
        case 'syncUsers':
            echo jnews::printYN(jNews_Subscribers::syncSubscribers(), _JNEWS_SYNC_USERS_SUCCESS, _JNEWS_ERROR);
            backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action);
            jNews_ConfigHTML::showConfigEdit();
            break;
        case 'sendtest':
            $my = JFactory::getUser();
            $mailing = new stdClass();
            $status = false;
            $mailing->id = 1;
            $mailing->images = '';
            $mailing->attachments = '';
            $mailing->fromname = trim($GLOBALS[JNEWS . 'sendmail_name']);
            $mailing->fromemail = trim($GLOBALS[JNEWS . 'sendmail_email']);
            if (empty($mailing->fromemail)) {
                $mailing->fromemail = trim($GLOBALS[JNEWS . 'sendmail_from']);
            }
            ### create the mail
            $mail = jNews_ProcessMail::getMailer($mailing);
            ### create content
            $mail->IsHTML(true);
            $mail->Body = '<p>This message has been sent at ' . date('l, j F Y h:i:s', jnews::getNow(0, true)) . ' from ' . JNEWS_JPATH_LIVE . ' to test your mail configuration.</p><br/><p style="color:green;">' . _JNEWS_SENDTEST_CONFIGSUCC . '</p>';
            $mail->AddAddress($my->email, $my->name);
            $mail->Subject = 'Test Email from ' . JNEWS_JPATH_LIVE;
            $status = $mail->Send();
            $success = 'Email "' . $mail->Subject . '" successfully sent to ' . $my->name . ' (' . $my->email . ')';
            $error = 'Failed sending "' . $mail->Subject . '" to ' . $my->name . ' (' . $my->email . '). <br/>' . _JNEWS_SENDTEST_CONFIGERROR;
            $message = is_bool($status) && $status ? jnews::printM('ok', $success) : jnews::printM('error', $error);
            backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action);
            jNews_ConfigHTML::showConfigEdit();
            echo $message;
            break;
        case 'apply':
        case 'save':
            JRequest::checkToken() or die('Invalid Token');
            if ($clear_log != 0) {
                @unlink(JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'save_log_file']);
            }
            $config = JRequest::getVar('config');
            $message = jnews::printYN($xf->saveConfig($config), _JNEWS_CONFIG_UPDATED, _JNEWS_ERROR);
            $listCreator = JRequest::getVar('list_creatorfe', '', 'post');
            if (!empty($listCreator)) {
                $xf->update('list_creatorfe', $listCreator);
            }
            //we update the active list
            $xf->updateActiveList();
            if ($GLOBALS[JNEWS . 'level'] > 1) {
                //we require the cron controller
                require_once JNEWSPATH_ADMIN . 'controllers' . DS . 'cron.jnews.php';
                //we update the published/enabld of the jnews cron plugin according to what is selected
                if (version_compare(JVERSION, '1.6.0', '<')) {
                    //j15
                    $db->setQuery("UPDATE `#__plugins` SET `published` = " . $config['jnewscronplugin'] . " WHERE `element`='jnewscron' ");
                } else {
                    //j16
                    $db->setQuery("UPDATE `#__extensions` SET `enabled` = " . $config['jnewscronplugin'] . " WHERE `type` = 'plugin' AND `element`='jnewscron' ");
                }
                $db->query();
                //Joobi Cron System
                $cron = $GLOBALS[JNEWS . 'j_cron'];
                if ($cron == 2) {
                    joobiCron('Yes');
                } else {
                    joobiCron('No');
                }
            }
            if ($task == 'apply') {
                backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action);
                jNews_ConfigHTML::showConfigEdit();
                echo $message;
            } else {
                backHTML::controlPanel();
            }
            break;
        case 'cancel':
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION);
            break;
        case 'cpanel':
            backHTML::controlPanel();
            break;
        case 'acaupdate':
            // update jnews datas from acajoom
            $msg = jNews_TableUpdate::executeUpdate();
            echo $msg . '<br><br>';
        default:
            backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action);
            jNews_ConfigHTML::showConfigEdit();
            break;
    }
    return true;
}
Exemple #12
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);
 }
Exemple #13
0
    public static function controlPanel()
    {
        unset($GLOBALS["task"]);
        unset($_REQUEST["task"]);
        $doc = JFactory::getDocument();
        $doc->addStyleSheet(JNEWS_URL_ADMIN . 'cssadmin/jnews.css');
        ?>
<div align="center" class="centermain">
<div id="jnews">
		<table class="">
            <tr>
         	<td width="58%" valign="top">
				<?php 
        echo backHTML::iconsPanel();
        ?>
			</td>
			<td width="42%" valign="top">

			<div style="width=100%;">

			<script type="text/javascript">
				function checkcid(myField) {
					myField.checked = true;
					isChecked(true);
				}
			</script>

			<form action="index.php" method="post" name="adminForm" id="adminForm">
				<input type="hidden" name="option" value="<?php 
        echo JNEWS_OPTION;
        ?>
" />
				<input type="hidden" name="act" value="jnews" />
				<input type="hidden" name="task" value="" />
				<input type="hidden" name="userid" value="" />
		    	<input type="hidden" name="boxchecked" value="0" />

			<?php 
        $tabs = new MosTabsjNews(1);
        $tabs->startPane('acaControlPanel');
        $tabs->startTab(_JNEWS_MENU_TAB_SUM, "acaControlPanel.Summary");
        ?>
			<table class="<?php 
        echo jnews::myTheme();
        ?>
">
			<tbody>
				<thead>
					<tr>
					 <th class="title" style="text-align: center;"><?php 
        echo '#';
        ?>
</th>
					 <th class="title" style="text-align: center;"><?php 
        echo _JNEWS_MENU_TAB_LIST;
        ?>
</th>
					 <th class="title" style="text-align: center;"><?php 
        echo _JNEWS_MENU_MAILING_TITLE;
        ?>
</th>
					</tr>
				</thead>
			 <?php 
        $html = '';
        $totalist = 0;
        $totalmail = 0;
        $totalsub = $GLOBALS[JNEWS . 'act_totalsubcribers0'];
        $totalsent = 0;
        $nb = explode(',', $GLOBALS[JNEWS . 'activelist']);
        $size = sizeof($nb);
        $countOfLists[1] = jNews_Lists::countLists(1);
        $countOfLists[2] = jNews_Lists::countLists(2);
        $countOfLists[7] = jNews_Mailing::countMails(7, true);
        $countOfMailings[1] = jNews_Mailing::countMails(1);
        $countOfMailings[2] = jNews_Mailing::countMails(2);
        $countOfMailings[7] = jNews_Mailing::countMails(7);
        for ($i = 0; $i < $size; $i++) {
            $index = $nb[$i];
            if ($GLOBALS[JNEWS . 'listshow' . $index] > 0 and $GLOBALS[JNEWS . 'listype' . $index] == 1) {
                $row = ($i + 1) % 2;
                $html .= '<tr class="row' . $row . '">';
                $html .= '<td><b>' . @constant($GLOBALS[JNEWS . 'listnames' . $index]) . '</b></td>';
                //					$html .= '<td style="text-align: center; ">' .$GLOBALS[JNEWS.'act_totallist'.$index].'1 </td>';
                $html .= '<td style="text-align: center; ">' . $countOfLists[$index] . ' </td>';
                //if the value to be is less than 0 we will display 0
                if ($GLOBALS[JNEWS . 'act_totalmailing' . $index] > 0) {
                    //						$html .= '<td style="text-align: center; ">' .$GLOBALS[JNEWS.'act_totalmailing'.$index].' </td>';
                    $html .= '<td style="text-align: center; ">' . $countOfMailings[$index] . ' </td>';
                } else {
                    $html .= '<td style="text-align: center; ">0</td>';
                }
                //					$html .= '<td style="text-align: center; ">' .$GLOBALS[JNEWS.'totalmailingsent'.$index].' </td>';
                $html .= '</tr>';
                //					$totalist = $totalist + $GLOBALS[JNEWS.'act_totallist'.$index];
                $totalist = array_sum($countOfLists);
                //					$totalmail = $totalmail + $GLOBALS[JNEWS.'act_totalmailing'.$index];
                $totalmail = array_sum($countOfMailings);
                $totalsent = $totalsent + $GLOBALS[JNEWS . 'totalmailingsent' . $index];
                if ($GLOBALS[JNEWS . 'act_totalsubcribers' . $index] > $totalsub) {
                    $totalsub = $GLOBALS[JNEWS . 'act_totalsubcribers' . $index];
                }
            }
        }
        $html .= '<tr>';
        $html .= '<td style="background-color: #CCFFFF;"><b>' . _JNEWS_CP_TOTAL . '</b></td>';
        $html .= '<td style="text-align: center; text-decoration: bold; background-color: #CCFFFF; border-top: 1px solid #000; ">' . $totalist . ' </td>';
        $html .= '<td style="text-align: center; text-decoration: bold; background-color: #CCFFFF; border-top: 1px solid #000; ">' . $totalmail . ' </td>';
        //			$html .= '<td style="text-align: center; text-decoration: bold; background-color: #CCFFFF; border-top: 1px solid #000; ">' .$totalsent.' </td>';
        //$html .= '<td style="text-align: center; ">' .$totalsub.' </td>';
        $html .= '</tr>';
        echo $html;
        ?>
			 </tbody></table>
			 <br />
			<?php 
        if (class_exists('jNews_Auto')) {
            echo jNews_Auto::showQueue();
        }
        $tabs->endTab();
        $tabs->startTab(_JNEWS_MENU_SUBSCRIBERS, "acaControlPanel.Subscribers");
        $emailsearch = '';
        $listId = 0;
        $limittotal = jNews_Subscribers::getSubscribersCount($listId);
        $setLimitSubs = jnews::setLimitPagination($limittotal);
        ?>
			<input type="hidden" name="listid" value="<?php 
        echo $listId;
        ?>
" />
			<input type="hidden" name="start" value="<?php 
        echo $setLimitSubs->start;
        ?>
" />
			<input type="hidden" name="limit" value="<?php 
        echo $setLimitSubs->end;
        ?>
" />
			<input type="hidden" name="listsearch" value="<?php 
        echo $emailsearch;
        ?>
" />

			<div style="margin-top: 10px;"><?php 
        echo jnews::setTop('', '', $setLimitSubs);
        ?>
</div>

			<table class="<?php 
        echo jnews::myTheme();
        ?>
">
				<thead>
					<tr>
						<th class="title">#</th>
						<th class="title" style="text-align: left;"><?php 
        echo _JNEWS_INPUT_NAME;
        ?>
</th>
						<th class="title" style="text-align: left;"><?php 
        echo _JNEWS_INPUT_EMAIL;
        ?>
</th>
						<th class="title" style="text-align: center;"><?php 
        echo _JNEWS_SIGNUP_DATE;
        ?>
</th>
					</tr>
				</thead>
				<?php 
        $subscribers = jNews_Subscribers::getSubscribers($setLimitSubs->start, $setLimitSubs->end, $emailsearch, $setLimitSubs->total, $listId, '', 0, 0, 'sub_dateD', 0, 0, null, 0);
        $i = 0;
        foreach ($subscribers as $subscriber) {
            $i++;
            if (!jNews_Subscribers::validEmail($subscriber->email)) {
                continue;
            }
            ?>
				<tr class="row<?php 
            echo ($i + 2) % 2;
            ?>
">
				<td><center><?php 
            echo $i + $setLimitSubs->start;
            ?>
</center></td>
				<td style="text-align: left;">
				<a href="index.php?option=<?php 
            echo JNEWS_OPTION;
            ?>
&act=subscribers&task=show&userid=<?php 
            echo $subscriber->id;
            ?>
" >
				<?php 
            echo $subscriber->name;
            ?>
</a></td>
				<td style="text-align: left;"><?php 
            echo $subscriber->email;
            ?>
</td>
				<td style="text-align: center;">
				<?php 
            echo date('l, jS F Y h:i:s A', jnews::getNow(0, true, $subscriber->subscribe_date));
            ?>
				</td>
				</tr>
				<?php 
        }
        ?>
			</table>

			<?php 
        $tabs->endTab();
        $tabs->startTab(_JNEWS_MENU_TAB_LIST, "acaControlPanel.Lists");
        $listsearch = '';
        $lists = jNews_Lists::getLists(0, 0, 1, '', false, false, false);
        $limittotal = count($lists);
        $setLimitLists = jnews::setLimitPagination($limittotal);
        ?>

			<input type="hidden" name="listid" value="<?php 
        echo $listId;
        ?>
" />
			<input type="hidden" name="start" value="<?php 
        echo $setLimitLists->start;
        ?>
" />
			<input type="hidden" name="limit" value="<?php 
        echo $setLimitLists->end;
        ?>
" />
			<input type="hidden" name="listsearch" value="<?php 
        echo $listsearch;
        ?>
" />

			<div style="margin-top: 10px;"><?php 
        echo jnews::setTop('', '', $setLimitLists);
        ?>
</div>

			<table class="<?php 
        echo jnews::myTheme();
        ?>
">
				<thead>
				<tr>
					<th class="title">#</th>
					<th class="title" width="65%"  style="text-align: left;"><?php 
        echo _JNEWS_LIST_NAME;
        ?>
</th>
					<th class="title" width="25%"  style="text-align: left;"><?php 
        echo _JNEWS_LIST_TYPE;
        ?>
</th>
					<th class="title"  style="text-align: center;">ID</th>
				</tr>
				</thead>
			<?php 
        $lists = jNews_Lists::getLists(0, 0, 1, 'listtypeA', false, false, false, false, false, $listsearch, $setLimitLists, 0, 0);
        $i = 0;
        foreach ($lists as $list) {
            $i++;
            $link = 'index.php?option=' . JNEWS_OPTION . '&act=mailing&task=show&listid=' . $list->id;
            ?>
				<tr class="row<?php 
            echo ($i + 2) % 2;
            ?>
">
					<td><?php 
            echo $i + $setLimitLists->start;
            ?>
</td>
					<td  style="text-align: left;">
						<a href="<?php 
            echo $link;
            ?>
">
							<?php 
            echo $list->list_name;
            ?>
</a>
					</td>
					<td  style="text-align: left;"><?php 
            if ($list->list_type == 1) {
                echo _JNEWS_LIST;
            } else {
                echo _JNEWS_AR;
            }
            ?>
</td>
					<td  style="text-align: center;"><?php 
            echo $list->id;
            ?>
</td>
					</tr>
			<?php 
        }
        ?>
			<tr>
				<th colspan="4">
				</th>
			</tr>
			</table>
			<?php 
        $tabs->endTab();
        ?>
			<?php 
        $tabs->endPane();
        ?>
			</form>
		</div>
		<div style="clear:both; float:left; margin-top: 10px;">
		<?php 
        echo jnews::printM('ok', _JNEWS_SERVER_LOCAL_TIME . ' : ' . date('l, j F Y H:i:s', jnews::getNow(0, true)));
        // - date('Z')
        ?>
		</div>
   <td>
   </tr>
   </table>
   </div>
</div>
<?php 
    }
Exemple #14
0
function lists($action, $task, $listId, $listType)
{
    $db = JFactory::getDBO();
    $my = JFactory::getUser();
    $css = '.icon-48-lists { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/lists.png)}';
    $doc = JFactory::getDocument();
    $doc->addStyleDeclaration($css, $type = 'text/css');
    $img = 'lists.png';
    $listsearch = JRequest::getVar('listsearch', '');
    $message = '';
    $xf = new jNews_Config();
    $showLists = true;
    $checkToggle = false;
    // defined toggle for publish and unpublish of mailings
    if (!empty($task) && $task == 'togle') {
        $checkToggle = true;
        $id = JRequest::getVar('listid');
        $col = JRequest::getVar('col');
        $listId = !empty($id) && !empty($col) ? $id : $listId;
        $task = !empty($listId) && !empty($col) ? $col : $task;
    }
    switch ($task) {
        case 'new':
        case 'add':
            $subscriber = jNews_Subscribers::getSubscriberInfoFromUserId($my->id);
            if (version_compare(JVERSION, '1.6.0', '<')) {
                //j15
                $acl = JFactory::getACL();
                $groups = $acl->get_group_children_tree(null, 'USERS', false);
            } else {
                //j16
                $db = JFactory::getDBO();
                $db->setQuery('SELECT a.*, a.title as text, a.id as value  FROM #__usergroups AS a ORDER BY a.lft ASC');
                $groups = $db->loadObjectList();
            }
            $allGroupIds = array();
            foreach ($groups as $oneGroup) {
                $allGroupIds[] = $oneGroup->value;
            }
            $newList = new stdClass();
            $showLists = false;
            $newList->id = '';
            $newList->html = 1;
            $newList->new_letter = 1;
            $newList->list_name = '';
            $newList->list_desc = '';
            $newList->template = '';
            if (empty($subscriber)) {
                $newList->sendername = '';
                $newList->senderemail = '';
                $newList->bounceadres = '';
            } else {
                $newList->sendername = '';
                $newList->senderemail = '';
                $newList->bounceadres = '';
            }
            $newList->hidden = 1;
            $newList->auto_add = 0;
            $newList->list_type = $listType;
            $newList->delay_min = 1;
            $newList->delay_max = 7;
            $newList->user_choose = 0;
            $newList->cat_id = '0:0';
            $newList->follow_up = '';
            $newList->notify_id = 0;
            $newList->owner = $my->id;
            $newList->acc_level = '24,25,7,8';
            $newList->acc_id = implode(',', $allGroupIds);
            $newList->published = 1;
            $newList->start_date = date('Y-m-d', time());
            $newList->next_date = jnews::getNow();
            $newList->subscribemessage = _JNEWS_DEFAULT_SUBSCRIBE_MESS;
            $newList->unsubscribemessage = _JNEWS_DEFAULT_UNSUBSCRIBE_MESS;
            $newList->notifyadminmsg = _JNEWS_UNSUBSCRIBE_ADMIN_NOTIFICATION;
            $newList->subnotifymsg = _JNEWS_SUBSDEFAULT_NOTIFYMSG;
            $newList->subnotifysend = 1;
            $newList->unsubscribesend = 1;
            $newList->unsubscribenotifyadmin = 1;
            $newList->footer = 1;
            $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">";
            $show = jNews_ListType::showType($newList->list_type, 'editlist');
            if ($listType == 1) {
                backHTML::_header(_JNEWS_NEW . ' ' . _JNEWS_LIST, $img, $message, $task, $action);
            } else {
                backHTML::_header(_JNEWS_NEW . ' ' . _JNEWS_AUTORESP . ' ' . _JNEWS_LIST, $img, $message, $task, $action);
            }
            backHTML::formStart('editlist', $newList->html, '');
            jNews_ListsHTML::editList($newList, $forms, $show, $listType);
            $go[] = jnews::makeObj('act', $action);
            $go[] = jnews::makeObj('listid', $newList->id);
            backHTML::formEnd($go);
            break;
        case 'doNew':
            JRequest::checkToken() or die('Invalid Token');
            $listname = JRequest::getVar('list_name', '');
            if (empty($listname)) {
                echo "<script> alert(' List name must be filled out. '); window.history.go(-1);</script>\n";
                return false;
            }
            $now = jnews::getNow();
            $query = "SELECT `id` FROM `#__jnews_lists` WHERE `list_name`= '" . addslashes($listname) . "' ";
            $db->setQuery($query);
            $lId = $db->loadResult();
            if ($lId > 0) {
                echo "<script> alert(' This list already exist, please choose another name. '); window.history.go(-1);</script>\n";
                return false;
            } else {
                $query = "INSERT INTO `#__jnews_lists` (`list_name`,`createdate`) VALUES ( '" . addslashes($listname) . "'  , '{$now}' )";
                $db->setQuery($query);
                $db->query();
            }
            $query = "SELECT * FROM `#__jnews_lists` WHERE `list_name`= '" . addslashes($listname) . "' ";
            $db->setQuery($query);
            $mynewlist = $db->loadObject();
            $mynewlist->list_name = stripslashes($mynewlist->list_name);
            $mynewlist->list_desc = stripslashes($mynewlist->list_desc);
            $mynewlist->template = $mynewlist->template;
            $mynewlist->layout = stripslashes($mynewlist->layout);
            $mynewlist->subscribemessage = stripslashes($mynewlist->subscribemessage);
            $mynewlist->unsubscribemessage = stripslashes($mynewlist->unsubscribemessage);
            $mynewlist->notifyadminmsg = stripslashes($mynewlist->notifyadminmsg);
            $mynewlist->subnotifysend = stripslashes($mynewlist->subnotifysend);
            $mynewlist->subnotifymsg = stripslashes($mynewlist->subnotifymsg);
            $listId = $mynewlist->id;
            $message = jnews::printYN(jNews_Lists::updateListFromEdit($listId, '', true, $listType), _JNEWS_LIST_ADDED, _JNEWS_ERROR);
            $xf->plus('totallist0', 1);
            $xf->plus('act_totallist0', 1);
            $xf->plus('totallist' . $listType, 1);
            $xf->plus('act_totallist' . $listType, 1);
            break;
        case 'edit':
            if ($listId == 0) {
                echo "<script> alert('" . addslashes(_JNEWS_SELECT_LIST) . "'); window.history.go(-1);</script>\n";
                return false;
            } else {
                $showLists = false;
                $query = 'SELECT * FROM `#__jnews_lists` WHERE `id` = ' . intval($listId);
                $db->setQuery($query);
                $listEdit = $db->loadObject();
                if ($listEdit->acc_id == 'all') {
                    if (version_compare(JVERSION, '1.6.0', '<')) {
                        //j15
                        $acl = JFactory::getACL();
                        $groups = $acl->get_group_children_tree(null, 'USERS', false);
                    } else {
                        //j16
                        $db = JFactory::getDBO();
                        $db->setQuery('SELECT a.*, a.title as text, a.id as value  FROM #__usergroups AS a ORDER BY a.lft ASC');
                        $groups = $db->loadObjectList();
                    }
                    $allGroupIds = array();
                    foreach ($groups as $oneGroup) {
                        $allGroupIds[] = $oneGroup->value;
                    }
                    $listEdit->acc_id = implode(',', $allGroupIds);
                }
                $listEdit->list_name = stripslashes($listEdit->list_name);
                $listEdit->list_desc = stripslashes($listEdit->list_desc);
                $listEdit->template = $listEdit->template;
                $listEdit->layout = stripslashes($listEdit->layout);
                $listEdit->subscribemessage = stripslashes($listEdit->subscribemessage);
                $listEdit->unsubscribemessage = stripslashes($listEdit->unsubscribemessage);
                $listEdit->notifyadminmsg = stripslashes($listEdit->notifyadminmsg);
                $listEdit->subnotifysend = stripslashes($listEdit->subnotifysend);
                $listEdit->subnotifymsg = stripslashes($listEdit->subnotifymsg);
                $listEdit->new_letter = 0;
                $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">";
                $show = jNews_ListType::showType($listEdit->list_type, 'editlist');
                backHTML::_header(_JNEWS_EDIT_A . @constant($GLOBALS[JNEWS . 'listname' . $listEdit->list_type]) . ' ' . _JNEWS_LIST, $img, $message, $task, $action);
                backHTML::formStart('listedit', $listEdit->html, '');
                jNews_ListsHTML::editList($listEdit, $forms, $show, $listType);
                $go[] = jnews::makeObj('act', $action);
                $go[] = jnews::makeObj('listid', $listEdit->id);
                backHTML::formEnd($go);
            }
            break;
        case 'update':
            JRequest::checkToken() or die('Invalid Token');
            $message = jnews::printYN(jNews_Lists::updateListFromEdit($listId, '', false, $listType), _JNEWS_LIST_UPDATED, _JNEWS_ERROR);
            break;
        case 'delete':
            JRequest::checkToken() or die('Invalid Token');
            $query = "SELECT list_name FROM #__jnews_lists WHERE id = {$listId}";
            $db->setQuery($query);
            $listName = $db->loadResult();
            $message = jnews::printYN(jNews_Lists::deleteList($listId), '"' . $listName . '"' . _JNEWS_LIST . _JNEWS_SUCCESS_DELETED, _JNEWS_ERROR);
            break;
        case 'copy':
            JRequest::checkToken() or die('Invalid Token');
            $message = jnews::printYN(jNews_Lists::copyList($listId), _JNEWS_LIST_COPY, _JNEWS_ERROR);
            break;
        case 'publish':
            if (!$checkToggle) {
                JRequest::checkToken() or die('Invalid Token');
            }
            $message = jnews::printYN(jNews_Lists::updateListFromList($listId, true, false), _JNEWS_PUBLISHED, _JNEWS_ERROR);
            if ($listType == 1) {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=list&listype=' . $listType);
            } else {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=arlist&listype=' . $listType);
            }
            break;
        case 'unpublish':
            if (!$checkToggle) {
                JRequest::checkToken() or die('Invalid Token');
            }
            $message = jnews::printYN(jNews_Lists::updateListFromList($listId, false, false), _JNEWS_UNPUBLISHED, _JNEWS_ERROR);
            if ($listType == 1) {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=list&listype=' . $listType . '&listid=' . $listId);
            } else {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=arlist&listype=' . $listType . '&listid=' . $listId);
            }
            break;
        case 'forms':
        case 'make':
            if (class_exists('jNews_CreateForm')) {
                jNews_CreateForm::taskOptions($task);
                $showLists = false;
            } else {
                $showLists = true;
            }
            break;
        case 'cpanel':
            backHTML::controlPanel();
            return true;
            break;
        case 'toggle':
            $listid = JRequest::getVar('listid');
            $column = JRequest::getVar('col');
            if (!empty($listid) && !empty($column)) {
                $passObj = new stdClass();
                $passObj->tableName = '#__jnews_lists';
                $passObj->columnName = $column;
                $passObj->whereColumn = 'id';
                $passObj->whereColumnValue = $listid;
                jnews::toggle($passObj);
            }
            if ($listType == 1) {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=list&listype=1');
            } else {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=arlist&listype=2');
            }
            break;
    }
    if ($showLists) {
        $limit = -1;
        //Title header
        if ($listType == 1) {
            backHTML::_header(_JNEWS_MENU_LIST, $img, $message, $task, $action);
        } else {
            backHTML::_header(_JNEWS_ARLIST, $img, $message, $task, $action);
        }
        $show = jNews_ListType::showType(0, 'showListsBack');
        $forms['main'] = "<form action='index.php' method='post' name='adminForm' id=\"adminForm\">";
        backHTML::formStart('show_mailing', '', '');
        $paginationStart = JRequest::getVar('pg');
        $app = JFactory::getApplication();
        if (!empty($paginationStart)) {
            $limitstart = 0;
            $limitend = $paginationStart;
        } else {
            $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int');
            $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int');
        }
        $limittotal = jNews_Lists::getListCount($listType);
        $limittotal = $limittotal[0];
        $setLimit = new stdClass();
        $setLimit->total = !empty($limittotal) ? $limittotal : 0;
        $setLimit->start = !empty($limitstart) ? $limitstart : 0;
        $setLimit->end = !empty($limitend) ? $limitend : $limittotal;
        // recheck start
        if ($setLimit->total == $setLimit->end) {
            $setLimit->start = 0;
        }
        $setSort = new stdClass();
        if ($listType == '2') {
            //autoresponder
            $key = JNEWS_OPTION . '.arlist';
            $column = 'id';
            $direction = 'desc';
        } else {
            //newsletter
            $key = JNEWS_OPTION . '.list';
            $column = 'list_name';
            $direction = 'asc';
        }
        $setSort->orderValue = $app->getUserStateFromRequest($key . 'filter_order', 'filter_order', $column, 'cmd');
        $setSort->orderDir = $app->getUserStateFromRequest($key . 'filter_order_Dir', 'filter_order_Dir', $direction, 'word');
        if ($listType == 2) {
            ?>
<script language="javascript" type="text/javascript">
	function submitbutton(pressbutton) {
		var form = document.adminForm;
		if (pressbutton == 'delete') {
			var $ok = confirm('Are you sure you want to delete?\r\nAll of the mailings attached in this auto-responder will be deleted as well.');
			if ( $ok == true ){
				form.action = 'index.php?option=<?php 
            echo JNEWS_OPTION;
            ?>
&act=arlist&task=delete';
			}else{
				return;
			}
		}
		submitform( pressbutton );
	}
</script>
<?php 
        }
        $listing = jNews_Lists::getLists(0, $listType, 1, '', false, false, false, false, false, $listsearch, $setLimit, $setSort);
        if (isset($setLimit->total) && !empty($listsearch)) {
            $lists = jNews_Lists::getLists(0, $listType, 1, '', false, false, false, false, false, $listsearch, $setSort);
            $setLimit->total = !empty($lists) ? count($lists) : $setLimit->total;
        }
        $totalSubs = array();
        $totalUnSubs = array();
        $db = JFactory::getDBO();
        if (!empty($listing)) {
            foreach ($listing as $list) {
                $totalSubs[] = jNews_Subscribers::getSubscribersCount($list->id, true);
                $totalUnSubs[] = jNews_Subscribers::getSubscribersCount($list->id, 2);
            }
        }
        jNews_ListsHTML::showListingLists($listing, $action, 'edit', $forms, $show, $listsearch, $setLimit->end, $setLimit, $totalSubs, $setSort, $totalUnSubs);
        $go[] = jnews::makeObj('act', $action);
        $go[] = jnews::makeObj('filter_order', $setSort->orderValue);
        $go[] = jnews::makeObj('filter_order_Dir', $setSort->orderDir);
        backHTML::formEnd($go);
        return true;
    }
}
Exemple #15
0
 function insertIntoQueue($queue)
 {
     static $alradyProceesed = array();
     $db = JFactory::getDBO();
     if ($queue->subscriber_id < 0) {
         return false;
     }
     //Added by Grace for the pending of queue
     $queue->published = $queue->send_date > time() ? 2 : 0;
     //Note: know what's the use of this line
     if (empty($queue->list_id)) {
         //this is for the smartnewsletter
         $queue->published = 2;
     }
     $confirmed = jNews_Subscribers::isConfirmed($queue->subscriber_id);
     $queue->suspend = $confirmed;
     $key = serialize($queue);
     if (isset($alradyProceesed[$key])) {
         return true;
     }
     $alradyProceesed[$key] = true;
     //if (!$exist){
     $query = 'INSERT IGNORE INTO `#__jnews_queue` (`type` , `subscriber_id` ,  `mailing_id`, `issue_nb`,' . ' `send_date`, `suspend` , `delay`, `acc_level`, `published`, `priority`, `attempt`) VALUES (' . intval($queue->type) . ', ' . intval($queue->subscriber_id) . ' , ' . intval($queue->mailing_id) . ', ' . intval($queue->issue_nb) . ', \'' . $queue->send_date . '\', ' . $queue->suspend . ' , ' . $queue->delay . ' , ' . $queue->acc_level . ' , ' . $queue->published . ' , ' . $queue->priority . ' , ' . $queue->attempt . ')';
     $db->setQuery($query);
     $db->query();
     // ONLY FOR AUTO-RESPONDERS --- ONLY FOR AUTO-RESPONDERS --- ONLY FOR AUTO-RESPONDERS --- ONLY FOR AUTO-RESPONDERS --- ONLY FOR AUTO-RESPONDERS --- ONLY FOR AUTO-RESPONDERS ---
     if (!empty($queue->list_id)) {
         $type = jNews_Lists::getListType($queue->list_id);
         if ($type == 2) {
             $delays = jNews_Mailing::getMailingInfoz($queue->mailing_id, 'delay');
             $newQueue->delay = $delays;
             $newQueue->send_date = time() + $delays * 60;
             // jnews::getNow( $delays );
             $newQueue->published = 2;
             $arPRiority = empty($GLOBALS[JNEWS . 'ar_prior']) ? 1 : $GLOBALS[JNEWS . 'ar_prior'];
             $newQueue->priority = $arPRiority;
             $query = 'UPDATE `#__jnews_queue` SET `send_date`=' . $newQueue->send_date;
             $query .= ' , `delay`=' . $newQueue->delay;
             $query .= ' , `published`=' . $newQueue->published;
             $query .= ' , `priority`=' . $newQueue->priority;
             $query .= ' , `suspend`=' . $confirmed;
             $query .= ' WHERE `subscriber_id` = ' . $queue->subscriber_id;
             $query .= ' and `mailing_id` = ' . $queue->mailing_id;
             $db->setQuery($query);
             $db->query();
         }
         return true;
     }
     //end if
     return true;
     //}
 }
Exemple #16
0
         $subscriber->params = '';
         $subscriber->admin_id = 62;
         //notice columns
         if ($GLOBALS[JNEWS . 'level'] > 2) {
             //check if the version of jnews is pro
             $subscriber->column1 = '';
             $subscriber->column2 = '';
             $subscriber->column3 = '';
             $subscriber->column4 = '';
             $subscriber->column5 = '';
         }
         //end if check if the version is pro
         //jNews_Subscribers::insertSubscriber($subscriber, $subscriberId);
         jNews_Subscribers::saveSubscriber($subscriber, $subscriberId, true, $listid);
         //get subscriber info by passing the user id
         $userInfo = jNews_Subscribers::getSubscriberInfoFromUserId($user->id);
     } else {
     }
     //end if
     //save the subscriber id and list to listssubscribers table
     $subscriber->id = $userInfo->id;
     $subscriber->list_id = $listid;
     $subscriber->flexicontentFlag = true;
     //a flag that the subscription is from a tenders subscription from the flexicontent module
     $subscriber->params = $params;
     jNews_ListsSubs::saveToListSubscribers($subscriber);
 }
 //clear jnews session
 $mySess->clear('flexi_countries', 'JNEWLSETTER');
 $mySess->clear('flexi_industries', 'JNEWLSETTER');
 $mySess->clear('modjnewsflexi_listid', 'JNEWLSETTER');
Exemple #17
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;
 }
Exemple #18
0
 public static function upgrade_News3()
 {
     $my = JFactory::getUser();
     $db = JFactory::getDBO();
     $xf = new jNews_Config();
     $newLists = array();
     $idImportedList = array();
     $i = 0;
     $db->setQuery("SELECT * FROM #__yanc_letters");
     $newsletters = $db->loadObjectList();
     $error = $db->getErrorMsg();
     $newSubscriber = null;
     $list = null;
     $mailings = null;
     $subscriberId = 0;
     $total = 0;
     if (!empty($error)) {
         echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error getting newsletters. Database error: <br />' . $error . '</p>';
         return false;
     } else {
         foreach ($newsletters as $newsletter) {
             $list->list_name = $newsletter->list_name;
             $list->list_desc = $newsletter->list_desc;
             $list->sendername = $newsletter->sendername;
             $list->senderemail = $newsletter->senderemail;
             $list->bounceadres = $newsletter->bounceadres;
             $list->layout = $newsletter->layout;
             $list->template = 0;
             $list->subscribemessage = $newsletter->subscribemessage;
             $list->unsubscribemessage = $newsletter->unsubscribemessage;
             $list->notifyadminmsg = $newsletter->notifyadminmsg;
             $list->html = $newsletter->html;
             $list->hidden = !$newsletter->hidden;
             $list->unsubscribesend = 1;
             $list->unsubscribenotifyadmin = 1;
             $list->list_type = '1';
             $list->auto_add = 0;
             $list->user_choose = 0;
             $list->cat_id = '0:0';
             $list->delay_min = 0;
             $list->delay_max = 0;
             $list->follow_up = 0;
             $list->owner = $my->id;
             $list->acc_level = $newsletter->aid;
             $list->acc_id = 29;
             $list->published = 1;
             $list->createdate = time();
             $list->footer = 1;
             $list->notify_id = 0;
             $list->notification = 0;
             $query = 'INSERT INTO `#__jnews_lists` (`list_name`) VALUES (\'' . $list->list_name . '\'  )';
             $db->setQuery($query);
             $db->query();
             $error = $db->getErrorMsg();
             if (!empty($error)) {
                 echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error adding list to database. Database error: <br />' . $error . '</p><br /><br />Are you trying to insert a list name which is already in use?    The list name has to be different for each list! <br /><br />';
             } else {
                 $query = 'SELECT * FROM `#__jnews_lists` WHERE `list_name`= \'' . $list->list_name . '\'';
                 $db->setQuery($query);
                 $mynewlist = $db->loadObject();
                 $error = $db->getErrorMsg();
                 $xf->plus('totallist0', 1);
                 $xf->plus('act_totallist0', 1);
                 $xf->plus('totallist1', 1);
                 $xf->plus('act_totallist1', 1);
                 if (!empty($error)) {
                     echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting listname. Database error: <br />' . $error . '</p>';
                     return false;
                 } else {
                     $idImportedList[$newsletter->id] = $mynewlist->list_id;
                     $newLists[$i] = $mynewlist->list_id;
                     $i++;
                     $list->id = $mynewlist->list_id;
                     $error = jNews_Lists::updateListData($list);
                     if (!$error) {
                         echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error inserting list. Database error: <br />' . $error . '</p>';
                     } else {
                         echo '<br /><b>' . @constant($GLOBALS[JNEWS . 'listnames1']) . ': </b>' . $list->list_name . ': ' . jnews::printM('green', _JNEWS_IMPORT_SUCCESS);
                         $db->setQuery("SELECT * FROM #__yanc_letters WHERE `list_id`=" . $newsletter->id);
                         $mailingsImports = $db->loadObjectList();
                         $error = $db->getErrorMsg();
                         if (!empty($error)) {
                             echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting mailings. Database error: <br />' . $error . '</p>';
                             return false;
                         } else {
                             $issue_nb = 1;
                             foreach ($mailingsImports as $mailingsImport) {
                                 $mailings->list_id = $mynewlist->list_id;
                                 $mailings->list_type = '1';
                                 $mailings->send_date = $mailingsImport->send_date;
                                 $mailings->subject = $mailingsImport->subject;
                                 $mailings->htmlcontent = $mailingsImport->htmlcontent;
                                 $mailings->textonly = $mailingsImport->textonly;
                                 $mailings->attachments = $mailingsImport->attachments;
                                 $mailings->images = $mailingsImport->images;
                                 $mailings->published = $mailingsImport->published;
                                 $mailings->visible = $mailingsImport->visible;
                                 $mailings->html = $mynewlist->html;
                                 $mailings->fromname = $list->sendername;
                                 $mailings->fromemail = $list->senderemail;
                                 $mailings->frombounce = $list->bounceadres;
                                 $mailings->author_id = $my->id;
                                 $mailings->delay = 0;
                                 $mailings->issue_nb = $issue_nb;
                                 $mailings->acc_level = 25;
                                 $mailings->createdate = $list->createdate;
                                 $issue_nb++;
                                 $error = jNews_Mailing::insertMailingData($mailings);
                                 if (!$error) {
                                     echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error inserting mailing. Database error: <br />' . $error . '</p>';
                                 } else {
                                     echo '<br /><b>' . _JNEWS_MENU_MAILING_TITLE . ': </b>' . $mailingsImport->subject . ': ' . jnews::printM('green', _JNEWS_IMPORT_SUCCESS);
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $db->setQuery("SELECT * FROM #__yanc_subscribers");
         $subscribers = $db->loadObjectList();
         $error = $db->getErrorMsg();
         if (!empty($error)) {
             echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting subscribers. Database error: <br />' . $error . '</p>';
             return false;
         } else {
             foreach ($subscribers as $subscriber) {
                 $newSubs = true;
                 $jnewssubscribers = jNews_Subscribers::getSubscribers(-1, -1, '', $total, 0, '', '', '', '', '');
                 //added one parameter for mailid
                 foreach ($jnewssubscribers as $jnewssubscriber) {
                     if ($subscriber->subscriber_email == $jnewssubscriber->email) {
                         $newSubs = false;
                         $subId[0] = $jnewssubscriber->id;
                     }
                 }
                 if ($newSubs) {
                     $newSubscriber->user_id = $subscriber->userid;
                     $newSubscriber->name = $subscriber->subscriber_name;
                     $newSubscriber->email = $subscriber->subscriber_email;
                     $newSubscriber->ip = $subscriber->ip;
                     $newSubscriber->receive_html = $subscriber->receive_html;
                     $newSubscriber->confirmed = $subscriber->confirmed;
                     $newSubscriber->subscribe_date = $subscriber->subscribe_date;
                     $newSubscriber->blacklist = 0;
                     $newSubscriber->timezone = '00:00:00';
                     $newSubscriber->language_iso = 'eng';
                     $newSubscriber->params = '';
                     if ($GLOBALS[JNEWS . 'level'] > 2) {
                         //check if the version of jnews is pro
                         $newSubscriber->column1 = $newSubscriber->column1;
                         $newSubscriber->column2 = $newSubscriber->column2;
                         $newSubscriber->column3 = $newSubscriber->column3;
                         $newSubscriber->column4 = $newSubscriber->column4;
                         $newSubscriber->column5 = $newSubscriber->column5;
                     }
                     //end if for check version pro
                     $error = jNews_Subscribers::saveSubscriber($newSubscriber, $subscriberId, true);
                     if (!empty($error)) {
                         if ($subscriberId < 1) {
                             echo ' Error inserting subscriber:' . $newSubscriber->name;
                         }
                         $error = '';
                         $subId[0] = $subscriberId;
                     } else {
                         echo '<br /><b>' . _JNEWS_MENU_SUBSCRIBERS . ': </b>' . $newSubscriber->name . ': ' . jnews::printM('green', _JNEWS_IMPORT_SUCCESS);
                         $d['email'] = $subscriber->email;
                         jNews_Subscribers::getSubscriberIdFromEmail($d);
                         $subId[0] = $d['subscriberId'];
                     }
                 } else {
                     echo '<br /><b>' . _JNEWS_MENU_SUBSCRIBERS . ': </b>' . $subscriber->subscriber_name . ': ' . jnews::printM('red', _JNEWS_IMPORT_EXIST);
                 }
                 $j = 0;
                 $queue = jNews_ListsSubs::getListSubscriberInfo($subId[0], $idImportedList[$subscriber->list_id]);
                 if (empty($queue)) {
                     $error = jNews_Queue::insertQueuesForNews($subId, $idImportedList[$subscriber->list_id], 29);
                     if (!$error) {
                         echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error inserting queue. Database error: <br />' . $error . '</p>';
                     }
                 }
             }
         }
     }
     return true;
 }
Exemple #19
0
 function onAfterRoute()
 {
     $redirectlink = trim(JRequest::getString('redirectlink'));
     $fromSubscribe = JRequest::getVar('fromSubscribe', '');
     // this is either we have a redirect setup or we come from the module
     if (empty($fromSubscribe) || empty($redirectlink)) {
         return '';
     }
     if (strtolower(substr(JPATH_ROOT, strlen(JPATH_ROOT) - 13)) == 'administrator') {
         $adminPath = strtolower(substr(JPATH_ROOT, strlen(JPATH_ROOT) - 13));
     } else {
         $adminPath = JPATH_ROOT;
     }
     if (!@(include_once $adminPath . DS . 'components' . DS . 'com_jnews' . DS . 'defines.php')) {
         return;
     }
     include_once JNEWSPATH_CLASS . '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';
     jimport('joomla.html.parameter');
     $db = JFactory::getDBO();
     $plugin = JPluginHelper::getPlugin('system', 'vmjnewssubs');
     $registry = new JRegistry();
     if (!method_exists($registry, 'loadString')) {
         $data = trim($plugin->params);
         $options = array('processSections' => false);
         if (substr($data, 0, 1) != '{' && substr($data, -1, 1) != '}') {
             $ini = JRegistryFormat::getInstance('INI');
             $obj = $ini->stringToObject($data, $options);
         } else {
             $obj = json_decode($data);
         }
         $registry->loadObject($obj);
     } else {
         $registry->loadString($plugin->params);
     }
     $params = $registry;
     $reqfield = $params->get('reqfield', 'user_email');
     $email = JRequest::getString('email');
     $reqvalue = $reqfield == 'user_email' ? $email : JRequest::get($reqfield);
     if (is_array($reqvalue)) {
         //if we find any no we do no
         if (empty($reqvalue)) {
             return '';
         }
         foreach ($reqvalue as $resultArVal) {
             if (empty($resultArVal)) {
                 return '';
             }
         }
     } else {
         if (empty($reqvalue) || empty($email) || in_array(strtolower($reqvalue), array('', '0', 'n', 'no', 'none', 'nein', 'non'))) {
             return;
         }
     }
     $user_id = JRequest::getInt('user_id');
     $email = trim(strip_tags($email));
     $fname = JRequest::getString('first_name', '');
     $mname = JRequest::getString('middle_name', '');
     $lname = JRequest::getString('last_name', '');
     $name = '';
     if (!empty($fname)) {
         $name .= $fname . ' ';
     }
     if (!empty($mname)) {
         $name .= $mname . ' ';
     }
     if (!empty($lname)) {
         $name .= $lname;
     }
     $name = trim($name);
     if (empty($name)) {
         $name = JRequest::getVar('username');
     }
     $subscriber = new stdClass();
     $subscriber->user_id = $user_id;
     $subscriber->name = $name;
     $subscriber->email = $email;
     $subscriber->ip = jNews_Subscribers::getIP();
     $subscriber->receive_html = 1;
     $subscriber->confirmed = $GLOBALS[JNEWS . 'require_confirmation'] == '1' ? 0 : 1;
     $subscriber->subscribe_date = time();
     $subscriber->language_iso = 'eng';
     $subscriber->timezone = '00:00:00';
     $subscriber->blacklist = 0;
     $subscriber->params = '';
     $subscriber->admin_id = 62;
     $status = jNews_Subscribers::saveSubscriber($subscriber, $user_id, true);
     if (!$status) {
         return;
     }
     $listsToSubscribe = $params->get('lists', '');
     $listsToSubscribe = str_replace(' ', '', $listsToSubscribe);
     if (!empty($listsToSubscribe)) {
         $condition = ' WHERE `id` IN (' . $listsToSubscribe . ')';
     } else {
         $condition = '';
     }
     $query = 'SELECT `id`, `list_type`,`params` from `#__jnews_lists`' . $condition;
     $db->setQuery($query);
     $lsidstoinsert = $db->loadObjectList();
     $error = $db->getErrorMsg();
     if (!empty($error)) {
         echo $error;
         return false;
     } else {
         //use for masterlists
         $listsA = array();
         foreach ($lsidstoinsert as $lsid) {
             $d['email'] = $subscriber->email;
             //get the subscriber id which is newly inserted
             jNews_Subscribers::getSubscriberIdFromEmail($d);
             //subscriber_id from the inserted subscriber
             if ($d['subscriberId'] > 0) {
                 $subscriber->id = $d['subscriberId'];
             } else {
                 $subscriber->id = $subscriber->user_id;
             }
             if (!empty($lsid->params)) {
                 //use for masterlists
                 $listsA[] = $lsid->id;
             } else {
                 //for non-masterlists
                 $subscriber->list_id = $lsid->id;
                 jNews_ListsSubs::saveToListSubscribers($subscriber);
             }
             if ($lsid->list_type == 2) {
                 $subscribe = array();
                 $subscribe[] = $lsid->id;
                 if (!empty($subscribe)) {
                     jNews_ListsSubs::subscribeARtoQueue($subscriber->id, $subscribe);
                 }
             }
         }
         //end of foreach
         if (!empty($listsA)) {
             //we check if the social class file exists for the implementation of master lists
             if (@(include_once JNEWSPATH_ADMIN . 'social' . DS . 'class.social.php')) {
                 if (class_exists('jNews_Social')) {
                     $listidSubsA = array();
                     $masterListSubscriber = new stdClass();
                     //we check if configuration for master lists is enabled
                     if ($GLOBALS[JNEWS . 'use_masterlists']) {
                         if ($GLOBALS[JNEWS . 'level'] > 1) {
                             //we validate if the user can be subscribed to the list then we return the masterlistid
                             //1 - MasterLists for all Potential Users
                             $listidSubsA[] = jNews_Social::includeMasterListIds($subscriber->id, 1, $listsA);
                             //2 - MasterLists for all Registered Subscribers
                             $listidSubsA[] = jNews_Social::includeMasterListIds($subscriber->id, 2, $listsA);
                         }
                         if ($GLOBALS[JNEWS . 'level'] > 2) {
                             //we validate if the user can be subscribed to the list then we return the masterlistid
                             //3 - MasterLists for all Front-end Subscribers
                             $listidSubsA[] = jNews_Social::includeMasterListIds($subscriber->id, 3, $listsA);
                         }
                     }
                     //we check first if $listidSubsA and if not empty we do the subscription to the lists
                     if (!empty($listidSubsA)) {
                         $masterListSubscriber->id = $subscriber->id;
                         $masterListSubscriber->list_id = $listidSubsA;
                         jNews_ListsSubs::saveToListSubscribers($masterListSubscriber);
                     }
                 }
             }
         }
     }
 }
Exemple #20
0
function com_install()
{
    if (defined('JPATH_ROOT') and class_exists('JFactory')) {
        define('JNEWS_JPATH_ROOT', JPATH_ROOT);
    }
    if (!defined('DS')) {
        define('DS', DIRECTORY_SEPARATOR);
    }
    if (is_dir(JNEWS_JPATH_ROOT . DS . "administrator" . DS . "components" . DS . "com_jnews" . DS)) {
        $filename_for_del = JNEWS_JPATH_ROOT . DS . "administrator" . DS . "components" . DS . "com_jnews" . DS . "admin.jnews.php";
        if (file_exists($filename_for_del)) {
            if (is_writable($filename_for_del)) {
                unlink($filename_for_del);
            }
        }
    }
    if (!defined('DS')) {
        define('DS', DIRECTORY_SEPARATOR);
    }
    require_once JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_jnews' . DS . 'defines.php';
    require_once JNEWSPATH_ADMIN . 'classes' . DS . 'config.php';
    require_once JNEWSPATH_ADMIN . 'admin.jnews.html.php';
    require_once JNEWSPATH_CLASS . DS . 'class.jnews.php';
    @ini_set('max_execution_time', 0);
    //If memory_limit less than 128M
    $limit = jnews::convertToBytes(@ini_get('memory_limit'));
    if ($limit < jnews::convertToBytes('128M')) {
        @ini_set('memory_limit', '128M');
    }
    $xf = new jNews_Config();
    $return = '';
    //we install the jNews Menus
    installMenu();
    $database = JFactory::getDBO();
    $q = " SELECT `text` FROM `#__jnews_xonfig` WHERE `akey` = 'version' ";
    $database->setQuery($q);
    $vers = $database->loadResult();
    $err = $database->getErrorMsg();
    $version = jnews::getVersion();
    //we check if availability column exists in jnews_templates
    $q = "SHOW FIELDS FROM `#__jnews_templates`";
    $database->setQuery($q);
    $templateFields = $database->loadObjectList('Field');
    if (!empty($version) and $version < '7.3.0') {
        $query[] = "ALTER TABLE `#__jnews_listssubscribers` ADD `params` TEXT NOT NULL";
        $query[] = "ALTER TABLE `#__jnews_queue` ADD `params` TEXT NOT NULL";
    }
    if (!empty($version) and $version < '7.2.0') {
        $query[] = "UPDATE `#__jnews_xonfig` SET `text`='jNews_Newsletter' WHERE `text`='newsletter' AND `akey`='classes1' ";
        $query[] = "UPDATE `#__jnews_xonfig` SET `text`='jNews_Autoresponder' WHERE `text`='autoresponder' AND `akey`='classes2' ";
        $query[] = "UPDATE `#__jnews_xonfig` SET `text`='jNews_Autonews' WHERE `text`='autonews' AND `akey`='classes7' ";
    }
    if (!empty($version) && $version < '7.1.0') {
        $query[] = "ALTER TABLE `#__jnews_lists` ADD `subnotifysend` TINYINT(1) NOT NULL DEFAULT '1', ADD `subnotifymsg` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL";
        $query[] = "ALTER TABLE `#__jnews_templates` ADD `csstyle` TEXT NOT NULL";
        $query[] = "UPDATE `#__jnews_templates` SET `body` = REPLACE(`body`,'components/com_jnews/templates/','media/com_jnews/templates/')";
    }
    if (!empty($version) && $version < '7.0.2') {
        $xf->insert('cron_pass', 'ibHrqqFb');
        $xf->insert('nextdate', '0');
        $xf->insert('lastdate', '0');
    }
    if (!empty($version) && $version < '6.1.2') {
        $xf->insert('url_pass', 'xfr1tyh6', 0);
        $xf->insert('create_newsubsrows', '5', 0);
        $xf->insert('use_backendview', '0', 0);
        $xf->insert('terms_condition', '0', 0);
        $xf->insert('show_terms', '0', 0);
        $xf->insert('check_terms', '0', 0);
    }
    if (empty($err) and !empty($version) and $version < '6.0.2') {
        if (@(include_once JNEWSPATH_ADMIN . 'social' . DS . 'class.social.php')) {
            if (class_exists('jNews_Social')) {
                $query[] = "ALTER TABLE `#__jnews_lists` ADD `siteend` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT '0'";
            }
        }
        $query[] = "ALTER TABLE `#__jnews_lists` CHANGE `acc_id` `acc_id` VARCHAR( 200 ) NOT NULL DEFAULT 'all'";
        $query[] = "ALTER TABLE `#__jnews_lists` CHANGE `acc_level` `acc_level` VARCHAR( 200 ) NOT NULL DEFAULT '24,25,7,8'";
        $query[] = "UPDATE `#__jnews_lists` SET `acc_id`= 'all' WHERE `acc_id`= 29";
        $query[] = "UPDATE `#__jnews_lists` SET `acc_level`='24,25,7,8' WHERE `acc_level`=25";
        $xf->insert('use_tags', '1', 0);
        $xf->insert('allow_sn', '0', 0);
        $xf->insert('show_sub_email', '0', 0);
        $xf->insert('red_subscription', '0', 0);
        $xf->insert('module_message', '0', 0);
        $xf->update('upload_url', '/components/com_jnews/upload');
    }
    if (empty($err) && !empty($version) && $version <= '4.2.2') {
        //alter the table template with the column availabiltity
        if (is_array($templateFields) && array_key_exists('availability', $templateFields) == false) {
            $query[] = "ALTER TABLE `#__jnews_templates` ADD `availability` TINYINT( 1 ) NOT NULL DEFAULT '1' ";
        }
        $xf->insert('captcha_width', '80', 0);
        $xf->insert('captcha_height', '25', 0);
    }
    if (empty($err) and !empty($version) and $version < '5.1.0') {
        //alter the table queue, we also add the type in the unique key
        $query[] = 'ALTER TABLE `#__jnews_queue` DROP INDEX `sub_mail` ,
					ADD UNIQUE `sub_mail` ( `subscriber_id` , `mailing_id` , `type` )';
        $xf->insert('forced_html', '1', 0);
    }
    if (empty($err) and !empty($version) and $version >= '1.2.0' and $version < '2.2.2') {
        $query[] = 'ALTER TABLE `#__jnews_lists` ADD `notifyadminmsg` text NOT NULL';
        $xf->insert('j_cron', '1', 0);
    }
    if (empty($err) and !empty($version) and $version < '4.0.2') {
        //delete the params column
        $q = "SHOW FIELDS FROM `#__jnews_queue`";
        $database->setQuery($q);
        $queueFields = $database->loadObjectList('Field');
        $q = "SHOW FIELDS FROM `#__jnews_lists`";
        $database->setQuery($q);
        $listFields = $database->loadObjectList('Field');
        if (version_compare(JVERSION, '1.6.0', '<')) {
            //j15
            //for the update in the jos_components table for the menu auto-responder
            $query[] = 'UPDATE `#__components`' . ' SET admin_menu_link = \'option=' . JNEWS_OPTION . '&act=arlist&listype=2\'' . ' WHERE `option`=\'com_jnews\'' . ' AND `name`=\'Auto-responders\'';
            //delete the name import in the _components table
            $query[] = 'DELETE FROM `#__components` WHERE `name`=\'Import\' AND `option`=\'com_jnews\'';
        }
        //update max_attempts to 5
        $query[] = 'UPDATE `#__jnews_xonfig` SET `text` = 5 WHERE `akey`=\'max_attempts\'';
        //update sched_prior to 5
        $query[] = 'UPDATE `#__jnews_xonfig` SET `text` = 5 WHERE `akey`=\'sched_prior\'';
        //update ar_prior
        $query[] = 'UPDATE `#__jnews_xonfig` SET `text` = 1 WHERE `akey`=\'ar_prior\'';
        //update sm_prior
        $query[] = 'UPDATE `#__jnews_xonfig` SET `text` = 5 WHERE `akey`=\'sm_prior\'';
        $xf->insert('priord_list', '0', 0);
        $xf->insert('priord_subs', '0', 0);
        $xf->insert('show_unsubscribe', '0', 0);
        $xf->insert('show_unsubscribelink', '1', 0);
        $xf->insert('show_subscriptionlink', '1', 0);
        $xf->insert('queue_status', '1', 0);
    }
    if (empty($err) and !empty($version) and $version <= '4.1.2') {
        $xf->insert('smtp_port', '25', 0);
        $xf->insert('smart_queue', '0', 0);
        $xf->insert('sub_info_fields', '0', 0);
        $xf->insert('enable_jsub', '0', 0);
    }
    if (!empty($version) && $version <= '7.2.2') {
        //add params column if not exists
        $q = "SHOW FIELDS FROM `#__jnews_mailings`";
        $database->setQuery($q);
        $queueFields = $database->loadObjectList('Field');
        //we drop the column params in the table jnews_queue
        if (!array_key_exists('params', $queueFields)) {
            $query[] = 'ALTER TABLE `#__jnews_mailings` ADD `params` TEXT NOT NULL';
        }
        $q = "SHOW FIELDS FROM `#__jnews_lists`";
        $database->setQuery($q);
        $queueFields = $database->loadObjectList('Field');
        //we drop the column params in the table jnews_queue
        if (!array_key_exists('params', $queueFields)) {
            $query[] = 'ALTER TABLE `#__jnews_lists` ADD `params` TEXT NOT NULL';
        }
        $xf->insert('smtp_secure', '', 0);
    }
    if (!empty($version) && $version <= '7.3.9') {
        $xf->insert('lasttime_cron_triggerred', '0', 0);
        $xf->insert('show_unsubscribe_all', '1', 0);
        $xf->insert('send_log_email', '0', 0);
        $query[] = 'ALTER TABLE `#__jnews_queue` ADD `block` TINYINT NOT NULL DEFAULT 0';
        //add block column in the queue table
        //we get the values of red_subscription, module_message, enable_captcha, captcha_width, captcha_height, show_terms, check_terms, terms_condition from config table to be able to insert it the module params
        $red_subscription = $xf->getKeyValues("red_subscripition");
        $module_message = $xf->getKeyValues("module_message");
        $enable_captcha = $xf->getKeyValues("enable_captcha");
        $captcha_width = $xf->getKeyValues("captcha_width");
        $captcha_height = $xf->getKeyValues("captcha_height");
        $show_terms = $xf->getKeyValues("show_terms");
        $check_terms = $xf->getKeyValues("check_terms");
        $terms_condition = $xf->getKeyValues("terms_condition");
        $additionalParams = '';
        $additionalParams .= "use_new=0" . "\n";
        $additionalParams .= "red_subscripition=" . $red_subscription . "\n";
        $additionalParams .= "module_message=" . $module_message . "\n";
        $additionalParams .= "enable_captcha=" . $enable_captcha . "\n";
        $additionalParams .= "captcha_width=" . $captcha_width . "\n";
        $additionalParams .= "captcha_height=" . $captcha_height . "\n";
        $additionalParams .= "show_terms=" . $show_terms . "\n";
        $additionalParams .= "check_terms=" . $check_terms . "\n";
        $additionalParams .= "terms_condition=" . $terms_condition . "\n";
        //we get the module params from the modules table and append with the values we get from above
        $db = JFactory::getDBO();
        $queryParam = "SELECT `id`,`params` FROM `#__modules` WHERE `module`='mod_jnews'";
        $db->setQuery($queryParam);
        $db->query();
        $jnewsModuleParamsO = $db->loadObjectList('id');
        if (!empty($jnewsModuleParamsO)) {
            foreach ($jnewsModuleParamsO as $key => $value) {
                $params = '';
                $params .= $value->params;
                $params .= $additionalParams;
                //we update the params of the module
                $queryUpdateParam = "UPDATE `#__modules` SET `params`='" . $params . "' WHERE `id`=" . $key;
                $db->setQuery($queryUpdateParam);
                $db->query();
            }
        }
        //we insert here the simplicity template
        $templatessql = 'simplicitytemplate.sql';
        //to be changed if we packaged the superpack
        $buffer = file_get_contents(JNEWSPATH_ADMIN . DS . $templatessql);
        // Graceful exit and rollback if read not successful
        if ($buffer) {
            // Create an array of queries from the sql file
            jimport('joomla.installer.helper');
            $queries = JInstallerHelper::splitSql($buffer);
            // No queries to process
            if (count($queries) != 0) {
                // Process each query in the $queries array (split out of sql file).
                foreach ($queries as $simplicityquery) {
                    $simplicityquery = trim($simplicityquery);
                    if ($simplicityquery != '' && $simplicityquery[0] != '#') {
                        $database->setQuery($simplicityquery);
                        if (!$database->query()) {
                            JError::raiseWarning(1, 'JInstaller::install: ' . JText::_('SQL Error') . " " . $database->stderr(true));
                        }
                    }
                }
                //endfoearch
            }
        }
    }
    if (!empty($version) && $version <= '7.4.5') {
        if (version_compare(JVERSION, '1.6.0', '>=')) {
            //j16
            $query[] = 'UPDATE `#__assets` SET `rules`=\'{"core.admin":{"1":1},"core.manage":{"1":1}}\' WHERE `name`=\'com_jnews\'';
        }
    }
    // ALTER TABLE `jos_jnews_mailings` CHANGE `cat_id` `cat_id` VARCHAR( 250 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0:0'
    if (empty($version) || $version < '7.5.0') {
        $xf->update('show_unsubscribelink', '1');
        $xf->update('show_subscriptionlink', '1');
        $xf->update('upload_url', '/media/com_jnews/upload');
        $q = "SHOW FIELDS FROM `#__jnews_mailings`";
        $database->setQuery($q);
        $queueFields = $database->loadObjectList('Field');
        if (!array_key_exists('smart_date', $queueFields)) {
            $query[] = 'ALTER TABLE `#__jnews_mailings` ADD `smart_date` TINYINT UNSIGNED NOT NULL DEFAULT 0';
        }
        $q = "SHOW FIELDS FROM `#__jnews_queue`";
        $database->setQuery($q);
        $queueFields = $database->loadObjectList('Field');
        if (!array_key_exists('params', $queueFields)) {
            $query[] = 'ALTER TABLE `#__jnews_queue` ADD `params` TEXT NOT NULL';
        }
        if (!array_key_exists('block', $queueFields)) {
            $query[] = 'ALTER TABLE `#__jnews_queue` ADD `block` TINYINT NOT NULL DEFAULT 0';
        }
    }
    if (empty($version) || version_compare($version, '7.6.0', '<')) {
        $xf->insert('sntag_norequired', '1');
        $conf = JFactory::getConfig();
        $xf->insert('sendmail_email', $conf->get('config.mailfrom'));
        $xf->insert('subs_redirect_url', '');
        $xf->insert('subscribe_notification', '');
        $xf->insert('unsubscribe_notification', '');
        $xf->insert('component_theme', 'joobilist');
        $xf->insert('allow_fe_autoresponder', '0');
    }
    if (empty($version) || version_compare($version, '7.7.0', '<')) {
        $xf->insert('archive_link', 'standard');
    }
    //Query to quickly synchronise all your subscribers during the install!
    $query[] = "INSERT IGNORE INTO `#__jnews_subscribers` ( `user_id` , `name` , `email` , `receive_html` , `confirmed` , `blacklist` , `subscribe_date` )" . "SELECT U.id, U.name, U.email, '1', '1', U.block , UNIX_TIMESTAMP(U.registerDate) from `#__users` as U;";
    if (empty($vers)) {
        if (version_compare(JVERSION, '1.6.0', '<')) {
            //j15
            $query[] = "UPDATE #__components SET ordering = -2147483800 WHERE admin_menu_link='option=com_jnews'";
            //		}else{ //j16
            //			$query[] = "UPDATE #__extensions SET ordering = -2147483800 WHERE element='option=com_jnews'";
        }
    }
    //We publish back the module
    $query[] = "UPDATE `#__modules` SET `published`= 1 WHERE `module` LIKE '%jnews%' ";
    $size = sizeof($query);
    for ($index = 0; $index < $size; $index++) {
        $database->setQuery($query[$index]);
        $database->query();
    }
    if (@(include_once JNEWSPATH_ADMIN . 'social' . DS . 'class.social.php')) {
        if (class_exists('jNews_Social')) {
            if (!empty($version) && $version < '6.0.2') {
                $xf->insert('use_masterlists', '1', 0);
                $xf->insert('list_creatorfe', '24,25,7,8', 0);
            }
            jNews_Social::createMasterList(1);
            jNews_Social::createMasterList(2);
            jNews_Social::createMasterList(3);
            jNews_Social::createMasterList(4);
        }
    }
    //we call sql file for the additional templates
    if (is_array($templateFields) && array_key_exists('availability', $templateFields)) {
        //line to be removed code #7321011
        $templatessql = 'dwntemplates.sql';
        //to be changed if we packaged the superpack
        $buffer = file_get_contents(JNEWSPATH_ADMIN . DS . $templatessql);
        // Graceful exit and rollback if read not successful
        if ($buffer) {
            // Create an array of queries from the sql file
            jimport('joomla.installer.helper');
            $queries = JInstallerHelper::splitSql($buffer);
            // No queries to process
            if (count($queries) != 0) {
                // Process each query in the $queries array (split out of sql file).
                foreach ($queries as $query) {
                    $query = trim($query);
                    if ($query != '' && $query[0] != '#') {
                        $database->setQuery($query);
                        if (!$database->query()) {
                            JError::raiseWarning(1, 'JInstaller::install: ' . JText::_('SQL Error') . " " . $database->stderr(true));
                            //return false;
                        }
                    }
                }
                //endfoearch
            }
        }
    }
    if (empty($vers)) {
        $xf->filetoDatabase($confiX);
    }
    //create the upload directory
    jnews::createDirectory(JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'media' . DS . JNEWS_OPTION . DS . 'upload' . DS);
    //check if CSS file exist if not move it
    jimport('joomla.filesystem.folder');
    $cssLocation = JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'media' . DS . JNEWS_OPTION . DS . 'modules' . DS;
    if (!JFolder::exists($cssLocation)) {
        JFolder::copy(JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'components' . DS . JNEWS_OPTION . DS . 'modules' . DS, $cssLocation);
    }
    if (empty($vers)) {
        setupMaiOptions($confiX);
    }
    //we install the default templates
    installDefTemplate();
    //we install the extensions
    installExtensions();
    //we send a welcome message to the admin/logged in user of the site that jNews is successfully installed
    //we will only send email at fresh install
    if (empty($version)) {
        sendWelcomeEmail();
    }
    if (jnews::checkCB()) {
        installPlugin();
    }
    jNews_Subscribers::updateCBSubscribers(true, true);
    $xf->update('component', $confiX['component']);
    $xf->update('type', $confiX['type']);
    $xf->update('version', $confiX['version']);
    $xf->update('level', $confiX['level']);
    if (!($confiX['type'] == 'GPL' || $confiX['type'] == 'CORE')) {
        $message = jnews::M('noimage', _JNEWS_THANKYOU, false);
    }
    if (empty($message)) {
        $message = '';
    }
    backHTML::_header(_JNEWS_MENU_INSTALL, 'install.png', $message, '', '');
    $html = '';
    $link = 'index.php?option=' . JNEWS_OPTION . '&act=start';
    $docuLink = 'http://www.joobi.co/index.php?option=com_content&view=article&id=7871:installation-errors&catid=29:jnews&Itemid=72';
    $html .= '&nbsp;' . _JNEWS_INSTALL_ERRORN . ' <a href="' . $docuLink . '">' . _JNEWS_INSTALL_DOC . '</a>';
    // if acajoom component exist... means this would be an update
    // display an update button
    require_once JNEWSPATH_CLASS . 'class.update.php';
    if (jNews_Update::checkAcajoom()) {
        //check if acajoom data are already transferred to jnews tables
        if (!jNews_Update::checkAcaUpdate()) {
            $html .= '<div style="border: 5px groove #F0F8FF; padding: 10px; position: fixed; right: 1px; top: 150px; background-color: #F0F8FF;">';
            $html .= '<img border="0" align="right" alt="jNews Logo" src="components/' . JNEWS_OPTION . '/images/jnewsletter.png" width="25">';
            $html .= '<br><br><span style="font-size:15px;text-decoration:none;">' . _JNEWS_INSTALL_ACAUPDATEMSG . '</span></b>';
            $html .= '<a href="index.php?option=' . JNEWS_OPTION . '&amp;act=acaupdate">';
            $html .= '<div style="background-image: url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'btn_orange.png); background-repeat:no-repeat; height: 15px; width: 170px; border:none; padding:13px 40px 15px; position:relative; left:50px; top:10px;">';
            $html .= '<span style="color: #FFF; font-weight: bold; padding-right:30px; margin-top: 5px; text-decoration: none;"> ' . _JNEWS_INSTALL_ACAUPDATEBTN . ' </span>';
            $html .= '</div></a>';
            $html .= '<br><br>';
            $html .= '<b>' . _JNEWS_INSTALL_ACAUPDATENOTE . '</b>';
            $html .= '<br><br>';
            $html .= '</div>';
        }
    }
    $html .= '<div style="float:center;padding: 20px; width:470px; margin-right: 10px;"><center>' . '<a href="index.php?option=' . JNEWS_OPTION . '&amp;act=start">
				<div style="background-image: url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'btn_orange.png); background-repeat:no-repeat; height: 40px; width: 232px; border:none; padding:12px 0 15px 0;">
				<span style="color: #FFF; font-weight: bold; padding-right:30px; margin-top: 5px; text-decoration: none;">' . _JNEWS_INSTALL_CLICKSTART . '</span></div>
				</a></center></div><div style="clear:both;"></div>';
    if ($confiX['level'] > 2) {
        backHTML::about();
        echo '<center>' . $html;
        echo $return . '</center>';
    } elseif ($confiX['level'] > 1) {
        backHTML::installPRO($html, $return);
    } else {
        backHTML::installPlus($html, $return);
    }
    return $return;
}
Exemple #21
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');
     }
 }
 function onAfterDeleteUser($user, $success, $msg)
 {
     if ($success === false) {
         return false;
     }
     if (strtolower(substr(JPATH_ROOT, strlen(JPATH_ROOT) - 13)) == 'administrator') {
         $adminPath = strtolower(substr(JPATH_ROOT, strlen(JPATH_ROOT) - 13));
     } else {
         $adminPath = JPATH_ROOT;
     }
     if (!@(include_once $adminPath . DS . 'components' . DS . 'com_jnews' . DS . 'defines.php')) {
         return;
     }
     require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . 'class.subscribers.php';
     include_once JNEWSPATH_CLASSN . 'class.jnews.php';
     $d['email'] = $user['email'];
     $infos = jNews_Subscribers::getSubscriberIdFromEmail($d);
     $subscriberid = $infos['subscriberId'];
     if (!empty($subscriberid)) {
         jNews_Subscribers::deleteSubscriber($subscriberid);
     }
     return true;
 }
Exemple #23
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;
}
 public static function subscribeARtoQueue($subscriberID, $subscribeARA)
 {
     $db = JFactory::getDBO();
     $confirmed = jNews_Subscribers::isConfirmed($subscriberID);
     //		$time = jnews::getNow();
     $time = time();
     //we check to make sure we are not wrong with the values passed
     if (is_array($subscribeARA)) {
         $list2Subscribe = count($subscribeARA > 1) ? implode(',', $subscribeARA) : $subscribeARA[0];
     } else {
         $list2Subscribe = $subscribeARA;
     }
     $selectQuery = 'SELECT ' . $subscriberID . ',A.`mailing_id`,' . $time . ' + B.`delay`*60,1,' . $confirmed . ',2';
     $selectQuery .= ' FROM `#__jnews_listmailings` as A LEFT JOIN `#__jnews_mailings` as B on A.`mailing_id` = B.`id`';
     $selectQuery .= ' WHERE A.`list_id` IN (' . $list2Subscribe . ') AND B.`published` = 1';
     $query = 'INSERT IGNORE INTO `#__jnews_queue` (`subscriber_id`,`mailing_id`,`send_date`,`priority`,`suspend`,`type`) ' . $selectQuery;
     $db->setQuery($query);
     $db->query();
     /**we call this public static function to add a flag in the queue that the subscriber had already received all of the mailings in the queue
      *from the subscribed AR
      */
     jNews_ListsSubs::flagAR($subscriberID, $subscribeARA);
 }