ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjCloud.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Repository/classes/class.ilObjectPlugin.php");
5 include_once("class.ilCloudUtil.php");
6 include_once("class.ilCloudConnector.php");
7 
16 class ilObjCloud extends ilObject2
17 {
21  protected $online = false;
22 
26  protected $service = "";
27 
31  protected $root_folder = "";
32 
36  protected $owner_id = 0;
37 
41  protected $auth_complete = false;
42 
43 
49  function __construct($a_ref_id = 0, $a_reference = true)
50  {
51  parent::__construct($a_ref_id, $a_reference);
52  }
53 
54  /*
55  * initType
56  */
57  public function initType()
58  {
59  $this->type = "cld";
60  }
61 
65  function doCreate()
66  {
67  global $ilDB, $ilUser;
68 
73  $this->setOwnerId($ilUser->getId());
74  $ilDB->manipulate("INSERT INTO il_cld_data " .
75  "(id, is_online, service, root_folder, root_id, owner_id, auth_complete) VALUES (" .
76  $ilDB->quote($this->getId(), "integer") . "," .
77  $ilDB->quote("", "integer") . "," .
78  $ilDB->quote("", "text") . "," .
79  $ilDB->quote("", "text") . "," .
80  $ilDB->quote("", "text") . "," .
81  $ilDB->quote($this->getOwnerId(), "integer") . "," .
82  $ilDB->quote("", "integer") .
83  ")");
84  }
85 
89  function doRead()
90  {
91  global $ilDB;
92 
93  $set = $ilDB->query("SELECT * FROM il_cld_data " .
94  " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
95 
96  while ($rec = $ilDB->fetchAssoc($set))
97  {
98  $this->setOnline($rec["is_online"]);
99  $this->setRootFolder($rec["root_folder"]);
100  $this->setRootId($rec["root_id"]);
101  $this->setServiceName($rec["service"]);
102  $this->setOwnerId($rec["owner_id"]);
103  $this->setAuthComplete($rec["auth_complete"]);
104  }
105  }
106 
110  function doUpdate()
111  {
112  global $ilDB;
113 
114  $ilDB->manipulate($up = "UPDATE il_cld_data SET " .
115  " is_online = " . $ilDB->quote($this->getOnline(), "integer") . "," .
116  " service = " . $ilDB->quote($this->getServiceName(), "text") . "," .
117  " root_folder = " . $ilDB->quote($this->getRootFolder(), "text") . "," .
118  " root_id = " . $ilDB->quote($this->getRootId(), "text") . "," .
119  " owner_id = " . $ilDB->quote($this->getOwnerId(), "integer") . "," .
120  " auth_complete = " . $ilDB->quote($this->getAuthComplete(), "integer") .
121  " WHERE id = " . $ilDB->quote($this->getId(), "integer")
122  );
123  }
124 
128  function doDelete()
129  {
130  global $ilDB;
131 
132  if ($this->getServiceName() != null)
133  {
134  $plugin_class = ilCloudConnector::getPluginClass($this->getServiceName(), $this->getId());
135  if ($plugin_class)
136  {
137  $plugin_class->doDelete($this->getId());
138  }
139  }
140 
141  $ilDB->manipulate("DELETE FROM il_cld_data WHERE " .
142  " id = " . $ilDB->quote($this->getId(), "integer")
143  );
144 
145  }
146 
150  function doClone($a_target_id, $a_copy_id, $new_obj)
151  {
152  global $ilDB;
153 
154  $new_obj->setOnline($this->getOnline());
155  $new_obj->setRootFolder($this->getRootFolder());
156  $new_obj->getRootId($this->getRootId());
157  $new_obj->setServiceName($this->getServiceName());
158  $new_obj->serOwnerId($this->getOwnerId());
159  $new_obj->setAuthComplete($this->getAuthComplete());
160  $new_obj->update();
161  }
162 
163 //
164 // Set/Get Methods for our example properties
165 //
166 
172  function setOnline($a_val)
173  {
174  $this->online = $a_val;
175  }
176 
182  function getOnline()
183  {
184  return $this->online;
185  }
186 
193  function setRootFolder($a_val,$no_check = false)
194  {
195  if($this->currentUserIsOwner() || $no_check || $this->getRootFolder() == null)
196  {
197  $a_val = ilCloudUtil::normalizePath($a_val);
198  $this->root_folder = $a_val;
199  }
200  else
201  {
203  }
204  }
205 
211  function getRootFolder()
212  {
213  return $this->root_folder;
214  }
215 
221  function setRootId($a_val,$no_check = false)
222  {
223  if ($this->currentUserIsOwner() || $no_check || $this->getRootId() == null)
224  {
225  $this->root_id = $a_val;
226  } else
227  {
229  }
230  }
231 
237  function getRootId()
238  {
239  return $this->root_id;
240  }
241 
247  function setServiceName($a_val)
248  {
249  $this->service_name = $a_val;
250  }
251 
257  function getServiceName()
258  {
259  return $this->service_name;
260  }
261 
265  public function setOwnerId($owner_id)
266  {
267  $this->owner_id = $owner_id;
268  }
269 
273  public function getOwnerId()
274  {
275  return $this->owner_id;
276  }
277 
281  public function currentUserIsOwner()
282  {
283  global $ilUser;
284  return $ilUser->getId() == $this->getOwnerId();
285  }
286 
291  {
292  $this->auth_complete = $auth_complete;
293  }
294 
298  public function getAuthComplete()
299  {
300  return $this->auth_complete;
301  }
302 }
303 ?>