ILIAS  Release_3_10_x_branch Revision 61812
 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  $q = 'REPLACE INTO '.$this->table
60  .' SET obj_id = '.$ilDB->quote($objId)
61  .', node_id = '.$ilDB->quote($nodeId)
62  .', ns = '.$ilDB->quote($namespace)
63  .', name = '.$ilDB->quote($name)
64  .', value = '.$ilDB->quote($value)
65  ;
66  } else {
67  $q = 'DELETE FROM '.$this->table
68  .' WHERE obj_id = '.$ilDB->quote($objId)
69  .' AND node_id = '.$ilDB->quote($nodeId)
70  .' AND ns = '.$ilDB->quote($namespace)
71  .' AND name = '.$ilDB->quote($name)
72  ;
73  }
74  //$this->writelog('put query='.$q);
75  $r = $ilDB->query($q);
76  }
77 
86  public function get($objDAV, $namespace, $name, $value)
87  {
88  global $ilDB;
89 
90  $objId = $objDAV->getObjectId();
91  $nodeId = $objDAV->getNodeId();
92 
93  $q = 'SELECT value FROM '.$this->table
94  .' WHERE obj_id = '.$ilDB->quote($objId)
95  .' AND node_id ='.$ilDB->quote($nodeId)
96  .' AND ns = '.$ilDB->quote($namespace)
97  .' AND name = '.$ilDB->quote($name)
98  ;
99  $r = $ilDB->query($q);
100  if ($row = $r->fetchRow(DB_FETCHMODE_ASSOC))
101  {
102  $value = $row['value'];
103  } else {
104  $value = null;
105  }
106  return $value;
107  }
115  public function getAll($objDAV)
116  {
117  global $ilDB;
118 
119  $objId = $objDAV->getObjectId();
120  $nodeId = $objDAV->getNodeId();
121 
122  $q = 'SELECT ns, name, value'
123  .' FROM '.$this->table
124  .' WHERE obj_id = '.$ilDB->quote($objId)
125  .' AND node_id ='.$ilDB->quote($nodeId)
126  ;
127  $r = $ilDB->query($q);
128  $result = array();
129  while ($row = $r->fetchRow(DB_FETCHMODE_ASSOC))
130  {
131  $result[] = array(
132  'namespace' => $row['ns'],
133  'name' => $row['name'],
134  'value' => $row['value']
135  );
136  }
137  return $result;
138  }
139 
163  public function copy($fromObjDAV, $toObjDAV)
164  {
165  global $ilDB;
166 
167  $fromObjId = $fromObjDAV->getObjectId();
168  $fromNodeId = $fromObjDAV->getNodeId();
169  $toObjId = $toObjDAV->getObjectId();
170  $toNodeId = $toObjDAV->getNodeId();
171 
172  $q = 'SELECT ns, name, value FROM '.$this->table
173  .' WHERE obj_id = '.$ilDB->quote($objId)
174  .' AND node_id ='.$ilDB->quote($nodeId)
175  .' FOR UPDATE'
176  ;
177  $r = $ilDB->query($q);
178  $result = array();
179  while ($row = $r->fetchRow(DB_FETCHMODE_ASSOC))
180  {
181  $q2 = 'INSERT INTO '.$this->table
182  .' (obj_id, node_id, ns, name, value)'
183  .' VALUES'
184  .'('.$ilDB->quote($row['obj_id'])
185  .', '.$ilDB->quote($row['node_id'])
186  .', '.$ilDB->quote($row['ns'])
187  .', '.$ilDB->quote($row['name'])
188  .', '.$ilDB->quote($row['value'])
189  .')'
190  ;
191  $r2 = $ilDB->query($q2);
192  }
193  }
194 
201  protected function writelog($message)
202  {
203  global $log, $ilias;
204  $log->write(
205  $ilias->account->getLogin()
206  .' DAV ilDAVProperties.'.str_replace("\n",";",$message)
207  );
208  /*
209  if ($this->logFile)
210  {
211  $fh = fopen($this->logFile, 'a');
212  fwrite($fh, date('Y-m-d h:i:s '));
213  fwrite($fh, str_replace("\n",";",$message));
214  fwrite($fh, "\n\n");
215  fclose($fh);
216  }*/
217  }
218 }
219 // END WebDAV
220 ?>