Merge pull request #6657 from JakubOnderka/app-controller-cleanup

fix: [internal] Remove unused method from AppController
pull/6662/head
Jakub Onderka 2020-11-27 09:05:27 +01:00 committed by GitHub
commit 02b29c1d19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 41 deletions

View File

@ -681,23 +681,6 @@ class AppController extends Controller
public $userRole = null;
protected function _isJson($data=false)
{
if ($data) {
return (json_decode($data) != null) ? true : false;
}
return $this->request->header('Accept') === 'application/json' || $this->RequestHandler->prefers() === 'json';
}
protected function _isCsv($data=false)
{
if ($this->params['ext'] === 'csv' || $this->request->header('Accept') === 'application/csv' || $this->RequestHandler->prefers() === 'csv') {
return true;
} else {
return false;
}
}
protected function _isRest()
{
return $this->IndexFilter->isRest();
@ -740,11 +723,6 @@ class AppController extends Controller
return $this->userRole['perm_site_admin'];
}
protected function _checkOrg()
{
return $this->Auth->user('org_id');
}
protected function _getApiAuthUser(&$key, &$exception)
{
if (strlen($key) == 40) {

View File

@ -1,6 +1,9 @@
<?php
App::uses('AppController', 'Controller');
/**
* @property EventGraph $EventGraph
*/
class EventGraphController extends AppController
{
public $components = array(
@ -19,30 +22,16 @@ class EventGraphController extends AppController
throw new MethodNotAllowedException(__('No event ID set.'));
}
// retrieve current org_id
$org_id = $this->_checkOrg();
// validate event
$this->loadModel('Event');
if (Validation::uuid($event_id)) {
$temp = $this->Event->find('first', array('recursive' => -1, 'fields' => array('Event.id'), 'conditions' => array('Event.uuid' => $eventId)));
if (empty($temp)) {
throw new NotFoundException('Invalid event');
}
$event_id = $temp['Event']['id'];
} elseif (!is_numeric($event_id)) {
throw new NotFoundException(__('Invalid event'));
}
$event = $this->Event->fetchEvent($this->Auth->user(), array('eventid' => $event_id));
$event = $this->Event->fetchSimpleEvent($this->Auth->user(), $event_id);
if (empty($event)) {
throw new NotFoundException('Invalid event');
}
// fetch eventGraphs
$conditions = [
'EventGraph.event_id' => $event_id,
'EventGraph.org_id' => $org_id
'EventGraph.event_id' => $event['Event']['id'],
'EventGraph.org_id' => $this->Auth->user('org_id'),
];
if (!is_null($graph_id)) {
$conditions['EventGraph.id'] = $graph_id;
@ -82,7 +71,7 @@ class EventGraphController extends AppController
}
$this->loadModel('Event');
$event = $this->Event->fetchEvent($this->Auth->user(), array('eventid' => $event_id));
$event = $this->Event->fetchSimpleEvent($this->Auth->user(), $event_id);
if (empty($event)) {
throw new NotFoundException('Invalid event');
}
@ -91,7 +80,7 @@ class EventGraphController extends AppController
if (!$this->_isSiteAdmin() && ($event['Event']['orgc_id'] != $this->Auth->user('org_id') && !$this->userRole['perm_modify'])) {
throw new UnauthorizedException(__('You do not have permission to do that.'));
} else {
$eventGraph['EventGraph']['event_id'] = $event_id;
$eventGraph['EventGraph']['event_id'] = $event['Event']['id'];
}
if (!isset($this->request->data['EventGraph']['network_json'])) {