| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: admin.massmail.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla 5 * @subpackage Massmail 6 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 7 * @license GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant 9 * to the GNU General Public License, and as distributed it includes or 10 * is derivative of works licensed under the GNU General Public License or 11 * other free or open source software licenses. 12 * See COPYRIGHT.php for copyright notices and details. 13 */ 14 15 // no direct access 16 defined( '_JEXEC' ) or die( 'Restricted access' ); 17 18 /* 19 * Make sure the user is authorized to view this page 20 */ 21 $user = & JFactory::getUser(); 22 if (!$user->authorize( 'com_massmail', 'manage' )) { 23 $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); 24 } 25 26 require_once( JApplicationHelper::getPath( 'admin_html' ) ); 27 28 switch ($task) 29 { 30 case 'send': 31 sendMail(); 32 break; 33 34 case 'cancel': 35 $mainframe->redirect( 'index.php' ); 36 break; 37 38 default: 39 messageForm( $option ); 40 break; 41 } 42 43 function messageForm( $option ) 44 { 45 $acl =& JFactory::getACL(); 46 47 $gtree = array( 48 JHTML::_('select.option', 0, '- '. JText::_( 'All User Groups' ) .' -' ) 49 ); 50 51 // get list of groups 52 $lists = array(); 53 $gtree = array_merge( $gtree, $acl->get_group_children_tree( null, 'users', false ) ); 54 $lists['gid'] = JHTML::_('select.genericlist', $gtree, 'mm_group', 'size="10"', 'value', 'text', 0 ); 55 56 HTML_massmail::messageForm( $lists, $option ); 57 } 58 59 function sendMail() 60 { 61 global $mainframe; 62 63 // Check for request forgeries 64 JRequest::checkToken() or jexit( 'Invalid Token' ); 65 66 $db =& JFactory::getDBO(); 67 $user =& JFactory::getUser(); 68 $acl =& JFactory::getACL(); 69 70 $mode = JRequest::getVar( 'mm_mode', 0, 'post', 'int' ); 71 $subject = JRequest::getVar( 'mm_subject', '', 'post', 'string' ); 72 $gou = JRequest::getVar( 'mm_group', '0', 'post', 'int' ); 73 $recurse = JRequest::getVar( 'mm_recurse', 'NO_RECURSE', 'post', 'word' ); 74 $bcc = JRequest::getVar( 'mm_bcc', 0, 'post', 'int' ); 75 76 // pulls message inoformation either in text or html format 77 if ( $mode ) { 78 $message_body = JRequest::getVar( 'mm_message', '', 'post', 'string', JREQUEST_ALLOWRAW ); 79 } else { 80 // automatically removes html formatting 81 $message_body = JRequest::getVar( 'mm_message', '', 'post', 'string' ); 82 } 83 84 // Check for a message body and subject 85 if (!$message_body || !$subject) { 86 $mainframe->redirect( 'index.php?option=com_massmail', JText::_( 'Please fill in the form correctly' ) ); 87 } 88 89 // get users in the group out of the acl 90 $to = $acl->get_group_objects( $gou, 'ARO', $recurse ); 91 JArrayHelper::toInteger($to['users']); 92 93 // Get sending email address 94 /* 95 $query = 'SELECT email' 96 . ' FROM #__users' 97 . ' WHERE id = '.(int) $user->get('id') 98 ; 99 $db->setQuery( $query ); 100 $user->set( 'email', $db->loadResult() ); 101 */ 102 103 // Get all users email and group except for senders 104 $query = 'SELECT email' 105 . ' FROM #__users' 106 . ' WHERE id != '.(int) $user->get('id') 107 . ( $gou !== 0 ? ' AND id IN (' . implode( ',', $to['users'] ) . ')' : '' ) 108 ; 109 110 $db->setQuery( $query ); 111 $rows = $db->loadObjectList(); 112 113 // Check to see if there are any users in this group before we continue 114 if ( ! count($rows) ) { 115 $msg = JText::_('No users could be found in this group.'); 116 $mainframe->redirect( 'index.php?option=com_massmail', $msg ); 117 } 118 119 $mailer =& JFactory::getMailer(); 120 $params =& JComponentHelper::getParams( 'com_massmail' ); 121 122 // Build e-mail message format 123 $mailer->setSender(array($mainframe->getCfg('mailfrom'), $mainframe->getCfg('fromname'))); 124 $mailer->setSubject($params->get('mailSubjectPrefix') . stripslashes( $subject)); 125 $mailer->setBody($message_body . $params->get('mailBodySuffix')); 126 $mailer->IsHTML($mode); 127 128 // Add recipients 129 130 if ( $bcc ) { 131 foreach ($rows as $row) { 132 $mailer->addBCC($row->email); 133 } 134 $mailer->addRecipient($mainframe->getCfg('mailfrom')); 135 }else { 136 foreach ($rows as $row) { 137 $mailer->addRecipient($row->email); 138 } 139 } 140 141 // Send the Mail 142 $rs = $mailer->Send(); 143 144 // Check for an error 145 if ( JError::isError($rs) ) { 146 $msg = $rs->getError(); 147 } else { 148 $msg = $rs ? JText::sprintf( 'E-mail sent to', count( $rows ) ) : JText::_('The mail could not be sent'); 149 } 150 151 // Redirect with the message 152 $mainframe->redirect( 'index.php?option=com_massmail', $msg ); 153 154 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |