ILIAS  release_8 Revision v8.24
ilECSObjectSettings Class Reference

Handles object exports to ECS. More...

+ Inheritance diagram for ilECSObjectSettings:
+ Collaboration diagram for ilECSObjectSettings:

Public Member Functions

 __construct (ilObject $a_content_object)
 Constructor. More...
 
 getContentObject ()
 Get content object. More...
 
 addSettingsToForm (ilPropertyFormGUI $a_form, $a_type)
 Fill ECS export settings "multiple servers". More...
 
 handleSettingsUpdate ()
 Update ECS Export Settings. More...
 
 handleContentUpdate ()
 Update ECS Content. More...
 
 doDelete (ilECSSetting $a_server, ilECSExport $a_export_settings)
 Delete ECS resource. More...
 

Static Public Member Functions

static getInstanceByObject (ilObject $a_content_obj)
 Get settings handler for repository object. More...
 
static _handleDelete (array $a_subbtree_nodes)
 handle delete Objects that are moved to the trash call ECS-Remove More...
 

Data Fields

const MAIL_SENDER = 6
 

Protected Member Functions

 getECSObjectType ()
 Get ECS resource identifier, e.g. More...
 
 isActive ()
 Is ECS (for current object) active? More...
 
 handleSettingsForServer (ilECSSetting $a_server, bool $a_export, array $a_mids)
 Save ECS settings (add- update- deleteResource) More...
 
 doAdd (ilECSSetting $a_server, ilECSExport $a_export_settings, array $a_mids)
 Add resource to ECS. More...
 
 doUpdate (ilECSSetting $a_server, ilECSExport $a_export_settings, array $a_mids=null)
 Update ECS resource. More...
 
 getParticipants (int $a_server_id, int $a_econtent_id)
 Get participants for server and ecs resource. More...
 
 sendNewContentNotification (ilECSSetting $a_server, $a_econtent_id)
 send notifications about new EContent More...
 
 handlePermissionUpdate (ilECSSetting $server)
 Handle permission update. More...
 
 getJsonCore (string $a_etype)
 Build core json structure. More...
 
 addMetadataToJson (object $a_json, ilECSSetting $a_server, array $a_definition)
 Add advanced metadata to json (export) More...
 
 buildJson (ilECSSetting $a_server)
 Build resource-specific json. More...
 

Protected Attributes

ilObject $content_obj
 

Private Attributes

ilLogger $logger
 
ilLanguage $lng
 
ilTree $tree
 
ilRbacAdmin $rbacAdmin
 
ilGlobalTemplateInterface $main_tpl
 

Detailed Description

Handles object exports to ECS.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 25 of file class.ilECSObjectSettings.php.

Constructor & Destructor Documentation

◆ __construct()

ilECSObjectSettings::__construct ( ilObject  $a_content_object)

Constructor.

Parameters
ilObject$a_content_object

Reimplemented in ilECSCourseSettings.

Definition at line 42 of file class.ilECSObjectSettings.php.

43 {
44 global $DIC;
45 $this->main_tpl = $DIC->ui()->mainTemplate();
46
47 $this->lng = $DIC->language();
48 $this->logger = $DIC->logger()->obj();
49 $this->tree = $DIC->repositoryTree();
50 $this->rbacAdmin = $DIC->rbac()->admin();
51
52 $this->content_obj = $a_content_object;
53 }
global $DIC
Definition: feed.php:28

