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

Services/Block/classes/class.ilCustomBlock.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 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 
00031 class ilCustomBlock 
00032 {
00033 
00034         protected $id;
00035         protected $context_obj_id;
00036         protected $context_obj_type;
00037         protected $context_sub_obj_id;
00038         protected $context_sub_obj_type;
00039         protected $type;
00040         protected $title;
00041 
00047         public function __construct($a_id = 0)
00048         {
00049                 if ($a_id > 0)
00050                 {
00051                         $this->setId($a_id);
00052                         $this->read();
00053                 }
00054 
00055         }
00056 
00062         public function setId($a_id)
00063         {
00064                 $this->id = $a_id;
00065         }
00066 
00072         public function getId()
00073         {
00074                 return $this->id;
00075         }
00076 
00082         public function setContextObjId($a_context_obj_id)
00083         {
00084                 $this->context_obj_id = $a_context_obj_id;
00085         }
00086 
00092         public function getContextObjId()
00093         {
00094                 return $this->context_obj_id;
00095         }
00096 
00102         public function setContextObjType($a_context_obj_type)
00103         {
00104                 $this->context_obj_type = $a_context_obj_type;
00105         }
00106 
00112         public function getContextObjType()
00113         {
00114                 return $this->context_obj_type;
00115         }
00116 
00122         public function setContextSubObjId($a_context_sub_obj_id)
00123         {
00124                 $this->context_sub_obj_id = $a_context_sub_obj_id;
00125         }
00126 
00132         public function getContextSubObjId()
00133         {
00134                 return $this->context_sub_obj_id;
00135         }
00136 
00142         public function setContextSubObjType($a_context_sub_obj_type)
00143         {
00144                 $this->context_sub_obj_type = $a_context_sub_obj_type;
00145         }
00146 
00152         public function getContextSubObjType()
00153         {
00154                 return $this->context_sub_obj_type;
00155         }
00156 
00162         public function setType($a_type)
00163         {
00164                 $this->type = $a_type;
00165         }
00166 
00172         public function getType()
00173         {
00174                 return $this->type;
00175         }
00176 
00182         public function setTitle($a_title)
00183         {
00184                 $this->title = $a_title;
00185         }
00186 
00192         public function getTitle()
00193         {
00194                 return $this->title;
00195         }
00196 
00201         public function create()
00202         {
00203                 global $ilDB;
00204                 
00205                 $query = "INSERT INTO il_custom_block (".
00206                         " context_obj_id".
00207                         ", context_obj_type".
00208                         ", context_sub_obj_id".
00209                         ", context_sub_obj_type".
00210                         ", type".
00211                         ", title".
00212                         " ) VALUES (".
00213                         $ilDB->quote($this->getContextObjId())
00214                         .",".$ilDB->quote($this->getContextObjType())
00215                         .",".$ilDB->quote($this->getContextSubObjId())
00216                         .",".$ilDB->quote($this->getContextSubObjType())
00217                         .",".$ilDB->quote($this->getType())
00218                         .",".$ilDB->quote($this->getTitle()).")";
00219                 $ilDB->query($query);
00220                 $this->setId($ilDB->getLastInsertId());
00221                 
00222 
00223         }
00224 
00229         public function read()
00230         {
00231                 global $ilDB;
00232                 
00233                 $query = "SELECT * FROM il_custom_block WHERE id = ".
00234                         $ilDB->quote($this->getId());
00235                 $set = $ilDB->query($query);
00236                 $rec = $set->fetchRow(DB_FETCHMODE_ASSOC);
00237 
00238                 $this->setContextObjId($rec["context_obj_id"]);
00239                 $this->setContextObjType($rec["context_obj_type"]);
00240                 $this->setContextSubObjId($rec["context_sub_obj_id"]);
00241                 $this->setContextSubObjType($rec["context_sub_obj_type"]);
00242                 $this->setType($rec["type"]);
00243                 $this->setTitle($rec["title"]);
00244 
00245         }
00246 
00251         public function update()
00252         {
00253                 global $ilDB;
00254                 
00255                 $query = "UPDATE il_custom_block SET ".
00256                         " context_obj_id = ".$ilDB->quote($this->getContextObjId()).
00257                         ", context_obj_type = ".$ilDB->quote($this->getContextObjType()).
00258                         ", context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId()).
00259                         ", context_sub_obj_type = ".$ilDB->quote($this->getContextSubObjType()).
00260                         ", type = ".$ilDB->quote($this->getType()).
00261                         ", title = ".$ilDB->quote($this->getTitle()).
00262                         " WHERE id = ".$ilDB->quote($this->getId());
00263                 
00264                 $ilDB->query($query);
00265 
00266         }
00267 
00272         public function delete()
00273         {
00274                 global $ilDB;
00275                 
00276                 $query = "DELETE FROM il_custom_block".
00277                         " WHERE id = ".$ilDB->quote($this->getId());
00278                 
00279                 $ilDB->query($query);
00280 
00281         }
00282 
00287         public function querygetBlocksForContext()
00288         {
00289                 global $ilDB;
00290                 
00291                 $query = "SELECT id, context_obj_id, context_obj_type, context_sub_obj_id, context_sub_obj_type, type, title ".
00292                         "FROM il_custom_block ".
00293                         "WHERE ".
00294                                 "context_obj_id = ".$ilDB->quote($this->getContextObjId()).
00295                                 " AND context_obj_type = ".$ilDB->quote($this->getContextObjType()).
00296                                 " AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId()).
00297                                 " AND context_sub_obj_type = ".$ilDB->quote($this->getContextSubObjType())."";
00298                                 
00299                 $set = $ilDB->query($query);
00300                 $result = array();
00301                 while($rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
00302                 {
00303                         $result[] = $rec;
00304                 }
00305                 
00306                 return $result;
00307 
00308         }
00309 
00314         public function queryBlocksForContext()
00315         {
00316                 global $ilDB;
00317                 
00318                 $query = "SELECT id, context_obj_id, context_obj_type, context_sub_obj_id, context_sub_obj_type, type, title ".
00319                         "FROM il_custom_block ".
00320                         "WHERE ".
00321                                 "context_obj_id = ".$ilDB->quote($this->getContextObjId()).
00322                                 " AND context_obj_type = ".$ilDB->quote($this->getContextObjType()).
00323                                 " AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId()).
00324                                 " AND context_sub_obj_type = ".$ilDB->quote($this->getContextSubObjType())."";
00325                                 
00326                 $set = $ilDB->query($query);
00327                 $result = array();
00328                 while($rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
00329                 {
00330                         $result[] = $rec;
00331                 }
00332                 
00333                 return $result;
00334 
00335         }
00336 
00341         public function queryTitleForId()
00342         {
00343                 global $ilDB;
00344                 
00345                 $query = "SELECT id ".
00346                         "FROM il_custom_block ".
00347                         "WHERE "."";
00348                                 
00349                 $set = $ilDB->query($query);
00350                 $result = array();
00351                 while($rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
00352                 {
00353                         $result[] = $rec;
00354                 }
00355                 
00356                 return $result;
00357 
00358         }
00359 
00364         public function queryCntBlockForContext()
00365         {
00366                 global $ilDB;
00367                 
00368                 $query = "SELECT count(*) as cnt ".
00369                         "FROM il_custom_block ".
00370                         "WHERE ".
00371                                 "context_obj_id = ".$ilDB->quote($this->getContextObjId()).
00372                                 " AND context_obj_type = ".$ilDB->quote($this->getContextObjType()).
00373                                 " AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId()).
00374                                 " AND context_sub_obj_type = ".$ilDB->quote($this->getContextSubObjType()).
00375                                 " AND type = ".$ilDB->quote($this->getType())."";
00376                                 
00377                 $set = $ilDB->query($query);
00378                 $result = array();
00379                 while($rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
00380                 {
00381                         $result[] = $rec;
00382                 }
00383                 
00384                 return $result;
00385 
00386         }
00387 
00388 
00389 }
00390 ?>

Generated on Fri Dec 13 2013 17:56:55 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1