ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilWebDAVLockObject.php
Go to the documentation of this file.
1 <?php
2 
3 require_once('Services/ActiveRecord/Connector/class.arConnectorSession.php');
4 
13 {
26  {
27  $this->token = $token;
28  $this->obj_id = $obj_id;
29  $this->ilias_owner = $ilias_owner;
30  $this->dav_owner = $dav_owner;
31  $this->expires = $expires;
32  $this->depth = $depth;
33  $this->type = $type;
34  $this->scope = $scope;
35  }
36 
37  protected $token;
38  protected $obj_id;
39  protected $ilias_owner;
40  protected $dav_owner;
41  protected $expires;
42  protected $depth;
43  protected $type;
44  protected $scope;
45 
49  public function getToken()
50  {
51  return $this->token;
52  }
53 
57  public function getObjId()
58  {
59  return $this->obj_id;
60  }
61 
65  public function getIliasOwner()
66  {
67  return $this->ilias_owner;
68  }
69 
73  public function getDavOwner()
74  {
75  return $this->dav_owner;
76  }
77 
81  public function getExpires()
82  {
83  return $this->expires;
84  }
85 
89  public function getDepth()
90  {
91  return $this->depth;
92  }
93 
97  public function getType()
98  {
99  return $this->type;
100  }
101 
105  public function getScope()
106  {
107  return $this->scope;
108  }
109 
110  public static function createFromAssocArray($assoc_array)
111  {
112  return new ilWebDAVLockObject(
113  $assoc_array['token'],
114  $assoc_array['obj_id'],
115  $assoc_array['ilias_owner'],
116  $assoc_array['dav_owner'],
117  $assoc_array['expires'],
118  $assoc_array['depth'],
119  $assoc_array['type'],
120  $assoc_array['scope']
121  );
122  }
123 
132  public static function createFromSabreLock(Sabre\DAV\Locks\LockInfo $lock_info, $obj_id)
133  {
134  global $DIC;
135 
136  $ilias_lock = new ilWebDAVLockObject(
137  $lock_info->token, // token
138  $obj_id, // obj_id
139  $DIC->user()->getId(), // ilias_owner
140  $lock_info->owner, // dav_owner
141  time() + 360, // expires (hard coded like in the old webdav)
142  $lock_info->depth, // depth
143  'w', // type
144  $lock_info->scope
145  ); // scope
146 
147  return $ilias_lock;
148  }
149 
150  public function getAsSabreDavLock($uri)
151  {
152  global $DIC;
153 
154  $timestamp = time();
155 
156  $sabre_lock = new Sabre\DAV\Locks\LockInfo();
157  $sabre_lock->created;
158  $sabre_lock->depth = $this->depth;
159  $sabre_lock->owner = $this->dav_owner;
160  $sabre_lock->scope = $this->scope;
161  $sabre_lock->timeout = $this->expires - $timestamp;
162  $sabre_lock->created = $this->expires - 3600;
163  $sabre_lock->token = $this->token;
164  $sabre_lock->uri = $uri;
165 
166  return $sabre_lock;
167  }
168 }
Represents a lock on an ilias object.
global $DIC
Definition: saml.php:7
__construct($token, $obj_id, $ilias_owner, $dav_owner, $expires, $depth, $type, $scope)
static createFromAssocArray($assoc_array)
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81
static createFromSabreLock(Sabre\DAV\Locks\LockInfo $lock_info, $obj_id)
Creates an ILIAS lock object from a sabreDAV lock object.