aliroExtConfig.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*******************************************************************************
00004  * Aliro - the modern, accessible content management system
00005  *
00006  * Aliro is open source software, free to use, and licensed under GPL.
00007  * You can find the full licence at http://www.gnu.org/copyleft/gpl.html GNU/GPL
00008  *
00009  * The author freely draws attention to the fact that Aliro derives from Mambo,
00010  * software that is controlled by the Mambo Foundation.  However, this section
00011  * of code is totally new.  If it should contain any fragments that are similar
00012  * to Mambo, please bear in mind (1) there are only so many ways to do things
00013  * and (2) the author of Aliro is also the author and copyright owner for large
00014  * parts of Mambo 4.6.
00015  *
00016  * Tribute should be paid to all the developers who took Mambo to the stage
00017  * it had reached at the time Aliro was created.  It is a feature rich system
00018  * that contains a good deal of innovation.
00019  *
00020  * Your attention is also drawn to the fact that Aliro relies on other items of
00021  * open source software, which is very much in the spirit of open source.  Aliro
00022  * wishes to give credit to those items of code.  Please refer to
00023  * http://aliro.org/credits for details.  The credits are not included within
00024  * the Aliro package simply to avoid providing a marker that allows hackers to
00025  * identify the system.
00026  *
00027  * Copyright in this code is strictly reserved by its author, Martin Brampton.
00028  * If it seems appropriate, the copyright will be vested in the Aliro Organisation
00029  * at a suitable time.
00030  *
00031  * Copyright (c) 2007 Martin Brampton
00032  *
00033  * http://aliro.org
00034  *
00035  * counterpoint@aliro.org
00036  *
00037  * aliroExtConfig is for creating configuration objects for extensions
00038  *
00039  */
00040 
00041 class aliroExtConfig {
00042     private $formalname = '';
00043     private $configs = array();
00044     private $remove = array();
00045     private $changed = array();
00046 
00047     public function __construct ($formalname) {
00048         $this->formalname = $formalname;
00049         $database = aliroDatabase::getInstance();
00050         $database->setQuery("SELECT property, value FROM #__configurations WHERE system='Aliro' AND component='$formalname'");
00051         $results = $database->loadObjectList();
00052         if ($results) foreach ($results as $result) $this->configs[$result->property] = $result->value;
00053     }
00054 
00055     public function get ($property) {
00056         return isset($this->configs[$property]) ? $this->configs[$property] : null;
00057     }
00058 
00059     public function delete ($property) {
00060         if (isset($this->configs[$property])) unset ($this->configs[$property]);
00061         $this->remove[$property] = 1;
00062     }
00063 
00064     public function set ($property, $value) {
00065         $this->configs[$property] = $value;
00066         if (isset($this->remove[$property])) unset ($this->remove[$property]);
00067         $this->changed[$property] = 1;
00068     }
00069 
00070     public function update () {
00071         $database = aliroDatabase::getInstance();
00072         if (count($this->remove)) {
00073             $deletelist = "'".implode ("','", $this->remove)."'";
00074             $database->doSQL("DELETE FROM #__configurations WHERE system='Aliro' AND component='$this->formalname' AND property IN ($deletelist)");
00075         }
00076         if (count($this->changed)) {
00077             foreach (array_keys($this->changed) as $property) $setitem[] = " WHEN property = '$property' THEN '{$this->configs[$property]}'";
00078             $changelist = implode("\n", $setitem);
00079             $database->doSQL("UPDATE #__configurations SET value = CASE $changelist END WHERE system = 'Aliro' AND component='$this->formalname'");
00080         }
00081 
00082     }
00083 
00084 }

Generated on Thu Apr 17 13:03:26 2008 for ALIRO by  doxygen 1.5.5