/**
  * Get single directory tree
  * @return array an array of ecs cms directory tree entries
  */
 public function getCourse($course_id, $a_details = false)
 {
     $this->path_postfix = '/campusconnect/courses/' . (int) $course_id;
     if ($a_details and $course_id) {
         $this->path_postfix .= '/details';
     }
     try {
         $this->prepareConnection();
         $this->setHeader(array());
         if ($a_details) {
             $this->addHeader('Accept', 'application/json');
         } else {
             $this->addHeader('Accept', 'text/uri-list');
         }
         $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->getHeader());
         $res = $this->call();
         if (substr($res, 0, 4) == 'http') {
             $json = file_get_contents($res);
             $ecs_result = new ilECSResult($json);
         } else {
             $ecs_result = new ilECSResult($res);
         }
         // Return ECSEContentDetails for details switch
         if ($a_details) {
             include_once './Services/WebServices/ECS/classes/class.ilECSEContentDetails.php';
             $details = new ilECSEContentDetails();
             $details->loadFromJson($ecs_result->getResult());
             return $details;
         }
         // Return json result
         return $ecs_result->getResult();
     } catch (ilCurlConnectionException $e) {
         throw new ilECSConnectorException('Error calling ECS service: ' . $e->getMessage());
     }
 }
示例#2
0
 /**
  * get auth resource
  *
  * @access public
  * @param auth hash (transfered via GET)
  * @throws ilECSConnectorException 
  */
 public function getAuth($a_hash, $a_details_only = FALSE)
 {
     global $ilLog;
     if (!strlen($a_hash)) {
         $ilLog->write(__METHOD__ . ': No auth hash given. Aborting.');
         throw new ilECSConnectorException('No auth hash given.');
     }
     $this->path_postfix = '/sys/auths/' . $a_hash;
     if ($a_details_only) {
         $this->path_postfix .= '/details';
     }
     try {
         $this->prepareConnection();
         $res = $this->call();
         $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
         $ilLog->write(__METHOD__ . ': Checking HTTP status...');
         if ($info != self::HTTP_CODE_OK) {
             $ilLog->write(__METHOD__ . ': Cannot get auth resource, did not receive HTTP 200. ');
             throw new ilECSConnectorException('Received HTTP status code: ' . $info);
         }
         $ilLog->write(__METHOD__ . ': ... got HTTP 200 (ok)');
         $ecs_result = new ilECSResult($res);
         // Return ECSEContentDetails for details switch
         if ($a_details_only) {
             include_once './Services/WebServices/ECS/classes/class.ilECSEContentDetails.php';
             $details = new ilECSEContentDetails();
             $details->loadFromJson($ecs_result->getResult());
             return $details;
         }
         return $ecs_result;
     } catch (ilCurlConnectionException $exc) {
         throw new ilECSConnectorException('Error calling ECS service: ' . $exc->getMessage());
     }
 }