ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMailOptions.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 define("IL_MAIL_LOCAL", 0);
25 define("IL_MAIL_EMAIL", 1);
26 define("IL_MAIL_BOTH", 2);
27 
38 {
39  var $ilias;
40 
41  // SOME QUASI STATIC CONSTANTS (possible values of incoming type)
42  var $LOCAL = 0;
43  var $EMAIL = 1;
44  var $BOTH = 2;
45 
52 
61 
68  function ilMailOptions($a_user_id)
69  {
70  global $ilias;
71 
72  define("DEFAULT_LINEBREAK",60);
73 
74  $this->ilias =& $ilias;
75  $this->table_mail_options = 'mail_options';
76 
77  $this->user_id = $a_user_id;
78  $this->getOptions();
79  }
80 
88  {
89  global $ilDB;
90 
91  /* Get setting for incoming mails */
92  if (!($incomingMail = $this->ilias->getSetting("mail_incoming_mail")))
93  {
94  /* No setting found -> set it to "local and forwarding" [2] */
95  $incomingMail = IL_MAIL_BOTH;
96  }
97 
98  $query = "INSERT INTO $this->table_mail_options " .
99  "VALUES(" . $ilDB->quote($this->user_id) . ", " .
100  $ilDB->quote(DEFAULT_LINEBREAK) . ", '', " .
101  $ilDB->quote($incomingMail) . ", '0')";
102 
103  $res = $this->ilias->db->query($query);
104  return true;
105  }
106 
114  function getOptions()
115  {
116  global $ilDB;
117 
118  $query = "SELECT * FROM $this->table_mail_options ".
119  "WHERE user_id = ".$ilDB->quote($this->user_id)." ";
120 
121  $row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
122 
123  $this->cronjob_notification = stripslashes($row->cronjob_notification);
124  $this->signature = stripslashes($row->signature);
125  $this->linebreak = stripslashes($row->linebreak);
126  $this->incoming_type = $row->incoming_type;
127 
128  if(!strlen(ilObjUser::_lookupEmail($this->user_id)))
129  {
130  $this->incoming_type = $this->LOCAL;
131  }
132 
133  return true;
134  }
135 
144  function updateOptions($a_signature, $a_linebreak, $a_incoming_type, $a_cronjob_notification)
145  {
146  global $ilDB, $ilias;
147 
148  $query = 'UPDATE '.$this->table_mail_options.'
149  SET
150  signature = '.$ilDB->quote($a_signature).',
151  linebreak = '.$ilDB->quote($a_linebreak).', ';
152  if ($ilias->getSetting('mail_notification'))
153  {
154  $query .= 'cronjob_notification = '.$ilDB->quote($a_cronjob_notification).', ';
155  }
156 
157  $query .='incoming_type = '.$ilDB->quote($a_incoming_type).'
158  WHERE 1
159  AND user_id = '.$ilDB->quote($this->user_id).' ';
160 
161  $res = $this->ilias->db->query($query);
162 
163  $this->cronjob_notification = $a_cronjob_notification;
164  $this->signature = $a_signature;
165  $this->linebreak = $a_linebreak;
166  $this->incoming_type = $a_incoming_type;
167 
168  return true;
169  }
175  function getLinebreak()
176  {
177  return $this->linebreak;
178  }
179 
185  function getSignature()
186  {
187  return $this->signature;
188  }
189 
190  function getIncomingType()
191  {
192  return $this->incoming_type;
193  }
194 
196  {
198  }
200  {
202  }
203 
204 
205 } // END class.ilFormatMail
206 ?>