ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 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 
199  function _lookupReminderMailTemplate($a_lang)
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 ?>