ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 $ilDB;
54 
55  $objId = $objDAV->getObjectId();
56  $nodeId = $objDAV->getNodeId();
57 
58  if(isset($value))
59  {
60  $ilDB->replace($this->table,
61  array(
62  'obj_id' => array('integer',$objId),
63  'node_id' => array('integer',$nodeId),
64  'ns' => array('text',$namespace),
65  'name' => array('text',$name)
66  ),
67  array('value' => array('clob',$value))
68  );
69 
70  /*
71  $q = 'REPLACE INTO '.$this->table
72  .' SET obj_id = '.$ilDB->quote($objId)
73  .', node_id = '.$ilDB->quote($nodeId)
74  .', ns = '.$ilDB->quote($namespace)
75  .', name = '.$ilDB->quote($name)
76  .', value = '.$ilDB->quote($value)
77  ;
78  */
79  }
80  else
81  {
82  $q = 'DELETE FROM '.$this->table
83  .' WHERE obj_id = '.$ilDB->quote($objId,'integer')
84  .' AND node_id = '.$ilDB->quote($nodeId,'integer')
85  .' AND ns = '.$ilDB->quote($namespace,'text')
86  .' AND name = '.$ilDB->quote($name,'text')
87  ;
88  $ilDB->manipulate($q);
89  }
90  //$this->writelog('put query='.$q);
91  #$r = $ilDB->query($q);
92  }
93 
102  public function get($objDAV, $namespace, $name, $value)
103  {
104  global $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(DB_FETCHMODE_ASSOC))
117  {
118  $value = $row['value'];
119  } else {
120  $value = null;
121  }
122  return $value;
123  }
131  public function getAll($objDAV)
132  {
133  global $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(DB_FETCHMODE_ASSOC))
146  {
147  $result[] = array(
148  'namespace' => $row['ns'],
149  'name' => $row['name'],
150  'value' => $row['value']
151  );
152  }
153  return $result;
154  }
155 
179  public function copy($fromObjDAV, $toObjDAV)
180  {
181  global $ilDB;
182 
183  $fromObjId = $fromObjDAV->getObjectId();
184  $fromNodeId = $fromObjDAV->getNodeId();
185  $toObjId = $toObjDAV->getObjectId();
186  $toNodeId = $toObjDAV->getNodeId();
187 
188  $q = 'SELECT ns, name, value FROM '.$this->table
189  .' WHERE obj_id = '.$ilDB->quote($objId,'integer')
190  .' AND node_id ='.$ilDB->quote($nodeId,'integer');
191 /* .' FOR UPDATE' */
192  $r = $ilDB->query($q);
193  $result = array();
194  while ($row = $r->fetchRow(DB_FETCHMODE_ASSOC))
195  {
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 $log, $ilias;
219  $log->write(
220  $ilias->account->getLogin()
221  .' DAV ilDAVProperties.'.str_replace("\n",";",$message)
222  );
223  /*
224  if ($this->logFile)
225  {
226  $fh = fopen($this->logFile, 'a');
227  fwrite($fh, date('Y-m-d h:i:s '));
228  fwrite($fh, str_replace("\n",";",$message));
229  fwrite($fh, "\n\n");
230  fclose($fh);
231  }*/
232  }
233 }
234 // END WebDAV
235 ?>