ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilECSExport.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 
35 {
36  protected $db = null;
37 
38  protected $obj_id = 0;
39  protected $econtent_id = 0;
40  protected $exported = false;
41 
49  public function __construct($a_obj_id)
50  {
51  global $ilDB;
52 
53  $this->obj_id = $a_obj_id;
54 
55  $this->db = $ilDB;
56  $this->read();
57  }
58 
66  public static function _getAllEContentIds()
67  {
68  global $ilDB;
69 
70  $query = "SELECT econtent_id FROM ecs_export ";
71  $res = $ilDB->query($query);
72  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
73  {
74  $econtent_ids[$row->econtent_id] = $row->econtent_id;
75  }
76  return $econtent_ids ? $econtent_ids : array();
77  }
78 
86  public static function _getExportedIDs()
87  {
88  global $ilDB;
89  $query = "SELECT obj_id FROM ecs_export ";
90  $res = $ilDB->query($query);
91  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
92  {
93  $obj_ids[] = $row->obj_id;
94  }
95  return $obj_ids ? $obj_ids : array();
96  }
97 
106  public static function _deleteEContentIds($a_ids)
107  {
108  global $ilDB;
109 
110  if(!is_array($a_ids) or !count($a_ids))
111  {
112  return true;
113  }
114  #$query = "DELETE FROM ecs_export WHERE econtent_id IN (".implode(',',ilUtil::quoteArray($a_ids)).')';
115  $query = "DELETE FROM ecs_export WHERE ".$ilDB->in('econtent_id',$a_ids,false,'integer');
116  $res = $ilDB->manipulate($query);
117  return true;
118  }
119 
128  public static function _isRemote($a_econtent_id)
129  {
130  global $ilDB;
131 
132  $query = "SELECT obj_id FROM ecs_export ".
133  "WHERE econtent_id = ".$ilDB->quote($a_econtent_id,'integer')." ";
134  $res = $ilDB->query($query);
135  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
136  {
137  return false;
138  }
139  return true;
140  }
141 
149  public function setExported($a_status)
150  {
151  $this->exported = $a_status;
152  }
153 
160  public function isExported()
161  {
162  return (bool) $this->exported;
163  }
164 
172  public function setEContentId($a_id)
173  {
174  $this->econtent_id = $a_id;
175  }
176 
184  public function getEContentId()
185  {
186  return $this->econtent_id;
187  }
188 
194  public function save()
195  {
196  global $ilDB;
197 
198  $query = "DELETE FROM ecs_export ".
199  "WHERE obj_id = ".$this->db->quote($this->obj_id,'integer')." ";
200  $res = $ilDB->manipulate($query);
201 
202  if($this->isExported())
203  {
204  $query = "INSERT INTO ecs_export (obj_id,econtent_id) ".
205  "VALUES ( ".
206  $this->db->quote($this->obj_id,'integer').", ".
207  $this->db->quote($this->getEContentId(),'integer')." ".
208  ")";
209  $res = $ilDB->manipulate($query);
210  }
211 
212  return true;
213  }
214 
219  private function read()
220  {
221  global $ilDB;
222 
223  $query = "SELECT * FROM ecs_export WHERE ".
224  "obj_id = ".$this->db->quote($this->obj_id,'integer')." ";
225  $res = $this->db->query($query);
226  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
227  {
228  $this->econtent_id = $row->econtent_id;
229  $this->exported = true;
230  }
231  }
232 }
233 ?>