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 class Backend_LetteravatarController extends Local_Controller_Action_Backend
0024 {
0025 
0026      /** @var Default_Model_Project */
0027     protected $_model;
0028     const DATA_ID_NAME = 'member_id';    
0029     const DATA_AVATAR_TYPE_ID = 'avatar_type_id';
0030     protected $_modelName = 'Default_Model_Member';
0031     protected $_pageTitle = 'Users with avatar type unknown';
0032     const RESULT_OK = "OK";
0033     const RESULT_ERROR = "ERROR";
0034     public function init()
0035     {
0036         $this->_model = new $this->_modelName();
0037         $this->view->pageTitle = $this->_pageTitle;
0038         parent::init();
0039     }
0040 
0041 
0042     public function indexAction()
0043     {
0044         $this->view->page = (int)$this->getParam('page', 1);        
0045 
0046     }
0047 
0048     public function listAction()
0049     {
0050         
0051         $startIndex = (int)$this->getParam('jtStartIndex');
0052         $pageSize = (int)$this->getParam('jtPageSize');
0053         $sorting = $this->getParam('jtSorting');
0054         if($sorting==null)
0055         {
0056             $sorting = 'member_id desc';
0057         }       
0058         
0059         $reports = $this->_model ->getMembersAvatarOldAutogenerated($sorting,(int)$pageSize,$startIndex);        
0060         $totalRecordCount = $this->_model ->getMembersAvatarOldAutogeneratedTotalCount();
0061 
0062         $jTableResult = array();
0063         $jTableResult['Result'] = self::RESULT_OK;
0064         $jTableResult['Records'] = $reports;
0065         $jTableResult['TotalRecordCount'] = $totalRecordCount;
0066 
0067         $this->_helper->json($jTableResult);
0068     }
0069 
0070     public function updateAction()
0071     {
0072         $member_id = (int)$this->getParam(self::DATA_ID_NAME, null);
0073         //$typeId = $this->getParam(self::DATA_AVATAR_TYPE_ID, null);
0074         $typeId = 2; // user uploaded
0075 
0076         if($member_id)
0077         {
0078             $this->_model->updateAvatarTypeId($member_id,$typeId);
0079         }
0080 
0081         $jTableResult = array();
0082         $jTableResult['Result'] = self::RESULT_OK;                      
0083         $this->_helper->json($jTableResult);
0084     }
0085 
0086 }