/** * @return mixed */ public function data() { if (isset($this->keyuniqid_admin)) { $admin = new backend_db_employee(); $data = $admin->s_data_session($this->keyuniqid_admin); $role['id'] = $data['id_role']; $role['name'] = $data['role_name']; return $role; } }
/** * Author: Gerits Aurelien <aurelien[at]magix-cms[point]com> * Copyright: MAGIX CMS * Date: 17/03/2013 * Time: 23:07 * License: Dual licensed under the MIT or GPL Version */ function smarty_function_role_admin($params, $template) { if (isset($_SESSION['id_admin']) and isset($_SESSION['email_admin']) and isset($_SESSION['keyuniqid_admin'])) { $admin = new backend_db_employee(); $data = $admin->s_data_session($_SESSION['keyuniqid_admin']); if (isset($params['items'])) { if (is_array($params['items'])) { if (array_key_exists($data['role_name'], $params['items'])) { return true; } } elseif (is_string($params['items'])) { if ($data['role_name'] === $params['items']) { return true; } } } } }
/** * @access private * Vérification de la session pour accèder à l'administration * @param bool $debug */ private function authSession($debug = false) { //Language model init class $language = new backend_model_language(); $language->run(); $token = isset($_SESSION['mc_auth_token']) ? $_SESSION['mc_auth_token'] : magixglobal_model_cryptrsa::tokenId(); $tokentools = $this->hashPassCreate($token); backend_controller_template::assign('hashpass', $tokentools); if (isset($this->email_admin) and isset($this->passwd_admin) and isset($this->hashtoken)) { if (strcasecmp($this->hashtoken, $tokentools) == 0) { if ($debug == true) { $firebug = new magixcjquery_debug_magixfire(); $firebug->magixFireGroup('tokentest'); if ($this->hashtoken) { if (strcasecmp($this->hashtoken, $tokentools) == 0) { $firebug->magixFireLog('session compatible'); } else { $firebug->magixFireError('session incompatible'); } } $firebug->magixFireLog($_SESSION); $firebug->magixFireGroupEnd(); } $auth_exist = parent::s_auth_exist($this->email_admin, $this->passwd_admin); if (count($auth_exist['id_admin']) == true) { $session = new backend_model_sessions(); $lang = new backend_model_language(); $string = $_SERVER['HTTP_USER_AGENT']; $string .= 'SHIFLETT'; /* Add any other data that is consistent */ $fingerprint = md5($string); //Fermeture de la première session, ses données sont sauvegardées. session_write_close(); $this->start_session(); $data = parent::s_data_session($auth_exist['keyuniqid_admin']); if (!isset($_SESSION['email_admin']) and !isset($_SESSION['keyuniqid_admin'])) { $lang = new backend_model_language(); $session->openSession($data['id_admin'], session_regenerate_id(true), $data['keyuniqid_admin']); //session_regenerate_id(true); $_SESSION['id_admin'] = $data['id_admin']; $_SESSION['email_admin'] = $data['email_admin']; $_SESSION['keyuniqid_admin'] = $data['keyuniqid_admin']; $_SESSION['adminLanguage'] = $lang->run(); if ($debug == true) { $firebug = new magixcjquery_debug_magixfire(); $firebug->magixFireGroup('adminsession'); $firebug->magixFireDump('User session', $_SESSION); $firebug->magixFireGroupEnd(); } magixglobal_model_redirect::backend_redirect_login(false); } else { $session->openSession($data['id_admin'], null, $data['keyuniqid_admin']); $_SESSION['id_admin'] = $data['id_admin']; $_SESSION['email_admin'] = $data['email_admin']; $_SESSION['keyuniqid_admin'] = $data['keyuniqid_admin']; $_SESSION['adminLanguage'] = $lang->run(); if ($debug == true) { $firebug = new magixcjquery_debug_magixfire(); $firebug->magixFireGroup('adminsession'); $firebug->magixFireDump('User session', $_SESSION); $firebug->magixFireGroupEnd(); } magixglobal_model_redirect::backend_redirect_login(false); } } else { $this->message->getNotify('error_login', array('method' => 'fetch', 'assignFetch' => 'login_message')); } } else { $this->message->getNotify('error_hash', array('method' => 'fetch', 'assignFetch' => 'login_message')); } } }
/** * @param $data_session * @return array */ public function all_data_employee($data_session) { $id_role = $data_session['id_role']; $array_access = parent::s_all_access_profile($id_role); foreach ($array_access as $key) { $class_name[$key['class_name']] = array('view_access' => $key['view_access'], 'add_access' => $key['add_access'], 'edit_access' => $key['edit_access'], 'delete_access' => $key['delete_access']); } return $class_name; }
/** * Chargement des données pour l'édition de l'utilisateur * @param $create */ private function load_data($create) { $data = parent::s_edit_employee($this->edit); $assign_exclude = array('passwd_admin', 'keyuniqid_admin'); foreach ($data as $key => $val) { if (!array_search($key, $assign_exclude)) { $create->assign($key, $val); } } }