ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 ilObjDiskQuotaSettings($a_id = 0,$a_call_by_reference = true)
69 {
70 // NOTE: We share the facs object with ilObjFileAccessSettings!
71 $this->type = "facs";
72 $this->ilObject($a_id,$a_call_by_reference);
73 }
74
80 public static function getInstance()
81 {
82 global $ilDB;
83
84 $query = "SELECT object_reference.ref_id FROM object_reference,tree,object_data ".
85 "WHERE tree.parent = ".$ilDB->quote(SYSTEM_FOLDER_ID,'integer')." ".
86 "AND object_data.type = ".$ilDB->quote('facs','text').
87 "AND object_reference.ref_id = tree.child ".
88 "AND object_reference.obj_id = object_data.obj_id";
89 $res = $ilDB->query($query);
90 $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
91 $ref_id = $row["ref_id"];
92 if($ref_id)
93 {
94 $obj = new self($ref_id);
95 $obj->read();
96 return $obj;
97 }
98 }
99
106 public function setDiskQuotaEnabled($newValue)
107 {
108 $this->diskQuotaEnabled = $newValue;
109 }
115 public function isDiskQuotaEnabled()
116 {
118 }
125 public function setDiskQuotaReminderMailEnabled($newValue)
126 {
127 $this->diskQuotaReminderMailEnabled = $newValue;
128 }
135 {
137 }
145 public function create()
146 {
147 parent::create();
148 $this->write();
149 }
155 public function update()
156 {
157 parent::update();
158 $this->write();
159 }
164 private function write()
165 {
166 $settings = new ilSetting('disk_quota');
167 $settings->set('enabled', $this->diskQuotaEnabled);
168 $settings->set('reminder_mail_enabled', $this->diskQuotaReminderMailEnabled);
169 $settings->set('summary_mail_enabled', $this->isDiskQuotaSummaryMailEnabled() ? 1 : 0);
170 $settings->set('summary_rcpt', $this->getSummaryRecipients());
171 $settings->set('wsp_enabled', $this->personalWorkspaceDiskQuotaEnabled);
172 }
177 public function read($a_force_db = false)
178 {
179 parent::read($a_force_db);
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
200 {
201 global $ilDB;
202
203 $set = $ilDB->query("SELECT * FROM mail_template ".
204 " WHERE type='dqta' AND lang = ".$ilDB->quote($a_lang,'text'));
205
206 if ($rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
207 {
208 return $rec;
209 }
210 return array();
211 }
212
213 function _writeReminderMailTemplate($a_lang, $a_subject, $a_sal_g, $a_sal_f, $a_sal_m, $a_body)
214 {
215 global $ilDB;
216
217 if(self::_lookupReminderMailTemplate($a_lang))
218 {
219 $values = array(
220 'subject' => array('text',$a_subject),
221 'body' => array('clob',$a_body),
222 'sal_g' => array('text',$a_sal_g),
223 'sal_f' => array('text',$a_sal_f),
224 'sal_m' => array('text',$a_sal_m)
225 );
226 $ilDB->update('mail_template',
227 $values,
228 array('lang' => array('text',$a_lang), 'type' => array('text','dqta'))
229 );
230 }
231 else
232 {
233 $values = array(
234 'subject' => array('text',$a_subject),
235 'body' => array('clob',$a_body),
236 'sal_g' => array('text',$a_sal_g),
237 'sal_f' => array('text',$a_sal_f),
238 'sal_m' => array('text',$a_sal_m),
239 'lang' => array('text',$a_lang),
240 'type' => array('text','dqta')
241 );
242 $ilDB->insert('mail_template',$values);
243 }
244 }
245
254 public function setSummaryRecipients($s_recipients)
255 {
256 if($s_recipients)
257 {
258 $s_recipients = explode(',', $s_recipients);
259 $loginnames = array();
260 foreach($s_recipients as $loginname)
261 {
262 $loginname = trim($loginname);
263 if(ilObjUser::_lookupId($loginname))
264 {
265 $loginnames[] = $loginname;
266 }
267 }
268 $s_recipients = implode(',', $loginnames);
269 }
270
271 $this->summary_recipients = $s_recipients;
272
273 return $this;
274 }
275
284 public function getSummaryRecipients()
285 {
287 }
288
298 public function isDiskQuotaSummaryMailEnabled($status = null)
299 {
300 if( null === $status )
301 {
303 }
304
305 $this->diskQuotaSummaryMailEnabled = $status;
306
307 return $this;
308 }
309
316 public function setPersonalWorkspaceDiskQuotaEnabled($newValue)
317 {
318 $this->personalWorkspaceDiskQuotaEnabled = $newValue;
319 }
326 {
328 }
329
330
331} // END class.ilObjDiskQuotaSettings
332?>
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
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)
_lookupReminderMailTemplate($a_lang)
Looks up the mail template for the specified language.
setSummaryRecipients($s_recipients)
Setter for summary recipients.
ilObjDiskQuotaSettings($a_id=0, $a_call_by_reference=true)
Constructor.
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.
getSummaryRecipients()
Getter fpr summary recipients.
write()
write object data into db
static getInstance()
Get settings instance.
setDiskQuotaReminderMailEnabled($newValue)
Sets the diskQuotaReminderMailEnabled property.
read($a_force_db=false)
read object data from db into object
isDiskQuotaReminderMailEnabled()
Gets the diskQuotaReminderMailEnabled property.
isPersonalWorkspaceDiskQuotaEnabled()
Gets the personalWorkspaceDiskQuotaEnabled property.
$diskQuotaReminderMailEnabled
Boolean property.
static _lookupId($a_user_str)
Lookup id by login.
Class ilObject Basic functions for all objects.
ilObject($a_id=0, $a_reference=true)
Constructor @access public.
ILIAS Setting Class.
global $ilDB