ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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  //copy online status if object is not the root copy object
155  $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
156 
157  if(!$cp_options->isRootNode($this->getRefId()))
158  {
159  $new_obj->setOnline($this->getOnline());
160  }
161 
162  $new_obj->setRootFolder($this->getRootFolder());
163  $new_obj->getRootId($this->getRootId());
164  $new_obj->setServiceName($this->getServiceName());
165  $new_obj->serOwnerId($this->getOwnerId());
166  $new_obj->setAuthComplete($this->getAuthComplete());
167  $new_obj->update();
168  }
169 
170 //
171 // Set/Get Methods for our example properties
172 //
173 
179  function setOnline($a_val)
180  {
181  $this->online = $a_val;
182  }
183 
189  function getOnline()
190  {
191  return $this->online;
192  }
193 
200  function setRootFolder($a_val,$no_check = false)
201  {
202  if($this->currentUserIsOwner() || $no_check || $this->getRootFolder() == null)
203  {
204  $a_val = ilCloudUtil::normalizePath($a_val);
205  $this->root_folder = $a_val;
206  }
207  else
208  {
210  }
211  }
212 
218  function getRootFolder()
219  {
220  return $this->root_folder;
221  }
222 
228  function setRootId($a_val,$no_check = false)
229  {
230  if ($this->currentUserIsOwner() || $no_check || $this->getRootId() == null)
231  {
232  $this->root_id = $a_val;
233  } else
234  {
236  }
237  }
238 
244  function getRootId()
245  {
246  return $this->root_id;
247  }
248 
254  function setServiceName($a_val)
255  {
256  $this->service_name = $a_val;
257  }
258 
264  function getServiceName()
265  {
266  return $this->service_name;
267  }
268 
272  public function setOwnerId($owner_id)
273  {
274  $this->owner_id = $owner_id;
275  }
276 
280  public function getOwnerId()
281  {
282  return $this->owner_id;
283  }
284 
288  public function currentUserIsOwner()
289  {
290  global $ilUser;
291  return $ilUser->getId() == $this->getOwnerId();
292  }
293 
298  {
299  $this->auth_complete = $auth_complete;
300  }
301 
305  public function getAuthComplete()
306  {
307  return $this->auth_complete;
308  }
309 }
310 ?>
__construct($a_ref_id=0, $a_reference=true)
Constructor.
getRootFolder()
Get root_folder.
doClone($a_target_id, $a_copy_id, $new_obj)
Do Cloning.
doRead()
Read data from db.
getRootId()
Get root_id.
const PERMISSION_TO_CHANGE_ROOT_FOLDER_DENIED
setServiceName($a_val)
Set service.
setOnline($a_val)
Set online.
getOnline()
Get online.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static getPluginClass($service_name, $obj_id)
setRootId($a_val, $no_check=false)
Set root_id.
setOwnerId($owner_id)
global $ilUser
Definition: imgupload.php:15
global $ilDB
setRootFolder($a_val, $no_check=false)
Set root_folder, this may only be changed by the owner of the object.
Class ilObjCloud.
Class ilObject2 This is an intermediate progress of ilObject class.
doCreate()
Create object.
doDelete()
Delete data from db.
Class ilCloudException.
static normalizePath($path)
getServiceName()
Get service.
doUpdate()
Update data.
setAuthComplete($auth_complete)