File indexing completed on 2024-05-12 05:58:30
0001 <?php 0002 0003 /** 0004 * ocs-webserver 0005 * 0006 * Copyright 2016 by pling GmbH. 0007 * 0008 * This file is part of ocs-webserver. 0009 * 0010 * This program is free software: you can redistribute it and/or modify 0011 * it under the terms of the GNU Affero General Public License as 0012 * published by the Free Software Foundation, either version 3 of the 0013 * License, or (at your option) any later version. 0014 * 0015 * This program is distributed in the hope that it will be useful, 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0018 * GNU Affero General Public License for more details. 0019 * 0020 * You should have received a copy of the GNU Affero General Public License 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0022 **/ 0023 class Backend_CategorytaggroupController extends Local_Controller_Action_Backend 0024 { 0025 const RESULT_OK = "OK"; 0026 const RESULT_ERROR = "ERROR"; 0027 0028 /** @var Default_Model_DbTable_ProjectCategory */ 0029 protected $_model; 0030 0031 protected $_authMember; 0032 0033 protected $_modelName = 'Default_Model_DbTable_ProjectCategory'; 0034 0035 public function init() 0036 { 0037 parent::init(); 0038 0039 $this->_model = new $this->_modelName(); 0040 0041 $this->view->pageTitle = 'Manage Category-Taggroup'; 0042 $this->view->author = $this->_authMember->username; 0043 } 0044 0045 public function indexAction() 0046 { 0047 0048 } 0049 0050 public function updateAction() 0051 { 0052 0053 $jTableResult = array(); 0054 try { 0055 0056 //$this->_model->moveToParent((int)$this->getParam('project_category_id', null), (int)$this->getParam('parent', null)); 0057 //$record = $this->_model->save($this->getAllParams()); 0058 $tagsid = $this->getParam('tag_group_id', null); 0059 $tagmodel = new Default_Model_TagGroup(); 0060 $tagmodel->updateTagGroupsPerCategory((int)$this->getParam('project_category_id', null), $tagsid); 0061 $jTableResult = array(); 0062 $jTableResult['Result'] = self::RESULT_OK; 0063 // $jTableResult['Record'] = $record->toArray(); 0064 } catch (Exception $e) { 0065 Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); 0066 $translate = Zend_Registry::get('Zend_Translate'); 0067 $jTableResult['Result'] = self::RESULT_ERROR; 0068 $jTableResult['Message'] = $translate->_('Error while processing data.'); 0069 } 0070 0071 $this->_helper->json($jTableResult); 0072 } 0073 0074 0075 public function listAction() 0076 { 0077 0078 $startIndex = (int)$this->getParam('jtStartIndex'); 0079 $pageSize = (int)$this->getParam('jtPageSize'); 0080 $sorting = $this->getParam('jtSorting'); 0081 $filter_deleted = (int)$this->getParam('filter_deleted', 1); 0082 0083 $records = $this->_model->fetchTreeWithParentIdAndTagGroups($filter_deleted, null); 0084 0085 $pagination = Zend_Paginator::factory($records); 0086 $pagination->setItemCountPerPage($pageSize); 0087 $pagination->setCurrentPageNumber(($startIndex / $pageSize) + 1); 0088 0089 $jTableResult = array(); 0090 $jTableResult['Result'] = self::RESULT_OK; 0091 $jTableResult['Records'] = (array)$pagination->getCurrentItems(); 0092 $jTableResult['TotalRecordCount'] = count($records); 0093 0094 $this->_helper->json($jTableResult); 0095 } 0096 0097 0098 0099 public function treeAction() 0100 { 0101 0102 $result = true; 0103 $cat_id = (int)$this->getParam('c'); 0104 0105 try { 0106 $records = $this->_model->fetchTreeForJTableStores($cat_id); 0107 0108 0109 } catch (Exception $e) { 0110 Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); 0111 $result = false; 0112 $records = array(); 0113 } 0114 0115 $jTableResult = array(); 0116 $jTableResult['Result'] = ($result == true) ? self::RESULT_OK : self::RESULT_ERROR; 0117 $jTableResult['Options'] = $records; 0118 0119 $this->_helper->json($jTableResult); 0120 } 0121 0122 0123 public function alltaggroupsAction() 0124 { 0125 0126 $result = true; 0127 $tagmodel = new Default_Model_TagGroup(); 0128 try { 0129 $resultRows = $tagmodel->fetchAllGroups(); 0130 $resultForSelect = array(); 0131 foreach ($resultRows as $row) { 0132 $resultForSelect[] = array('DisplayText' => $row['group_name'].'['.$row['group_id'].']', 'Value' => $row['group_id']); 0133 } 0134 0135 } catch (Exception $e) { 0136 Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); 0137 $result = false; 0138 $records = array(); 0139 } 0140 0141 $jTableResult = array(); 0142 $jTableResult['Result'] = ($result == true) ? self::RESULT_OK : self::RESULT_ERROR; 0143 $jTableResult['Options'] = $resultForSelect; 0144 0145 $this->_helper->json($jTableResult); 0146 } 0147 0148 0149 0150 }