• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/MetaData/classes/class.ilMDEntity.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00032 include_once 'class.ilMDBase.php';
00033 
00034 class ilMDEntity extends ilMDBase
00035 {
00036         function ilMDEntity($a_rbac_id = 0,$a_obj_id = 0,$a_obj_type = '')
00037         {
00038                 parent::ilMDBase($a_rbac_id,
00039                                                  $a_obj_id,
00040                                                  $a_obj_type);
00041         }
00042 
00043         // SET/GET
00044         function setEntity($a_entity)
00045         {
00046                 $this->entity = $a_entity;
00047         }
00048         function getEntity()
00049         {
00050                 return $this->entity;
00051         }
00052 
00053         function save()
00054         {
00055                 if($this->db->autoExecute('il_meta_entity',
00056                                                                   $this->__getFields(),
00057                                                                   DB_AUTOQUERY_INSERT))
00058                 {
00059                         $this->setMetaId($this->db->getLastInsertId());
00060 
00061                         return $this->getMetaId();
00062                 }
00063                 return false;
00064         }
00065 
00066         function update()
00067         {
00068                 if($this->getMetaId())
00069                 {
00070                         if($this->db->autoExecute('il_meta_entity',
00071                                                                           $this->__getFields(),
00072                                                                           DB_AUTOQUERY_UPDATE,
00073                                                                           "meta_entity_id = '".$this->getMetaId()."'"))
00074                         {
00075                                 return true;
00076                         }
00077                 }
00078                 return false;
00079         }
00080 
00081         function delete()
00082         {
00083                 if($this->getMetaId())
00084                 {
00085                         $query = "DELETE FROM il_meta_entity ".
00086                                 "WHERE meta_entity_id = '".$this->getMetaId()."'";
00087                         
00088                         $this->db->query($query);
00089                         
00090                         return true;
00091                 }
00092                 return false;
00093         }
00094                         
00095 
00096         function __getFields()
00097         {
00098                 return array('rbac_id'  => $this->getRBACId(),
00099                                          'obj_id'       => $this->getObjId(),
00100                                          'obj_type'     => $this->getObjType(),
00101                                          'parent_type' => $this->getParentType(),
00102                                          'parent_id' => $this->getParentId(),
00103                                          'entity'       => $this->getEntity());
00104         }
00105 
00106         function read()
00107         {
00108                 if($this->getMetaId())
00109                 {
00110                         $query = "SELECT * FROM il_meta_entity ".
00111                                 "WHERE meta_entity_id = '".$this->getMetaId()."'";
00112 
00113                         $res = $this->db->query($query);
00114                         while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00115                         {
00116                                 $this->setRBACId($row->rbac_id);
00117                                 $this->setObjId($row->obj_id);
00118                                 $this->setObjType($row->obj_type);
00119                                 $this->setParentId($row->parent_id);
00120                                 $this->setParentType($row->parent_type);
00121                                 $this->setEntity($row->entity);
00122                         }
00123                 }
00124                 return true;
00125         }
00126                                 
00127         /*
00128          * XML Export of all meta data
00129          * @param object (xml writer) see class.ilMD2XML.php
00130          * 
00131          */
00132         function toXML(&$writer)
00133         {
00134                 $writer->xmlElement('Entity',null,$this->getEntity());
00135         }
00136 
00137 
00138         // STATIC
00139         function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
00140         {
00141                 global $ilDB;
00142 
00143                 $query = "SELECT meta_entity_id FROM il_meta_entity ".
00144                         "WHERE rbac_id = '".$a_rbac_id."' ".
00145                         "AND obj_id = '".$a_obj_id."' ".
00146                         "AND parent_id = '".$a_parent_id."' ".
00147                         "AND parent_type = '".$a_parent_type."' ".
00148                         "ORDER BY meta_entity_id ";
00149 
00150                 $res = $ilDB->query($query);
00151                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00152                 {
00153                         $ids[] = $row->meta_entity_id;
00154                 }
00155                 return $ids ? $ids : array();
00156         }
00157 }
00158 ?>

Generated on Fri Dec 13 2013 13:52:11 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1