Use MY_Controller instead of global hook

This commit is contained in:
Eike Foken
2011-09-16 00:16:44 +02:00
parent 7a83935410
commit 76f5b3678c
16 changed files with 151 additions and 52 deletions

View File

@@ -10,12 +10,6 @@
|
*/
$hook['post_controller_constructor'] = array(
'class' => '',
'function' => 'check_login',
'filename' => 'global.php',
'filepath' => 'hooks'
);
/* End of file hooks.php */
/* Location: ./application/config/hooks.php */

View File

@@ -1,6 +1,6 @@
<?php
<?php defined('BASEPATH') || exit('No direct script access allowed');
/*
* Copyright (c) 2011 Karsten Heiken <karsten@disposed.de>
* Copyright (c) 2011 Karsten Heiken, Eike Foken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -22,11 +22,11 @@
*/
/**
* Static about page
* Static about page.
*
* @author Karsten Heiken <karsten@disposed.de>
*/
class About extends CI_Controller {
class About extends MY_Controller {
/**
* Constructor.

View File

@@ -1,7 +1,6 @@
<?php
<?php defined('BASEPATH') || exit('No direct script access allowed');
/*
* Copyright (c) 2011 Karsten Heiken <karsten@disposed.de>
* Copyright (c) 2011 Karsten Heiken, Eike Foken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -28,7 +27,7 @@
* @author Karsten Heiken <karsten@disposed.de>
* @author Eike Foken <kontakt@eikefoken.de>
*/
class Ajax extends CI_Controller {
class Ajax extends MY_Controller {
/**
* Constructor.

View File

@@ -1,7 +1,6 @@
<?php
<?php defined('BASEPATH') || exit('No direct script access allowed');
/*
* Copyright (c) 2011 Karsten Heiken <karsten@disposed.de>
* Copyright (c) 2011 Karsten Heiken, Eike Foken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,20 +1,39 @@
<?php defined('BASEPATH') || exit("No direct script access allowed");
<?php defined('BASEPATH') || exit('No direct script access allowed');
/*
* Copyright (c) 2011 Karsten Heiken, Eike Foken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* Authentication controller.
*
* @author Eike Foken <kontakt@eikefoken.de>
*/
class Auth extends CI_Controller {
class Auth extends MY_Controller {
/**
* Constructor.
*/
public function __construct() {
parent::__construct();
$this->load->library('access');
$this->load->library('form_validation');
$this->load->model('user');
}
/**
@@ -114,9 +133,6 @@ class Auth extends CI_Controller {
if ($this->input->post('new_password') != '') {
$username = $this->session->userdata('username');
$change = $this->access->changePassword($username, $this->input->post('old_password'), $this->input->post('new_password'));
// if ($change) {
// $this->logout();
// }
}
// update users table

View File

@@ -1,6 +1,6 @@
<?php
<?php defined('BASEPATH') || exit('No direct script access allowed');
/*
* Copyright (c) 2011 Karsten Heiken <karsten@disposed.de>
* Copyright (c) 2011 Karsten Heiken, Eike Foken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -24,7 +24,7 @@
/**
* @author Karsten Heiken <karsten@disposed.de>
*/
class Dashboard extends CI_Controller {
class Dashboard extends MY_Controller {
/**
* Constructor.

View File

@@ -27,7 +27,7 @@
* @author Karsten Heiken <karsten@disposed.de>
* @author Eike Foken <kontakts@eikefoken.de>
*/
class Experiments extends CI_Controller {
class Experiments extends MY_Controller {
/**
* Constructor.

View File

@@ -26,7 +26,7 @@
* @author Karsten Heiken <karsten@disposed.de>
* @author Eike Foken <kontakt@eikefoken.de>
*/
class Jobs extends CI_Controller {
class Jobs extends MY_Controller {
/**
* Constructor.

View File

@@ -1,6 +1,6 @@
<?php
<?php defined('BASEPATH') || exit('No direct script access allowed');
/*
* Copyright (c) 2011 Karsten Heiken <karsten@disposed.de>
* Copyright (c) 2011 Karsten Heiken, Eike Foken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -22,11 +22,11 @@
*/
/**
* Static license page
* Static license page.
*
* @author Karsten Heiken <karsten@disposed.de>
*/
class License extends CI_Controller {
class License extends MY_Controller {
/**
* Constructor.

View File

@@ -1,7 +1,6 @@
<?php
<?php defined('BASEPATH') || exit('No direct script access allowed');
/*
* Copyright (c) 2011 Karsten Heiken <karsten@disposed.de>
* Copyright (c) 2011 Karsten Heiken, Eike Foken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -23,9 +22,10 @@
*/
/**
*
* @author Karsten Heiken <karsten@disposed.de>
*/
class Programs extends CI_Controller {
class Programs extends MY_Controller {
/**
* Constructor.

View File

@@ -1,6 +1,6 @@
<?php
<?php defined('BASEPATH') || exit('No direct script access allowed');
/*
* Copyright (c) 2011 Karsten Heiken <karsten@disposed.de>
* Copyright (c) 2011 Karsten Heiken, Eike Foken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,7 +26,7 @@
* @author Karsten Heiken <karsten@disposed.de>
* @author Eike Foken <kontakt@eikefoken.de>
*/
class Projects extends CI_Controller {
class Projects extends MY_Controller {
/**
* Constructor.
@@ -36,7 +36,6 @@ class Projects extends CI_Controller {
$this->load->library('form_validation');
$this->load->model('experiment');
$this->load->model('job');
$this->load->model('share');
}
/**

View File

@@ -1,6 +1,6 @@
<?php
<?php defined('BASEPATH') || exit('No direct script access allowed');
/*
* Copyright (c) 2011 Karsten Heiken <karsten@disposed.de>
* Copyright (c) 2011 Karsten Heiken, Eike Foken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,7 +26,7 @@
*
* @author Karsten Heiken <karsten@disposed.de>
*/
class Results extends CI_Controller {
class Results extends MY_Controller {
/**
* Constructor.
@@ -38,6 +38,9 @@ class Results extends CI_Controller {
$this->load->model('server');
}
/**
*
*/
public function index() {
}

View File

@@ -1,11 +1,32 @@
<?php defined('BASEPATH') || exit('No direct script access allowed');
/*
* Copyright (c) 2011 Karsten Heiken, Eike Foken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* Search projects and experiments.
*
* @author Eike Foken <kontakt@eikefoken.de>
*/
class Search extends CI_Controller {
class Search extends MY_Controller {
/**
* Calls the parent constructor.

View File

@@ -1,6 +1,6 @@
<?php defined('BASEPATH') || exit('No direct script access allowed');
/*
* Copyright (c) 2011 Eike Foken <kontakt@eikefoken.de>
* Copyright (c) 2011 Karsten Heiken, Eike Foken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,14 +25,13 @@
*
* @author Eike Foken <kontakt@eikefoken.de>
*/
class Users extends CI_Controller {
class Users extends MY_Controller {
/**
* Calls the parent constructor.
*/
public function __construct() {
parent::__construct();
$this->load->model('user');
}
/**

View File

@@ -1,6 +1,6 @@
<?php
<?php defined('BASEPATH') || exit('No direct script access allowed');
/*
* Copyright (c) 2011 Karsten Heiken <karsten@disposed.de>
* Copyright (c) 2011 Karsten Heiken, Eike Foken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,8 +26,11 @@
*
* @author Karsten Heiken <karsten@disposed.de>
*/
class Xmlrpc extends CI_Controller {
class Xmlrpc extends MY_Controller {
/**
* Calls the parent constructor.
*/
function __construct() {
parent::__construct();
@@ -120,6 +123,11 @@ class Xmlrpc extends CI_Controller {
return $this->xmlrpc->send_response($response);
}
/**
*
* @param mixed $request
* @return mixed
*/
function _job_done($request) {
$this->load->model('job');
$parameters = $request->output_parameters();
@@ -142,5 +150,7 @@ class Xmlrpc extends CI_Controller {
), 'struct');
return $this->xmlrpc->send_response($response);
}
}
/* End of file xmlrpc.php */
/* Location: ./application/controllers/xmlrpc.php */

View File

@@ -0,0 +1,59 @@
<?php defined('BASEPATH') || exit('No direct script access allowed');
/*
* Copyright (c) 2011 Karsten Heiken, Eike Foken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* Extends CI's controller.
*
* @author Eike Foken <kontakt@eikefoken.de>
*/
class MY_Controller extends CI_Controller {
/**
* Contains a list of public controllers.
*
* @var array
*/
private $public_controllers = array('auth', 'xmlrpc');
/**
* Calls the parent contructor.
*/
public function __construct() {
parent::__construct();
if (!in_array($this->router->class, $this->public_controllers)) {
// redirect if the user is not logged in
if (!$this->input->is_ajax_request() && !$this->access->isLoggedIn()) {
redirect('auth/login');
}
// show message if side is marked as offline
if ($this->setting->get('offline') == 1 && !$this->access->isAdmin()) {
show_error($this->setting->get('offline_message'));
}
}
}
}
/* End of file MY_Controller.php */
/* Location: ./application/core/MY_Controller.php */