Annotation of /mambo/branches/4.6/administrator/components/com_massmail/admin.massmail.php
Parent Directory
|
Revision Log
Revision 165 - (view) (download)
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | * @version $Id: admin.massmail.php,v 1.1 2005/07/22 01:52:35 eddieajau Exp $ | ||
| 4 : | * @package Mambo | ||
| 5 : | * @subpackage Massmail | ||
| 6 : | * @copyright (C) 2000 - 2005 Miro International Pty Ltd | ||
| 7 : | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL | ||
| 8 : | * Mambo is Free Software | ||
| 9 : | */ | ||
| 10 : | |||
| 11 : | /** ensure this file is being included by a parent file */ | ||
| 12 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 13 : | |||
| 14 : | // ensure user has access to this function | ||
| 15 : | if (!$acl->acl_check( 'administration', 'manage', 'users', $my->usertype, 'components', 'com_massmail' )) { | ||
| 16 : | mosRedirect( 'index2.php', _NOT_AUTH ); | ||
| 17 : | } | ||
| 18 : | |||
| 19 : | require_once( $mainframe->getPath( 'admin_html' ) ); | ||
| 20 : | |||
| 21 : | switch ($task) { | ||
| 22 : | case 'send': | ||
| 23 : | sendMail(); | ||
| 24 : | break; | ||
| 25 : | |||
| 26 : | case 'cancel': | ||
| 27 : | mosRedirect( 'index2.php' ); | ||
| 28 : | break; | ||
| 29 : | |||
| 30 : | default: | ||
| 31 : | messageForm( $option ); | ||
| 32 : | break; | ||
| 33 : | } | ||
| 34 : | |||
| 35 : | function messageForm( $option ) { | ||
| 36 : | global $acl; | ||
| 37 : | |||
| 38 : | $gtree = array( | ||
| 39 : | csouza | 165 | mosHTML::makeOption( 0, T_('- All User Groups -') ) |
| 40 : | root | 1 | ); |
| 41 : | |||
| 42 : | // get list of groups | ||
| 43 : | $lists = array(); | ||
| 44 : | $gtree = array_merge( $gtree, $acl->get_group_children_tree( null, 'USERS', false ) ); | ||
| 45 : | $lists['gid'] = mosHTML::selectList( $gtree, 'mm_group', 'size="10"', 'value', 'text', 0 ); | ||
| 46 : | |||
| 47 : | HTML_massmail::messageForm( $lists, $option ); | ||
| 48 : | } | ||
| 49 : | |||
| 50 : | function sendMail() { | ||
| 51 : | global $database, $my, $acl; | ||
| 52 : | global $mosConfig_sitename; | ||
| 53 : | global $mosConfig_mailfrom, $mosConfig_fromname; | ||
| 54 : | |||
| 55 : | $mode = mosGetParam( $_POST, 'mm_mode', 0 ); | ||
| 56 : | $subject = mosGetParam( $_POST, 'mm_subject', '' ); | ||
| 57 : | $gou = mosGetParam( $_POST, 'mm_group', NULL ); | ||
| 58 : | $recurse = mosGetParam( $_POST, 'mm_recurse', 'NO_RECURSE' ); | ||
| 59 : | // pulls message inoformation either in text or html format | ||
| 60 : | if ( $mode ) { | ||
| 61 : | $message_body = $_POST['mm_message']; | ||
| 62 : | } else { | ||
| 63 : | // automatically removes html formatting | ||
| 64 : | $message_body = mosGetParam( $_POST, 'mm_message', '' ); | ||
| 65 : | } | ||
| 66 : | $message_body = stripslashes( $message_body ); | ||
| 67 : | |||
| 68 : | if (!$message_body || !$subject || $gou === null) { | ||
| 69 : | csouza | 165 | $msg = T_('Please fill in the form correctly'); |
| 70 : | mosRedirect( 'index2.php?option=com_massmail&mosmsg='.$msg ); | ||
| 71 : | root | 1 | } |
| 72 : | |||
| 73 : | // get users in the group out of the acl | ||
| 74 : | $to = $acl->get_group_objects( $gou, 'ARO', $recurse ); | ||
| 75 : | |||
| 76 : | $rows = array(); | ||
| 77 : | if ( count( $to['users'] ) || $gou === '0' ) { | ||
| 78 : | // Get sending email address | ||
| 79 : | $query = "SELECT email FROM #__users WHERE id='$my->id'"; | ||
| 80 : | $database->setQuery( $query ); | ||
| 81 : | $my->email = $database->loadResult(); | ||
| 82 : | |||
| 83 : | // Get all users email and group except for senders | ||
| 84 : | $query = "SELECT email FROM #__users" | ||
| 85 : | . "\n WHERE id != '$my->id'" | ||
| 86 : | . ( $gou !== '0' ? " AND id IN (" . implode( ',', $to['users'] ) . ")" : '' ) | ||
| 87 : | ; | ||
| 88 : | $database->setQuery( $query ); | ||
| 89 : | $rows = $database->loadObjectList(); | ||
| 90 : | |||
| 91 : | // Build e-mail message format | ||
| 92 : | csouza | 165 | $message_header = sprintf( T_("This is an email from '%s' |
| 93 : | |||
| 94 : | Message: | ||
| 95 : | "), $mosConfig_sitename ); | ||
| 96 : | root | 1 | $message = $message_header . $message_body; |
| 97 : | $subject = $mosConfig_sitename. ' / '. stripslashes( $subject); | ||
| 98 : | |||
| 99 : | //Send email | ||
| 100 : | foreach ($rows as $row) { | ||
| 101 : | mosMail( $mosConfig_mailfrom, $mosConfig_fromname, $row->email, $subject, $message, $mode ); | ||
| 102 : | } | ||
| 103 : | } | ||
| 104 : | |||
| 105 : | csouza | 165 | $msg = sprintf(Tn_('E-mail sent to %d user.', 'E-mail sent to %d users.', count($rows)), count($rows)); |
| 106 : | root | 1 | mosRedirect( 'index2.php?option=com_massmail', $msg ); |
| 107 : | } | ||
| 108 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

