/** * Log the user into the application * * @param UserAuth array $user_auth -- Set user_name and password (password needs to be * in the right encoding for the type of authentication the user is setup for. * @param String $application -- The name of the application you are logging in from. (Currently unused). * @return Array(session_id, error) -- session_id is the id of the session that was * created. Error is set if there was any error during creation. */ function login($user_auth, $application = 'test') { $error = new SoapError(); $success = false; $user_auth["user_name"] = addslashes($user_auth["user_name"]); $user_auth["password"] = addslashes($user_auth["password"]); $_POST['login'] = '******'; $_REQUEST['login'] = '******'; if (isset($user_auth["user_name"]) || isset($user_auth["password"])) { dPsessionStart(array('AppUI')); $AppUI = new CAppUI(); $ok = $AppUI->login($user_auth["user_name"], $user_auth["password"]); if (!$ok) { $error->set_error('invalid_login'); return array('id' => -1, 'error' => $error->get_soap_array()); $AppUI->setMsg('Login Failed'); } else { //Register login in user_acces_log $AppUI->registerLogin(); addHistory('login', $AppUI->user_id, 'login', $AppUI->user_first_name . ' ' . $AppUI->user_last_name); $_SESSION['AppUI'] = $AppUI; $success = true; } } if ($success) { $_SESSION['is_valid_session'] = true; $_SESSION['type'] = 'user'; return array('id' => session_id(), 'error' => $error); } $error->set_error('invalid_login'); return array('id' => -1, 'error' => $error); }