4include_once
"Services/Object/classes/class.ilObject2.php";
35 public function __construct($a_id = 0,$a_call_by_reference =
true)
39 parent::__construct($a_id,$a_call_by_reference);
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';
90 return parent::beforeCreate();
117 $query =
"SELECT organization FROM ".static::DB_TABLE_NAME.
118 " WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ";
122 return $row->organization;
143 $this->organization = $a_organization;
173 $this->local_information = $a_info;
206 $query =
"SELECT mid FROM ".static::DB_TABLE_NAME.
207 " WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ";
223 $this->remote_link = $a_link;
248 include_once
'./Services/WebServices/ECS/classes/class.ilECSImport.php';
252 include_once(
'./Services/WebServices/ECS/classes/class.ilECSUser.php');
254 $ecs_user_data = $user->toGET();
255 $GLOBALS[
'ilLog']->write(__METHOD__.
': Using ecs user data '.$ecs_user_data);
258 include_once
'./Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
260 if(!$part->isTokenEnabled())
266 $ecs_url_hash =
'ecs_hash_url='.urlencode(
$server->getServerURI().
'/sys/auths/'.
$auth_hash);
277 $GLOBALS[
'ilLog']->write(__METHOD__.
': ECS full link: '. $link);
291 include_once
'./Services/WebServices/ECS/classes/class.ilECSAuth.php';
292 include_once
'./Services/WebServices/ECS/classes/class.ilECSConnector.php';
293 include_once
'./Services/WebServices/ECS/classes/class.ilECSImport.php';
294 include_once
'./Services/WebServices/ECS/classes/class.ilECSSetting.php';
303 $auth->setPid($import_info->getMID());
306 $realm = sha1($a_plain_realm);
307 $GLOBALS[
'ilLog']->write(__METHOD__.
': Using realm '.$a_plain_realm);
308 $auth->setRealm($realm);
309 $GLOBALS[
'ilLog']->write(__METHOD__.
' Mid is '.$this->getMID());
310 $this->auth_hash = $connector->addAuth(@json_encode($auth),$this->
getMID());
315 $ilLog->write(__METHOD__.
': Caught error from ECS Auth resource: '.$exc->getMessage());
328 "obj_id" => array(
"integer", $this->
getId()),
329 "local_information" => array(
"text",
""),
330 "remote_link" => array(
"text",
""),
331 "mid" => array(
"integer", 0),
332 "organization" => array(
"text",
"")
359 "mid" => array(
"integer", $this->
getMID()),
365 $where = array(
"obj_id" => array(
"integer", $this->
getId()));
387 include_once(
'./Services/WebServices/ECS/classes/class.ilECSImport.php');
390 $query =
"DELETE FROM ".$this->getTableName().
391 " WHERE obj_id = ".$this->db->quote($this->
getId() ,
'integer').
" ";
392 $ilDB->manipulate(
$query);
400 $query =
"SELECT * FROM ".$this->getTableName().
401 " WHERE obj_id = ".$this->db->quote($this->
getId() ,
'integer').
" ";
438 include_once
'./Services/WebServices/ECS/classes/class.ilECSUtils.php';
440 $a_server->
getServerId(), $a_ecs_content, $a_owner);
442 include_once
'./Services/WebServices/ECS/classes/class.ilECSCategoryMapping.php';
444 $matchable_content));
460 $ilLog->write(
'updateFromECSContent: '.print_r($a_ecs_content,
true));
463 $organisation =
null;
466 include_once
'./Services/WebServices/ECS/classes/class.ilECSUtils.php';
468 $ilLog->write(
'found organisation: '.$organisation);
473 $this->
setTitle($a_ecs_content->title);
477 $ilLog->write(
'updateCustomFromECSContent');
482 $ilLog->write(
'ilObject->update()');
485 include_once
'./Services/WebServices/ECS/classes/class.ilECSUtils.php';
487 $a_server->
getServerId(), $a_ecs_content, $a_owner);
490 include_once
'./Services/WebServices/ECS/classes/class.ilECSCategoryMapping.php';
507 $ilLog->write(
"importing metadata from json: ".print_r($a_json,
true));
509 include_once(
'./Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php');
510 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
511 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
515 foreach($values_records as $values_record)
518 $values_record->read();
523 foreach($a_definition as
$id =>
$type)
536 if($field = $mappings->getMappingByECSName($a_mapping_mode,
$id))
540 foreach($values_records as $values_record)
542 $adv_md_defs = $values_record->getDefinitions();
543 if(isset($adv_md_defs[$field]))
545 $adv_md_def = $adv_md_defs[$field];
554 $raw_value = $a_json->$target;
558 if(!is_object($timePlace))
560 include_once(
'./Services/WebServices/ECS/classes/class.ilECSTimePlace.php');
561 if(is_object($raw_value))
564 $timePlace->loadFromJSON($raw_value);
571 $raw_value = $timePlace;
574 if($adv_md_def->importFromECS(
$type, $raw_value,
$id))
583 foreach($values_records as $values_record)
586 foreach($values_record->getADTGroup()->getElements() as $element_id => $element)
588 if(!$element->isNull())
590 $additional[$element_id] = array(
"disabled"=>array(
"integer", 1));
616 include_once(
'./Services/WebServices/ECS/classes/class.ilECSExport.php');
617 include_once(
'./Services/WebServices/ECS/classes/class.ilECSImport.php');
637 return $this->
handleUpdate($a_server, $a_econtent_id, $a_mids);
655 include_once(
'./Services/WebServices/ECS/classes/class.ilECSEContentDetails.php');
657 $a_econtent_id, $this->getECSObjectType());
661 $ilLog->write(__METHOD__.
': Handling delete of deprecated remote object. DONE');
665 $ilLog->write(__METHOD__.
': Receivers are '. print_r($details->getReceivers(),
true));
666 $ilLog->write(__METHOD__.
': Senders are '. print_r($details->getSenders(),
true));
669 include_once(
'./Services/WebServices/ECS/classes/class.ilECSParticipantSettings.php');
672 $ilLog->write(
'Ignoring disabled participant. MID: '.$details->getOwner());
677 include_once
'Services/WebServices/ECS/classes/class.ilECSImport.php';
678 include_once
'Services/WebServices/ECS/classes/class.ilECSConnector.php';
679 foreach(array_intersect($a_mids,$details->getReceivers()) as
$mid)
689 $json =
$res->getResult();
690 $GLOBALS[
'ilLog']->write(__METHOD__.
': Received json: '.print_r($json,
true));
691 if(!is_object($json))
695 if(!is_object($json))
703 $ilLog->write(__METHOD__ .
': Error parsing result. '.$exc->getMessage());
713 $ilLog->write(__METHOD__.
': Handling update for existing object');
717 $ilLog->write(__METHOD__.
': Cannot instantiate remote object. Got object type '.$remote->getType());
720 $remote->updateFromECSContent($a_server,$json,$details->getMySender());
724 $GLOBALS[
'ilLog']->write(__METHOD__.
': my sender '. $details->getMySender().
'vs mid'.
$mid);
726 $ilLog->write(__METHOD__.
': Handling create for non existing object');
730 $ilLog->write(__METHOD__.
': Updating import status');
731 include_once(
'./Services/WebServices/ECS/classes/class.ilECSImport.php');
733 $import->setEContentId($a_econtent_id);
735 $import->setMID(
$mid);
738 $ilLog->write(__METHOD__.
': Sending notification');
743 $ilLog->write(__METHOD__.
': done');
752 include_once(
'Services/WebServices/ECS/classes/class.ilECSSetting.php');
754 if(!count($rcps = $settings->getEContentRecipients()))
759 include_once(
'./Services/Mail/classes/class.ilMail.php');
760 include_once(
'./Services/Language/classes/class.ilLanguageFactory.php');
763 $lang->loadLanguageModule(
'ecs');
765 $mail =
new ilMail(self::MAIL_SENDER);
766 $message =
$lang->txt(
'ecs_'.$this->
getType().
'_created_body_a').
"\n\n";
770 $message .=
$lang->txt(
'desc').
': '.
$desc.
"\n";
773 include_once(
'./Services/Link/classes/class.ilLink.php');
775 $message .=
$lang->txt(
"perma_link").
': '.$href.
"\n\n";
776 $message .= ilMail::_getAutoGeneratedMessageString();
778 $mail->sendMail($settings->getEContentRecipientsAsString(),
780 $lang->txt(
'ecs_new_econtent_subject'),
781 $message,array(),array(
'normal'));
799 include_once(
'./Services/WebServices/ECS/classes/class.ilECSImport.php');
804 $ilLog->write(__METHOD__.
': Received obj_ids '.print_r($obj_ids,
true));
806 foreach($obj_ids as $obj_id)
809 foreach($references as
$ref_id)
813 $ilLog->write(__METHOD__.
': Deleting obsolete remote course: '.$tmp_obj->getTitle());
815 $tree->deleteTree($tree->getNodeData(
$ref_id));
836 include_once
'./Services/WebServices/ECS/classes/class.ilECSConnector.php';
838 $connector->addHeader(
'X-EcsQueryStrings', $a_sender_only ?
'sender=true' :
'all=true');
842 return $list->getResult()->getLinkIds();
847 $ilLog->write(__METHOD__ .
': Error getting resource list. '.$exc->getMessage());
An exception for terminatinating execution or to throw for unit testing.
static getInstancesForObjectId($a_obj_id, $a_obj_type=null, $a_sub_type="-", $a_sub_id=0)
Get instances for given object id.
static handleUpdate($a_obj_id, $a_server_id, $a_matchable_content)
Handle update of ecs content and create references.
static getMatchingCategory($a_server_id, $a_matchable_content)
get matching category
const HTTP_CODE_NOT_FOUND
static getInstanceByServerId($a_server_id)
Get singleton instance.
Presentation of ecs content details (http://...campusconnect/courselinks/id/details)
static getInstance($a_server_id, $a_econtent_id, $a_resource_type)
Get data from server.
const TYPE_REMOTE_GLOSSARY
const TYPE_REMOTE_LEARNING_MODULE
const TYPE_REMOTE_CATEGORY
static _isRemote($a_server_id, $a_econtent_id)
is remote object
Storage of ECS imported objects.
static _lookupEContentId($a_obj_id)
get econent_id
static _deleteByObjId($a_obj_id)
Delete by obj_id.
static _lookupObjIds($a_server_id, $a_econtent_id)
Lookup obj_id.
static _isImported($a_server_id, $a_econtent_id, $a_mid, $a_sub_id=null)
check if econtent is imported for a specific mid
static lookupServerId($a_obj_id)
Lookup server id of imported content @global <type> $ilDB.
static getInstanceByServerId($a_server_id)
Get instance by server id.
getServerId()
Get current server id.
static getInstanceByServerId($a_server_id)
Get singleton instance per server.
getImportId()
get import id
Representation of ECS EContent Time Place.
Stores relevant user data.
static getMatchableContent($a_resource_id, $a_server_id, $a_ecs_content, $a_owner)
Convert ECS content to rule matchable values.
static lookupParticipantName($a_owner, $a_server_id)
Lookup participant name.
static _getLanguage($a_lang_key='')
Get langauge object.
static _getStaticLink($a_ref_id, $a_type='', $a_fallback_goto=true, $append="")
Get static link.
This class handles base functions for mail handling.
Remote category app class.
Remote glossary app class.
Remote learning module app class.
Class ilObject2 This is an intermediate progress of ilObject class.
getRefId()
get reference id @access public
setTitle($a_title)
set object title
putInTree($a_parent_ref)
maybe this method should be in tree object!?
setPermissions($a_parent_ref)
set permissions of object
getType()
get object type @access public
getDescription()
get object description
setOwner($a_owner)
set object owner
update()
update object in db
setDescription($a_desc)
set object description
createReference()
creates reference for object
getId()
get object id @access public
getTitle()
get object title @access public
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getAllReferences($a_id)
get all reference ids of object
Remote object app base class.
getAllResourceIds(ilECSSetting $a_server, $a_sender_only=false)
Get all available resources.
updateCustomFromECSContent(ilECSSetting $a_server, $ecs_content)
update remote object settings from ecs content
doUpdateCustomFields(array &$a_fields)
Add custom fields to db update.
getOrganization()
get organization
handleCreate(ilECSSetting $a_server, $a_econtent_id, array $a_mids)
Handle creation.
createFromECSEContent(ilECSSetting $a_server, $a_ecs_content, $a_owner)
create remote object from ECSContent object
setRemoteLink($a_link)
set remote link
getTableName()
Get db table name.
doReadCustomFields($a_row)
Read custom fields from db row.
getLocalInformation()
get local information
getRemoteLink()
get remote link
doCreate()
Create remote object.
__construct($a_id=0, $a_call_by_reference=true)
Constructor.
doUpdate()
Update remote object.
isLocalObject()
Is remote object from same installation?
static _lookupMID($a_obj_id)
lookup owner mid
getFullRemoteLink()
get full remote link Including ecs generated hash and auth mode
doDelete()
Delete remote object.
setOrganization($a_organization)
set organization
getRealmPlain()
Get realm plain.
handleDelete(ilECSSetting $a_server, $a_econtent_id, $a_mid=0)
Handle delete event.
static _lookupOrganization($a_obj_id)
lookup organization
getECSObjectType()
Get ECS resource identifier, e.g.
createAuthResource($a_plain_realm)
create authentication resource on ecs server
handleUpdate(ilECSSetting $a_server, $a_econtent_id, array $a_mids)
Handle update event.
importMetadataFromJson($a_json, ilECSSetting $a_server, array $a_definition, $a_mapping_mode)
Add advanced metadata to json (export)
setLocalInformation($a_info)
set local information
updateFromECSContent(ilECSSetting $a_server, $a_ecs_content, $a_owner)
update remote object settings from ecs content
sendNewContentNotification($a_server_id)
send notifications about new EContent
doCreateCustomFields(array &$a_fields)
Add custom fields to db insert.
static getInstanceByEventType($a_type)
Get instance by ilECSEvent(QueueReader) type.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang