From 63747dad1820d275e25472ae8ae3d612cddf9aef Mon Sep 17 00:00:00 2001 From: Thomas Mudrunka Date: Fri, 23 Sep 2011 19:56:40 +0200 Subject: [PATCH] Prvni verze systemu vymenitelnych backendu --- index.php | 12 +++---- lib/Sklad_Auth.class/common.php | 34 +++++++++++++++++++ .../internal.php} | 20 ++--------- 3 files changed, 43 insertions(+), 23 deletions(-) create mode 100755 lib/Sklad_Auth.class/common.php rename lib/{Sklad_LMS-fake.class.php => Sklad_Auth.class/internal.php} (71%) diff --git a/index.php b/index.php index c23213f..7bde575 100755 --- a/index.php +++ b/index.php @@ -20,7 +20,7 @@ require_once('sklad.conf.php'); set_include_path(DIR_LIB.PATH_SEPARATOR.get_include_path()); -require_once('Sklad_LMS-fake.class.php'); +require_once('Sklad_Auth.class/common.php'); require_once('HTTP_Auth.class.php'); require_once('Locale.class.php'); require_once('Barcode.class.php'); @@ -421,7 +421,7 @@ EOF; */ class Sklad_DB extends PDO { function __construct() { - $this->lms = new Sklad_LMS(); + $this->auth = new Sklad_Auth(); parent::__construct( DB_DSN, DB_USER, DB_PASS, @@ -607,8 +607,8 @@ class Sklad_DB extends PDO { $row_quoted[$column] = '0'; break; case $table.'_author': - $row_quoted[$column] = $this->lms->get_authorized_user_id(); - //die($this->lms->get_authorized_user_id().'=USER'); + $row_quoted[$column] = $this->auth->get_authorized_user_id(); + //die($this->auth->get_authorized_user_id().'=USER'); break; } } @@ -747,7 +747,7 @@ class Sklad_UI { } function check_auth() { - new HTTP_Auth('SkladovejSystem', true, array($this->db->lms,'check_auth')); + new HTTP_Auth('SkladovejSystem', true, array($this->db->auth,'check_auth')); } function post_redirect_get($location, $message='', $error=false) { @@ -843,7 +843,7 @@ class Sklad_UI { //Sephirot: if(!isset($PATH_CHUNKS[1])) $PATH_CHUNKS[1]=''; if($_SERVER['REQUEST_METHOD'] != 'POST' && $PATH_CHUNKS[1]!='barcode') //TODO: tyhle podminky naznacujou, ze je v navrhu nejaka drobna nedomyslenost... - echo $this->html->header($PATH_INFO,$this->db->lms->get_authorized_user_id()); + echo $this->html->header($PATH_INFO,$this->db->auth->get_authorized_user_id()); switch($PATH_CHUNKS[1]) { //TODO: Move some branches to plugins if possible case 'test': //test die('Tell me why you cry'); diff --git a/lib/Sklad_Auth.class/common.php b/lib/Sklad_Auth.class/common.php new file mode 100755 index 0000000..eff35d2 --- /dev/null +++ b/lib/Sklad_Auth.class/common.php @@ -0,0 +1,34 @@ +. +*/ + +/** +* Trida implementuje podpurne funkce spolecne pro vsechny implementace tridy Sklad_Auth +* +* @package Sklad_Auth_common +* @author Tomas Mudrunka +*/ +class Sklad_Auth_common { + function get_authorized_user_id($die=true) { + if(isset($this->authorized_user_id)) return $this->authorized_user_id; + if($die) die('No user authorized!!!'); + return false; + } +} + +require_once(BACKEND_AUTH.'.php'); diff --git a/lib/Sklad_LMS-fake.class.php b/lib/Sklad_Auth.class/internal.php similarity index 71% rename from lib/Sklad_LMS-fake.class.php rename to lib/Sklad_Auth.class/internal.php index cc84e12..1ef39d2 100755 --- a/lib/Sklad_LMS-fake.class.php +++ b/lib/Sklad_Auth.class/internal.php @@ -17,33 +17,19 @@ * along with this program. If not, see . */ -/** -* Trida implementuje podpurne funkce spolecne pro vsechny implementace tridy Sklad_LMS -* -* @package Sklad_LMS_common -* @author Tomas Mudrunka -*/ -class Sklad_LMS_common { - function get_authorized_user_id($die=true) { - if(isset($this->authorized_user_id)) return $this->authorized_user_id; - if($die) die('No user authorized!!!'); - return false; - } -} - /** * Trida predstira spojeni s LMS a podvrhuje smysluplna data pro testovaci ucely * -* @package Sklad_LMS +* @package Sklad_Auth * @author Tomas Mudrunka */ -class Sklad_LMS extends Sklad_LMS_common { //FAKE! +class Sklad_Auth extends Sklad_Auth_common { //FAKE! function check_auth($user, $pass) { $users = array( //You can specify multiple users in this array DB_USER => DB_PASS ); if(isset($GLOBALS['fake_lms_users'])) $users = $GLOBALS['fake_lms_users'] + $users; - $this->authorized_user_id=23; //LMS user_id + $this->authorized_user_id=23; //Auth user_id return (isset($users[$user]) && ($users[$user] == $pass)); } } -- 2.30.2