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

