ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  public 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  public function doCreate()
66  {
67  global $DIC;
68  $ilDB = $DIC['ilDB'];
69  $ilUser = $DIC['ilUser'];
70 
75  $this->setOwnerId($ilUser->getId());
76  $ilDB->manipulate("INSERT INTO il_cld_data " .
77  "(id, is_online, service, root_folder, root_id, owner_id, auth_complete) VALUES (" .
78  $ilDB->quote($this->getId(), "integer") . "," .
79  $ilDB->quote("", "integer") . "," .
80  $ilDB->quote("", "text") . "," .
81  $ilDB->quote("", "text") . "," .
82  $ilDB->quote("", "text") . "," .
83  $ilDB->quote($this->getOwnerId(), "integer") . "," .
84  $ilDB->quote("", "integer") .
85  ")");
86  }
87 
91  public function doRead()
92  {
93  global $DIC;
94  $ilDB = $DIC['ilDB'];
95 
96  $set = $ilDB->query("SELECT * FROM il_cld_data " .
97  " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
98 
99  while ($rec = $ilDB->fetchAssoc($set)) {
100  $this->setOnline($rec["is_online"]);
101  $this->setRootFolder($rec["root_folder"]);
102  $this->setRootId($rec["root_id"]);
103  $this->setServiceName($rec["service"]);
104  $this->setOwnerId($rec["owner_id"]);
105  $this->setAuthComplete($rec["auth_complete"]);
106  }
107  }
108 
112  public function doUpdate()
113  {
114  global $DIC;
115  $ilDB = $DIC['ilDB'];
116 
117  $ilDB->manipulate(
118  $up = "UPDATE il_cld_data SET " .
119  " is_online = " . $ilDB->quote($this->getOnline(), "integer") . "," .
120  " service = " . $ilDB->quote($this->getServiceName(), "text") . "," .
121  " root_folder = " . $ilDB->quote($this->getRootFolder(), "text") . "," .
122  " root_id = " . $ilDB->quote($this->getRootId(), "text") . "," .
123  " owner_id = " . $ilDB->quote($this->getOwnerId(), "integer") . "," .
124  " auth_complete = " . $ilDB->quote($this->getAuthComplete(), "integer") .
125  " WHERE id = " . $ilDB->quote($this->getId(), "integer")
126  );
127  }
128 
132  public function doDelete()
133  {
134  global $DIC;
135  $ilDB = $DIC['ilDB'];
136 
137  if ($this->getServiceName() != null) {
138  $plugin_class = ilCloudConnector::getPluginClass($this->getServiceName(), $this->getId());
139  if ($plugin_class) {
140  $plugin_class->doDelete($this->getId());
141  }
142  }
143 
144  $ilDB->manipulate(
145  "DELETE FROM il_cld_data WHERE " .
146  " id = " . $ilDB->quote($this->getId(), "integer")
147  );
148  }
149 
153  public function doClone($a_target_id, $a_copy_id, $new_obj)
154  {
155  global $DIC;
156  $ilDB = $DIC['ilDB'];
157 
158  //copy online status if object is not the root copy object
159  $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
160 
161  if (!$cp_options->isRootNode($this->getRefId())) {
162  $new_obj->setOnline($this->getOnline());
163  }
164 
165  $new_obj->setRootFolder($this->getRootFolder());
166  $new_obj->getRootId($this->getRootId());
167  $new_obj->setServiceName($this->getServiceName());
168  $new_obj->serOwnerId($this->getOwnerId());
169  $new_obj->setAuthComplete($this->getAuthComplete());
170  $new_obj->update();
171  }
172 
173 //
174  // Set/Get Methods for our example properties
175 //
176 
182  public function setOnline($a_val)
183  {
184  $this->online = $a_val;
185  }
186 
192  public function getOnline()
193  {
194  return $this->online;
195  }
196 
203  public function setRootFolder($a_val, $no_check = false)
204  {
205  if ($this->currentUserIsOwner() || $no_check || $this->getRootFolder() == null) {
206  $a_val = ilCloudUtil::normalizePath($a_val);
207  $this->root_folder = $a_val;
208  } else {
210  }
211  }
212 
218  public function getRootFolder()
219  {
220  return $this->root_folder;
221  }
222 
228  public function setRootId($a_val, $no_check = false)
229  {
230  if ($this->currentUserIsOwner() || $no_check || $this->getRootId() == null) {
231  $this->root_id = $a_val;
232  } else {
234  }
235  }
236 
242  public function getRootId()
243  {
244  return $this->root_id;
245  }
246 
252  public function setServiceName($a_val)
253  {
254  $this->service_name = $a_val;
255  }
256 
262  public function getServiceName()
263  {
264  return $this->service_name;
265  }
266 
270  public function setOwnerId($owner_id)
271  {
272  $this->owner_id = $owner_id;
273  }
274 
278  public function getOwnerId()
279  {
280  return $this->owner_id;
281  }
282 
286  public function currentUserIsOwner()
287  {
288  global $DIC;
289  $ilUser = $DIC['ilUser'];
290  return $ilUser->getId() == $this->getOwnerId();
291  }
292 
297  {
298  $this->auth_complete = $auth_complete;
299  }
300 
304  public function getAuthComplete()
305  {
306  return $this->auth_complete;
307  }
308 }
__construct($a_ref_id=0, $a_reference=true)
Constructor.
global $DIC
Definition: saml.php:7
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)
$ilUser
Definition: imgupload.php:18
setRootId($a_val, $no_check=false)
Set root_id.
setOwnerId($owner_id)
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)