/** * This public static function is used for the view of sendReady for manual sending */ public static function sendReady($mailingId, $listId, $listType) { ?> <div id="manualsend"></div> <?php JHTML::_('behavior.modal'); $formLink3 = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=mailing&task=send', true, false, true); ?> <form class="modal" action="<?php echo $formLink3; ?> " method="post" name="adminForm" autocomplete="off" id="adminForm"> <div> <fieldset class="adminform"> <legend> <?php echo 'Sending Status'; ?> </legend> <?php $doc = JFactory::getDocument(); $doc->addStyleSheet(JNEWS_URL_ADMIN . 'cssadmin/jnews.css'); if (empty($mailingId) || $mailingId == 0) { $warning = 'Please select a newsletter to be sent.'; jnews::displayInfo($warning, 'warning'); return; } $queueCount = jNews_Queue::getQueueCount($mailingId); $new = false; $mailing = jNews_Mailing::getOneMailing('', $mailingId, '', $new); if (empty($queueCount)) { if (empty($listId)) { $listIds = jNews_Mailing::getMailingList($mailingId); } if (!empty($listIds)) { ?> <br/> <fieldset class="adminform"> <legend> <?php echo $mailing->subject . ' will be sent to '; ?> </legend> <br/> <table class="adminlist" cellspacing="1" align="center"> <tbody> <?php $listNames = jNews_Mailing::getMailingListName($listIds); foreach ($listNames as $key => $listName) { if (isset($listIds[$key])) { ?> <tr><td><?php echo $listName . ' ( ' . jNews_Subscribers::getSubscribersCount($listIds[$key], true, true, true) . ' subscribers ) '; ?> </td></tr> <?php } } ?> </tbody> </table> <br/> </fieldset> <?php } else { $warning = $mailing->subject . ' will be sent to none of the created Lists.'; jnews::displayInfo($warning, 'warning'); } } else { $info = 'There are ' . $queueCount . ' in the queue for the Newsletter ' . $mailing->subject . ' <br/>Do you want to continue sending this newsletter?'; jnews::displayInfo($info, 'info'); ?> <input type="hidden" name="totalsend" value="<?php echo $queueCount; ?> " /> <?php } ?> <br/> <input type="submit" value="<?php echo empty($queueCount) ? _JNEWS_MENU_SEND : _JNEWS_MENU_CONTINUE; ?> "> <input type="hidden" name="mailingid" value="<?php echo $mailingId; ?> " /> <input type="hidden" name="option" value="<?php echo JNEWS_OPTION; ?> " /> <input type="hidden" name="task" value="<?php echo empty($queueCount) ? 'send' : 'continuesend'; ?> " /> <input type="hidden" name="act" value="mailing" /> <?php if (version_compare(JVERSION, '3.0.0', '<')) { echo JHTML::_('form.token'); } else { echo JHtml::_('form.token'); } ?> </div> </form> <?php }
public static function getSubscribers($start = -1, $limit = -1, $emailsearch, &$total, $listId, $mailingId, $blackList = 0, $confirmed = 0, $order = '', $mailId = '', $ownedlists = 0, $setSort = null, $subType = 0, $countUser = false) { //added one parameter mailid $db = JFactory::getDBO(); $my = JFactory::getUser(); $flag = false; $limitFlag = false; $mainframe = JFactory::getApplication(); if (version_compare(JVERSION, '1.6.0', '>=')) { //j16 $gid = JAccess::getGroupsByUser($my->id, false); $my->gid = $gid[0]; } $gidAdmins = array(24, 25, 7, 8); $query = $countUser ? 'SELECT COUNT(M.id) ' : 'SELECT DISTINCT M.*,U.username '; //for multiple lists if ($listId == 0) { $query .= ' FROM `#__jnews_subscribers` AS M LEFT JOIN `#__users` as U ON M.user_id = U.id '; if (!$mainframe->isAdmin() and ($ownedlists != 0 and !empty($ownedlists)) and !in_array($my->gid, $gidAdmins)) { $query .= 'LEFT JOIN `#__jnews_listssubscribers` AS N ON N.subscriber_id=M.id WHERE N.list_id IN (' . implode($ownedlists, ',') . ')'; } else { if (!$mainframe->isAdmin() and ($ownedlists == 0 or empty($ownedlists))) { //return; } } } else { $query .= ' FROM `#__jnews_subscribers` AS M LEFT JOIN `#__users` as U ON M.user_id = U.id LEFT JOIN `#__jnews_listssubscribers` AS N'; $query .= ' ON M.id = N.subscriber_id WHERE '; if (!empty($mailId)) { $lists = jNews_Mailing::getMailingList($mailId); $query .= 'N.list_id IN ('; $query .= 'SELECT `list_id` FROM `#__jnews_listmailings` WHERE `mailing_id`=' . $mailId . ')'; } else { //if the mailing is sent to one or more lists if (is_array($listId)) { $lsId = count($listId) > 1 ? implode(',', $listId) : $listId[0]; if (!empty($ownedlists)) { $lsId = $ownedlists; } $query .= 'N.list_id IN (' . $lsId . ')'; } else { $query .= 'N.list_id =' . $listId; } } $flag = true; } //type of subscirber to show used in the listing switch ($subType) { case 1: if (!$flag) { $query .= ' LEFT JOIN `#__jnews_listssubscribers` AS N ON N.subscriber_id=M.id '; } $query .= $flag ? ' AND ' : ' WHERE '; $query .= ' N.unsubscribe = 0 '; $flag = true; break; case 2: if (!$flag) { $query .= ' LEFT JOIN `#__jnews_listssubscribers` AS N ON N.subscriber_id=M.id '; } $query .= $flag ? ' AND ' : ' WHERE '; $query .= ' N.unsubscribe = 1 '; $flag = true; break; case 3: //waiting confirmation $query .= $flag ? ' AND ' : ' WHERE '; $flag = true; $query .= ' M.confirmed = 0 '; break; case 4: // blocked $query .= $flag ? ' AND ' : ' WHERE '; $flag = true; $query .= ' M.blacklist = 1 '; break; case '0': default: break; } if ($mailingId > 0 and $flag) { $query .= ' AND N.mailing_id = ' . $mailingId; } if ($blackList == 1) { $query .= $flag ? ' AND ' : ' WHERE '; if ($confirmed == 1) { $query .= ' M.blacklist = 0 AND M.confirmed = 1 '; $flag = true; } else { $query .= ' M.blacklist = 0 '; $flag = true; } } if (!empty($emailsearch)) { if ($flag) { $query .= ' AND ( M.email LIKE \'%' . $emailsearch . '%\' OR M.name LIKE \'%' . $emailsearch . '%\' '; if (is_numeric($emailsearch)) { $query .= ' OR M.id=' . $emailsearch . ' '; } $query .= ' ) '; } else { if ($mainframe->isAdmin()) { $query .= ' WHERE ( M.email LIKE \'%' . $emailsearch . '%\' OR M.name LIKE \'%' . $emailsearch . '%\' '; } else { if (($ownedlists != 0 || !empty($ownedlists) && $listId == 0) && $flag) { $query .= ' AND ( M.email LIKE \'%' . $emailsearch . '%\' OR M.name LIKE \'%' . $emailsearch . '%\' '; } else { $query .= ' WHERE ( M.email LIKE \'%' . $emailsearch . '%\' OR M.name LIKE \'%' . $emailsearch . '%\' '; } //endelse } //endelse if (is_numeric($emailsearch)) { $query .= ' OR M.id=' . $emailsearch . ' '; } $query .= ' ) '; } } if ($listId != 0 && !$countUser) { $query .= ' GROUP BY M.id '; } // no sorting or limit if we count if (!$countUser) { if (!empty($setSort)) { $s = is_int($setSort->orderValue) ? "{$setSort->orderValue}" : "`{$setSort->orderValue}`"; $query .= "ORDER BY {$s} {$setSort->orderDir}"; } else { if (!empty($order)) { $query .= jnews::orderBy($order); } } if ($start != -1 && $limit != -1) { $query .= ' LIMIT ' . $start . ', ' . $limit; $limitFlag = true; } } $db->setQuery($query); if (!$countUser) { $subscribers = $db->loadObjectList(); } else { $subscribers = $db->loadResult(); } return $subscribers; }
static function _deleteSubsQueuePriv($subscriber_id, $mailing_ids, $listID) { static $alreadyProssed = array(); $key = $subscriber_id . '.' . $mailing_ids . '.' . $listID; if (isset($alreadyProssed[$key])) { return true; } $alreadyProssed[$key] = true; $db = JFactory::getDBO(); $status = true; $listIds = jNews_Mailing::getMailingList($mailing_ids); $key = array_search($listID, $listIds); unset($listIds[$key]); if (!empty($listIds)) { if (is_array($listIds)) { foreach ($listIds as $listId) { if (!empty($listssubscribers)) { if (!$listssubscribers->unsubscribe) { $status = false; } } } } else { $status = !empty($listssubscribers) ? true : false; } } //end if if ($status) { if ($subscriber_id > 0) { static $myResultA = array(); $myKey = $subscriber_id . '.' . $mailing_ids; if (isset($myResultA[$myKey])) { return true; } $myResultA[$myKey] = true; $query = 'DELETE FROM `#__jnews_queue` WHERE `subscriber_id` = ' . $subscriber_id; $query .= ' AND `mailing_id` = ' . $mailing_ids; $db->setQuery($query); $db->query(); return true; } } }