• Main Page
  • Related Pages
  • 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-2005 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 
00034 require_once "class.ilObject.php";
00035 
00036 class ilObjStyleSettings extends ilObject
00037 {
00038         var $styles;
00039         
00046         function ilObjStyleSettings($a_id = 0,$a_call_by_reference = true)
00047         {
00048                 $this->type = "stys";
00049                 $this->ilObject($a_id,$a_call_by_reference);
00050                 
00051                 $this->styles = array();
00052         }
00053         
00059         function addStyle($a_style_id)
00060         {
00061                 $this->styles[$a_style_id] =
00062                         array("id" => $a_style_id,
00063                         "title" => ilObject::_lookupTitle($a_style_id));
00064         }
00065 
00066         
00070         function removeStyle($a_id)
00071         {
00072                 unset($a_id);
00073         }
00074 
00075 
00082         function update()
00083         {
00084                 global $ilDB;
00085                 
00086                 if (!parent::update())
00087                 {                       
00088                         return false;
00089                 }
00090 
00091                 // save styles of style folder
00092                 $q = "DELETE FROM style_folder_styles WHERE folder_id = ".
00093                         $ilDB->quote($this->getId());
00094                 $ilDB->query($q);
00095                 foreach($this->styles as $style)
00096                 {
00097                         $q = "INSERT INTO style_folder_styles (folder_id, style_id) VALUES".
00098                                 "(".$ilDB->quote($this->getId()).", ".
00099                                 $ilDB->quote($style["id"]).")";
00100                         $ilDB->query($q);
00101                 }
00102                 
00103                 return true;
00104         }
00105         
00109         function read()
00110         {
00111                 global $ilDB;
00112 
00113                 parent::read();
00114 
00115                 // get styles of style folder
00116                 $q = "SELECT * FROM style_folder_styles, object_data as obj WHERE folder_id = ".
00117                         $ilDB->quote($this->getId()).
00118                         " AND style_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                 }
00127         }
00128         
00132         function _lookupActivatedStyle($a_skin, $a_style)
00133         {
00134                 global $ilDB;
00135                 
00136                 $q = "SELECT count(*) AS cnt FROM settings_deactivated_styles".
00137                         " WHERE skin = ".$ilDB->quote($a_skin).
00138                         " AND style = ".$ilDB->quote($a_style);
00139                 
00140                 $cnt_set = $ilDB->query($q);
00141                 $cnt_rec = $cnt_set->fetchRow(DB_FETCHMODE_ASSOC);
00142                 
00143                 if ($cnt_rec["cnt"] > 0)
00144                 {
00145                         return false;
00146                 }
00147                 else
00148                 {
00149                         return true;
00150                 }
00151         }
00152         
00156         function _deactivateStyle($a_skin, $a_style)
00157         {
00158                 global $ilDB;
00159 
00160                 $q = "REPLACE into settings_deactivated_styles".
00161                         " (skin, style) VALUES ".
00162                         " (".$ilDB->quote($a_skin).",".
00163                         " ".$ilDB->quote($a_style).")";
00164 
00165                 $ilDB->query($q);
00166         }
00167 
00171         function _activateStyle($a_skin, $a_style)
00172         {
00173                 global $ilDB;
00174 
00175                 $q = "DELETE FROM settings_deactivated_styles".
00176                         " WHERE skin = ".$ilDB->quote($a_skin).
00177                         " AND style = ".$ilDB->quote($a_style);
00178 
00179                 $ilDB->query($q);
00180         }
00181         
00187         function getStyles()
00188         {
00189                 return $this->styles;
00190         }
00191         
00192         
00200         function ilClone($a_parent_ref)
00201         {               
00202                 global $rbacadmin;
00203 
00204                 // always call parent clone function first!!
00205                 $new_ref_id = parent::ilClone($a_parent_ref);
00206                 
00207                 // get object instance of cloned object
00208                 //$newObj =& $this->ilias->obj_factory->getInstanceByRefId($new_ref_id);
00209 
00210                 // create a local role folder & default roles
00211                 //$roles = $newObj->initDefaultRoles();
00212 
00213                 // ...finally assign role to creator of object
00214                 //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "n");          
00215 
00216                 // always destroy objects in clone method because clone() is recursive and creates instances for each object in subtree!
00217                 //unset($newObj);
00218 
00219                 // ... and finally always return new reference ID!!
00220                 return $new_ref_id;
00221         }
00222 
00229         function delete()
00230         {               
00231                 // always call parent delete function first!!
00232                 if (!parent::delete())
00233                 {
00234                         return false;
00235                 }
00236                 
00237                 //put here your module specific stuff
00238                 
00239                 return true;
00240         }
00241 
00251         function initDefaultRoles()
00252         {
00253                 global $rbacadmin;
00254                 
00255                 // create a local role folder
00256                 //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
00257 
00258                 // create moderator role and assign role to rolefolder...
00259                 //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
00260                 //$roles[] = $roleObj->getId();
00261 
00262                 //unset($rfoldObj);
00263                 //unset($roleObj);
00264 
00265                 return $roles ? $roles : array();
00266         }
00267 
00281         function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00282         {
00283                 global $tree;
00284                 
00285                 switch ($a_event)
00286                 {
00287                         case "link":
00288                                 
00289                                 //var_dump("<pre>",$a_params,"</pre>");
00290                                 //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
00291                                 //exit;
00292                                 break;
00293                         
00294                         case "cut":
00295                                 
00296                                 //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
00297                                 //exit;
00298                                 break;
00299                                 
00300                         case "copy":
00301                         
00302                                 //var_dump("<pre>",$a_params,"</pre>");
00303                                 //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
00304                                 //exit;
00305                                 break;
00306 
00307                         case "paste":
00308                                 
00309                                 //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
00310                                 //exit;
00311                                 break;
00312                         
00313                         case "new":
00314                                 
00315                                 //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
00316                                 //exit;
00317                                 break;
00318                 }
00319                 
00320                 // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
00321                 if ($a_node_id==$_GET["ref_id"])
00322                 {       
00323                         $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
00324                         $parent_type = $parent_obj->getType();
00325                         if($parent_type == $this->getType())
00326                         {
00327                                 $a_node_id = (int) $tree->getParentId($a_node_id);
00328                         }
00329                 }
00330                 
00331                 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
00332         }
00333 } // END class.ilObjStyleSettings
00334 ?>

Generated on Fri Dec 13 2013 09:06:34 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1