References $DIC, ILIAS\Repository\lng(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

Member Function Documentation

◆ _handleDelete()

static ilECSObjectSettings::_handleDelete ( array  $a_subbtree_nodes)
static

handle delete Objects that are moved to the trash call ECS-Remove

See also
ilRepUtil

Definition at line 414 of file class.ilECSObjectSettings.php.

414 : void
415 {
416 // active?
417 if (!ilECSServerSettings::getInstance()->activeServerExists()) {
418 return;
419 }
420 $exportManager = ilECSExportManager::getInstance();
421 $exported = $exportManager->getExportedIds();
422 foreach ($a_subbtree_nodes as $node) {
423 if (in_array(
424 $node['obj_id'],
425 $exported,
426 true
427 ) && $content_obj = ilObjectFactory::getInstanceByRefId($node['child'], false)) {
429
430 // Read export server ids
431 foreach ($exportManager->getExportServerIds($node['obj_id']) as $sid) {
433 $export_settings = new ilECSExport($sid, $content_obj->getId());
434 if ($settings) {
435 $settings->doDelete($server, $export_settings);
436 }
437 }
438 }
439 }
440 }
static getInstance()
Get the singelton instance of this ilECSExportManager.
Storage of an ECS exported object.
static getInstanceByObject(ilObject $a_content_obj)
Get settings handler for repository object.
static getInstance()
Get singleton instance.
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
$server
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200

References $content_obj, $server, ILIAS\LTI\ToolProvider\$settings, ilObject\getId(), ilECSExportManager\getInstance(), ilECSServerSettings\getInstance(), getInstanceByObject(), ilObjectFactory\getInstanceByRefId(), and ilECSSetting\getInstanceByServerId().

+ Here is the call graph for this function:

◆ addMetadataToJson()

ilECSObjectSettings::addMetadataToJson ( object  $a_json,
ilECSSetting  $a_server,
array  $a_definition 
)
protected

Add advanced metadata to json (export)

Definition at line 572 of file class.ilECSObjectSettings.php.

572 : void
573 {
575
576 $values = ilECSUtils::getAdvancedMDValuesForObjId($this->content_obj->getId());
577
578 foreach ($a_definition as $id => $type) {
579 if (is_array($type)) {
580 [$type , $target] = $type;
581 } else {
582 $target = $id;
583 }
584
585 if ($field = $mappings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, $id)) {
586 $value = $values[$field] ?? '';
587
588 switch ($type) {
590 $a_json->{$target} = explode(',', $value);
591 break;
592
594 $a_json->{$target} = (int) $value;
595 break;
596
598 $a_json->{$target} = (string) $value;
599 break;
600
602 if (!isset($a_json->{$target})) {
603 $a_json->{$target} = new ilECSTimePlace();
604 }
605 $a_json->{$target}->{'set' . ucfirst($id)}($value);
606 break;
607 }
608 }
609 }
610 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static getInstanceByServerId(int $a_server_id)
Get singleton instance.
getServerId()
Get current server id.
Representation of ECS EContent Time Place.
static getAdvancedMDValuesForObjId(int $a_obj_id)
Get advanced metadata values for object id.
const TYPE_TIMEPLACE
$type

References $id, $type, ilECSUtils\getAdvancedMDValuesForObjId(), ilECSDataMappingSettings\getInstanceByServerId(), ilECSSetting\getServerId(), ILIAS\Repository\int(), ilECSDataMappingSetting\MAPPING_EXPORT, ilECSUtils\TYPE_ARRAY, ilECSUtils\TYPE_INT, ilECSUtils\TYPE_STRING, and ilECSUtils\TYPE_TIMEPLACE.

Referenced by ilECSCourseSettings\buildJson().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addSettingsToForm()

ilECSObjectSettings::addSettingsToForm ( ilPropertyFormGUI  $a_form,
  $a_type 
)

Fill ECS export settings "multiple servers".

to be used in ilObject->initEditForm()

Definition at line 120 of file class.ilECSObjectSettings.php.

120 : bool
121 {
122 $this->logger->debug('Show ecs settings.');
123 if (!$this->isActive()) {
124 $this->logger->debug('Object type is not active. => no settings.');
125 return false;
126 }
127
128 $obj_id = $this->content_obj->getId();
129
130 // Return if no participant is enabled for export and the current object is not released
131 if (!$this->getContentObject()->withReferences()) {
132 $this->logger->debug('Called withot references. => no settings.');
133 return true;
134 }
135 $exportManager = ilECSExportManager::getInstance();
136 $exportableParticipants = (new ilECSParticipantSettingsRepository())->getExportableParticipants($a_type);
137 if (!$exportableParticipants && !$exportManager->_isExported($obj_id)) {
138 $this->logger->debug('Object type is not exportable. => no settings.');
139 return true;
140 }
141 if (
142 $this->tree->checkForParentType($this->tree->getParentId($this->getContentObject()->getRefId()), 'crs', false) ||
143 $this->tree->checkForParentType($this->tree->getParentId($this->getContentObject()->getRefId()), 'grp', false)
144 ) {
145 $this->logger->debug('Parent crs/grp in path. => no settings.');
146 return true;
147 }
148
149 $this->lng->loadLanguageModule('ecs');
150
151 // show ecs property form section
152 $ecs = new ilFormSectionHeaderGUI();
153 $ecs->setTitle($this->lng->txt('ecs_' . $a_type . '_export'));
154 $a_form->addItem($ecs);
155
156
157 // release or not
158 $exp = new ilRadioGroupInputGUI($this->lng->txt('ecs_' . $a_type . '_export_obj_settings'), 'ecs_export');
159 $exp->setRequired(true);
160 $exp->setValue($exportManager->_isExported($obj_id) ? "1" : "0");
161 $off = new ilRadioOption($this->lng->txt('ecs_' . $a_type . '_export_disabled'), "0");
162 $exp->addOption($off);
163 $on = new ilRadioOption($this->lng->txt('ecs_' . $a_type . '_export_enabled'), "1");
164 $exp->addOption($on);
165 $a_form->addItem($exp);
166
167 // Show all exportable participants
168 $publish_for = new ilCheckboxGroupInputGUI($this->lng->txt('ecs_publish_for'), 'ecs_sid');
169
170 // @TODO: Active checkboxes for recipients
171 //$publish_for->setValue((array) $members);
172
173 // Read receivers
174 $receivers = array();
175 foreach ($exportManager->getExportServerIds($obj_id) as $sid) {
176 $exp = new ilECSExport($sid, $obj_id);
177
178 $participants = null;
180 $sid,
181 $exp->getEContentId(),
182 $this->getECSObjectType()
183 );
184 if ($details instanceof ilECSEContentDetails) {
185 $participants = $details->getReceivers();
186 }
187 if ($participants) {
188 foreach ($participants as $mid) {
189 $receivers[] = $sid . '_' . $mid;
190 }
191 }
192 }
193 $publish_for->setValue($receivers);
194
195 foreach ($exportableParticipants as $pInfo) {
196 $partSetting = new ilECSParticipantSetting($pInfo['sid'], $pInfo['mid']);
197
198 $com = new ilCheckboxOption(
199 $partSetting->getCommunityName() . ': ' . $partSetting->getTitle(),
200 'sid_mid'
201 );
202 $com->setValue($pInfo['sid'] . '_' . $pInfo['mid']);
203 $publish_for->addOption($com);
204 }
205 $on->addSubItem($publish_for);
206 return true;
207 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Presentation of ecs content details (http://...campusconnect/courselinks/id/details)
static getInstanceFromServer(int $a_server_id, int $a_econtent_id, string $a_resource_type)
Get data from server.
getContentObject()
Get content object.
isActive()
Is ECS (for current object) active?
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
array $details
Details for error message relating to last request processed.
Definition: System.php:109

References ILIAS\LTI\ToolProvider\$details, ilPropertyFormGUI\addItem(), getContentObject(), ilECSExportManager\getInstance(), ilECSEContentDetails\getInstanceFromServer(), isActive(), ILIAS\Repository\lng(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ buildJson()

ilECSObjectSettings::buildJson ( ilECSSetting  $a_server)
abstractprotected

Build resource-specific json.

Returns
mixed

Reimplemented in ilECSCategorySettings, ilECSCourseSettings, ilECSFileSettings, ilECSGlossarySettings, ilECSGroupSettings, ilECSLearningModuleSettings, ilECSTestSettings, and ilECSWikiSettings.

Referenced by doAdd(), and doUpdate().

+ Here is the caller graph for this function:

◆ doAdd()

ilECSObjectSettings::doAdd ( ilECSSetting  $a_server,
ilECSExport  $a_export_settings,
array  $a_mids 
)
protected

Add resource to ECS.

Definition at line 321 of file class.ilECSObjectSettings.php.

321 : void
322 {
323 $this->logger->info(__METHOD__ . ': Starting ECS add resource...');
324
325 $json = $this->buildJson($a_server);
326
327 $connector = new ilECSConnector($a_server);
328 $connector->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, implode(',', $a_mids));
329 $econtent_id = $connector->addResource(
330 $this->getECSObjectType(),
331 json_encode($json, JSON_THROW_ON_ERROR)
332 );
333
334 // status changed
335 $a_export_settings->setExported(true);
336 $a_export_settings->setEContentId($econtent_id);
337 $a_export_settings->save();
338
339 $this->handlePermissionUpdate($a_server);
340
341 // Send mail
342 $this->sendNewContentNotification($a_server, $econtent_id);
343 }
setEContentId(int $a_id)
set econtent id
setExported(bool $a_status)
Set exported.
sendNewContentNotification(ilECSSetting $a_server, $a_econtent_id)
send notifications about new EContent
handlePermissionUpdate(ilECSSetting $server)
Handle permission update.
getECSObjectType()
Get ECS resource identifier, e.g.
buildJson(ilECSSetting $a_server)
Build resource-specific json.

References buildJson(), getECSObjectType(), handlePermissionUpdate(), ilECSConnector\HEADER_MEMBERSHIPS, ILIAS\Repository\logger(), ilECSExport\save(), sendNewContentNotification(), ilECSExport\setEContentId(), and ilECSExport\setExported().

Referenced by handleSettingsForServer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doDelete()

ilECSObjectSettings::doDelete ( ilECSSetting  $a_server,
ilECSExport  $a_export_settings 
)

Delete ECS resource.

as it is called from self::_handleDelete() it has to be public...

Exceptions
ilECSConnectorException

Definition at line 385 of file class.ilECSObjectSettings.php.

385 : void
386 {
387 // already exported?
388 if ($a_export_settings->isExported()) {
389 $econtent_id = $a_export_settings->getEContentId();
390 if (!$econtent_id) {
391 $this->logger->warning(__METHOD__ . ': Missing eid. Aborting.');
392 throw new ilECSConnectorException('Missing ECS content ID. Aborting.');
393 }
394 $connector = new ilECSConnector($a_server);
395
396 $this->logger->info(__METHOD__ . ': Start deleting ECS content...');
397 $connector->deleteResource(
398 $this->getECSObjectType(),
399 $econtent_id
400 );
401
402 // status changed
403 $a_export_settings->setExported(false);
404 $a_export_settings->save();
405 }
406 }
getEContentId()
get econtent id
isExported()
check if an object is exported or not

References ilECSExport\getEContentId(), getECSObjectType(), ilECSExport\isExported(), ILIAS\Repository\logger(), ilECSExport\save(), and ilECSExport\setExported().

Referenced by handleSettingsForServer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doUpdate()

ilECSObjectSettings::doUpdate ( ilECSSetting  $a_server,
ilECSExport  $a_export_settings,
array  $a_mids = null 
)
protected

Update ECS resource.

Parameters
ilECSSetting$a_server
ilECSExport$a_export_settings
array$a_mids
Exceptions
ilECSConnectorException

Definition at line 353 of file class.ilECSObjectSettings.php.

353 : void
354 {
355 $econtent_id = $a_export_settings->getEContentId();
356 if (!$econtent_id) {
357 $this->logger->warning(__METHOD__ . ': Missing eid. Aborting.');
358 throw new ilECSConnectorException('Missing ECS content ID. Aborting.');
359 }
360 $connector = new ilECSConnector($a_server);
361
362 if (!$a_mids) {
363 $a_mids = $this->getParticipants($a_server->getServerId(), $econtent_id);
364 }
365 $this->logger->info(__METHOD__ . ': Start updating ECS content - ' . print_r($a_mids, true));
366 $connector->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, implode(',', (array) $a_mids));
367
368 $json = $this->buildJson($a_server);
369 $connector->updateResource(
370 $this->getECSObjectType(),
371 $econtent_id,
372 json_encode($json, JSON_THROW_ON_ERROR)
373 );
374
375 $this->handlePermissionUpdate($a_server);
376 }
getParticipants(int $a_server_id, int $a_econtent_id)
Get participants for server and ecs resource.

References buildJson(), ilECSExport\getEContentId(), getECSObjectType(), getParticipants(), ilECSSetting\getServerId(), handlePermissionUpdate(), ilECSConnector\HEADER_MEMBERSHIPS, and ILIAS\Repository\logger().

Referenced by handleContentUpdate(), and handleSettingsForServer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContentObject()

ilECSObjectSettings::getContentObject ( )

Get content object.

Returns
ilObject

Definition at line 89 of file class.ilECSObjectSettings.php.

89 : \ilObject
90 {
91 return $this->content_obj;
92 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $content_obj.

Referenced by addSettingsToForm(), ilECSCourseSettings\buildJson(), and getJsonCore().

+ Here is the caller graph for this function:

◆ getECSObjectType()

ilECSObjectSettings::getECSObjectType ( )
abstractprotected

Get ECS resource identifier, e.g.

"/campusconnect/courselinks"

Reimplemented in ilECSCategorySettings, ilECSCourseSettings, ilECSFileSettings, ilECSGlossarySettings, ilECSGroupSettings, ilECSLearningModuleSettings, ilECSTestSettings, and ilECSWikiSettings.

Referenced by doAdd(), doDelete(), doUpdate(), and getParticipants().

+ Here is the caller graph for this function:

◆ getInstanceByObject()

static ilECSObjectSettings::getInstanceByObject ( ilObject  $a_content_obj)
static

Get settings handler for repository object.

Definition at line 58 of file class.ilECSObjectSettings.php.

59 {
60 switch ($a_content_obj->getType()) {
61 case 'crs':
62 return new ilECSCourseSettings($a_content_obj);
63
64 case 'cat':
65 return new ilECSCategorySettings($a_content_obj);
66
67 case 'file':
68 return new ilECSFileSettings($a_content_obj);
69
70 case 'glo':
71 return new ilECSGlossarySettings($a_content_obj);
72
73 case 'grp':
74 return new ilECSGroupSettings($a_content_obj);
75
76 case 'lm':
77 return new ilECSLearningModuleSettings($a_content_obj);
78
79 case 'wiki':
80 return new ilECSWikiSettings($a_content_obj);
81 }
82 return null;
83 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilECSGroupSettings.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Handles object exports to ECS.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ilObject\getType().

Referenced by _handleDelete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getJsonCore()

ilECSObjectSettings::getJsonCore ( string  $a_etype)
protected

Build core json structure.

Definition at line 555 of file class.ilECSObjectSettings.php.

555 : object
556 {
557 $json = new stdClass();
558 $json->lang = 'en_EN'; // :TODO: obsolet?
559 $json->id = 'il_' . IL_INST_ID . '_' . $this->getContentObject()->getType() . '_' . $this->getContentObject()->getId();
560 $json->etype = $a_etype;
561 $json->title = $this->content_obj->getTitle();
562 $json->abstract = $this->content_obj->getLongDescription();
563
564 $json->url = ilLink::_getLink($this->content_obj->getRefId(), $this->content_obj->getType());
565
566 return $json;
567 }
const IL_INST_ID
Definition: constants.php:40

References ilLink\_getLink(), getContentObject(), and IL_INST_ID.

Referenced by ilECSCategorySettings\buildJson(), ilECSCourseSettings\buildJson(), ilECSFileSettings\buildJson(), ilECSGlossarySettings\buildJson(), ilECSGroupSettings\buildJson(), ilECSLearningModuleSettings\buildJson(), ilECSTestSettings\buildJson(), and ilECSWikiSettings\buildJson().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParticipants()

ilECSObjectSettings::getParticipants ( int  $a_server_id,
int  $a_econtent_id 
)
protected

Get participants for server and ecs resource.

Definition at line 445 of file class.ilECSObjectSettings.php.

445 : array
446 {
447 $receivers = array();
448 foreach ((array) $a_server_id as $sid) {
449 $participants = null;
451 if ($details instanceof ilECSEContentDetails) {
452 $participants = $details->getReceivers();
453 }
454 if ($participants) {
455 foreach ($participants as $mid) {
456 $receivers[] = $mid;
457 }
458 }
459 }
460 return $receivers;
461 }

References ILIAS\LTI\ToolProvider\$details, getECSObjectType(), and ilECSEContentDetails\getInstanceFromServer().

Referenced by doUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleContentUpdate()

ilECSObjectSettings::handleContentUpdate ( )

Update ECS Content.

to be used AFTER metadata-/content-updates

Definition at line 292 of file class.ilECSObjectSettings.php.

292 : bool
293 {
294 if (!$this->isActive()) {
295 return true;
296 }
297 $exportManager = ilECSExportManager::getInstance();
298 $export_servers = $exportManager->getExportServerIds($this->content_obj->getId());
299 foreach ($export_servers as $server_id) {
301 if ($server->isEnabled()) {
302 try {
303 $export_settings = new ilECSExport($server_id, $this->content_obj->getId());
304
305 // already exported, update ecs
306 if ($export_settings->isExported()) {
307 $this->doUpdate($server, $export_settings);
308 }
309 } catch (ilECSConnectorException $exc) {
310 $this->logger->warning(__METHOD__ . ': Cannot handle ECS content update. ' . $exc->getMessage());
311 return false;
312 }
313 }
314 }
315 return true;
316 }
doUpdate(ilECSSetting $a_server, ilECSExport $a_export_settings, array $a_mids=null)
Update ECS resource.

References $server, doUpdate(), ilECSExportManager\getInstance(), ilECSSetting\getInstanceByServerId(), isActive(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ handlePermissionUpdate()

ilECSObjectSettings::handlePermissionUpdate ( ilECSSetting  $server)
protected

Handle permission update.

Definition at line 537 of file class.ilECSObjectSettings.php.

537 : void
538 {
539 if (
540 ($this->content_obj->getType() === 'crs') ||
541 ($this->content_obj->getType() === 'grp')
542 ) {
543 $this->logger->info(__METHOD__ . ': Permission update for courses/groups');
544 $this->rbacAdmin->grantPermission(
545 $server->getGlobalRole(),
546 ilRbacReview::_getOperationIdsByName(array('join','visible')),
547 $this->content_obj->getRefId()
548 );
549 }
550 }
static _getOperationIdsByName(array $operations)
get ops_id's by name.

References $server, ilRbacReview\_getOperationIdsByName(), and ILIAS\Repository\logger().

Referenced by doAdd(), and doUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleSettingsForServer()

ilECSObjectSettings::handleSettingsForServer ( ilECSSetting  $a_server,
bool  $a_export,
array  $a_mids 
)
protected

Save ECS settings (add- update- deleteResource)

Parameters
arrayarray of participant mids
Exceptions
ilECSConnectorException

Definition at line 266 of file class.ilECSObjectSettings.php.

266 : void
267 {
268 $export_settings = new ilECSExport($a_server->getServerId(), $this->content_obj->getId());
269
270 // already exported?
271 if ($export_settings->isExported()) {
272 // still exportable: update ecs
273 if ($a_export) {
274 $this->doUpdate($a_server, $export_settings, $a_mids);
275 }
276 // not exportable anymore
277 else {
278 $this->doDelete($a_server, $export_settings);
279 }
280 }
281 // not exported yet
282 elseif ($a_export) {
283 $this->doAdd($a_server, $export_settings, $a_mids);
284 }
285 }
doAdd(ilECSSetting $a_server, ilECSExport $a_export_settings, array $a_mids)
Add resource to ECS.
doDelete(ilECSSetting $a_server, ilECSExport $a_export_settings)
Delete ECS resource.

References doAdd(), doDelete(), doUpdate(), and ilECSSetting\getServerId().

Referenced by handleSettingsUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleSettingsUpdate()

ilECSObjectSettings::handleSettingsUpdate ( )

Update ECS Export Settings.

Processes post data from addSettingstoForm() to be used in ilObject->update() AFTER object data has been updated

Returns
bool

Definition at line 217 of file class.ilECSObjectSettings.php.

217 : bool
218 {
219 if (!$this->isActive()) {
220 return true;
221 }
222
223 // Parse post data
224 $mids = array();
225 foreach ((array) $_POST['ecs_sid'] as $sid_mid) {
226 $tmp = explode('_', $sid_mid);
227 $mids[$tmp[0]][] = $tmp[1];
228 }
229
230 try {
231 // Update for each server
232 foreach ((new ilECSParticipantSettingsRepository())->getServersContaingExports() as $server_id) {
234 if ($server->isEnabled()) {
235 // Export
236 $export = true;
237 if (!$_POST['ecs_export']) {
238 $export = false;
239 }
240 if (
241 !isset($mids[$server_id]) ||
242 !is_array($mids[$server_id]) ||
243 !count($mids[$server_id])) {
244 $export = false;
245 }
247 $server,
248 $export,
249 $mids[$server_id] ?? []
250 );
251 }
252 }
253 } catch (ilECSConnectorException $exc) {
254 $this->main_tpl->setOnScreenMessage('failure', 'Error exporting to ECS server: ' . $exc->getMessage());
255 return false;
256 }
257 return true;
258 }
handleSettingsForServer(ilECSSetting $a_server, bool $a_export, array $a_mids)
Save ECS settings (add- update- deleteResource)

References $server, ilECSSetting\getInstanceByServerId(), handleSettingsForServer(), and isActive().

+ Here is the call graph for this function:

◆ isActive()

ilECSObjectSettings::isActive ( )
protected

Is ECS (for current object) active?

Definition at line 102 of file class.ilECSObjectSettings.php.

102 : bool
103 {
104 if (ilECSServerSettings::getInstance()->activeServerExists()) {
105 // imported objects cannot be exported => why not
106 #if(!ilECSImportManager::getInstance()->lookupServerId($this->content_obj->getId()))
107 {
108 return true;
109 }
110 }
111
112 return false;
113 }

References ilECSServerSettings\getInstance().

Referenced by addSettingsToForm(), handleContentUpdate(), and handleSettingsUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendNewContentNotification()

ilECSObjectSettings::sendNewContentNotification ( ilECSSetting  $a_server,
  $a_econtent_id 
)
protected

send notifications about new EContent

Definition at line 466 of file class.ilECSObjectSettings.php.

466 : bool
467 {
468 if (!count($rcps = $a_server->getApprovalRecipients())) {
469 return true;
470 }
471
473 $lang->loadLanguageModule('ecs');
474
475 // @TODO: read mail
476 $mail = new ilMail(self::MAIL_SENDER);
477 $message = $lang->txt('ecs_export_created_body_a') . "\n\n";
478 $message .= $lang->txt('title') . ': ' . $this->content_obj->getTitle() . "\n";
479 if (($desc = $this->content_obj->getDescription()) !== '') {
480 $message .= $lang->txt('desc') . ': ' . $desc . "\n";
481 }
482
483 // Participant info
484 $message .= ("\n" . $lang->txt('ecs_published_for'));
485
486 try {
487 $found = false;
488
489 $receivers = null;
491 $a_server->getServerId(),
492 $a_econtent_id,
493 $this->getECSObjectType()
494 );
495 if ($details instanceof ilECSEContentDetails) {
496 $receivers = $details->getReceivers();
497 }
498 if ($receivers) {
499 foreach ($receivers as $member) {
500 $found = true;
501
502 $part = ilECSCommunityReader::getInstanceByServerId($a_server->getServerId())->getParticipantByMID($member);
503
504 $message .= ("\n\n" . $part->getParticipantName() . "\n");
505 $message .= ($part->getDescription());
506 }
507 }
508 if ($found) {
509 $message .= "\n\n";
510 } else {
511 $message .= (' ' . $lang->txt('ecs_not_published') . "\n\n");
512 }
513 } catch (ilECSConnectorException $e) {
514 $this->logger->warning(__METHOD__ . ': Cannot read approvements.');
515 return false;
516 }
517
518 $href = ilLink::_getStaticLink($this->content_obj->getRefId(), 'crs', true);
519 $message .= $lang->txt("perma_link") . ': ' . $href . "\n\n";
521
522 $mail->enqueue(
524 '',
525 '',
526 $lang->txt('ecs_new_approval_subject'),
527 $message,
528 array()
529 );
530
531 return true;
532 }
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
getApprovalRecipientsAsString()
get approval recipients as string
getApprovalRecipients()
get approval recipients
static _getLanguage(string $a_lang_key='')
Get language object.
static _getAutoGeneratedMessageString(ilLanguage $lang=null)
$lang
Definition: xapiexit.php:26
$message
Definition: xapiexit.php:32

References ILIAS\LTI\ToolProvider\$details, Vendor\Package\$e, $lang, $message, ilMail\_getAutoGeneratedMessageString(), ilLanguageFactory\_getLanguage(), ilLink\_getStaticLink(), ilECSSetting\getApprovalRecipients(), ilECSSetting\getApprovalRecipientsAsString(), ilECSCommunityReader\getInstanceByServerId(), ilECSEContentDetails\getInstanceFromServer(), ilECSSetting\getServerId(), and ILIAS\Repository\logger().

Referenced by doAdd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $content_obj

ilObject ilECSObjectSettings::$content_obj
protected

Definition at line 27 of file class.ilECSObjectSettings.php.

Referenced by _handleDelete(), and getContentObject().

◆ $lng

ilLanguage ilECSObjectSettings::$lng
private

Definition at line 30 of file class.ilECSObjectSettings.php.

◆ $logger

ilLogger ilECSObjectSettings::$logger
private

Definition at line 29 of file class.ilECSObjectSettings.php.

◆ $main_tpl

ilGlobalTemplateInterface ilECSObjectSettings::$main_tpl
private

Definition at line 35 of file class.ilECSObjectSettings.php.

◆ $rbacAdmin

ilRbacAdmin ilECSObjectSettings::$rbacAdmin
private

Definition at line 32 of file class.ilECSObjectSettings.php.

◆ $tree

ilTree ilECSObjectSettings::$tree
private

Definition at line 31 of file class.ilECSObjectSettings.php.

◆ MAIL_SENDER

const ilECSObjectSettings::MAIL_SENDER = 6

Definition at line 34 of file class.ilECSObjectSettings.php.


The documentation for this class was generated from the following file: