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

0001 <?php
0002 /**
0003  *  ocs-webserver
0004  *
0005  *  Copyright 2016 by pling GmbH.
0006  *
0007  *    This file is part of ocs-webserver.
0008  *
0009  *    This program is free software: you can redistribute it and/or modify
0010  *    it under the terms of the GNU Affero General Public License as
0011  *    published by the Free Software Foundation, either version 3 of the
0012  *    License, or (at your option) any later version.
0013  *
0014  *    This program is distributed in the hope that it will be useful,
0015  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  *    GNU Affero General Public License for more details.
0018  *
0019  *    You should have received a copy of the GNU Affero General Public License
0020  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021  **/
0022 
0023 /**
0024  * Class Backend_MemberController
0025  *
0026  * @deprecated
0027  */
0028 class Backend_MemberController extends Zend_Controller_Action
0029 {
0030 
0031     /** @var Default_Model_Member */
0032     protected $_model = null;
0033 
0034     public function init()
0035     {
0036         $this->_model = new Default_Model_Member();
0037         $this->initView();
0038     }
0039 
0040 
0041     public function initView()
0042     {
0043         parent::initView(); // TODO: Change the autogenerated stub
0044 
0045         $this->_helper->layout()->setLayoutPath(APPLICATION_PATH . "/modules/backend/layout");
0046         $this->_helper->layout()->setLayout('layout');
0047 
0048         return $this->view;
0049     }
0050 
0051     public function indexAction()
0052     {
0053 
0054     }
0055 
0056 
0057     public function getmemberAction()
0058     {
0059         $this->_helper->layout->disableLayout();
0060 
0061         $start = $this->getParam('start', 0);
0062         $count = $this->getParam('count', 20);
0063         $sort = $this->getParam('sort', 'username');
0064         $dir = $this->getParam('dir', 'yui-dt-desc');
0065         $dir = ($dir == 'yui-dt-desc') ? 'DESC' : 'ASC';
0066         $filter = $this->getParam('filter', null);
0067 
0068         $sel = $this->_model->select()->setIntegrityCheck(false);
0069         $sel->from($this->_model, array(
0070             'member_id',
0071             'firstname',
0072             'lastname',
0073             'username',
0074             'mail',
0075             'paypal_mail',
0076             'created_at',
0077             'last_online',
0078             'mail_checked',
0079             'agb',
0080             'newsletter'
0081         ))->where('is_deleted=0')->where('is_active=1')->order($sort . ' ' . $dir)->limit($count, $start)
0082         ;
0083 
0084         if ($filter) {
0085             foreach ($filter as $field => $value) {
0086                 $sel->where($field . ' like "' . $value . '%"');
0087             }
0088         }
0089 
0090         $memberData = $this->_model->fetchAll($sel);
0091         $memberData = $memberData->toArray();
0092 
0093         $responsData['results'] = $memberData;
0094 
0095         $sel2 = $this->_model->select();
0096         $sel2->where('is_deleted=0')->where('is_active=1');
0097 
0098         $responsData['totalRecords'] = count($this->_model->fetchAll($sel2)->toArray());
0099 
0100         $this->_helper->json($responsData);
0101     }
0102 
0103 
0104     public function detailsAction()
0105     {
0106         $memberId = $this->getParam('id');
0107 
0108         $member = $this->_model->fetchRow('member_id=' . $memberId);
0109 
0110         $this->view->member = $member;
0111     }
0112 
0113 
0114     public function editAction()
0115     {
0116 
0117     }
0118 
0119     public function deleteAction()
0120     {
0121         $this->_helper->layout->disableLayout();
0122 
0123         $member_id = $this->getParam('member_id');
0124 
0125         $this->_model->setDeleted($member_id);
0126 
0127         $identity = Zend_Auth::getInstance()->getIdentity();
0128 
0129         try {
0130             Default_Model_ActivityLog::logActivity($member_id, null, $identity->member_id,
0131                 Default_Model_ActivityLog::BACKEND_USER_DELETE, null);
0132         } catch (Exception $e) {
0133             Zend_Registry::get('logger')->err($e->getMessage() . PHP_EOL . $e->getTraceAsString());
0134         }
0135 
0136         $this->_helper->json(true);
0137     }
0138 
0139 
0140     public function closeAction()
0141     {
0142 
0143     }
0144 
0145     public function activateAction()
0146     {
0147         $this->_helper->layout->disableLayout();
0148 
0149         $member_id = $this->getParam('member_id');
0150 
0151         $this->_model->setActivated($member_id);
0152 
0153         $this->_helper->json(true);
0154     }
0155 
0156     public function doexcludeAction()
0157     {
0158         $memberId = (int)$this->getParam('member_id', null);
0159         $member = $this->_model->find($memberId)->current();
0160         $exclude = (int)$this->getParam('pling_excluded', null);
0161         $excludOrg = $member['pling_excluded'];
0162 
0163         $sql = "UPDATE `member` SET `pling_excluded` = :exclude WHERE `member_id` = :member_id";
0164         $this->_model->getAdapter()->query($sql, array('exclude' => $exclude, 'member_id' => $memberId));
0165 
0166         $auth = Zend_Auth::getInstance();
0167         $identity = $auth->getIdentity();
0168 
0169         $logArray = array();
0170         $logArray['title'] = $member['username'];
0171         $logArray['description'] = 'Change pling_excluded from ' . $excludOrg . ' to ' . $exclude;
0172 
0173         Default_Model_ActivityLog::logActivity($memberId, $memberId, $identity->member_id,
0174             Default_Model_ActivityLog::BACKEND_USER_PLING_EXCLUDED, $logArray);
0175 
0176         $jTableResult = array();
0177         $jTableResult['Result'] = 'OK';
0178 
0179         $this->_helper->json($jTableResult);
0180     }
0181 
0182     private function getMemberForm()
0183     {
0184 
0185         $form = new Zend_Form();
0186     }
0187 
0188 }