File indexing completed on 2024-12-22 05:33:27
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 * Created: 11.01.2019 0024 */ 0025 class Backend_ProjectcloneController extends Local_Controller_Action_Backend 0026 { 0027 const RESULT_OK = "OK"; 0028 const RESULT_ERROR = "ERROR"; 0029 0030 /** @var Default_Model_DbTable_ProjectClone */ 0031 protected $_model; 0032 0033 protected $_modelName = 'Default_Model_DbTable_ProjectClone'; 0034 0035 0036 /** 0037 * 0038 */ 0039 public function init() 0040 { 0041 $this->_model = new $this->_modelName(); 0042 0043 $this->view->pageTitle = 'Manage Project Clones'; 0044 0045 parent::init(); 0046 } 0047 0048 public function indexAction() 0049 { 0050 0051 } 0052 0053 public function createAction() 0054 { 0055 $jTableResult = array(); 0056 try { 0057 $newRow = $this->_model->createRow($this->getAllParams()); 0058 $result = $newRow->save(); 0059 0060 $jTableResult['Result'] = self::RESULT_OK; 0061 $jTableResult['Record'] = $newRow->toArray(); 0062 } catch (Exception $e) { 0063 Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); 0064 $translate = Zend_Registry::get('Zend_Translate'); 0065 $jTableResult['Result'] = self::RESULT_ERROR; 0066 $jTableResult['Message'] = $translate->_('Error while processing data.'); 0067 } 0068 0069 $this->_helper->json($jTableResult); 0070 } 0071 0072 public function updateAction() 0073 { 0074 $jTableResult = array(); 0075 try { 0076 $record = $this->_model->save($this->getAllParams()); 0077 0078 $jTableResult = array(); 0079 $jTableResult['Result'] = self::RESULT_OK; 0080 $jTableResult['Record'] = $record->toArray(); 0081 } catch (Exception $e) { 0082 Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); 0083 $translate = Zend_Registry::get('Zend_Translate'); 0084 $jTableResult['Result'] = self::RESULT_ERROR; 0085 $jTableResult['Message'] = $translate->_('Error while processing data.'); 0086 } 0087 0088 $this->_helper->json($jTableResult); 0089 } 0090 0091 public function deleteAction() 0092 { 0093 $id = (int)$this->getParam('project_clone_id', null); 0094 0095 $this->_model->Delete(array('project_clone_id = ?' => $id)); 0096 0097 $jTableResult = array(); 0098 $jTableResult['Result'] = self::RESULT_OK; 0099 0100 $this->_helper->json($jTableResult); 0101 } 0102 0103 public function listAction() 0104 { 0105 $startIndex = (int)$this->getParam('jtStartIndex'); 0106 $pageSize = (int)$this->getParam('jtPageSize'); 0107 $sorting = $this->getParam('jtSorting'); 0108 0109 $result = $this->_model->listAll($startIndex, $pageSize, $sorting); 0110 0111 $jTableResult = array(); 0112 $jTableResult['Result'] = self::RESULT_OK; 0113 $jTableResult['Records'] = $result['rows']; 0114 $jTableResult['TotalRecordCount'] = $result['totalCount']; 0115 0116 $this->_helper->json($jTableResult); 0117 } 0118 0119 }