4 include_once
"Services/Object/classes/class.ilObject2.php";
35 public function __construct($a_id = 0,$a_call_by_reference =
true)
54 include_once
'Modules/RemoteCourse/classes/class.ilObjRemoteCourse.php';
58 include_once
'Modules/RemoteCategory/classes/class.ilObjRemoteCategory.php';
62 include_once
'Modules/RemoteFile/classes/class.ilObjRemoteFile.php';
66 include_once
'Modules/RemoteGlossary/classes/class.ilObjRemoteGlossary.php';
70 include_once
'Modules/RemoteGroup/classes/class.ilObjRemoteGroup.php';
74 include_once
'Modules/RemoteLearningModule/classes/class.ilObjRemoteLearningModule.php';
78 include_once
'Modules/RemoteWiki/classes/class.ilObjRemoteWiki.php';
82 include_once
'Modules/RemoteTest/classes/class.ilObjRemoteTest.php';
118 $query =
"SELECT organization FROM ".$a_table.
119 " WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ";
123 return $row->organization;
144 $this->organization = $a_organization;
174 $this->local_information = $a_info;
208 $query =
"SELECT mid FROM ".$a_table.
209 " WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ";
225 $this->remote_link = $a_link;
250 include_once
'./Services/WebServices/ECS/classes/class.ilECSImport.php';
254 include_once(
'./Services/WebServices/ECS/classes/class.ilECSUser.php');
256 $ecs_user_data = $user->toGET();
257 $GLOBALS[
'ilLog']->write(__METHOD__.
': Using ecs user data '.$ecs_user_data);
260 include_once
'./Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
262 if(!$part->isTokenEnabled())
268 $ecs_url_hash =
'ecs_hash_url='.urlencode(
$server->getServerURI().
'/sys/auths/'.
$auth_hash);
279 $GLOBALS[
'ilLog']->write(__METHOD__.
': ECS full link: '. $link);
293 include_once
'./Services/WebServices/ECS/classes/class.ilECSAuth.php';
294 include_once
'./Services/WebServices/ECS/classes/class.ilECSConnector.php';
295 include_once
'./Services/WebServices/ECS/classes/class.ilECSImport.php';
296 include_once
'./Services/WebServices/ECS/classes/class.ilECSSetting.php';
305 $auth->setPid($import_info->getMID());
308 $realm = sha1($a_plain_realm);
309 $GLOBALS[
'ilLog']->write(__METHOD__.
': Using realm '.$a_plain_realm);
310 $auth->setRealm($realm);
311 $GLOBALS[
'ilLog']->write(__METHOD__.
' Mid is '.$this->getMID());
312 $this->auth_hash = $connector->addAuth(@json_encode(
$auth),$this->
getMID());
317 $ilLog->write(__METHOD__.
': Caught error from ECS Auth resource: '.$exc->getMessage());
330 "obj_id" => array(
"integer", $this->
getId()),
331 "local_information" => array(
"text",
""),
332 "remote_link" => array(
"text",
""),
333 "mid" => array(
"integer", 0),
334 "organization" => array(
"text",
"")
361 "mid" => array(
"integer", $this->
getMID()),
367 $where = array(
"obj_id" => array(
"integer", $this->
getId()));
389 include_once(
'./Services/WebServices/ECS/classes/class.ilECSImport.php');
392 $query =
"DELETE FROM ".$this->getTableName().
393 " WHERE obj_id = ".$this->db->quote($this->
getId() ,
'integer').
" ";
394 $ilDB->manipulate(
$query);
402 $query =
"SELECT * FROM ".$this->getTableName().
403 " WHERE obj_id = ".$this->db->quote($this->
getId() ,
'integer').
" ";
440 include_once
'./Services/WebServices/ECS/classes/class.ilECSUtils.php';
442 $a_server->
getServerId(), $a_ecs_content, $a_owner);
444 include_once
'./Services/WebServices/ECS/classes/class.ilECSCategoryMapping.php';
446 $matchable_content));
462 $ilLog->write(
'updateFromECSContent: '.print_r($a_ecs_content,
true));
465 $organisation = null;
468 include_once
'./Services/WebServices/ECS/classes/class.ilECSUtils.php';
470 $ilLog->write(
'found organisation: '.$organisation);
475 $this->
setTitle($a_ecs_content->title);
479 $ilLog->write(
'updateCustomFromECSContent');
484 $ilLog->write(
'ilObject->update()');
487 include_once
'./Services/WebServices/ECS/classes/class.ilECSUtils.php';
489 $a_server->
getServerId(), $a_ecs_content, $a_owner);
492 include_once
'./Services/WebServices/ECS/classes/class.ilECSCategoryMapping.php';
509 $ilLog->write(
"importing metadata from json: ".print_r($a_json,
true));
511 include_once(
'./Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php');
512 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
513 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
517 foreach($values_records as $values_record)
520 $values_record->read();
525 foreach($a_definition as
$id =>
$type)
538 if($field = $mappings->getMappingByECSName($a_mapping_mode,
$id))
542 foreach($values_records as $values_record)
544 $adv_md_defs = $values_record->getDefinitions();
545 if(isset($adv_md_defs[$field]))
547 $adv_md_def = $adv_md_defs[$field];
556 $raw_value = $a_json->$target;
560 if(!is_object($timePlace))
562 include_once(
'./Services/WebServices/ECS/classes/class.ilECSTimePlace.php');
563 if(is_object($raw_value))
566 $timePlace->loadFromJSON($raw_value);
573 $raw_value = $timePlace;
576 if($adv_md_def->importFromECS(
$type, $raw_value,
$id))
585 foreach($values_records as $values_record)
588 foreach($values_record->getADTGroup()->getElements() as $element_id => $element)
590 if(!$element->isNull())
592 $additional[$element_id] = array(
"disabled"=>array(
"integer", 1));
618 include_once(
'./Services/WebServices/ECS/classes/class.ilECSExport.php');
619 include_once(
'./Services/WebServices/ECS/classes/class.ilECSImport.php');
639 return $this->
handleUpdate($a_server, $a_econtent_id, $a_mids);
657 include_once(
'./Services/WebServices/ECS/classes/class.ilECSEContentDetails.php');
663 $ilLog->write(__METHOD__.
': Handling delete of deprecated remote object. DONE');
667 $ilLog->write(__METHOD__.
': Receivers are '. print_r($details->getReceivers(),
true));
668 $ilLog->write(__METHOD__.
': Senders are '. print_r($details->getSenders(),
true));
671 include_once(
'./Services/WebServices/ECS/classes/class.ilECSParticipantSettings.php');
674 $ilLog->write(
'Ignoring disabled participant. MID: '.$details->getOwner());
679 include_once
'Services/WebServices/ECS/classes/class.ilECSImport.php';
680 include_once
'Services/WebServices/ECS/classes/class.ilECSConnector.php';
681 foreach(array_intersect($a_mids,$details->getReceivers()) as
$mid)
691 $json =
$res->getResult();
692 $GLOBALS[
'ilLog']->write(__METHOD__.
': Received json: '.print_r($json,
true));
693 if(!is_object($json))
697 if(!is_object($json))
705 $ilLog->write(__METHOD__ .
': Error parsing result. '.$exc->getMessage());
715 $ilLog->write(__METHOD__.
': Handling update for existing object');
719 $ilLog->write(__METHOD__.
': Cannot instantiate remote object. Got object type '.$remote->getType());
722 $remote->updateFromECSContent($a_server,$json,$details->getMySender());
726 $GLOBALS[
'ilLog']->write(__METHOD__.
': my sender '. $details->getMySender().
'vs mid'.
$mid);
728 $ilLog->write(__METHOD__.
': Handling create for non existing object');
732 $ilLog->write(__METHOD__.
': Updating import status');
733 include_once(
'./Services/WebServices/ECS/classes/class.ilECSImport.php');
737 $import->setMID($mid);
740 $ilLog->write(__METHOD__.
': Sending notification');
745 $ilLog->write(__METHOD__.
': done');
754 include_once(
'Services/WebServices/ECS/classes/class.ilECSSetting.php');
756 if(!count($rcps = $settings->getEContentRecipients()))
761 include_once(
'./Services/Mail/classes/class.ilMail.php');
762 include_once(
'./Services/Language/classes/class.ilLanguageFactory.php');
765 $lang->loadLanguageModule(
'ecs');
767 $mail =
new ilMail(self::MAIL_SENDER);
768 $message =
$lang->txt(
'ecs_'.$this->
getType().
'_created_body_a').
"\n\n";
772 $message .=
$lang->txt(
'desc').
': '.
$desc.
"\n";
775 include_once(
'./Services/Link/classes/class.ilLink.php');
777 $message .=
$lang->txt(
"perma_link").
': '.$href.
"\n\n";
780 $mail->sendMail($settings->getEContentRecipientsAsString(),
782 $lang->txt(
'ecs_new_econtent_subject'),
783 $message,array(),array(
'normal'));
801 include_once(
'./Services/WebServices/ECS/classes/class.ilECSImport.php');
806 $ilLog->write(__METHOD__.
': Received obj_ids '.print_r($obj_ids,
true));
808 foreach($obj_ids as $obj_id)
811 foreach($references as
$ref_id)
815 $ilLog->write(__METHOD__.
': Deleting obsolete remote course: '.$tmp_obj->getTitle());
817 $tree->deleteTree($tree->getNodeData($ref_id));
838 include_once
'./Services/WebServices/ECS/classes/class.ilECSConnector.php';
840 $connector->addHeader(
'X-EcsQueryStrings', $a_sender_only ?
'sender=true' :
'all=true');
844 return $list->getResult()->getLinkIds();
849 $ilLog->write(__METHOD__ .
': Error getting resource list. '.$exc->getMessage());