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 if (!empty($plugins)) {
/** * Extract Album informations from object * @access public * @static * @param \stdClass $album Object represent Album * @return Album */ public static function extractInfos($album) { // create Album instance $albumItem = new self(); // update informations $albumItem->setUri((string) isset($album->href) ? $album->href : ''); $albumItem->setName((string) isset($album->name) ? $album->name : ''); // is popularity available ? if (isset($album->popularity)) { // update popularity $albumItem->setPopularity((double) $album->popularity); } // is released date available ? if (isset($album->released)) { // update released dates $albumItem->setReleased((string) $album->released); } // is teritories availabality available ? if (isset($album->availability) && isset($album->availability->territories)) { // update territories availability $albumItem->setTerritories(explode(' ', $album->availability->territories)); } // is artists available (from search service) ? if (isset($album->artists) && is_array($album->artists)) { // setup artists container $artists = array(); // iterate artists foreach ($album->artists as $artist) { // create Artist and store on container $artists[] = Artist::extractInfos($artist); } // set artists of album $albumItem->setArtists($artists); } // is artists available (from lookup service) ? if (isset($album->{'artist-id'}) && isset($album->artist)) { // create and store principal artist $albumItem->setArtist(Artist::build($album->{'artist-id'}, $album->artist)); } // is tracks available ? if (isset($album->tracks) && is_array($album->tracks)) { // setup tracks container $tracks = array(); // iterate external ids foreach ($album->tracks as $track) { // create Track and store on container $tracks[] = Track::extractInfos($track); } // set albums tracks $albumItem->setTracks($tracks); } // is external ids available ? if (isset($album->{'external-ids'}) && is_array($album->{'external-ids'})) { // setup external ids container $externalIds = array(); // iterate external ids foreach ($album->{'external-ids'} as $externalId) { // create ExternalId and store on container $externalIds[] = ExternalId::extractInfos($externalId); } // set external ids of album $albumItem->setExternalIds($externalIds); } // return album instance return $albumItem; }
/** * 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; }
/** * Extract Track informations from object * @access public * @static * @param \stdClass $track Object represent Track * @return Track */ public static function extractInfos($track) { // create Track instance $trackItem = new self(); // update informations $trackItem->setUri((string) $track->href); $trackItem->setName((string) $track->name); // is popularity available ? if (isset($track->popularity)) { // update popularity $trackItem->setPopularity((double) $track->popularity); } // is disc number available ? if (isset($track->{'disc-number'})) { // update disc number $trackItem->setDiscNumber($track->{'disc-number'}); } // is track number available ? if (isset($track->{'track-number'})) { // update track number $trackItem->setTrackNumber($track->{'track-number'}); } // is track length available ? if (isset($track->length)) { // update track length $trackItem->setLength($track->length); } // is track albul available ? if (isset($track->album)) { // update track album $trackItem->setAlbum(Album::extractInfos($track->album)); } // is artists available ? if (isset($track->artists) && is_array($track->artists)) { // setup artists container $artists = array(); // iterate artists foreach ($track->artists as $artist) { // create Artist and store on container $artists[] = Artist::extractInfos($artist); } // set artists of track $trackItem->setArtists($artists); } // is external ids available ? if (isset($track->{'external-ids'}) && is_array($track->{'external-ids'})) { // setup external ids container $externalIds = array(); // iterate external ids foreach ($track->{'external-ids'} as $externalId) { // create ExternalId and store on container $externalIds[] = ExternalId::extractInfos($externalId); } // set external ids of track $trackItem->setExternalIds($externalIds); } // is teritories availabality available ? if (isset($track->availability) && isset($track->availability->territories)) { // update territories availability $trackItem->setTerritories(explode(' ', $track->availability->territories)); } // on retourne l'instance de la piste return $trackItem; }
public static function ExtractExternalId($data, $singleResult = false, $CourseExtension = '', $ExternalIdExtension = '', $isResult = true) { // generates an assoc array of courses by using a defined list of // its attributes $course = DBJson::getObjectsByAttributes($data, Course::getDBPrimaryKey(), Course::getDBConvert(), $CourseExtension); // generates an assoc array of external IDs by using a defined list of // its attributes $externalIds = DBJson::getObjectsByAttributes($data, ExternalId::getDBPrimaryKey(), ExternalId::getDBConvert(), $ExternalIdExtension); // concatenates the external IDs and the associated courses $res = DBJson::concatObjectListsSingleResult($data, $externalIds, ExternalId::getDBPrimaryKey(), ExternalId::getDBConvert()['EX_course'], $course, Course::getDBPrimaryKey(), $CourseExtension, $ExternalIdExtension); if ($isResult) { // to reindex $res = array_values($res); $res = ExternalId::decodeExternalId($res, false); if ($singleResult == true) { // only one object as result if (count($res) > 0) { $res = $res[0]; } } } return $res; }