File indexing completed on 2024-05-12 05:58:32

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_ReportCommentsController extends Local_Controller_Action_Backend
0024 {
0025 
0026     const RESULT_OK = "OK";
0027     const RESULT_ERROR = "ERROR";
0028 
0029     /** @var Default_Model_DbTable_ReportComments */
0030     protected $_model;
0031 
0032     protected $_modelName = 'Default_Model_DbTable_ReportComments';
0033 
0034     /**
0035      *
0036      */
0037     public function init()
0038     {
0039         $this->_model = new $this->_modelName();
0040 
0041         $this->view->pageTitle = 'Manage Reported Comments';
0042 
0043         parent::init();
0044     }
0045 
0046     public function indexAction()
0047     {
0048 
0049     }
0050 
0051     public function createAction()
0052     {
0053         //        $jTableResult = array();
0054         //        try {
0055         //            $newRow = $this->_model->createRow($this->getAllParams());
0056         //            $result = $newRow->save();
0057         //
0058         //            $jTableResult['Result'] = self::RESULT_OK;
0059         //            $jTableResult['Record'] = $newRow->toArray();
0060         //        } catch (Exception $e) {
0061         //            Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true));
0062         //            $translate = Zend_Registry::get('Zend_Translate');
0063         //            $jTableResult['Result'] = self::RESULT_ERROR;
0064         //            $jTableResult['Message'] = $translate->_('Error while processing data.');
0065         //        }
0066         //
0067         //        $this->_helper->json($jTableResult);
0068     }
0069 
0070     public function updateAction()
0071     {
0072         $jTableResult = array();
0073         try {
0074             $record = $this->_model->save($this->getAllParams());
0075 
0076             $jTableResult = array();
0077             $jTableResult['Result'] = self::RESULT_OK;
0078             $jTableResult['Record'] = $record->toArray();
0079         } catch (Exception $e) {
0080             Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true));
0081             $translate = Zend_Registry::get('Zend_Translate');
0082             $jTableResult['Result'] = self::RESULT_ERROR;
0083             $jTableResult['Message'] = $translate->_('Error while processing data.');
0084         }
0085 
0086         $this->_helper->json($jTableResult);
0087     }
0088 
0089     public function deleteAction()
0090     {
0091         $reportId = (int)$this->getParam('project_report_id', null);
0092 
0093         $this->_model->setDelete($reportId);
0094 
0095         $jTableResult = array();
0096         $jTableResult['Result'] = self::RESULT_OK;
0097 
0098         $this->_helper->json($jTableResult);
0099     }
0100 
0101     public function listAction()
0102     {
0103         $startIndex = (int)$this->getParam('jtStartIndex');
0104         $pageSize = (int)$this->getParam('jtPageSize');
0105         $sorting = $this->getParam('jtSorting');
0106 
0107         $dataModel = new Backend_Model_Reports();
0108 
0109         $jTableResult = array();
0110         $jTableResult['Result'] = self::RESULT_OK;
0111         $jTableResult['Records'] = $dataModel->getReportsForComments($startIndex, $pageSize, $sorting);
0112         $jTableResult['TotalRecordCount'] = $dataModel->getTotalCountForReportedComments();
0113 
0114         $this->_helper->json($jTableResult);
0115     }
0116 
0117     public function fetchAction()
0118     {
0119         $jTableResult = array();
0120         try {
0121             $commentId = (int)$this->getParam('c');
0122 
0123             $model = new Default_Model_ProjectComments();
0124             $record = $model->getCommentWithMember($commentId);
0125             $this->view->comment = $record;
0126             $view = $this->view->render('reportcomments/comment.phtml');
0127 
0128             $jTableResult = array();
0129             $jTableResult['Result'] = self::RESULT_OK;
0130             $jTableResult['Record'] = $record;
0131             $jTableResult['ViewRecord'] = $view;
0132         } catch (Exception $e) {
0133             Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true));
0134             $translate = Zend_Registry::get('Zend_Translate');
0135             $jTableResult['Result'] = self::RESULT_ERROR;
0136             $jTableResult['Message'] = $translate->_('Error while processing data.');
0137         }
0138 
0139         $this->_helper->json($jTableResult);
0140     }
0141 
0142     public function statusAction()
0143     {
0144         $jTableResult = array();
0145         try {
0146 
0147             $commentId = (int)$this->getParam('c');
0148 
0149             $model = new Default_Model_DbTable_Comments();
0150             $record = $model->find($commentId)->current();
0151             $record->comment_active = ($record->comment_active ? 0 : 1);
0152             $record->save();
0153 
0154             $jTableResult = array();
0155             $jTableResult['Result'] = self::RESULT_OK;
0156             $jTableResult['Record'] = $record->toArray();
0157         } catch (Exception $e) {
0158             Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true));
0159             $translate = Zend_Registry::get('Zend_Translate');
0160             $jTableResult['Result'] = self::RESULT_ERROR;
0161             $jTableResult['Message'] = $translate->_('Error while processing data.');
0162         }
0163 
0164         $this->_helper->json($jTableResult);
0165     }
0166 
0167 }