function _initLanguage() { $this->log("initLanguage", GLZ_LOG_SYSTEM); // inizializza la lingua $this->_language = org_glizy_Session::get('glizy.language', NULL); $this->_languageId = org_glizy_Session::get('glizy.languageId', NULL); if (is_null($this->_languageId)) { $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); // try to read the browser language $this->log("Read browser language", GLZ_LOG_SYSTEM); $ar = org_glizy_ObjectFactory::createModel('org.glizycms.core.models.Language'); if (!$ar->find(array('language_code' => $lang, 'language_FK_site_id' => __Config::get('SITE_ID')))) { $this->log("Read defaul language", GLZ_LOG_SYSTEM); $ar->emptyRecord(); $ar->find(array('language_isDefault' => 1, 'language_FK_site_id' => __Config::get('SITE_ID'))); } $this->_language = $ar->language_code; $this->_languageId = $ar->language_id; org_glizy_Session::set('glizy.language', $this->_language); org_glizy_Session::set('glizy.languageId', $this->_languageId); } org_glizy_ObjectValues::set('org.glizy', 'languageId', $this->_languageId); // importa i file di localizzazione if (file_exists(org_glizy_Paths::getRealPath('CORE_CLASSES') . 'org/glizy/locale/' . $this->getLanguage() . '.php')) { $this->log("Import locale file", GLZ_LOG_SYSTEM); require_once org_glizy_Paths::getRealPath('CORE_CLASSES') . 'org/glizy/locale/' . $this->getLanguage() . '.php'; } else { require_once org_glizy_Paths::getRealPath('CORE_CLASSES') . 'org/glizy/locale/en.php'; } }
static function reset($type = NULL) { $messages =& org_glizy_Session::get('org.glizy.application.MessageStack', array()); if (is_null($type) || $type == 'ALL') { $messages = array(); } else { $messages[$type] = array(); } org_glizy_Session::set('org.glizy.application.MessageStack', $messages); }
public function logout() { org_glizy_Session::start(); $evt = array('type' => GLZ_EVT_USERLOGOUT, 'data' => ''); $this->dispatchEvent($evt); if (org_glizy_Config::get('USER_LOG')) { $user = org_glizy_Session::get('glizy.user'); $arLog =& org_glizy_ObjectFactory::createModel('org.glizy.models.UserLog'); $arLog->load($user['logId']); $arLog->delete(); } org_glizy_Session::removeAll(); setcookie("glizy_username", "", time() - 3600); setcookie("glizy_password", "", time() - 3600); }
function process() { $allowGroups = $this->getAttribute('allowGroups') != '' ? explode(',', $this->getAttribute('allowGroups')) : array(); if ((!org_glizy_Session::get('glizy.userLogged') || !(count($allowGroups) ? in_array($this->_user->groupId, $allowGroups) : true)) && $this->getAttribute('enabled')) { if (org_glizy_helpers_Link::scriptUrl() != org_glizy_helpers_Link::makeUrl('link', array('pageId' => org_glizy_Config::get('START_PAGE')))) { if ($this->getAttribute('showErrorMessage')) { org_glizy_Session::set('glizy.loginError', org_glizy_locale_Locale::get('GLZ_LOGIN_NOACCESS')); } org_glizy_Session::set('glizy.loginUrl', __Request::get('__url__')); } org_glizy_helpers_Navigation::gotoUrl(org_glizy_helpers_Link::makeUrl('link', array('pageId' => $this->getAttribute('accessPageId')))); exit; } if ($this->getAttribute('checkAcl') && !$this->_user->acl($this->_application->getPageId(), 'visible')) { header('HTTP/1.0 403 Forbidden'); exit; } }
function __construct($componentId) { org_glizy_Session::init(); $this->_pageId = strtolower(org_glizy_ObjectValues::get('org.glizy.application', 'pageId')); $this->_componentId = $componentId; $this->_allValues = org_glizy_Session::get(GLZ_SESSION_EX_PREFIX, array(), false, true); if (!array_key_exists($this->_pageId, $this->_allValues)) { $this->_allValues[$this->_pageId] = array(); } foreach ($this->_allValues as $k => $v) { if ($k != $this->_pageId) { foreach ($v as $kk => $vv) { if ($vv['type'] != GLZ_SESSION_EX_PERSISTENT) { unset($this->_allValues[$k][$kk]); } } } } $this->_values =& $this->_allValues[$this->_pageId]; org_glizy_Session::set(GLZ_SESSION_EX_PREFIX, $this->_allValues); /* da verificare $url = org_glizy_Request::get( '__back__url__' ); $userted = array(); if ( !empty( $url ) ) { foreach($this->_values as $k=>$v) { $val = explode( "_", $k ); if ( count( $val ) == 2 && !in_array( $val[1], $userted) ) { $userted[] = $val[1]; if ( strpos( $url, $val[1].'='.$v['value'] ) === false ) { $url .= '&'.$val[1].'='.$v['value']; } } } org_glizy_Request::set( '__back__url__', $url ); } */ }
function __construct($id, $groupId) { parent::__construct($id, $groupId); $this->roles = array(); $this->aclMatrix = array(); if ($id) { // TODO ora la matrice è memorizzata nella sessione // e non può essere invalidata dal gestore dei ruoli per tutti gli utenti $roles = org_glizy_Session::exists('glizy.roles'); if (!empty($roles)) { $this->roles = org_glizy_Session::get('glizy.roles'); $this->aclMatrix = org_glizy_Session::get('glizy.aclMatrix'); } else { $it = org_glizy_ObjectFactory::createModelIterator('org.glizy.models.Role', 'getPermissions', array('params' => array('id' => $id, 'groupId' => $groupId))); foreach ($it as $ar) { // se il ruolo non è attivo passa al prossimo if (!$ar->role_active) { continue; } // se il ruolo non è stato ancora processato if (!$this->roles[$ar->role_id]) { $this->roles[$ar->role_id] = true; $permissions = unserialize($ar->role_permissions); // unione delle matrici dei permessi foreach ($permissions as $name => $actions) { foreach ((array) $actions as $action => $value) { $this->aclMatrix[strtolower($name)][$action] |= $value; } } } } org_glizy_Session::set('glizy.roles', $this->roles); org_glizy_Session::set('glizy.aclMatrix', $this->aclMatrix); } } }
function getEditingLanguageIsDefault() { return org_glizy_Session::get('glizy.editingLanguageIsDefault'); }
private function redirectAfterLogin() { $destPage = ''; $accessPageId = $this->getAttribute('accessPageId'); if ($accessPageId && $accessPageId != $this->_application->getPageId()) { $destPage = strpos($accessPageId, 'http') !== false ? $accessPageId : org_glizy_helpers_Link::makeUrl('link', array('pageId' => $this->getAttribute('accessPageId'))); } $url = org_glizy_Session::get('glizy.loginUrl', $destPage); if ($url) { org_glizy_Session::remove('glizy.loginUrl'); org_glizy_helpers_Navigation::gotoUrl($url); } }
function login() { $this->log("login", GLZ_LOG_SYSTEM); if (org_glizy_Session::get('glizy.userLogged')) { $this->log("user is logged", GLZ_LOG_SYSTEM); $user = org_glizy_Session::get('glizy.user'); // crea l'utente $this->_user =& org_glizy_ObjectFactory::createObject('org.glizy.application.User', $user); org_glizy_ObjectValues::setByReference('org.glizy', 'user', $this->_user); org_glizy_ObjectValues::set('org.glizy', 'userId', $this->_user->id); if (org_glizy_Config::get('USER_LOG')) { $this->log("log user access", GLZ_LOG_SYSTEM); $arLog =& org_glizy_ObjectFactory::createModel('org.glizy.models.UserLog'); $arLog->load($user['logId']); $arLog->userlog_FK_user_id = $user['id']; $arLog->save(); } } else { $this->log("user not logged", GLZ_LOG_SYSTEM); // utente finto $user = 0; // crea l'utente $this->_user =& org_glizy_ObjectFactory::createObject('org.glizy.application.User', $user); org_glizy_ObjectValues::setByReference('org.glizy', 'user', $this->_user); org_glizy_ObjectValues::set('org.glizy', 'userId', 0); } }