} if (strlen($externalType) == 0) { $RequestError = true; $addExternalIdNotifications[] = MakeNotification("error", Language::Get('main', 'missingAliasType', $langTemplate)); } if ($externalType == 2 && strlen($externalTypeName) == 0) { $RequestError = true; $addExternalIdNotifications[] = MakeNotification("error", Language::Get('main', 'missingAliasPrefix', $langTemplate)); } if (!$RequestError) { if ($externalType == 1) { $externalTypeName = 'S'; } // add externalId $URI = $serverURI . "/DB/DBExternalId/externalid"; $ext = ExternalId::createExternalId($externalTypeName . '_' . $externalId, $cid); http_post_data($URI, ExternalId::encodeExternalId($ext), true, $messageNewAc); if ($messageNewAc != "201") { $RequestError = true; $addExternalIdNotifications[] = MakeNotification("error", Language::Get('main', 'errorCreateAlias', $langTemplate)); } } // show notification if ($RequestError == false) { $addExternalIdNotifications[] = MakeNotification("success", Language::Get('main', 'successEditCourse', $langTemplate)); } } elseif ($_POST['action'] == "Plugins") { $plugins = cleanInput($_POST['plugins']); // bool which is true if any error occured $RequestError = false; // which need to be deleted
/** * Logs in a user. * * @param string $username * @param string $password * @return true if login is successful */ public function loginUser($username, $password) { global $databaseURI; global $logicURI; // check if logged in in studip $studip = $this->checkUserInStudip($this->uid, $this->sid); $studipStatus = null; if ($studip == true) { ///Logger::Log("inStudip", LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log'); $url = "{$databaseURI}/user/user/{$username}"; $message = null; $this->userData = http_get($url, false, $message); ///Logger::Log("ostepuUser_url: ".$url, LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log'); ///Logger::Log("ostepuUser_message: ".$message, LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log'); ///Logger::Log("ostepuUser_data: ".$this->userData, LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log'); $this->userData = json_decode($this->userData, true); // check if user exists in our system if ($message != "404" && empty($this->userData) == false) { // save logged in uid $_SESSION['UID'] = $this->userData['id']; // refresh Session in UI and DB $refresh = $this->refreshSession(); if (isset($_GET['vid']) && (!isset($_GET['cid']) || $this->cid === null)) { // convert vid to cid // create course if does not exist $this->cid = $this->convertVidToCid($_GET['vid']); ///Logger::Log("cid: ".$this->cid , LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log'); if ($this->cid === null) { // create course $studipStatus = $this->getUserStatusInStudip($this->uid, $this->vid); if ($studipStatus === CourseStatus::getStatusDefinition(true)['administrator']) { ///Logger::Log("createCourse>>".$_GET['vid'] , LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log'); $courseObject = $this->getCourseInStudip($this->vid); if ($courseObject !== null) { $url = "{$logicURI}/course"; $courseObject = http_post_data($url, Course::encodeCourse($courseObject), false, $message); if ($message === 201) { // new course was created $courseObject = Course::decodeCourse($courseObject); if ($courseObject !== null) { $this->cid = $courseObject->getId(); $url = "{$databaseURI}/externalid"; $externalId = ExternalId::createExternalId('S_' . $_GET['vid'], $this->cid); $externalId = http_post_data($url, ExternalId::encodeExternalId($externalId), false, $message); if ($message !== 201) { // create externalId fails, remove course $url = "{$logicURI}/course/course/" . $this->cid; http_delete($url, false, $message); $this->cid = null; } if ($this->cid !== null && $studipStatus === CourseStatus::getStatusDefinition(true)['administrator']) { // redirect user to course settings /// ??? } } } } } } } if (!isset($this->cid) || $this->cid === null) { set_error("unbekannte Veranstaltung!!!"); exit; } // get the courseStatus for given course $this->courseStatus = $this->findCourseStatus(); ///Logger::Log("courseStatus: ".$this->courseStatus , LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log'); // if user has no status in course create it if (!isset($this->courseStatus)) { if ($studipStatus === null) { $studipStatus = $this->getUserStatusInStudip($this->uid, $this->vid); } if ($studipStatus !== null) { ///Logger::Log("createCourseStatus" , LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log'); // check whether an registration is allowed $courseData = $this->getCourseData($this->cid); if ($courseData === null) { // no course data set_error("Keine Veranstaltung gefunden!"); exit; } if ($courseData->getSettings() !== null) { $end = Course::containsSetting($courseData, 'RegistrationPeriodEnd'); if ($end !== null && $end != 0 && $end < time()) { // no registration allowed set_error("Eine Anmeldung ist nicht möglich!!! Ablaufdatum: " . date('d.m.Y - H:i', $end)); exit; } } $CourseStatusResponse = $this->createCourseStatus($this->userData['id'], $this->cid, $studipStatus); // set courseStatus to studipStatus only if status is created in DB successfully if ($CourseStatusResponse == true) { $this->courseStatus = $studipStatus; } } } return $refresh; } else { // get new user from studIP $newUser = $this->getUserInStudip($username); // if user is a valid user if ($newUser != "not found") { ///Logger::Log("creatUser: "******""); } } } } return false; }