ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilWebDAVDBManager.php
Go to the documentation of this file.
1<?php
2
13{
17 protected $db;
18
19 private $lock_table = 'dav_lock';
20
21 public function __construct($db)
22 {
23 $this->db = $db;
24 }
25
27 {
28 $select_query = "SELECT count(*) AS cnt FROM $this->locks_table WHERE token = " . $this->db->quote($token, 'text');
29 $select_result = $this->db->query($select_query);
30 $row = $this->db->fetchAssoc($select_result);
31 if (isset($row)) {
32 return true;
33 }
34 return false;
35 }
36
43 {
44 $query = "SELECT * FROM $this->lock_table"
45 . " WHERE token = " . $this->db->quote($token, 'text')
46 . " AND expires > " . $this->db->quote(time(), 'integer');
47
48 $select_result = $this->db->query($query);
49 $row = $this->db->fetchAssoc($select_result);
50
51 if ($row) {
53 }
54
55 return false;
56 }
57
58 public function getLockObjectWithObjIdFromDB($obj_id)
59 {
60 $query = "SELECT * FROM $this->lock_table WHERE obj_id = "
61 . $this->db->quote($obj_id, 'integer')
62 . " AND expires > " . $this->db->quote(time(), 'integer');
63 $select_result = $this->db->query($query);
64 $row = $this->db->fetchAssoc($select_result);
65
66 if ($row) {
68 }
69
70 return false;
71 }
72
73 public function saveLockToDB(ilWebDAVLockObject $ilias_lock)
74 {
75 $this->db->insert($this->lock_table, array(
76 'token' => array('text', $ilias_lock->getToken()),
77 'obj_id' => array('integer', $ilias_lock->getObjId()),
78 'ilias_owner' => array('integer', $ilias_lock->getIliasOwner()),
79 'dav_owner' => array('text', $ilias_lock->getDavOwner()),
80 'expires' => array('integer', $ilias_lock->getExpires()),
81 'depth' => array('integer', $ilias_lock->getDepth()),
82 'type' => array('text', $ilias_lock->getType()),
83 'scope' => array('integer', $ilias_lock->getScope())
84 ));
85 }
86
94 {
95 return $this->db->manipulate("DELETE FROM $this->lock_table WHERE token = " . $this->db->quote($token, "integer"));
96 }
97
103 public function purgeExpiredLocksFromDB()
104 {
105 return $this->db->manipulate("DELETE FROM $this->lock_table WHERE expires < " . $this->db->quote(time(), 'integer'));
106 }
107}
An exception for terminatinating execution or to throw for unit testing.
Class ilWebDAVDBManager.
getLockObjectWithTokenFromDB($token)
Returns lock Object from given tocken.
removeLockWithTokenFromDB($token)
Removes one specific lock.
purgeExpiredLocksFromDB()
Removes all locks from DB that are expired (expires < time())
saveLockToDB(ilWebDAVLockObject $ilias_lock)
Represents a lock on an ilias object.
static createFromAssocArray($assoc_array)
$query
$token
Definition: xapitoken.php:52