Source for file messages.class.php

Documentation is available at messages.class.php

  1. <?php
  2. /**
  3. @package Mambo
  4. @subpackage Messages
  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. class mosMessage extends mosDBTable {
  14.     /** @var int Primary key */
  15.     var $message_id=null;
  16.     /** @var int */
  17.     var $user_id_from=null;
  18.     /** @var int */
  19.     var $user_id_to=null;
  20.     /** @var int */
  21.     var $folder_id=null;
  22.     /** @var datetime */
  23.     var $date_time=null;
  24.     /** @var int */
  25.     var $state=null;
  26.     /** @var int */
  27.     var $priority=null;
  28.     /** @var string */
  29.     var $subject=null;
  30.     /** @var text */
  31.     var $message=null;
  32.     
  33.     /**
  34.     * @param database A database connector object
  35.     */
  36.     function mosMessage&$db {
  37.         $this->mosDBTable'#__messages''message_id'$db );
  38.     }
  39.     
  40.     function send$from_id=null$to_id=null$subject=null$message=null {
  41.         global $database;
  42.         global $mosConfig_site_name;
  43.         
  44.         if (is_object$this )) {
  45.             $from_id $from_id $from_id $this->user_id_from;
  46.             $to_id $to_id $to_id $this->user_id_to;
  47.             $subject $subject $subject $this->subject;
  48.             $message $message $message $this->message;
  49.         }
  50.         
  51.         $database->setQuery"SELECT cfg_name, cfg_value"
  52.         . "\nFROM #__messages_cfg"
  53.         . "\nWHERE user_id='$to_id'"
  54.         );
  55.         $config $database->loadObjectList'cfg_name' );
  56.         $locked @$config['lock']->cfg_value;
  57.         $domail @$config['mail_on_new']->cfg_value;
  58.         
  59.         if (!$locked{
  60.             
  61.             $this->user_id_from = $from_id;
  62.             $this->user_id_to = $to_id;
  63.             $this->subject = $subject;
  64.             $this->message = $message;
  65.             $this->date_time = date"Y-m-d H:i:s" );
  66.  
  67.             if ($this->store()) {
  68.                 if ($domail{
  69.                     $database->setQuery"SELECT email FROM #__users WHERE id='$to_id');
  70.                     $recipient $database->loadResult();
  71.                     $subject T_('A new private message has arrived');
  72.                     $msg T_('A new private message has arrived');
  73.                     mosMail($mosConfig_mailfrom$mosConfig_fromname$recipient$subject$msg);
  74.                 }
  75.                 return true;
  76.             }
  77.         else {
  78.             if (is_object$this )) {
  79.                 $this->_error = T_('The user has locked their mailbox. Message failed.');
  80.             }
  81.         }
  82.         return false;
  83.     }
  84. }
  85. ?>

Documentation generated on Mon, 05 May 2008 16:21:11 +0400 by phpDocumentor 1.4.0