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

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: 31.05.2017
0024  */
0025 class ModerationController extends Local_Controller_Action_DomainSwitch
0026 {
0027 
0028     /** @var Default_Model_Project */
0029     protected $_model;
0030     const DATA_ID_NAME = 'project_id';
0031     const DATA_NOTE = 'note';
0032     const DATA_VALUE = 'value';
0033     protected $_modelName = 'Default_Model_ProjectModeration';
0034     protected $_pageTitle = 'Moderate GHNS excluded';
0035     const RESULT_OK = "OK";
0036     const RESULT_ERROR = "ERROR";
0037     public function init()
0038     {
0039         $this->_model = new $this->_modelName();
0040         $this->view->pageTitle = $this->_pageTitle;
0041         parent::init();
0042     }
0043 
0044 
0045     public function indexAction()
0046     {
0047         $this->view->page = (int)$this->getParam('page', 1);        
0048   }
0049   
0050   
0051 
0052     public function listAction()
0053     {
0054       $startIndex = (int)$this->getParam('jtStartIndex');
0055       $pageSize = (int)$this->getParam('jtPageSize');
0056       $sorting = $this->getParam('jtSorting');
0057       if($sorting==null)
0058       {
0059         $sorting = 'created_at desc';
0060       }
0061       $filter['member_id'] = $this->getParam('filter_member_id');
0062 
0063       $mod = new Default_Model_ProjectModeration();    
0064       $reports = $mod->getList($filter['member_id'],$sorting,(int)$pageSize,$startIndex);
0065       //$reports = $mod->getList();
0066 
0067       $totalRecordCount = $mod->getTotalCount($filter);
0068       
0069       $jTableResult = array();
0070       $jTableResult['Result'] = self::RESULT_OK;
0071       $jTableResult['Records'] = $reports;
0072       $jTableResult['TotalRecordCount'] = $totalRecordCount;
0073 
0074       $this->_helper->json($jTableResult);
0075     }
0076 
0077     public function updateAction()
0078     {
0079       $dataId = (int)$this->getParam(self::DATA_ID_NAME, null);
0080       $note = $this->getParam(self::DATA_NOTE, null);
0081       $value = $this->getParam(self::DATA_VALUE, null);
0082       if($value==null)
0083       {
0084         $value = 0;
0085       }
0086       if($value==0)
0087       {
0088     $tableTags = new Default_Model_Tags();
0089     $tableTags->saveGhnsExcludedTagForProject($dataId, 0);
0090       }
0091 
0092       $auth = Zend_Auth::getInstance();
0093           $identity = $auth->getIdentity();
0094       $mod = new Default_Model_ProjectModeration();   
0095       //createModeration($project_id,$project_moderation_type_id, $is_set, $userid,$note)
0096       $mod->createModeration($dataId,Default_Model_ProjectModeration::M_TYPE_GET_HOT_NEW_STUFF_EXCLUDED, $value, $identity->member_id,$note);
0097       $jTableResult = array();
0098           $jTableResult['Result'] = self::RESULT_OK;                    
0099           $this->_helper->json($jTableResult);
0100     }
0101 
0102 
0103   public function productmoderationAction()
0104     {   
0105     $this->view->headTitle('Watchlist - Product Moderation','SET');   
0106     }
0107 
0108   public function listmoderationAction()
0109     {
0110       $startIndex = (int)$this->getParam('jtStartIndex');
0111       $pageSize = (int)$this->getParam('jtPageSize');
0112       $sorting = $this->getParam('jtSorting');
0113       if($sorting==null)
0114       {
0115         $sorting = 'comment_created_at desc';
0116       }
0117       $mod = new Default_Model_ProjectComments();    
0118       $comments = $mod->fetchCommentsWithType(Default_Model_DbTable_Comments::COMMENT_TYPE_MODERATOR,$sorting,(int)$pageSize,$startIndex);          
0119     $printDateSince = new Default_View_Helper_PrintDateSince();        
0120         $helperImage = new Default_View_Helper_Image();
0121         foreach ($comments as &$value) {            
0122             $value['comment_created_at'] = $printDateSince->printDateSince($value['comment_created_at']);
0123       $value['profile_image_url'] = $helperImage->Image($value['profile_image_url'], array('width' => '200', 'height' => '200', 'crop' => 2)); 
0124       $value['image_small'] = $helperImage->Image($value['image_small'], array('width' => '100', 'height' => '100', 'crop' => 2)); 
0125         }
0126     
0127     
0128     $totalRecordCount = $mod->fetchCommentsWithTypeCount(Default_Model_DbTable_Comments::COMMENT_TYPE_MODERATOR);     
0129       $jTableResult = array();
0130       $jTableResult['Result'] = self::RESULT_OK;
0131       $jTableResult['Records'] = $comments;
0132       $jTableResult['TotalRecordCount'] = $totalRecordCount;
0133       $this->_helper->json($jTableResult);
0134     }
0135 
0136       
0137 
0138 }