ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
4define("IL_MAIL_LOCAL", 0);
5define("IL_MAIL_EMAIL", 1);
6define("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, $ilSetting;
70
71 /* Get default setting for incoming mails */
72 $incomingMail = $ilSetting->get("mail_incoming_mail", IL_MAIL_BOTH);
73
74 $statement = $ilDB->manipulateF('
75 INSERT INTO '.$this->table_mail_options.'
76 ( user_id,
77 linebreak,
78 signature,
79 incoming_type,
80 cronjob_notification
81 )
82 VALUES(%s, %s, %s, %s, %s)',
83 array('integer', 'integer', 'text', 'integer', 'integer'),
84 array($this->user_id, DEFAULT_LINEBREAK, NULL, $incomingMail, '0'));
85
86 return true;
87 }
88
96 function getOptions()
97 {
98 global $ilDB;
99
100 $res = $ilDB->queryf('
101 SELECT * FROM '.$this->table_mail_options.'
102 WHERE user_id = %s',
103 array('integer'), array($this->user_id));
104
105 $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
106
107 $this->cronjob_notification = stripslashes($row->cronjob_notification);
108 $this->signature = stripslashes($row->signature);
109 $this->linebreak = stripslashes($row->linebreak);
110 $this->incoming_type = $row->incoming_type;
111
112 if(!strlen(ilObjUser::_lookupEmail($this->user_id)))
113 {
114 $this->incoming_type = $this->LOCAL;
115 }
116
117 return true;
118 }
119
128 function updateOptions($a_signature, $a_linebreak, $a_incoming_type, $a_cronjob_notification)
129 {
130 global $ilDB, $ilias;
131
132 $data = array();
133 $data_types = array();
134
135 $query = 'UPDATE '.$this->table_mail_options.'
136 SET signature = %s,
137 linebreak = %s, ';
138
139 array_push($data_types, 'text', 'integer');
140 array_push($data, $a_signature, $a_linebreak);
141
142 if ($ilias->getSetting('mail_notification'))
143 {
144 $query .= 'cronjob_notification = %s, ';
145 array_push($data_types, 'integer');
146 array_push($data, $a_cronjob_notification);
147 }
148
149 $query .='incoming_type = %s WHERE user_id = %s';
150 array_push($data, $a_incoming_type, $this->user_id);
151 array_push($data_types, 'integer', 'integer');
152
153 $statement = $ilDB->manipulateF($query, $data_types, $data);
154
155 $this->cronjob_notification = $a_cronjob_notification;
156 $this->signature = $a_signature;
157 $this->linebreak = $a_linebreak;
158 $this->incoming_type = $a_incoming_type;
159
160 return true;
161 }
167 function getLinebreak()
168 {
169 return $this->linebreak;
170 }
171
177 function getSignature()
178 {
179 return $this->signature;
180 }
181
183 {
185 }
186
188 {
190 }
192 {
194 }
195
196
197} // END class.ilFormatMail
198?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
const IL_MAIL_BOTH
Class UserMail this class handles user mails.
updateOptions($a_signature, $a_linebreak, $a_incoming_type, $a_cronjob_notification)
update user options
__construct($a_user_id)
Constructor setup an mail object.
createMailOptionsEntry()
create entry in table_mail_options for a new user this method should only be called from createUser()...
getOptions()
get options of user and set variables $signature and $linebreak this method shouldn't bew called from...
getLinebreak()
get linebreak of user @access public
getSignature()
get signature of user @access public
_lookupEmail($a_user_id)
Lookup email.
redirection script todo: (a better solution should control the processing via a xml file)
global $ilSetting
Definition: privfeed.php:40
global $ilDB