ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjDiskQuotaSettings.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
38include_once "./Services/Object/classes/class.ilObject.php";
39
41{
50
52 private static $dqSettings;
53
56
58 private $summary_recipients = '';
59
61
68 public function __construct($a_id = 0,$a_call_by_reference = true)
69 {
70 // NOTE: We share the facs object with ilObjFileAccessSettings!
71 $this->type = "facs";
72 parent::__construct($a_id,$a_call_by_reference);
73 }
74
80 public static function getInstance()
81 {
82 global $DIC;
83 $ilDB = $DIC['ilDB'];
84
85 $query = "SELECT object_reference.ref_id FROM object_reference,tree,object_data ".
86 "WHERE tree.parent = ".$ilDB->quote(SYSTEM_FOLDER_ID,'integer')." ".
87 "AND object_data.type = ".$ilDB->quote('facs','text').
88 "AND object_reference.ref_id = tree.child ".
89 "AND object_reference.obj_id = object_data.obj_id";
90 $res = $ilDB->query($query);
92 $ref_id = $row["ref_id"];
93 if($ref_id)
94 {
95 $obj = new self($ref_id);
96 $obj->read();
97 return $obj;
98 }
99 }
100
107 public function setDiskQuotaEnabled($newValue)
108 {
109 $this->diskQuotaEnabled = $newValue;
110 }
116 public function isDiskQuotaEnabled()
117 {
119 }
126 public function setDiskQuotaReminderMailEnabled($newValue)
127 {
128 $this->diskQuotaReminderMailEnabled = $newValue;
129 }
136 {
138 }
146 public function create()
147 {
148 parent::create();
149 $this->write();
150 }
156 public function update()
157 {
158 parent::update();
159 $this->write();
160 }
165 private function write()
166 {
167 $settings = new ilSetting('disk_quota');
168 $settings->set('enabled', $this->diskQuotaEnabled);
169 $settings->set('reminder_mail_enabled', $this->diskQuotaReminderMailEnabled);
170 $settings->set('summary_mail_enabled', $this->isDiskQuotaSummaryMailEnabled() ? 1 : 0);
171 $settings->set('summary_rcpt', $this->getSummaryRecipients());
172 $settings->set('wsp_enabled', $this->personalWorkspaceDiskQuotaEnabled);
173 }
177 public function read()
178 {
179 parent::read();
180
181 $settings = new ilSetting('disk_quota');
182 $this->diskQuotaEnabled = $settings->get('enabled') == true;
183 $this->diskQuotaReminderMailEnabled = $settings->get('reminder_mail_enabled') == true;
184 $this->isDiskQuotaSummaryMailEnabled($settings->get('summary_mail_enabled') == 1 ? true : false);
185 $this->setSummaryRecipients($settings->get('summary_rcpt'));
186 $this->setPersonalWorkspaceDiskQuotaEnabled($settings->get('wsp_enabled'));
187 }
188
189
199 public static function _lookupReminderMailTemplate($a_lang)
200 {
201 global $DIC;
202 $ilDB = $DIC['ilDB'];
203
204 $set = $ilDB->query("SELECT * FROM mail_template ".
205 " WHERE type='dqta' AND lang = ".$ilDB->quote($a_lang,'text'));
206
207 if ($rec = $set->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
208 {
209 return $rec;
210 }
211 return array();
212 }
213
214 function _writeReminderMailTemplate($a_lang, $a_subject, $a_sal_g, $a_sal_f, $a_sal_m, $a_body)
215 {
216 global $DIC;
217 $ilDB = $DIC['ilDB'];
218
219 if(self::_lookupReminderMailTemplate($a_lang))
220 {
221 $values = array(
222 'subject' => array('text',$a_subject),
223 'body' => array('clob',$a_body),
224 'sal_g' => array('text',$a_sal_g),
225 'sal_f' => array('text',$a_sal_f),
226 'sal_m' => array('text',$a_sal_m)
227 );
228 $ilDB->update('mail_template',
229 $values,
230 array('lang' => array('text',$a_lang), 'type' => array('text','dqta'))
231 );
232 }
233 else
234 {
235 $values = array(
236 'subject' => array('text',$a_subject),
237 'body' => array('clob',$a_body),
238 'sal_g' => array('text',$a_sal_g),
239 'sal_f' => array('text',$a_sal_f),
240 'sal_m' => array('text',$a_sal_m),
241 'lang' => array('text',$a_lang),
242 'type' => array('text','dqta')
243 );
244 $ilDB->insert('mail_template',$values);
245 }
246 }
247
256 public function setSummaryRecipients($s_recipients)
257 {
258 if($s_recipients)
259 {
260 $s_recipients = explode(',', $s_recipients);
261 $loginnames = array();
262 foreach($s_recipients as $loginname)
263 {
264 $loginname = trim($loginname);
265 if(ilObjUser::_lookupId($loginname))
266 {
267 $loginnames[] = $loginname;
268 }
269 }
270 $s_recipients = implode(',', $loginnames);
271 }
272
273 $this->summary_recipients = $s_recipients;
274
275 return $this;
276 }
277
286 public function getSummaryRecipients()
287 {
289 }
290
300 public function isDiskQuotaSummaryMailEnabled($status = null)
301 {
302 if( null === $status )
303 {
305 }
306
307 $this->diskQuotaSummaryMailEnabled = $status;
308
309 return $this;
310 }
311
318 public function setPersonalWorkspaceDiskQuotaEnabled($newValue)
319 {
320 $this->personalWorkspaceDiskQuotaEnabled = $newValue;
321 }
328 {
330 }
331
332
333} // END class.ilObjDiskQuotaSettings
334?>
An exception for terminatinating execution or to throw for unit testing.
static $dqSettings
DiskQuota Settings variable.
isDiskQuotaEnabled()
Gets the diskQuotaEnabled property.
_writeReminderMailTemplate($a_lang, $a_subject, $a_sal_g, $a_sal_f, $a_sal_m, $a_body)
static _lookupReminderMailTemplate($a_lang)
Looks up the mail template for the specified language.
setSummaryRecipients($s_recipients)
Setter for summary recipients.
setDiskQuotaEnabled($newValue)
Sets the diskQuotaEnabled property.
isDiskQuotaSummaryMailEnabled($status=null)
Setter/Getter to activate/deactivate the summary mail cron job.
setPersonalWorkspaceDiskQuotaEnabled($newValue)
Sets the personalWorkspaceDiskQuotaEnabled property.
__construct($a_id=0, $a_call_by_reference=true)
Constructor.
getSummaryRecipients()
Getter fpr summary recipients.
write()
write object data into db
static getInstance()
Get settings instance.
setDiskQuotaReminderMailEnabled($newValue)
Sets the diskQuotaReminderMailEnabled property.
isDiskQuotaReminderMailEnabled()
Gets the diskQuotaReminderMailEnabled property.
isPersonalWorkspaceDiskQuotaEnabled()
Gets the personalWorkspaceDiskQuotaEnabled property.
read()
read object data from db into object
$diskQuotaReminderMailEnabled
Boolean property.
static _lookupId($a_user_str)
Lookup id by login.
Class ilObject Basic functions for all objects.
ILIAS Setting Class.
global $ilDB
global $DIC