ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
66  public function createMailOptionsEntry()
67  {
68  global $ilDB, $ilSetting;
69 
70  $incomingMail = $ilSetting->get('mail_incoming_mail') ? $ilSetting->get('mail_incoming_mail'): IL_MAIL_LOCAL;
71  $ilDB->insert('mail_options',
72  array(
73  'user_id' => array('integer', $this->user_id),
74  'linebreak' => array('integer', DEFAULT_LINEBREAK),
75  'signature' => array('text', NULL),
76  'incoming_type' => array('integer', $incomingMail),
77  'cronjob_notification' => array('integer', 0)
78  ));
79 
80  return true;
81  }
82 
90  function getOptions()
91  {
92  global $ilDB;
93 
94  $res = $ilDB->queryf('
95  SELECT * FROM '.$this->table_mail_options.'
96  WHERE user_id = %s',
97  array('integer'), array($this->user_id));
98 
100 
101  $this->cronjob_notification = stripslashes($row->cronjob_notification);
102  $this->signature = stripslashes($row->signature);
103  $this->linebreak = stripslashes($row->linebreak);
104  $this->incoming_type = $row->incoming_type;
105 
106  if(!strlen(ilObjUser::_lookupEmail($this->user_id)))
107  {
108  $this->incoming_type = $this->LOCAL;
109  }
110 
111  return true;
112  }
113 
122  public function updateOptions($a_signature, $a_linebreak, $a_incoming_type, $a_cronjob_notification)
123  {
128  global $ilDB, $ilSetting;
129 
130  $this->cronjob_notification = $a_cronjob_notification;
131  $this->signature = $a_signature;
132  $this->linebreak = $a_linebreak;
133  $this->incoming_type = $a_incoming_type;
134 
135  $data = array(
136  'signature' => array('text', $this->signature),
137  'linebreak' => array('integer', $this->linebreak),
138  'incoming_type' => array('integer', $this->incoming_type)
139  );
140  if($ilSetting->get('mail_notification'))
141  {
142  $data['cronjob_notification'] = array('integer', $this->cronjob_notification);
143  }
144  else
145  {
146  $data['cronjob_notification'] = array('integer', self::lookupNotificationSetting($this->user_id));
147  }
148 
149  $ilDB->replace(
150  $this->table_mail_options,
151  array(
152  'user_id' => array('integer', $this->user_id)
153  ),
154  $data
155  );
156 
157  return true;
158  }
164  function getLinebreak()
165  {
166  return $this->linebreak;
167  }
168 
174  function getSignature()
175  {
176  return $this->signature;
177  }
178 
179  function getIncomingType()
180  {
181  return $this->incoming_type;
182  }
183 
185  {
187  }
189  {
191  }
192 
197  protected static function lookupNotificationSetting($usr_id)
198  {
202  global $ilDB;
203 
204  $query = "SELECT cronjob_notification FROM mail_options WHERE user_id = " . $ilDB->quote($usr_id, 'integer');
205  $row = $ilDB->fetchAssoc($ilDB->query($query));
206  return (int)$row['cronjob_notification'];
207  }
208 } // END class.ilFormatMail
209 ?>
Class UserMail this class handles user mails.
getLinebreak()
get linebreak of user public
getOptions()
get options of user and set variables $signature and $linebreak this method shouldn&#39;t bew called from...
createMailOptionsEntry()
create entry in table_mail_options for a new user this method should only be called from createUser()...
__construct($a_user_id)
Constructor setup an mail object.
const IL_MAIL_LOCAL
redirection script todo: (a better solution should control the processing via a xml file) ...
Create styles array
The data for the language used.
global $ilSetting
Definition: privfeed.php:17
static _lookupEmail($a_user_id)
Lookup email.
global $ilDB
getSignature()
get signature of user public