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

classes/class.ilObjStyleSettings.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 
00033 require_once "class.ilObject.php";
00034 
00035 class ilObjStyleSettings extends ilObject
00036 {
00037         var $styles;
00038         
00045         function ilObjStyleSettings($a_id = 0,$a_call_by_reference = true)
00046         {
00047                 $this->type = "stys";
00048                 $this->ilObject($a_id,$a_call_by_reference);
00049                 
00050                 $this->styles = array();
00051         }
00052         
00058         function addStyle($a_style_id)
00059         {
00060                 $this->styles[$a_style_id] =
00061                         array("id" => $a_style_id,
00062                         "title" => ilObject::_lookupTitle($a_style_id));
00063         }
00064 
00065         
00069         function removeStyle($a_id)
00070         {
00071                 unset($a_id);
00072         }
00073 
00074 
00081         function update()
00082         {
00083                 global $ilDB;
00084                 
00085                 if (!parent::update())
00086                 {                       
00087                         return false;
00088                 }
00089 
00090                 // save styles of style folder
00091                 $q = "DELETE FROM style_folder_styles WHERE folder_id = ".
00092                         $ilDB->quote($this->getId());
00093                 $ilDB->query($q);
00094                 foreach($this->styles as $style)
00095                 {
00096                         $q = "INSERT INTO style_folder_styles (folder_id, style_id) VALUES".
00097                                 "(".$ilDB->quote($this->getId()).", ".
00098                                 $ilDB->quote($style["id"]).")";
00099                         $ilDB->query($q);
00100                 }
00101                 
00102                 return true;
00103         }
00104         
00108         function read()
00109         {
00110                 global $ilDB;
00111 
00112                 parent::read();
00113 
00114                 // get styles of style folder
00115                 $q = "SELECT * FROM style_folder_styles, object_data as obj, style_data WHERE folder_id = ".
00116                         $ilDB->quote($this->getId()).
00117                         " AND style_id = obj.obj_id".
00118                         " AND style_data.id = obj.obj_id";
00119 
00120                 $style_set = $ilDB->query($q);
00121                 while ($style_rec = $style_set->fetchRow(DB_FETCHMODE_ASSOC))
00122                 {
00123                         $this->styles[$style_rec["style_id"]] =
00124                                 array("id" => $style_rec["style_id"],
00125                                 "title" => $style_rec["title"],
00126                                 "category" => $style_rec["category"]);
00127 //echo "<br>-".$style_rec["category"]."-";
00128                 }
00129         }
00130         
00134         function _lookupActivatedStyle($a_skin, $a_style)
00135         {
00136                 global $ilDB;
00137                 
00138                 $q = "SELECT count(*) AS cnt FROM settings_deactivated_styles".
00139                         " WHERE skin = ".$ilDB->quote($a_skin).
00140                         " AND style = ".$ilDB->quote($a_style);
00141                 
00142                 $cnt_set = $ilDB->query($q);
00143                 $cnt_rec = $cnt_set->fetchRow(DB_FETCHMODE_ASSOC);
00144                 
00145                 if ($cnt_rec["cnt"] > 0)
00146                 {
00147                         return false;
00148                 }
00149                 else
00150                 {
00151                         return true;
00152                 }
00153         }
00154         
00158         function _deactivateStyle($a_skin, $a_style)
00159         {
00160                 global $ilDB;
00161 
00162                 $q = "REPLACE into settings_deactivated_styles".
00163                         " (skin, style) VALUES ".
00164                         " (".$ilDB->quote($a_skin).",".
00165                         " ".$ilDB->quote($a_style).")";
00166 
00167                 $ilDB->query($q);
00168         }
00169 
00173         function _activateStyle($a_skin, $a_style)
00174         {
00175                 global $ilDB;
00176 
00177                 $q = "DELETE FROM settings_deactivated_styles".
00178                         " WHERE skin = ".$ilDB->quote($a_skin).
00179                         " AND style = ".$ilDB->quote($a_style);
00180 
00181                 $ilDB->query($q);
00182         }
00183         
00189         function getStyles()
00190         {
00191                 return $this->styles;
00192         }
00193         
00194 
00201         function delete()
00202         {               
00203                 // always call parent delete function first!!
00204                 if (!parent::delete())
00205                 {
00206                         return false;
00207                 }
00208                 
00209                 //put here your module specific stuff
00210                 
00211                 return true;
00212         }
00213 
00223         function initDefaultRoles()
00224         {
00225                 global $rbacadmin;
00226                 
00227                 // create a local role folder
00228                 //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
00229 
00230                 // create moderator role and assign role to rolefolder...
00231                 //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
00232                 //$roles[] = $roleObj->getId();
00233 
00234                 //unset($rfoldObj);
00235                 //unset($roleObj);
00236 
00237                 return $roles ? $roles : array();
00238         }
00239 
00253         function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00254         {
00255                 global $tree;
00256                 
00257                 switch ($a_event)
00258                 {
00259                         case "link":
00260                                 
00261                                 //var_dump("<pre>",$a_params,"</pre>");
00262                                 //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
00263                                 //exit;
00264                                 break;
00265                         
00266                         case "cut":
00267                                 
00268                                 //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
00269                                 //exit;
00270                                 break;
00271                                 
00272                         case "copy":
00273                         
00274                                 //var_dump("<pre>",$a_params,"</pre>");
00275                                 //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
00276                                 //exit;
00277                                 break;
00278 
00279                         case "paste":
00280                                 
00281                                 //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
00282                                 //exit;
00283                                 break;
00284                         
00285                         case "new":
00286                                 
00287                                 //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
00288                                 //exit;
00289                                 break;
00290                 }
00291                 
00292                 // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
00293                 if ($a_node_id==$_GET["ref_id"])
00294                 {       
00295                         $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
00296                         $parent_type = $parent_obj->getType();
00297                         if($parent_type == $this->getType())
00298                         {
00299                                 $a_node_id = (int) $tree->getParentId($a_node_id);
00300                         }
00301                 }
00302                 
00303                 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
00304         }
00305 } // END class.ilObjStyleSettings
00306 ?>

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