File indexing completed on 2025-02-09 07:14:33
0001 <?php 0002 /** 0003 * ocs-webserver 0004 * 0005 * Copyright 2016 by pling GmbH. 0006 * 0007 * This file is part of ocs-webserver. 0008 * 0009 * This program is free software: you can redistribute it and/or modify 0010 * it under the terms of the GNU Affero General Public License as 0011 * published by the Free Software Foundation, either version 3 of the 0012 * License, or (at your option) any later version. 0013 * 0014 * This program is distributed in the hope that it will be useful, 0015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 * GNU Affero General Public License for more details. 0018 * 0019 * You should have received a copy of the GNU Affero General Public License 0020 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 **/ 0022 class Default_Model_DbTable_ConfigOperatingSystem extends Local_Model_Table 0023 { 0024 0025 protected $_keyColumnsForRow = array('os_id'); 0026 protected $_key = 'os_id'; 0027 protected $_name = "config_operating_system"; 0028 0029 public function fetchOsNamesForJTable($id = null) 0030 { 0031 $select = $this->select()->from($this->_name)->columns('name')->group('name'); 0032 0033 $resultRows = $this->fetchAll($select); 0034 0035 $resultForSelect = array(); 0036 foreach ($resultRows as $row) { 0037 $resultForSelect[] = array('DisplayText' => $row['name'], 'Value' => $row['os_id']); 0038 } 0039 0040 return $resultForSelect; 0041 } 0042 0043 0044 0045 public function deleteId($dataId) 0046 { 0047 $sql = "DELETE FROM {$this->_name} WHERE {$this->_key} = ?"; 0048 $this->_db->query($sql,$dataId)->execute(); 0049 } 0050 0051 0052 /** 0053 * @return array 0054 */ 0055 public function fetchOperatingSystems() 0056 { 0057 if (Zend_Registry::isRegistered('cache')) { 0058 /** @var Zend_Cache_Core $cache */ 0059 $cache = Zend_Registry::get('cache'); 0060 $cacheName = __FUNCTION__; 0061 if (false == ($configArray = $cache->load($cacheName))) { 0062 $resultSet = $this->queryOperatingSystems(); 0063 $configArray = $this->createOperatingSystemsArray($resultSet); 0064 $cache->save($configArray, $cacheName); 0065 } 0066 } else { 0067 $resultSet = $this->queryOperatingSystems(); 0068 $configArray = $this->createOperatingSystemsArray($resultSet); 0069 } 0070 0071 return $configArray; 0072 } 0073 0074 /** 0075 * @return array 0076 */ 0077 private function queryOperatingSystems() 0078 { 0079 $sql = "SELECT os_id, displayname FROM {$this->_name} ORDER BY `order`;"; 0080 $resultSet = $this->_db->fetchAll($sql); 0081 return $resultSet; 0082 } 0083 0084 /** 0085 * @param array $resultSetConfig 0086 * @return array 0087 */ 0088 private function createOperatingSystemsArray($resultSetConfig) 0089 { 0090 $result = array(); 0091 foreach ($resultSetConfig as $element) { 0092 $result[$element['os_id']] = $element['displayname']; 0093 } 0094 return $result; 0095 } 0096 0097 }