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;
249 include_once(
'./Services/WebServices/ECS/classes/class.ilECSUser.php');
251 $ecs_user_data = $user->toGET();
252 $GLOBALS[
'ilLog']->write(__METHOD__.
': Using ecs user data '.$ecs_user_data);
254 include_once
'./Services/WebServices/ECS/classes/class.ilECSImport.php';
260 $ecs_url_hash =
'ecs_hash_url='.urlencode(
$server->getServerURI().
'/sys/auths/'.
$auth_hash);
271 $GLOBALS[
'ilLog']->write(__METHOD__.
': ECS full link: '. $link);
285 include_once
'./Services/WebServices/ECS/classes/class.ilECSAuth.php';
286 include_once
'./Services/WebServices/ECS/classes/class.ilECSConnector.php';
287 include_once
'./Services/WebServices/ECS/classes/class.ilECSImport.php';
288 include_once
'./Services/WebServices/ECS/classes/class.ilECSSetting.php';
298 $realm = sha1($a_plain_realm);
299 $GLOBALS[
'ilLog']->write(__METHOD__.
': Using realm '.$a_plain_realm);
300 $auth->setRealm($realm);
301 $GLOBALS[
'ilLog']->write(__METHOD__.
' Mid is '.$this->getMID());
302 $this->auth_hash = $connector->addAuth(@json_encode(
$auth),$this->
getMID());
307 $ilLog->write(__METHOD__.
': Caught error from ECS Auth resource: '.$exc->getMessage());
320 "obj_id" => array(
"integer", $this->
getId()),
321 "local_information" => array(
"text",
""),
322 "remote_link" => array(
"text",
""),
323 "mid" => array(
"integer", 0),
324 "organization" => array(
"text",
"")
351 "mid" => array(
"integer", $this->
getMID()),
357 $where = array(
"obj_id" => array(
"integer", $this->
getId()));
379 include_once(
'./Services/WebServices/ECS/classes/class.ilECSImport.php');
382 $query =
"DELETE FROM ".$this->getTableName().
383 " WHERE obj_id = ".$this->db->quote($this->
getId() ,
'integer').
" ";
384 $ilDB->manipulate(
$query);
392 $query =
"SELECT * FROM ".$this->getTableName().
393 " WHERE obj_id = ".$this->db->quote($this->
getId() ,
'integer').
" ";
430 include_once
'./Services/WebServices/ECS/classes/class.ilECSUtils.php';
432 $a_server->
getServerId(), $a_ecs_content, $a_owner);
434 include_once
'./Services/WebServices/ECS/classes/class.ilECSCategoryMapping.php';
436 $matchable_content));
452 $ilLog->write(
'updateFromECSContent: '.print_r($a_ecs_content,
true));
455 $organisation = null;
458 include_once
'./Services/WebServices/ECS/classes/class.ilECSUtils.php';
460 $ilLog->write(
'found organisation: '.$organisation);
465 $this->
setTitle($a_ecs_content->title);
469 $ilLog->write(
'updateCustomFromECSContent');
474 $ilLog->write(
'ilObject->update()');
477 include_once
'./Services/WebServices/ECS/classes/class.ilECSUtils.php';
479 $a_server->
getServerId(), $a_ecs_content, $a_owner);
482 include_once
'./Services/WebServices/ECS/classes/class.ilECSCategoryMapping.php';
499 $ilLog->write(
"importing metadata from json: ".print_r($a_definition,
true));
501 include_once(
'./Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php');
502 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
503 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
506 foreach($a_definition as
$id =>
$type)
519 if($field = $mappings->getMappingByECSName($a_mapping_mode,
$id))
524 $value = implode(
',', (array) $a_json->$target);
528 $value = (int) $a_json->$target;
532 $value = (
string) $a_json->$target;
536 if(!is_object($timePlace))
538 include_once(
'./Services/WebServices/ECS/classes/class.ilECSTimePlace.php');
539 if(is_object($a_json->$target))
542 $timePlace->loadFromJSON($a_json->$target);
557 $value = $timePlace->{
'getUT'.ucfirst(
$id)}();
563 $value = $timePlace->{
'get'.ucfirst(
$id)}();
568 include_once
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php';
570 $mdv->toggleDisabledStatus(
true);
571 $mdv->setValue($value);
583 protected function updateCustomFromECSContent(
ilECSSetting $a_server, $ecs_content)
593 public function isLocalObject()
595 include_once(
'./Services/WebServices/ECS/classes/class.ilECSExport.php');
596 include_once(
'./Services/WebServices/ECS/classes/class.ilECSImport.php');
614 public function handleCreate(
ilECSSetting $a_server, $a_econtent_id, array $a_mids)
616 return $this->handleUpdate($a_server, $a_econtent_id, $a_mids);
629 public function handleUpdate(
ilECSSetting $a_server, $a_econtent_id, array $a_mids)
634 include_once(
'./Services/WebServices/ECS/classes/class.ilECSEContentDetails.php');
636 $a_econtent_id, $this->getECSObjectType());
639 $this->handleDelete($a_server, $a_econtent_id);
640 $ilLog->write(__METHOD__.
': Handling delete of deprecated remote object. DONE');
644 $ilLog->write(__METHOD__.
': Receivers are '. print_r($details->getReceivers(),
true));
645 $ilLog->write(__METHOD__.
': Senders are '. print_r($details->getSenders(),
true));
648 include_once(
'./Services/WebServices/ECS/classes/class.ilECSParticipantSettings.php');
651 $ilLog->write(
'Ignoring disabled participant. MID: '.$details->getOwner());
656 include_once
'Services/WebServices/ECS/classes/class.ilECSImport.php';
657 include_once
'Services/WebServices/ECS/classes/class.ilECSConnector.php';
658 foreach(array_intersect($a_mids,$details->getReceivers()) as $mid)
663 $res = $connector->getResource($this->getECSObjectType(), $a_econtent_id);
668 $json =
$res->getResult();
669 $GLOBALS[
'ilLog']->write(__METHOD__.
': Received json: '.print_r($json,
true));
670 if(!is_object($json))
674 if(!is_object($json))
682 $ilLog->write(__METHOD__ .
': Error parsing result. '.$exc->getMessage());
692 $ilLog->write(__METHOD__.
': Handling update for existing object');
696 $ilLog->write(__METHOD__.
': Cannot instantiate remote object. Got object type '.$remote->getType());
699 $remote->updateFromECSContent($a_server,$json,$details->getMySender());
703 $GLOBALS[
'ilLog']->write(__METHOD__.
': my sender '. $details->getMySender().
'vs mid'. $mid);
705 $ilLog->write(__METHOD__.
': Handling create for non existing object');
706 $this->createFromECSEContent($a_server,$json,$details->getMySender());
709 $ilLog->write(__METHOD__.
': Updating import status');
710 include_once(
'./Services/WebServices/ECS/classes/class.ilECSImport.php');
714 $import->setMID($mid);
717 $ilLog->write(__METHOD__.
': Sending notification');
718 $this->sendNewContentNotification($a_server->
getServerId());
722 $ilLog->write(__METHOD__.
': done');
729 protected function sendNewContentNotification($a_server_id)
731 include_once(
'Services/WebServices/ECS/classes/class.ilECSSetting.php');
733 if(!count($rcps = $settings->getEContentRecipients()))
738 include_once(
'./Services/Mail/classes/class.ilMail.php');
739 include_once(
'./Services/Language/classes/class.ilLanguageFactory.php');
742 $lang->loadLanguageModule(
'ecs');
744 $mail =
new ilMail(self::MAIL_SENDER);
745 $message =
$lang->txt(
'ecs_'.$this->getType().
'_created_body_a').
"\n\n";
746 if(strlen($this->getOrganization()))
748 $message .=
$lang->txt(
'organization').
': '.$this->getOrganization().
"\n";
750 $message .=
$lang->txt(
'title').
': '.$this->getTitle().
"\n";
751 if(strlen($desc = $this->getDescription()))
753 $message .=
$lang->txt(
'desc').
': '.$desc.
"\n";
756 include_once(
'./Services/Link/classes/class.ilLink.php');
758 $message .=
$lang->txt(
"perma_link").
': '.$href.
"\n\n";
761 $mail->sendMail($settings->getEContentRecipientsAsString(),
763 $lang->txt(
'ecs_new_econtent_subject'),
764 $message,array(),array(
'normal'));
777 public function handleDelete(
ilECSSetting $a_server, $a_econtent_id, $a_mid = 0)
782 include_once(
'./Services/WebServices/ECS/classes/class.ilECSImport.php');
787 $ilLog->write(__METHOD__.
': Received obj_ids '.print_r($obj_ids,
true));
789 foreach($obj_ids as $obj_id)
792 foreach($references as
$ref_id)
796 $ilLog->write(__METHOD__.
': Deleting obsolete remote course: '.$tmp_obj->getTitle());
798 $tree->deleteTree($tree->getNodeData($ref_id));
813 public function getAllResourceIds(
ilECSSetting $a_server, $a_sender_only =
false)
819 include_once
'./Services/WebServices/ECS/classes/class.ilECSConnector.php';
821 $connector->addHeader(
'X-EcsQueryStrings', $a_sender_only ?
'sender=true' :
'all=true');
822 $list = $connector->getResourceList($this->getECSObjectType());
825 return $list->getResult()->getLinkIds();
830 $ilLog->write(__METHOD__ .
': Error getting resource list. '.$exc->getMessage());