ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMailOptions.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 define("IL_MAIL_LOCAL", 0);
5 define("IL_MAIL_EMAIL", 1);
6 define("IL_MAIL_BOTH", 2);
7 
18 {
19  var $ilias;
20 
21  // SOME QUASI STATIC CONSTANTS (possible values of incoming type)
22  var $LOCAL = 0;
23  var $EMAIL = 1;
24  var $BOTH = 2;
25 
32 
41 
48  public function __construct($a_user_id)
49  {
50  global $ilias;
51 
52  define("DEFAULT_LINEBREAK",60);
53 
54  $this->ilias = $ilias;
55  $this->table_mail_options = 'mail_options';
56 
57  $this->user_id = $a_user_id;
58  $this->getOptions();
59  }
60 
68  {
69  global $ilDB;
70 
71  /* Get setting for incoming mails */
72  if (!($incomingMail = $this->ilias->getSetting("mail_incoming_mail")))
73  {
74  /* No setting found -> set it to "local and forwarding" [2] */
75  $incomingMail = IL_MAIL_BOTH;
76  }
77 
78  $statement = $ilDB->manipulateF('
79  INSERT INTO '.$this->table_mail_options.'
80  ( user_id,
81  linebreak,
82  signature,
83  incoming_type,
84  cronjob_notification
85  )
86  VALUES(%s, %s, %s, %s, %s)',
87  array('integer', 'integer', 'text', 'integer', 'integer'),
88  array($this->user_id, DEFAULT_LINEBREAK, NULL, $incomingMail, '0'));
89 
90  return true;
91  }
92 
100  function getOptions()
101  {
102  global $ilDB;
103 
104  $res = $ilDB->queryf('
105  SELECT * FROM '.$this->table_mail_options.'
106  WHERE user_id = %s',
107  array('integer'), array($this->user_id));
108 
109  $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
110 
111  $this->cronjob_notification = stripslashes($row->cronjob_notification);
112  $this->signature = stripslashes($row->signature);
113  $this->linebreak = stripslashes($row->linebreak);
114  $this->incoming_type = $row->incoming_type;
115 
116  if(!strlen(ilObjUser::_lookupEmail($this->user_id)))
117  {
118  $this->incoming_type = $this->LOCAL;
119  }
120 
121  return true;
122  }
123 
132  function updateOptions($a_signature, $a_linebreak, $a_incoming_type, $a_cronjob_notification)
133  {
134  global $ilDB, $ilias;
135 
136  $data = array();
137  $data_types = array();
138 
139  $query = 'UPDATE '.$this->table_mail_options.'
140  SET signature = %s,
141  linebreak = %s, ';
142 
143  array_push($data_types, 'text', 'integer');
144  array_push($data, $a_signature, $a_linebreak);
145 
146  if ($ilias->getSetting('mail_notification'))
147  {
148  $query .= 'cronjob_notification = %s, ';
149  array_push($data_types, 'integer');
150  array_push($data, $a_cronjob_notification);
151  }
152 
153  $query .='incoming_type = %s WHERE user_id = %s';
154  array_push($data, $a_incoming_type, $this->user_id);
155  array_push($data_types, 'integer', 'integer');
156 
157  $statement = $ilDB->manipulateF($query, $data_types, $data);
158 
159  $this->cronjob_notification = $a_cronjob_notification;
160  $this->signature = $a_signature;
161  $this->linebreak = $a_linebreak;
162  $this->incoming_type = $a_incoming_type;
163 
164  return true;
165  }
171  function getLinebreak()
172  {
173  return $this->linebreak;
174  }
175 
181  function getSignature()
182  {
183  return $this->signature;
184  }
185 
186  function getIncomingType()
187  {
188  return $this->incoming_type;
189  }
190 
192  {
194  }
196  {
198  }
199 
200 
201 } // END class.ilFormatMail
202 ?>