File indexing completed on 2024-12-22 05:33:26

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  * Created: 12.10.2018
0023  */
0024 
0025 class Backend_GroupController extends Local_Controller_Action_Backend
0026 {
0027 
0028     public function newgroupAction()
0029     {
0030         $this->_helper->layout()->disableLayout();
0031         //$this->_helper->viewRenderer->setNoRender(true);
0032 
0033         /** @var Zend_Controller_Request_Http $request */
0034         $request = $this->_request;
0035         $header = $this->getHeaders();
0036         Zend_Registry::get('logger')->info(__METHOD__ . ' - gitlab event data header: ' . json_encode($header));
0037         $body = $request->getRawBody();
0038         Zend_Registry::get('logger')->info(__METHOD__ . ' - gitlab event data body: ' . $body);
0039         $data = Zend_Json::decode($body);
0040         Zend_Registry::get('logger')->info(__METHOD__ . ' - gitlab event data decoded: ' . PHP_EOL . print_r($data, true));
0041 
0042         $modelGroup = new Backend_Model_Group();
0043 
0044         try {
0045             $modelGroup->processEventData($data);
0046         } catch (Exception $e) {
0047             Zend_Registry::get('logger')->warn($e->getMessage() .PHP_EOL . $e->getTraceAsString());
0048         }
0049 
0050     }
0051 
0052     private function getHeaders()
0053     {
0054         if (false === function_exists('getallheaders'))
0055         {
0056             $headers = [];
0057             foreach ($_SERVER as $name => $value)
0058             {
0059                 if (substr($name, 0, 5) == 'HTTP_')
0060                 {
0061                     $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
0062                 }
0063             }
0064             return $headers;
0065         }
0066 
0067         return getallheaders();
0068     }
0069 
0070 }