ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilECSParticipantSetting.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 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 
33 {
34  const IMPORT_UNCHANGED = 0;
35  const IMPORT_RCRS = 1;
36  const IMPORT_CRS = 2;
37  const IMPORT_CMS = 3;
38 
39  private $server_id = 0;
40  private $mid = 0;
41  private $export = false;
42  private $import = false;
43  private $import_type = 1;
44  private $title = '';
45  private $cname = '';
46 
47 
48  private $exists = false;
49 
50 
57  public function __construct($a_server_id,$mid)
58  {
59  $this->server_id = $a_server_id;
60  $this->mid = $mid;
61  $this->read();
62  }
63 
68  public function getServerId()
69  {
70  return $this->server_id;
71  }
72 
73  public function setMid($a_mid)
74  {
75  $this->mid = $a_mid;
76  }
77 
78  public function getMid()
79  {
80  return $this->mid;
81  }
82 
83  public function enableExport($a_status)
84  {
85  $this->export = $a_status;
86  }
87 
88  public function isExportEnabled()
89  {
90  return (bool) $this->export;
91  }
92 
93  public function enableImport($a_status)
94  {
95  $this->import = $a_status;
96  }
97 
98  public function isImportEnabled()
99  {
100  return $this->import;
101  }
102 
103  public function setImportType($a_type)
104  {
105  if($a_type != self::IMPORT_UNCHANGED)
106  {
107  $this->import_type = $a_type;
108  }
109  }
110 
111  public function getImportType()
112  {
113  return $this->import_type;
114  }
115 
116  public function setTitle($a_title)
117  {
118  $this->title = $a_title;
119  }
120 
121  public function getTitle()
122  {
123  return $this->title;
124  }
125 
126  public function getCommunityName()
127  {
128  return $this->cname;
129  }
130 
131  public function setCommunityName($a_name)
132  {
133  $this->cname = $a_name;
134  }
135 
136  private function exists()
137  {
138  return $this->exists;
139  }
140 
145  public function update()
146  {
147  global $ilDB;
148 
149  if(!$this->exists())
150  {
151  return $this->create();
152  }
153  $query = 'UPDATE ecs_part_settings '.
154  'SET '.
155  'sid = '.$ilDB->quote((int) $this->getServerId(),'integer').', '.
156  'mid = '.$ilDB->quote((int) $this->getMid(),'integer').', '.
157  'export = '.$ilDB->quote((int) $this->isExportEnabled(),'integer').', '.
158  'import = '.$ilDB->quote((int) $this->isImportEnabled(),'integer').', '.
159  'import_type = '.$ilDB->quote((int) $this->getImportType(),'integer').', '.
160  'title = '.$ilDB->quote($this->getTitle(),'text').', '.
161  'cname = '.$ilDB->quote($this->getCommunityName(),'text').' '.
162  'WHERE sid = '.$ilDB->quote((int) $this->getServerId(),'integer').' '.
163  'AND mid = '.$ilDB->quote((int) $this->getMid(),'integer');
164  $aff = $ilDB->manipulate($query);
165  return true;
166  }
167 
168  private function create()
169  {
170  global $ilDB;
171 
172  $query = 'INSERT INTO ecs_part_settings '.
173  '(sid,mid,export,import,import_type,title,cname) '.
174  'VALUES( '.
175  $ilDB->quote($this->getServerId(),'integer').', '.
176  $ilDB->quote($this->getMid(),'integer').', '.
177  $ilDB->quote((int) $this->isExportEnabled(),'integer').', '.
178  $ilDB->quote((int) $this->isImportEnabled(),'integer').', '.
179  $ilDB->quote((int) $this->getImportType(),'integer').', '.
180  $ilDB->quote($this->getTitle(),'text').', '.
181  $ilDB->quote($this->getCommunityName(),'text').' '.
182  ')';
183  $aff = $ilDB->manipulate($query);
184  return true;
185 
186  }
187 
193  public function delete()
194  {
195  global $ilDB;
196 
197  $query = 'DELETE FROM ecs_part_settings '.
198  'WHERE sid = '.$ilDB->quote($this->getServerId(),'integer').' '.
199  'AND mid = '.$ilDB->quote($this->getMid(),'integer');
200  $ilDB->manipulate($query);
201  return true;
202  }
203 
208  public function read()
209  {
210  global $ilDB;
211 
212  $query = 'SELECT * FROM ecs_part_settings '.
213  'WHERE sid = '.$ilDB->quote($this->getServerId(),'integer').' '.
214  'AND mid = '.$ilDB->quote($this->getMid(),'integer');
215 
216  $res = $ilDB->query($query);
217 
218  $this->exists = ($res->numRows() ? true : false);
219 
220  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
221  {
222  $this->enableExport($row->export);
223  $this->enableImport($row->import);
224  $this->setImportType($row->import_type);
225  $this->setTitle($row->title);
226  $this->setCommunityName($row->cname);
227  }
228  return true;
229  }
230 }
231 ?>