ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilDAVProperties.php
Go to the documentation of this file.
1 <?php
2 // BEGIN WebDAV
3 /*
4  +-----------------------------------------------------------------------------+
5  | ILIAS open source |
6  +-----------------------------------------------------------------------------+
7  | Copyright (c) 1998-2005 ILIAS open source, University of Cologne |
8  | |
9  | This program is free software; you can redistribute it and/or |
10  | modify it under the terms of the GNU General Public License |
11  | as published by the Free Software Foundation; either version 2 |
12  | of the License, or (at your option) any later version. |
13  | |
14  | This program is distributed in the hope that it will be useful, |
15  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17  | GNU General Public License for more details. |
18  | |
19  | You should have received a copy of the GNU General Public License |
20  | along with this program; if not, write to the Free Software |
21  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22  +-----------------------------------------------------------------------------+
23 */
24 
25 
38 {
39  private $table = 'dav_property';
40 
41 
50  public function put($objDAV, $namespace, $name, $value)
51  {
52  //$this->writelog('put ns='.$namespace.' name='.$name.' value='.$value);
53  global $DIC;
54  $ilDB = $DIC['ilDB'];
55 
56  $objId = $objDAV->getObjectId();
57  $nodeId = $objDAV->getNodeId();
58 
59  if (isset($value)) {
60  $ilDB->replace(
61  $this->table,
62  array(
63  'obj_id' => array('integer',$objId),
64  'node_id' => array('integer',$nodeId),
65  'ns' => array('text',$namespace),
66  'name' => array('text',$name)
67  ),
68  array('value' => array('clob',$value))
69  );
70 
71  /*
72  $q = 'REPLACE INTO '.$this->table
73  .' SET obj_id = '.$ilDB->quote($objId)
74  .', node_id = '.$ilDB->quote($nodeId)
75  .', ns = '.$ilDB->quote($namespace)
76  .', name = '.$ilDB->quote($name)
77  .', value = '.$ilDB->quote($value)
78  ;
79  */
80  } else {
81  $q = 'DELETE FROM ' . $this->table
82  . ' WHERE obj_id = ' . $ilDB->quote($objId, 'integer')
83  . ' AND node_id = ' . $ilDB->quote($nodeId, 'integer')
84  . ' AND ns = ' . $ilDB->quote($namespace, 'text')
85  . ' AND name = ' . $ilDB->quote($name, 'text')
86  ;
87  $ilDB->manipulate($q);
88  }
89  //$this->writelog('put query='.$q);
90  #$r = $ilDB->query($q);
91  }
92 
101  public function get($objDAV, $namespace, $name, $value)
102  {
103  global $DIC;
104  $ilDB = $DIC['ilDB'];
105 
106  $objId = $objDAV->getObjectId();
107  $nodeId = $objDAV->getNodeId();
108 
109  $q = 'SELECT value FROM ' . $this->table
110  . ' WHERE obj_id = ' . $ilDB->quote($objId, 'integer')
111  . ' AND node_id =' . $ilDB->quote($nodeId, 'integer')
112  . ' AND ns = ' . $ilDB->quote($namespace, 'text')
113  . ' AND name = ' . $ilDB->quote($name, 'text')
114  ;
115  $r = $ilDB->query($q);
116  if ($row = $r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
117  $value = $row['value'];
118  } else {
119  $value = null;
120  }
121  return $value;
122  }
130  public function getAll($objDAV)
131  {
132  global $DIC;
133  $ilDB = $DIC['ilDB'];
134 
135  $objId = $objDAV->getObjectId();
136  $nodeId = $objDAV->getNodeId();
137 
138  $q = 'SELECT ns, name, value'
139  . ' FROM ' . $this->table
140  . ' WHERE obj_id = ' . $ilDB->quote($objId, 'integer')
141  . ' AND node_id =' . $ilDB->quote($nodeId, 'integer')
142  ;
143  $r = $ilDB->query($q);
144  $result = array();
145  while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
146  $result[] = array(
147  'namespace' => $row['ns'],
148  'name' => $row['name'],
149  'value' => $row['value']
150  );
151  }
152  return $result;
153  }
154 
179  public function copy($fromObjDAV, $toObjDAV)
180  {
181  global $DIC;
182  $ilDB = $DIC['ilDB'];
183 
184  $fromObjId = $fromObjDAV->getObjectId();
185  $fromNodeId = $fromObjDAV->getNodeId();
186  $toObjId = $toObjDAV->getObjectId();
187  $toNodeId = $toObjDAV->getNodeId();
188 
189  $q = 'SELECT ns, name, value FROM ' . $this->table
190  . ' WHERE obj_id = ' . $ilDB->quote($objId, 'integer')
191  . ' AND node_id =' . $ilDB->quote($nodeId, 'integer');
192  /* .' FOR UPDATE' */
193  $r = $ilDB->query($q);
194  $result = array();
195  while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
196  $q2 = 'INSERT INTO ' . $this->table
197  . ' (obj_id, node_id, ns, name, value)'
198  . ' VALUES'
199  . '(' . $ilDB->quote($row['obj_id'])
200  . ', ' . $ilDB->quote($row['node_id'])
201  . ', ' . $ilDB->quote($row['ns'])
202  . ', ' . $ilDB->quote($row['name'])
203  . ', ' . $ilDB->quote($row['value'])
204  . ')'
205  ;
206  $r2 = $ilDB->manipulate($q2);
207  }
208  }
209 
216  protected function writelog($message)
217  {
218  global $DIC;
219  $log = $DIC['log'];
220  $ilias = $DIC['ilias'];
221  $log->write(
222  $ilias->account->getLogin()
223  . ' DAV ilDAVProperties.' . str_replace("\n", ";", $message)
224  );
225  /*
226  if ($this->logFile)
227  {
228  $fh = fopen($this->logFile, 'a');
229  fwrite($fh, date('Y-m-d h:i:s '));
230  fwrite($fh, str_replace("\n",";",$message));
231  fwrite($fh, "\n\n");
232  fclose($fh);
233  }*/
234  }
235 }
236 // END WebDAV
if($err=$client->getError()) $namespace
writelog($message)
Writes a message to the logfile.,.
$result
global $DIC
Definition: saml.php:7
getAll($objDAV)
Gets all properties from the specified DAV object.
put($objDAV, $namespace, $name, $value)
Puts a property for the specified DAV object.
if($format !==null) $name
Definition: metadata.php:146
$r
Definition: example_031.php:79
catch(Exception $e) $message
copy($fromObjDAV, $toObjDAV)
Moves all properties from one dav object to another.
Create styles array
The data for the language used.
global $ilDB