ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
38 include_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  $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  }
176  public function read()
177  {
178  parent::read();
179 
180  $settings = new ilSetting('disk_quota');
181  $this->diskQuotaEnabled = $settings->get('enabled') == true;
182  $this->diskQuotaReminderMailEnabled = $settings->get('reminder_mail_enabled') == true;
183  $this->isDiskQuotaSummaryMailEnabled($settings->get('summary_mail_enabled') == 1 ? true : false);
184  $this->setSummaryRecipients($settings->get('summary_rcpt'));
185  $this->setPersonalWorkspaceDiskQuotaEnabled($settings->get('wsp_enabled'));
186  }
187 
188 
198  public static function _lookupReminderMailTemplate($a_lang)
199  {
200  global $DIC;
201  $ilDB = $DIC['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(ilDBConstants::FETCHMODE_ASSOC)) {
207  return $rec;
208  }
209  return array();
210  }
211 
212  public function _writeReminderMailTemplate($a_lang, $a_subject, $a_sal_g, $a_sal_f, $a_sal_m, $a_body)
213  {
214  global $DIC;
215  $ilDB = $DIC['ilDB'];
216 
217  if (self::_lookupReminderMailTemplate($a_lang)) {
218  $values = array(
219  'subject' => array('text',$a_subject),
220  'body' => array('clob',$a_body),
221  'sal_g' => array('text',$a_sal_g),
222  'sal_f' => array('text',$a_sal_f),
223  'sal_m' => array('text',$a_sal_m)
224  );
225  $ilDB->update(
226  'mail_template',
227  $values,
228  array('lang' => array('text',$a_lang), 'type' => array('text','dqta'))
229  );
230  } else {
231  $values = array(
232  'subject' => array('text',$a_subject),
233  'body' => array('clob',$a_body),
234  'sal_g' => array('text',$a_sal_g),
235  'sal_f' => array('text',$a_sal_f),
236  'sal_m' => array('text',$a_sal_m),
237  'lang' => array('text',$a_lang),
238  'type' => array('text','dqta')
239  );
240  $ilDB->insert('mail_template', $values);
241  }
242  }
243 
252  public function setSummaryRecipients($s_recipients)
253  {
254  if ($s_recipients) {
255  $s_recipients = explode(',', $s_recipients);
256  $loginnames = array();
257  foreach ($s_recipients as $loginname) {
258  $loginname = trim($loginname);
259  if (ilObjUser::_lookupId($loginname)) {
260  $loginnames[] = $loginname;
261  }
262  }
263  $s_recipients = implode(',', $loginnames);
264  }
265 
266  $this->summary_recipients = $s_recipients;
267 
268  return $this;
269  }
270 
279  public function getSummaryRecipients()
280  {
282  }
283 
293  public function isDiskQuotaSummaryMailEnabled($status = null)
294  {
295  if (null === $status) {
297  }
298 
299  $this->diskQuotaSummaryMailEnabled = $status;
300 
301  return $this;
302  }
303 
310  public function setPersonalWorkspaceDiskQuotaEnabled($newValue)
311  {
312  $this->personalWorkspaceDiskQuotaEnabled = $newValue;
313  }
320  {
322  }
323 } // END class.ilObjDiskQuotaSettings
setPersonalWorkspaceDiskQuotaEnabled($newValue)
Sets the personalWorkspaceDiskQuotaEnabled property.
isDiskQuotaReminderMailEnabled()
Gets the diskQuotaReminderMailEnabled property.
global $DIC
Definition: saml.php:7
isPersonalWorkspaceDiskQuotaEnabled()
Gets the personalWorkspaceDiskQuotaEnabled property.
$diskQuotaSummaryMailEnabled
Boolean property.
static _lookupReminderMailTemplate($a_lang)
Looks up the mail template for the specified language.
static _lookupId($a_user_str)
Lookup id by login.
$diskQuotaReminderMailEnabled
Boolean property.
getSummaryRecipients()
Getter fpr summary recipients.
isDiskQuotaEnabled()
Gets the diskQuotaEnabled property.
setDiskQuotaEnabled($newValue)
Sets the diskQuotaEnabled property.
foreach($_POST as $key=> $value) $res
write()
write object data into db
$query
_writeReminderMailTemplate($a_lang, $a_subject, $a_sal_g, $a_sal_f, $a_sal_m, $a_body)
static $dqSettings
DiskQuota Settings variable.
Create styles array
The data for the language used.
setSummaryRecipients($s_recipients)
Setter for summary recipients.
update($pash, $contents, Config $config)
setDiskQuotaReminderMailEnabled($newValue)
Sets the diskQuotaReminderMailEnabled property.
global $ilDB
read()
read object data from db into object
static getInstance()
Get settings instance.
__construct($a_id=0, $a_call_by_reference=true)
Constructor.
isDiskQuotaSummaryMailEnabled($status=null)
Setter/Getter to activate/deactivate the summary mail cron job.