ILIAS  release_7 Revision v7.30-3-g800a261c036
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
4include_once("./Services/Repository/classes/class.ilObjectPlugin.php");
5include_once("class.ilCloudUtil.php");
6include_once("class.ilCloudConnector.php");
7
16class ilObjCloud extends ilObject2
17{
18
22 protected $online = false;
26 protected $service = "";
30 protected $root_folder = "";
34 protected $owner_id = 0;
38 protected $auth_complete = false;
39
40
46 public function __construct($a_ref_id = 0, $a_reference = true)
47 {
48 parent::__construct($a_ref_id, $a_reference);
49 }
50
51
52 /*
53 * initType
54 */
55 public function initType()
56 {
57 $this->type = "cld";
58 }
59
60
64 public function doCreate()
65 {
66 global $DIC;
67 $ilDB = $DIC['ilDB'];
68 $ilUser = $DIC['ilUser'];
69
74 $this->setOwnerId($ilUser->getId());
75 $ilDB->manipulate("INSERT INTO il_cld_data " .
76 "(id, is_online, service, root_folder, root_id, owner_id, auth_complete) VALUES (" .
77 $ilDB->quote($this->getId(), "integer") . "," .
78 $ilDB->quote("", "integer") . "," .
79 $ilDB->quote("", "text") . "," .
80 $ilDB->quote("", "text") . "," .
81 $ilDB->quote("", "text") . "," .
82 $ilDB->quote($this->getOwnerId(), "integer") . "," .
83 $ilDB->quote("", "integer") .
84 ")");
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
109
113 public function doUpdate()
114 {
115 global $DIC;
116 $ilDB = $DIC['ilDB'];
117
118 $ilDB->manipulate(
119 $up = "UPDATE il_cld_data SET " .
120 " is_online = " . $ilDB->quote($this->getOnline(), "integer") . "," .
121 " service = " . $ilDB->quote($this->getServiceName(), "text") . "," .
122 " root_folder = " . $ilDB->quote($this->getRootFolder(), "text") . "," .
123 " root_id = " . $ilDB->quote($this->getRootId(), "text") . "," .
124 " owner_id = " . $ilDB->quote($this->getOwnerId(), "integer") . "," .
125 " auth_complete = " . $ilDB->quote($this->getAuthComplete(), "integer") .
126 " WHERE id = " . $ilDB->quote($this->getId(), "integer")
127 );
128 }
129
130
134 public function doDelete()
135 {
136 global $DIC;
137 $ilDB = $DIC['ilDB'];
138
139 if ($this->getServiceName() != null) {
140 $plugin_class = ilCloudConnector::getPluginClass($this->getServiceName(), $this->getId());
141 if ($plugin_class) {
142 $plugin_class->doDelete($this->getId());
143 }
144 }
145
146 $ilDB->manipulate(
147 "DELETE FROM il_cld_data WHERE " .
148 " id = " . $ilDB->quote($this->getId(), "integer")
149 );
150 }
151
152
156 public function doClone($a_target_id, $a_copy_id, $new_obj)
157 {
158 global $DIC;
159 $ilDB = $DIC['ilDB'];
160
161 //copy online status if object is not the root copy object
162 $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
163
164 if (!$cp_options->isRootNode($this->getRefId())) {
165 $new_obj->setOnline($this->getOnline());
166 }
167
168 $new_obj->setRootFolder($this->getRootFolder());
169 $new_obj->getRootId($this->getRootId());
170 $new_obj->setServiceName($this->getServiceName());
171 $new_obj->serOwnerId($this->getOwnerId());
172 $new_obj->setAuthComplete($this->getAuthComplete());
173 $new_obj->update();
174 }
175
176 //
177 // Set/Get Methods for our example properties
178 //
179
185 public function setOnline($a_val)
186 {
187 $this->online = $a_val;
188 }
189
190
196 public function getOnline()
197 {
198 return $this->online;
199 }
200
201
208 public function setRootFolder($a_val, $no_check = false)
209 {
210 if ($this->currentUserIsOwner() || $no_check || $this->getRootFolder() == null) {
211 $a_val = ilCloudUtil::normalizePath($a_val);
212 $this->root_folder = $a_val;
213 } else {
215 }
216 }
217
218
224 public function getRootFolder()
225 {
226 return $this->root_folder;
227 }
228
229
235 public function setRootId($a_val, $no_check = false)
236 {
237 if ($this->currentUserIsOwner() || $no_check || $this->getRootId() == null) {
238 $this->root_id = $a_val;
239 } else {
241 }
242 }
243
244
250 public function getRootId()
251 {
252 return $this->root_id;
253 }
254
255
261 public function setServiceName($a_val)
262 {
263 $this->service_name = $a_val;
264 }
265
266
272 public function getServiceName()
273 {
274 return $this->service_name;
275 }
276
277
281 public function setOwnerId($owner_id)
282 {
283 $this->owner_id = $owner_id;
284 }
285
286
290 public function getOwnerId()
291 {
292 return $this->owner_id;
293 }
294
295
299 public function currentUserIsOwner()
300 {
301 global $DIC;
302 $ilUser = $DIC['ilUser'];
303
304 return $ilUser->getId() == $this->getOwnerId();
305 }
306
307
312 {
313 $this->auth_complete = $auth_complete;
314 }
315
316
320 public function getAuthComplete()
321 {
323 }
324}
An exception for terminatinating execution or to throw for unit testing.
static getPluginClass($service_name, $obj_id)
Class ilCloudException.
const PERMISSION_TO_CHANGE_ROOT_FOLDER_DENIED
static normalizePath($path)
static _getInstance($a_copy_id)
Get instance of copy wizard options.
Class ilObjCloud.
setRootId($a_val, $no_check=false)
Set root_id.
doUpdate()
Update data.
setServiceName($a_val)
Set service.
getServiceName()
Get service.
getOnline()
Get online.
doDelete()
Delete data from db.
setAuthComplete($auth_complete)
getRootId()
Get root_id.
setOwnerId($owner_id)
doClone($a_target_id, $a_copy_id, $new_obj)
Do Cloning.
doRead()
Read data from db.
setRootFolder($a_val, $no_check=false)
Set root_folder, this may only be changed by the owner of the object.
__construct($a_ref_id=0, $a_reference=true)
Constructor.
getRootFolder()
Get root_folder.
setOnline($a_val)
Set online.
doCreate()
Create object.
Class ilObject2 This is an intermediate progress of ilObject class.
getId()
get object id @access public
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilDB