$time_gap = time() - strtotime($gCurrentSession->getValue('ses_timestamp', 'Y-m-d H:i:s')); // if cookie ADMIDIO_DATA is set and last user activity is longer ago, then create auto login if possible if (array_key_exists($gCookiePraefix . '_DATA', $_COOKIE) && $time_gap > $gPreferences['logout_minutes'] * 60 && $gCurrentSession->hasObject('gCurrentUser')) { // restore user from auto login session $autoLogin = new AutoLogin($gDb, $gSessionId); $autoLogin->setValidLogin($gCurrentSession, $_COOKIE[$gCookiePraefix . '_DATA']); $userIdAutoLogin = $autoLogin->getValue('atl_usr_id'); } } else { // create new session object and store it in PHP session $gCurrentSession = new Session($gDb, $gSessionId); $_SESSION['gCurrentSession'] = $gCurrentSession; // create system component $gSystemComponent = new Component($gDb); $gSystemComponent->readDataByColumns(array('com_type' => 'SYSTEM', 'com_name_intern' => 'CORE')); $gCurrentSession->addObject('gSystemComponent', $gSystemComponent); // if cookie ADMIDIO_DATA is set then there could be an auto login // the auto login must be done here because after that the corresponding organization must be set if (array_key_exists($gCookiePraefix . '_DATA', $_COOKIE)) { // restore user from auto login session $autoLogin = new AutoLogin($gDb, $gSessionId); $autoLogin->setValidLogin($gCurrentSession, $_COOKIE[$gCookiePraefix . '_DATA']); $userIdAutoLogin = $autoLogin->getValue('atl_usr_id'); // create object of the organization of config file with their preferences if ($autoLogin->getValue('atl_org_id') > 0) { $gCurrentOrganization = new Organization($gDb, $autoLogin->getValue('atl_org_id')); } else { $gCurrentOrganization = new Organization($gDb, $g_organization); } } else { // create object of the organization of config file with their preferences
$gCurrentSession->refreshSession(); // read system component $gSystemComponent =& $gCurrentSession->getObject('gSystemComponent'); // read language data from session and assign them to the language object $gL10n->addLanguageData($gCurrentSession->getObject('gLanguageData')); // read organization data from session object $gCurrentOrganization =& $gCurrentSession->getObject('gCurrentOrganization'); $gPreferences = $gCurrentOrganization->getPreferences(); } else { // create new session object and store it in PHP session $gCurrentSession = new Session($gDb, $gSessionId, $gCookiePraefix); $_SESSION['gCurrentSession'] = $gCurrentSession; // create system component $gSystemComponent = new Component($gDb); $gSystemComponent->readDataByColumns(array('com_type' => 'SYSTEM', 'com_name_intern' => 'CORE')); $gCurrentSession->addObject('gSystemComponent', $gSystemComponent); // create object of the organization of config file with their preferences if ($gCurrentSession->getOrganizationId() > 0) { $gCurrentOrganization = new Organization($gDb, $gCurrentSession->getOrganizationId()); } else { $gCurrentOrganization = new Organization($gDb, $g_organization); } if ($gCurrentOrganization->getValue('org_id') === 0) { // organization not found exit('<div style="color: #cc0000;">Error: The organization of the config.php could not be found in the database!</div>'); } // add the organization to the session $gPreferences = $gCurrentOrganization->getPreferences(); $gCurrentSession->addObject('gCurrentOrganization', $gCurrentOrganization); $gCurrentSession->setValue('ses_org_id', $gCurrentOrganization->getValue('org_id')); // create a language data object and assign it to the language object