ILIAS  eassessment Revision 61809
 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  $statement = $ilDB->manipulateF('
99  INSERT INTO '.$this->table_mail_options.'
100  ( user_id,
101  linebreak,
102  signature,
103  incoming_type,
104  cronjob_notification
105  )
106  VALUES(%s, %s, %s, %s, %s)',
107  array('integer', 'integer', 'text', 'integer', 'integer'),
108  array($this->user_id, DEFAULT_LINEBREAK, NULL, $incomingMail, '0'));
109 
110  return true;
111  }
112 
120  function getOptions()
121  {
122  global $ilDB;
123 
124  $res = $ilDB->queryf('
125  SELECT * FROM '.$this->table_mail_options.'
126  WHERE user_id = %s',
127  array('integer'), array($this->user_id));
128 
129  $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
130 
131  $this->cronjob_notification = stripslashes($row->cronjob_notification);
132  $this->signature = stripslashes($row->signature);
133  $this->linebreak = stripslashes($row->linebreak);
134  $this->incoming_type = $row->incoming_type;
135 
136  if(!strlen(ilObjUser::_lookupEmail($this->user_id)))
137  {
138  $this->incoming_type = $this->LOCAL;
139  }
140 
141  return true;
142  }
143 
152  function updateOptions($a_signature, $a_linebreak, $a_incoming_type, $a_cronjob_notification)
153  {
154  global $ilDB, $ilias;
155 
156  $data = array();
157  $data_types = array();
158 
159  $query = 'UPDATE '.$this->table_mail_options.'
160  SET signature = %s,
161  linebreak = %s, ';
162 
163  array_push($data_types, 'text', 'integer');
164  array_push($data, $a_signature, $a_linebreak);
165 
166  if ($ilias->getSetting('mail_notification'))
167  {
168  $query .= 'cronjob_notification = %s, ';
169  array_push($data_types, 'integer');
170  array_push($data, $a_cronjob_notification);
171  }
172 
173  $query .='incoming_type = %s WHERE user_id = %s';
174  array_push($data, $a_incoming_type, $this->user_id);
175  array_push($data_types, 'integer', 'integer');
176 
177  $statement = $ilDB->manipulateF($query, $data_types, $data);
178 
179  $this->cronjob_notification = $a_cronjob_notification;
180  $this->signature = $a_signature;
181  $this->linebreak = $a_linebreak;
182  $this->incoming_type = $a_incoming_type;
183 
184  return true;
185  }
191  function getLinebreak()
192  {
193  return $this->linebreak;
194  }
195 
201  function getSignature()
202  {
203  return $this->signature;
204  }
205 
206  function getIncomingType()
207  {
208  return $this->incoming_type;
209  }
210 
212  {
214  }
216  {
218  }
219 
220 
221 } // END class.ilFormatMail
222 ?>