/** * Update enrolment status * @param type $a_obj_id * @param ilObjUser $user * @param type $a_status * @return boolean */ protected static function updateEnrolmentStatus($a_obj_id, ilObjUser $user, $a_status) { include_once './Services/WebServices/ECS/classes/class.ilECSRemoteUser.php'; $remote = ilECSRemoteUser::factory($user->getId()); if (!$remote instanceof ilECSRemoteUser) { return FALSE; } include_once './Services/WebServices/ECS/classes/Connectors/class.ilECSEnrolmentStatus.php'; $enrol = new ilECSEnrolmentStatus(); $enrol->setId('il_' . $GLOBALS['ilSetting']->get('inst_id', 0) . '_' . ilObject::_lookupType($a_obj_id) . '_' . $a_obj_id); $enrol->setPersonId($remote->getRemoteUserId()); $enrol->setPersonIdType(ilECSEnrolmentStatus::ID_UID); $enrol->setStatus($a_status); try { include_once './Services/WebServices/ECS/classes/Connectors/class.ilECSEnrolmentStatusConnector.php'; $con = new ilECSEnrolmentStatusConnector(ilECSSetting::getInstanceByServerId(1)); $con->addEnrolmentStatus($enrol, $remote->getMid()); } catch (ilECSConnectorException $e) { $GLOBALS['ilLog']->write(__METHOD__ . ': update enrolment status faild with message: ' . $e->getMessage()); return false; } }
/** * Called from base class after successful login * * @param string username */ public function loginObserver($a_username, $a_auth) { include_once './Services/WebServices/ECS/classes/class.ilECSUser.php'; $user = new ilECSUser($_GET); if (!($usr_id = ilObject::_lookupObjIdByImportId($user->getImportId()))) { $username = $this->createUser($user); } else { $username = $this->updateUser($user, $usr_id); } // set user imported include_once './Services/WebServices/ECS/classes/class.ilECSImport.php'; $import = new ilECSImport($this->getCurrentServer()->getServerId(), $usr_id); $import->save(); // Store remote user data include_once './Services/WebServices/ECS/classes/class.ilECSRemoteUser.php'; $remote = new ilECSRemoteUser(); $remote->setServerId($this->getCurrentServer()->getServerId()); $remote->setMid($this->getMID()); $remote->setRemoteUserId($user->getImportId()); $remote->setUserId(ilObjUser::_lookupId($username)); $GLOBALS['ilLog']->write(__METHOD__ . ': Current username ' . $username); if (!$remote->exists()) { $remote->create(); } $a_auth->setAuth($username); $this->log->write(__METHOD__ . ': Login succesesful'); return true; }