• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Mail/classes/class.ilMailOptions.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 define("IL_MAIL_LOCAL", 0);
00025 define("IL_MAIL_EMAIL", 1);
00026 define("IL_MAIL_BOTH", 2);
00027 
00037 class ilMailOptions
00038 {
00039         var $ilias;
00040 
00041         // SOME QUASI STATIC CONSTANTS (possible values of incoming type)
00042         var $LOCAL = 0;
00043         var $EMAIL = 1;
00044         var $BOTH = 2;
00045 
00051         var $linebreak;
00052 
00058         var $signature;
00059         var $incoming_type;
00060         var $cronjob_notification;
00061 
00068         function ilMailOptions($a_user_id)
00069         {
00070                 global $ilias;
00071 
00072                 define("DEFAULT_LINEBREAK",60);
00073 
00074                 $this->ilias =& $ilias;
00075                 $this->table_mail_options = 'mail_options';
00076 
00077                 $this->user_id = $a_user_id;
00078                 $this->getOptions();
00079         }
00080 
00087     function createMailOptionsEntry()
00088     {
00089         global $ilDB;
00090                 
00091                 /* Get setting for incoming mails */
00092                 if (!($incomingMail = $this->ilias->getSetting("mail_incoming_mail")))
00093                 {
00094                         /* No setting found -> set it to "local and forwarding" [2] */
00095                         $incomingMail = IL_MAIL_BOTH;
00096                 }
00097 
00098         $query = "INSERT INTO $this->table_mail_options " .
00099                  "VALUES(" . $ilDB->quote($this->user_id) . ", " . 
00100                                          $ilDB->quote(DEFAULT_LINEBREAK) . ", '', " . 
00101                                                          $ilDB->quote($incomingMail) . ", '0')";
00102 
00103         $res = $this->ilias->db->query($query);
00104         return true;
00105     }
00106 
00114         function getOptions()
00115         {
00116                 global $ilDB;
00117                 
00118                 $query = "SELECT * FROM $this->table_mail_options ".
00119                         "WHERE user_id = ".$ilDB->quote($this->user_id)." ";
00120 
00121                 $row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
00122                 
00123                 $this->cronjob_notification = stripslashes($row->cronjob_notification);
00124                 $this->signature = stripslashes($row->signature);
00125                 $this->linebreak = stripslashes($row->linebreak);
00126                 $this->incoming_type = $row->incoming_type;
00127                 
00128                 if(!strlen(ilObjUser::_lookupEmail($this->user_id)))
00129                 {
00130                         $this->incoming_type = $this->LOCAL;
00131                 }
00132 
00133                 return true;
00134         }
00135 
00144         function updateOptions($a_signature, $a_linebreak, $a_incoming_type, $a_cronjob_notification)
00145         {
00146                 global $ilDB, $ilias;
00147                 
00148                 $query = 'UPDATE '.$this->table_mail_options.' 
00149                                   SET
00150                                   signature = '.$ilDB->quote($a_signature).', 
00151                               linebreak = '.$ilDB->quote($a_linebreak).', ';            
00152                 if ($ilias->getSetting('mail_notification'))
00153                 {               
00154                         $query .= 'cronjob_notification = '.$ilDB->quote($a_cronjob_notification).', ';
00155                 }
00156                                                 
00157                 $query .='incoming_type = '.$ilDB->quote($a_incoming_type).'
00158                                   WHERE 1
00159                                   AND user_id = '.$ilDB->quote($this->user_id).' ';                     
00160 
00161                 $res = $this->ilias->db->query($query);
00162 
00163                 $this->cronjob_notification = $a_cronjob_notification;
00164                 $this->signature = $a_signature;
00165                 $this->linebreak = $a_linebreak;
00166                 $this->incoming_type = $a_incoming_type;
00167 
00168                 return true;
00169         }
00175         function getLinebreak()
00176         {
00177                 return $this->linebreak;
00178         }
00179 
00185         function getSignature()
00186         {
00187                 return $this->signature;
00188         }
00189 
00190         function getIncomingType()
00191         {
00192                 return $this->incoming_type;
00193         }
00194         
00195         function setCronjobNotification()
00196         {
00197                 return $this->cronjob_notification;
00198         }
00199         function getCronjobNotification()
00200         {
00201                 return $this->cronjob_notification;
00202         }
00203         
00204         
00205 } // END class.ilFormatMail
00206 ?>

Generated on Fri Dec 13 2013 17:56:57 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1