ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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{
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 $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 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 {
101 $this->setOnline($rec["is_online"]);
102 $this->setRootFolder($rec["root_folder"]);
103 $this->setRootId($rec["root_id"]);
104 $this->setServiceName($rec["service"]);
105 $this->setOwnerId($rec["owner_id"]);
106 $this->setAuthComplete($rec["auth_complete"]);
107 }
108 }
109
113 function doUpdate()
114 {
115 global $DIC;
116 $ilDB = $DIC['ilDB'];
117
118 $ilDB->manipulate($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 function doDelete()
133 {
134 global $DIC;
135 $ilDB = $DIC['ilDB'];
136
137 if ($this->getServiceName() != null)
138 {
139 $plugin_class = ilCloudConnector::getPluginClass($this->getServiceName(), $this->getId());
140 if ($plugin_class)
141 {
142 $plugin_class->doDelete($this->getId());
143 }
144 }
145
146 $ilDB->manipulate("DELETE FROM il_cld_data WHERE " .
147 " id = " . $ilDB->quote($this->getId(), "integer")
148 );
149
150 }
151
155 function doClone($a_target_id, $a_copy_id, $new_obj)
156 {
157 global $DIC;
158 $ilDB = $DIC['ilDB'];
159
160 //copy online status if object is not the root copy object
161 $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
162
163 if(!$cp_options->isRootNode($this->getRefId()))
164 {
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 function setOnline($a_val)
186 {
187 $this->online = $a_val;
188 }
189
195 function getOnline()
196 {
197 return $this->online;
198 }
199
206 function setRootFolder($a_val,$no_check = false)
207 {
208 if($this->currentUserIsOwner() || $no_check || $this->getRootFolder() == null)
209 {
210 $a_val = ilCloudUtil::normalizePath($a_val);
211 $this->root_folder = $a_val;
212 }
213 else
214 {
216 }
217 }
218
224 function getRootFolder()
225 {
226 return $this->root_folder;
227 }
228
234 function setRootId($a_val,$no_check = false)
235 {
236 if ($this->currentUserIsOwner() || $no_check || $this->getRootId() == null)
237 {
238 $this->root_id = $a_val;
239 } else
240 {
242 }
243 }
244
250 function getRootId()
251 {
252 return $this->root_id;
253 }
254
260 function setServiceName($a_val)
261 {
262 $this->service_name = $a_val;
263 }
264
270 function getServiceName()
271 {
272 return $this->service_name;
273 }
274
278 public function setOwnerId($owner_id)
279 {
280 $this->owner_id = $owner_id;
281 }
282
286 public function getOwnerId()
287 {
288 return $this->owner_id;
289 }
290
294 public function currentUserIsOwner()
295 {
296 global $DIC;
297 $ilUser = $DIC['ilUser'];
298 return $ilUser->getId() == $this->getOwnerId();
299 }
300
305 {
306 $this->auth_complete = $auth_complete;
307 }
308
312 public function getAuthComplete()
313 {
315 }
316}
317?>
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 $ilDB
global $DIC
$ilUser
Definition: imgupload.php:18