, Suchi & Berg GmbH * @access public * @package core */ // +---------------------------------------------------------------------------+ // This file is part of Stud.IP // SeminarCategories.class.php // // Copyright (C) 2008 André Noack , data-quest GmbH // +---------------------------------------------------------------------------+ // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or any later version. // +---------------------------------------------------------------------------+ // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // +---------------------------------------------------------------------------+ class SeminarCategories { private static $seminar_categories = []; private $sem_class_data = []; private $sem_type_data = []; /** * Enter description here... * * @param String $id * @return Array */ public static function Get($id) { if (empty(self::$seminar_categories[$id])) { $cat = new SeminarCategories($id); if ($cat->id !== false) { self::$seminar_categories[$id] = $cat; } else { self::$seminar_categories[$id] = false; } } return self::$seminar_categories[$id]; } /** * Enter description here... * * @return Array */ public static function GetAll(){ $ret = []; foreach($GLOBALS['SEM_CLASS'] as $id => $sem_class){ $ret[] = self::get($id); } return $ret; } /** * Enter description here... * * @param String $id * @return String */ public static function GetByTypeId($id){ return self::Get($GLOBALS['SEM_TYPE'][$id]['class']); } /** * Enter description here... * * @param String $seminar_id * @return SeminarCategories */ public static function GetBySeminarId($seminar_id){ return self::GetByTypeId(Seminar::GetInstance($seminar_id)->status); } /** * Enter description here... * * @param String $sem_class_id */ private function __construct($sem_class_id) { if(isset($GLOBALS['SEM_CLASS'][$sem_class_id])){ $this->sem_class_data = $GLOBALS['SEM_CLASS'][$sem_class_id]; $this->sem_class_data['id'] = $sem_class_id; foreach($GLOBALS['SEM_TYPE'] as $type_id => $type_data){ if($type_data['class'] == $sem_class_id) { $this->sem_type_data[$type_id] = $type_data['name']; } } } } /** * Enter description here... * * @param String $type_id * @return String */ public function getNameOfType($type_id){ return isset($this->sem_type_data[$type_id]) ? $this->sem_type_data[$type_id] : ''; } /** * Enter description here... * * @return Array */ public function getTypes(){ return $this->sem_type_data; } public function __get($attribute){ if(isset($this->sem_class_data[$attribute])){ return $this->sem_class_data[$attribute]; } else { return false; } } } ?>