Source for file admin.massmail.php

Documentation is available at admin.massmail.php

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

Documentation generated on Mon, 05 May 2008 16:15:27 +0400 by phpDocumentor 1.4.0