ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
61  $ilDB->replace($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  }
81  else
82  {
83  $q = 'DELETE FROM '.$this->table
84  .' WHERE obj_id = '.$ilDB->quote($objId,'integer')
85  .' AND node_id = '.$ilDB->quote($nodeId,'integer')
86  .' AND ns = '.$ilDB->quote($namespace,'text')
87  .' AND name = '.$ilDB->quote($name,'text')
88  ;
89  $ilDB->manipulate($q);
90  }
91  //$this->writelog('put query='.$q);
92  #$r = $ilDB->query($q);
93  }
94 
103  public function get($objDAV, $namespace, $name, $value)
104  {
105  global $DIC;
106  $ilDB = $DIC['ilDB'];
107 
108  $objId = $objDAV->getObjectId();
109  $nodeId = $objDAV->getNodeId();
110 
111  $q = 'SELECT value FROM '.$this->table
112  .' WHERE obj_id = '.$ilDB->quote($objId,'integer')
113  .' AND node_id ='.$ilDB->quote($nodeId,'integer')
114  .' AND ns = '.$ilDB->quote($namespace,'text')
115  .' AND name = '.$ilDB->quote($name,'text')
116  ;
117  $r = $ilDB->query($q);
118  if ($row = $r->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
119  {
120  $value = $row['value'];
121  } else {
122  $value = null;
123  }
124  return $value;
125  }
133  public function getAll($objDAV)
134  {
135  global $DIC;
136  $ilDB = $DIC['ilDB'];
137 
138  $objId = $objDAV->getObjectId();
139  $nodeId = $objDAV->getNodeId();
140 
141  $q = 'SELECT ns, name, value'
142  .' FROM '.$this->table
143  .' WHERE obj_id = '.$ilDB->quote($objId,'integer')
144  .' AND node_id ='.$ilDB->quote($nodeId,'integer')
145  ;
146  $r = $ilDB->query($q);
147  $result = array();
148  while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
149  {
150  $result[] = array(
151  'namespace' => $row['ns'],
152  'name' => $row['name'],
153  'value' => $row['value']
154  );
155  }
156  return $result;
157  }
158 
183  public function copy($fromObjDAV, $toObjDAV)
184  {
185  global $DIC;
186  $ilDB = $DIC['ilDB'];
187 
188  $fromObjId = $fromObjDAV->getObjectId();
189  $fromNodeId = $fromObjDAV->getNodeId();
190  $toObjId = $toObjDAV->getObjectId();
191  $toNodeId = $toObjDAV->getNodeId();
192 
193  $q = 'SELECT ns, name, value FROM '.$this->table
194  .' WHERE obj_id = '.$ilDB->quote($objId,'integer')
195  .' AND node_id ='.$ilDB->quote($nodeId,'integer');
196 /* .' FOR UPDATE' */
197  $r = $ilDB->query($q);
198  $result = array();
199  while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
200  {
201  $q2 = 'INSERT INTO '.$this->table
202  .' (obj_id, node_id, ns, name, value)'
203  .' VALUES'
204  .'('.$ilDB->quote($row['obj_id'])
205  .', '.$ilDB->quote($row['node_id'])
206  .', '.$ilDB->quote($row['ns'])
207  .', '.$ilDB->quote($row['name'])
208  .', '.$ilDB->quote($row['value'])
209  .')'
210  ;
211  $r2 = $ilDB->manipulate($q2);
212  }
213  }
214 
221  protected function writelog($message)
222  {
223  global $DIC;
224  $log = $DIC['log'];
225  $ilias = $DIC['ilias'];
226  $log->write(
227  $ilias->account->getLogin()
228  .' DAV ilDAVProperties.'.str_replace("\n",";",$message)
229  );
230  /*
231  if ($this->logFile)
232  {
233  $fh = fopen($this->logFile, 'a');
234  fwrite($fh, date('Y-m-d h:i:s '));
235  fwrite($fh, str_replace("\n",";",$message));
236  fwrite($fh, "\n\n");
237  fclose($fh);
238  }*/
239  }
240 }
241 // END WebDAV
242 ?>
if($err=$client->getError()) $namespace
writelog($message)
Writes a message to the logfile.,.
$result
getAll($objDAV)
Gets all properties from the specified DAV object.
put($objDAV, $namespace, $name, $value)
Puts a property for the specified DAV object.
$r
Definition: example_031.php:79
copy($fromObjDAV, $toObjDAV)
Moves all properties from one dav object to another.
Create styles array
The data for the language used.
global $ilDB
global $DIC