1<?php 2/* 3 +-----------------------------------------------------------------------------+ 4 | ILIAS open source | 5 +-----------------------------------------------------------------------------+ 6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne | 7 | | 8 | This program is free software; you can redistribute it and/or | 9 | modify it under the terms of the GNU General Public License | 10 | as published by the Free Software Foundation; either version 2 | 11 | of the License, or (at your option) any later version. | 12 | | 13 | This program is distributed in the hope that it will be useful, | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 | GNU General Public License for more details. | 17 | | 18 | You should have received a copy of the GNU General Public License | 19 | along with this program; if not, write to the Free Software | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 21 +-----------------------------------------------------------------------------+ 22*/ 23 24 25/** 26* Class ilObjRootFolder 27* 28* @author Stefan Meyer <meyer@leifos.com> 29* @version $Id$Id: class.ilObjRootFolder.php,v 1.12 2003/11/20 17:04:19 shofmann Exp $ 30* 31* @extends ilObject 32*/ 33 34require_once "./Services/Object/classes/class.ilObject.php"; 35require_once "./Services/Container/classes/class.ilContainer.php"; 36 37class ilObjRootFolder extends ilContainer 38{ 39 /** 40 * Constructor 41 * @access public 42 * @param integer reference_id or object_id 43 * @param boolean treat the id as reference_id (true) or object_id (false) 44 */ 45 public function __construct($a_id, $a_call_by_reference = true) 46 { 47 $this->type = "root"; 48 parent::__construct($a_id, $a_call_by_reference); 49 } 50 51 52 53 /** 54 * delete rootfolder and all related data 55 * 56 * @access public 57 * @return boolean true if all object data were removed; false if only a references were removed 58 */ 59 public function delete() 60 { 61 // delete is disabled 62 63 $message = get_class($this) . "::delete(): Can't delete root folder!"; 64 $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING); 65 return false; 66 67 // always call parent delete function first!! 68 if (!parent::delete()) { 69 return false; 70 } 71 72 // put here rootfolder specific stuff 73 74 return true; 75 ; 76 } 77 78 /** 79 * get all translations from this category 80 * 81 * @access public 82 * @return array 83 */ 84 public function getTranslations() 85 { 86 global $ilDB; 87 88 $q = "SELECT * FROM object_translation WHERE obj_id = " . 89 $ilDB->quote($this->getId(), 'integer') . " ORDER BY lang_default DESC"; 90 $r = $this->ilias->db->query($q); 91 92 $num = 0; 93 94 $data["Fobject"] = array(); 95 while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) { 96 $data["Fobject"][$num] = array("title" => $row->title, 97 "desc" => $row->description, 98 "lang" => $row->lang_code 99 ); 100 $num++; 101 } 102 103 // first entry is always the default language 104 $data["default_language"] = 0; 105 106 return $data ? $data : array(); 107 } 108 109 // remove translations of current category 110 public function deleteTranslation($a_lang) 111 { 112 global $ilDB; 113 114 $query = "DELETE FROM object_translation WHERE obj_id= " . 115 $ilDB->quote($this->getId(), 'integer') . " AND lang_code = " . 116 $ilDB->quote($a_lang, 'text'); 117 $res = $ilDB->manipulate($query); 118 } 119 120 // remove all Translations of current category 121 public function removeTranslations() 122 { 123 global $ilDB; 124 125 $query = "DELETE FROM object_translation WHERE obj_id= " . 126 $ilDB->quote($this->getId(), 'integer'); 127 $res = $ilDB->manipulate($query); 128 } 129 130 // add a new translation to current category 131 public function addTranslation($a_title, $a_desc, $a_lang, $a_lang_default) 132 { 133 global $ilDB; 134 135 if (empty($a_title)) { 136 $a_title = "NO TITLE"; 137 } 138 139 $query = "INSERT INTO object_translation " . 140 "(obj_id,title,description,lang_code,lang_default) " . 141 "VALUES " . 142 "(" . $ilDB->quote($this->getId(), 'integer') . "," . 143 $ilDB->quote($a_title, 'text') . "," . 144 $ilDB->quote($a_desc, 'text') . "," . 145 $ilDB->quote($a_lang, 'text') . "," . 146 $ilDB->quote($a_lang_default, 'integer') . ")"; 147 $res = $ilDB->manipulate($query); 148 return true; 149 } 150 151 public function addAdditionalSubItemInformation(&$a_item_data) 152 { 153 include_once './Services/Object/classes/class.ilObjectActivation.php'; 154 ilObjectActivation::addAdditionalSubItemInformation($a_item_data); 155 } 156} // END class.ObjRootFolder 157