ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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...
 
 getSettingsSection (FieldFactory $field_factory, Refinery $refinery)
 
 saveSettingsSection (array $section)
 
 handleSettingsUpdate (ilPropertyFormGUI $form)
 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...
 
 ecsCanBeActivatedForObject (ilECSExportManager $export_manager, array $exportable_participants)
 
 getTrafoForECSExportSection (Refinery $refinery)
 
 getValueForECSExportOptionalGroup (ilECSExportManager $export_manager, array $potential_receivers)
 
 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 Member Functions

 handleSettings (bool $ecs_export, array $selected_receivers)
 

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 32 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 49 of file class.ilECSObjectSettings.php.

50 {
51 global $DIC;
52 $this->main_tpl = $DIC->ui()->mainTemplate();
53
54 $this->lng = $DIC->language();
55 $this->logger = $DIC->logger()->obj();
56 $this->tree = $DIC->repositoryTree();
57 $this->rbacAdmin = $DIC->rbac()->admin();
58
59 $this->content_obj = $a_content_object;
60 }
global $DIC
Definition: shib_login.php:26

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 548 of file class.ilECSObjectSettings.php.

548 : void
549 {
550 // active?
551 if (!ilECSServerSettings::getInstance()->activeServerExists()) {
552 return;
553 }
554 $exportManager = ilECSExportManager::getInstance();
555 $exported = $exportManager->getExportedIds();
556 foreach ($a_subbtree_nodes as $node) {
557 if (in_array(
558 $node['obj_id'],
559 $exported,
560 true
561 ) && $content_obj = ilObjectFactory::getInstanceByRefId($node['child'], false)) {
563
564 // Read export server ids
565 foreach ($exportManager->getExportServerIds($node['obj_id']) as $sid) {
567 $export_settings = new ilECSExport($sid, $content_obj->getId());
568 if ($settings) {
569 $settings->doDelete($server, $export_settings);
570 }
571 }
572 }
573 }
574 }
$settings
Definition: index.php:44
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
Definition: shib_login.php:28

References $server, $settings, ilECSExportManager\getInstance(), ilECSServerSettings\getInstance(), ilObjectFactory\getInstanceByRefId(), and ilECSSetting\getInstanceByServerId().

Referenced by ILIAS\Repository\Deletion\EventStandardAdapter\beforeMoveToTrash().

+ Here is the call graph for this function:
+ Here is the caller 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 706 of file class.ilECSObjectSettings.php.

706 : void
707 {
709
710 $values = ilECSUtils::getAdvancedMDValuesForObjId($this->content_obj->getId());
711
712 foreach ($a_definition as $id => $type) {
713 if (is_array($type)) {
714 [$type , $target] = $type;
715 } else {
716 $target = $id;
717 }
718
719 if ($field = $mappings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, $id)) {
720 $value = $values[$field] ?? '';
721
722 switch ($type) {
724 $a_json->{$target} = explode(',', $value);
725 break;
726
728 $a_json->{$target} = (int) $value;
729 break;
730
732 $a_json->{$target} = (string) $value;
733 break;
734
736 if (!isset($a_json->{$target})) {
737 $a_json->{$target} = new ilECSTimePlace();
738 }
739 $a_json->{$target}->{'set' . ucfirst($id)}($value);
740 break;
741 }
742 }
743 }
744 }
$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

References $id, ILIAS\Scripts\PHPStan\$target, 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 127 of file class.ilECSObjectSettings.php.

127 : bool
128 {
129 $export_manager = ilECSExportManager::getInstance();
130 $exportable_participants = (new ilECSParticipantSettingsRepository())->getExportableParticipants($a_type);
131 $obj_id = $this->content_obj->getId();
132
133 if (!$this->ecsCanBeActivatedForObject($export_manager, $exportable_participants)) {
134 return false;
135 }
136
137 $this->lng->loadLanguageModule('ecs');
138
139 // show ecs property form section
140 $ecs = new ilFormSectionHeaderGUI();
141 $ecs->setTitle($this->lng->txt('ecs_' . $a_type . '_export'));
142 $a_form->addItem($ecs);
143
144
145 // release or not
146 $exp = new ilRadioGroupInputGUI($this->lng->txt('ecs_' . $a_type . '_export_obj_settings'), 'ecs_export');
147 $exp->setRequired(true);
148 $exp->setValue($export_manager->_isExported($obj_id) ? "1" : "0");
149 $off = new ilRadioOption($this->lng->txt('ecs_' . $a_type . '_export_disabled'), "0");
150 $exp->addOption($off);
151 $on = new ilRadioOption($this->lng->txt('ecs_' . $a_type . '_export_enabled'), "1");
152 $exp->addOption($on);
153 $a_form->addItem($exp);
154
155 // Show all exportable participants
156 $publish_for = new ilCheckboxGroupInputGUI($this->lng->txt('ecs_publish_for'), 'ecs_sid');
157
158 // @TODO: Active checkboxes for recipients
159 //$publish_for->setValue((array) $members);
160
161 // Read receivers
162 $receivers = array();
163 foreach ($export_manager->getExportServerIds($obj_id) as $sid) {
164 $exp = new ilECSExport($sid, $obj_id);
165
166 $participants = null;
168 $sid,
169 $exp->getEContentId(),
170 $this->getECSObjectType()
171 );
172 if ($details instanceof ilECSEContentDetails) {
173 $participants = $details->getReceivers();
174 }
175 if ($participants) {
176 foreach ($participants as $mid) {
177 $receivers[] = $sid . '_' . $mid;
178 }
179 }
180 }
181 $publish_for->setValue($receivers);
182
183 foreach ($exportable_participants as $pInfo) {
184 $partSetting = new ilECSParticipantSetting($pInfo['sid'], $pInfo['mid']);
185
186 $com = new ilCheckboxOption(
187 $partSetting->getCommunityName() . ': ' . $partSetting->getTitle(),
188 'sid_mid'
189 );
190 $com->setValue($pInfo['sid'] . '_' . $pInfo['mid']);
191 $publish_for->addOption($com);
192 }
193 $on->addSubItem($publish_for);
194 return true;
195 }
This class represents a property in a property form.
This class represents an option in a checkbox group.
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.
ecsCanBeActivatedForObject(ilECSExportManager $export_manager, array $exportable_participants)
This class represents a section header in a property form.
This class represents a property in a property form.
This class represents an option in a radio group.

References ilPropertyFormGUI\addItem(), ecsCanBeActivatedForObject(), ilECSExportManager\getInstance(), ilECSEContentDetails\getInstanceFromServer(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ buildJson()

ilECSObjectSettings::buildJson ( ilECSSetting  $a_server)
abstractprotected

◆ doAdd()

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

Add resource to ECS.

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

455 : void
456 {
457 $this->logger->info(__METHOD__ . ': Starting ECS add resource...');
458
459 $json = $this->buildJson($a_server);
460
461 $connector = new ilECSConnector($a_server);
462 $connector->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, implode(',', $a_mids));
463 $econtent_id = $connector->addResource(
464 $this->getECSObjectType(),
465 json_encode($json, JSON_THROW_ON_ERROR)
466 );
467
468 // status changed
469 $a_export_settings->setExported(true);
470 $a_export_settings->setEContentId($econtent_id);
471 $a_export_settings->save();
472
473 $this->handlePermissionUpdate($a_server);
474
475 // Send mail
476 $this->sendNewContentNotification($a_server, $econtent_id);
477 }
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 ilECSConnector\HEADER_MEMBERSHIPS, ILIAS\Repository\logger(), ilECSExport\save(), ilECSExport\setEContentId(), and ilECSExport\setExported().

+ Here is the call 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 519 of file class.ilECSObjectSettings.php.

519 : void
520 {
521 // already exported?
522 if ($a_export_settings->isExported()) {
523 $econtent_id = $a_export_settings->getEContentId();
524 if (!$econtent_id) {
525 $this->logger->warning(__METHOD__ . ': Missing eid. Aborting.');
526 throw new ilECSConnectorException('Missing ECS content ID. Aborting.');
527 }
528 $connector = new ilECSConnector($a_server);
529
530 $this->logger->info(__METHOD__ . ': Start deleting ECS content...');
531 $connector->deleteResource(
532 $this->getECSObjectType(),
533 $econtent_id
534 );
535
536 // status changed
537 $a_export_settings->setExported(false);
538 $a_export_settings->save();
539 }
540 }
getEContentId()
get econtent id
isExported()
check if an object is exported or not

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

+ Here is the call 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 487 of file class.ilECSObjectSettings.php.

487 : void
488 {
489 $econtent_id = $a_export_settings->getEContentId();
490 if (!$econtent_id) {
491 $this->logger->warning(__METHOD__ . ': Missing eid. Aborting.');
492 throw new ilECSConnectorException('Missing ECS content ID. Aborting.');
493 }
494 $connector = new ilECSConnector($a_server);
495
496 if (!$a_mids) {
497 $a_mids = $this->getParticipants($a_server->getServerId(), $econtent_id);
498 }
499 $this->logger->info(__METHOD__ . ': Start updating ECS content - ' . print_r($a_mids, true));
500 $connector->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, implode(',', (array) $a_mids));
501
502 $json = $this->buildJson($a_server);
503 $connector->updateResource(
504 $this->getECSObjectType(),
505 $econtent_id,
506 json_encode($json, JSON_THROW_ON_ERROR)
507 );
508
509 $this->handlePermissionUpdate($a_server);
510 }
getParticipants(int $a_server_id, int $a_econtent_id)
Get participants for server and ecs resource.

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

+ Here is the call graph for this function:

◆ ecsCanBeActivatedForObject()

ilECSObjectSettings::ecsCanBeActivatedForObject ( ilECSExportManager  $export_manager,
array  $exportable_participants 
)
protected

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

239 : bool {
240 $this->logger->debug('Show ecs settings.');
241 if (!$this->isActive()) {
242 $this->logger->debug('Object type is not active. => no settings.');
243 return false;
244 }
245
246 $obj_id = $this->content_obj->getId();
247
248 // Return if no participant is enabled for export and the current object is not released
249 if (!$this->getContentObject()->withReferences()) {
250 $this->logger->debug('Called without references. => no settings.');
251 return false;
252 }
253
254 if (!$exportable_participants && !$export_manager->_isExported($obj_id)) {
255 $this->logger->debug('Object type is not exportable. => no settings.');
256 return false;
257 }
258 if (
259 $this->tree->checkForParentType($this->tree->getParentId($this->getContentObject()->getRefId()), 'crs', false) ||
260 $this->tree->checkForParentType($this->tree->getParentId($this->getContentObject()->getRefId()), 'grp', false)
261 ) {
262 $this->logger->debug('Parent crs/grp in path. => no settings.');
263 return false;
264 }
265
266 return true;
267 }
_isExported(int $a_obj_id)
Check if object is exported.
getContentObject()
Get content object.
isActive()
Is ECS (for current object) active?

References ILIAS\Repository\logger().

Referenced by addSettingsToForm().

+ 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 96 of file class.ilECSObjectSettings.php.

96 : \ilObject
97 {
98 return $this->content_obj;
99 }
Class ilObject Basic functions for all objects.

References $content_obj.

Referenced by ilECSCourseSettings\buildJson().

+ Here is the caller graph for this function:

◆ getECSObjectType()

ilECSObjectSettings::getECSObjectType ( )
abstractprotected

◆ getInstanceByObject()

static ilECSObjectSettings::getInstanceByObject ( ilObject  $a_content_obj)
static

Get settings handler for repository object.

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

66 {
67 switch ($a_content_obj->getType()) {
68 case 'crs':
69 return new ilECSCourseSettings($a_content_obj);
70
71 case 'cat':
72 return new ilECSCategorySettings($a_content_obj);
73
74 case 'file':
75 return new ilECSFileSettings($a_content_obj);
76
77 case 'glo':
78 return new ilECSGlossarySettings($a_content_obj);
79
80 case 'grp':
81 return new ilECSGroupSettings($a_content_obj);
82
83 case 'lm':
84 return new ilECSLearningModuleSettings($a_content_obj);
85
86 case 'wiki':
87 return new ilECSWikiSettings($a_content_obj);
88 }
89 return null;
90 }
Class ilECSCategorySettings.
Class ilECSCourseSettings.
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().

+ Here is the call graph for this function:

◆ getJsonCore()

ilECSObjectSettings::getJsonCore ( string  $a_etype)
protected

Build core json structure.

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

689 : object
690 {
691 $json = new stdClass();
692 $json->lang = 'en_EN'; // :TODO: obsolet?
693 $json->id = 'il_' . IL_INST_ID . '_' . $this->getContentObject()->getType() . '_' . $this->getContentObject()->getId();
694 $json->etype = $a_etype;
695 $json->title = $this->content_obj->getTitle();
696 $json->abstract = $this->content_obj->getLongDescription();
697
698 $json->url = ilLink::_getLink($this->content_obj->getRefId(), $this->content_obj->getType());
699
700 return $json;
701 }
const IL_INST_ID
Definition: constants.php:40

References 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 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 579 of file class.ilECSObjectSettings.php.

579 : array
580 {
581 $receivers = array();
582 foreach ((array) $a_server_id as $sid) {
583 $participants = null;
584 $details = ilECSEContentDetails::getInstanceFromServer($sid, $a_econtent_id, $this->getECSObjectType());
585 if ($details instanceof ilECSEContentDetails) {
586 $participants = $details->getReceivers();
587 }
588 if ($participants) {
589 foreach ($participants as $mid) {
590 $receivers[] = $mid;
591 }
592 }
593 }
594 return $receivers;
595 }

References ilECSEContentDetails\getInstanceFromServer().

+ Here is the call graph for this function:

◆ getSettingsSection()

ilECSObjectSettings::getSettingsSection ( FieldFactory  $field_factory,
Refinery  $refinery 
)

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

200 : ?Section {
201 $type = $this->content_obj->getType();
202 $export_manager = ilECSExportManager::getInstance();
203 $exportable_participants = (new ilECSParticipantSettingsRepository())->getExportableParticipants($type);
204
205 if (!$this->ecsCanBeActivatedForObject($export_manager, $exportable_participants)) {
206 return null;
207 }
208
209 $this->lng->loadLanguageModule('ecs');
210 $trafo = $this->getTrafoForECSExportSection($refinery);
211
212 $potential_receivers = [];
213
214 foreach ($exportable_participants as $participant) {
215 $participant_setting = new ilECSParticipantSetting($participant['sid'], $participant['mid']);
216 $potential_receivers[$participant['sid'] . '_' . $participant['mid']] = $field_factory->checkbox(
217 $participant_setting->getCommunityName() . ': ' . $participant_setting->getTitle()
218 );
219 }
220
221 $value = $this->getValueForECSExportOptionalGroup(
222 $export_manager,
223 array_keys($potential_receivers)
224 );
225
226 $inputs['ecs_export'] = $field_factory->optionalGroup(
227 $potential_receivers,
228 $this->lng->txt('ecs_' . $type . '_export_obj_settings')
229 )
230 ->withValue($value);
231
232 return $field_factory->section($inputs, $this->lng->txt('ecs_' . $type . '_export'))
233 ->withAdditionalTransformation($trafo);
234 }
getValueForECSExportOptionalGroup(ilECSExportManager $export_manager, array $potential_receivers)
getTrafoForECSExportSection(Refinery $refinery)
This describes section inputs.
Definition: Section.php:29

◆ getTrafoForECSExportSection()

ilECSObjectSettings::getTrafoForECSExportSection ( Refinery  $refinery)
protected

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

270 {
271 return $refinery->custom()->transformation(
272 function (?array $vs): array {
273 if ($vs['ecs_export'] === null) {
274 return [
275 'is_exported' => false
276 ];
277 }
278
279 return [
280 'is_exported' => true,
281 'values' => array_keys($vs['ecs_export'])
282 ];
283 }
284 );
285 }
A transformation is a function from one datatype to another.

References ILIAS\UI\examples\Layout\Page\Mail\$refinery.

◆ getValueForECSExportOptionalGroup()

ilECSObjectSettings::getValueForECSExportOptionalGroup ( ilECSExportManager  $export_manager,
array  $potential_receivers 
)
protected

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

290 : ?array {
291 $obj_id = $this->content_obj->getId();
292 $active_receivers = null;
293 foreach ($export_manager->getExportServerIds($obj_id) as $sid) {
294 $exp = new ilECSExport($sid, $obj_id);
295
296 $participants = null;
298 $sid,
299 $exp->getEContentId(),
300 $this->getECSObjectType()
301 );
302 if ($details instanceof ilECSEContentDetails) {
303 $participants = $details->getReceivers();
304 }
305 if ($participants === null) {
306 continue;
307 }
308 foreach ($participants as $mid) {
309 $active_receivers[$sid . '_' . $mid] = true;
310 }
311 }
312
313 if ($active_receivers === null) {
314 return null;
315 }
316
317 $missing_keys = (array_diff($potential_receivers, array_keys($active_receivers)));
318 foreach ($missing_keys as $key) {
319 $active_receivers[$key] = false;
320 }
321
322 return $active_receivers;
323 }
getExportServerIds(int $a_obj_id)
lookup server ids of exported materials

References ilECSEContentDetails\getInstanceFromServer().

+ Here is the call graph for this function:

◆ handleContentUpdate()

ilECSObjectSettings::handleContentUpdate ( )

Update ECS Content.

to be used AFTER metadata-/content-updates

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

426 : bool
427 {
428 if (!$this->isActive()) {
429 return true;
430 }
431 $exportManager = ilECSExportManager::getInstance();
432 $export_servers = $exportManager->getExportServerIds($this->content_obj->getId());
433 foreach ($export_servers as $server_id) {
435 if ($server->isEnabled()) {
436 try {
437 $export_settings = new ilECSExport($server_id, $this->content_obj->getId());
438
439 // already exported, update ecs
440 if ($export_settings->isExported()) {
441 $this->doUpdate($server, $export_settings);
442 }
443 } catch (ilECSConnectorException $exc) {
444 $this->logger->warning(__METHOD__ . ': Cannot handle ECS content update. ' . $exc->getMessage());
445 return false;
446 }
447 }
448 }
449 return true;
450 }
doUpdate(ilECSSetting $a_server, ilECSExport $a_export_settings, ?array $a_mids=null)
Update ECS resource.

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

+ Here is the call graph for this function:

◆ handlePermissionUpdate()

ilECSObjectSettings::handlePermissionUpdate ( ilECSSetting  $server)
protected

Handle permission update.

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

671 : void
672 {
673 if (
674 ($this->content_obj->getType() === 'crs') ||
675 ($this->content_obj->getType() === 'grp')
676 ) {
677 $this->logger->info(__METHOD__ . ': Permission update for courses/groups');
678 $this->rbacAdmin->grantPermission(
679 $server->getGlobalRole(),
680 ilRbacReview::_getOperationIdsByName(array('join','visible')),
681 $this->content_obj->getRefId()
682 );
683 }
684 }
static _getOperationIdsByName(array $operations)
get ops_id's by name.

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

+ Here is the call graph for this function:

◆ handleSettings()

ilECSObjectSettings::handleSettings ( bool  $ecs_export,
array  $selected_receivers 
)
private

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

348 : bool {
349 if (!$this->isActive()) {
350 return true;
351 }
352
353 // Parse post data
354 $mids = array();
355 foreach ((array) $selected_receivers as $sid_mid) {
356 $tmp = explode('_', $sid_mid);
357 if (1 === count($tmp)) {
358 $mids[$tmp[0]][] = $tmp[0];
359 } else {
360 $mids[$tmp[0]][] = $tmp[1];
361 }
362 }
363
364 try {
365 // Update for each server
366 foreach ((new ilECSParticipantSettingsRepository())->getServersContaingExports() as $server_id) {
368 if ($server->isEnabled()) {
369 // Export
370 $export = true;
371 if (!$ecs_export) {
372 $export = false;
373 }
374 if (
375 !isset($mids[$server_id]) ||
376 !is_array($mids[$server_id]) ||
377 !count($mids[$server_id])) {
378 $export = false;
379 }
381 $server,
382 $export,
383 $mids[$server_id] ?? []
384 );
385 }
386 }
387 } catch (ilECSConnectorException $exc) {
388 $this->main_tpl->setOnScreenMessage('failure', 'Error exporting to ECS server: ' . $exc->getMessage());
389 return false;
390 }
391 return true;
392 }
handleSettingsForServer(ilECSSetting $a_server, bool $a_export, array $a_mids)
Save ECS settings (add- update- deleteResource)

◆ 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 400 of file class.ilECSObjectSettings.php.

400 : void
401 {
402 $export_settings = new ilECSExport($a_server->getServerId(), $this->content_obj->getId());
403
404 // already exported?
405 if ($export_settings->isExported()) {
406 // still exportable: update ecs
407 if ($a_export) {
408 $this->doUpdate($a_server, $export_settings, $a_mids);
409 }
410 // not exportable anymore
411 else {
412 $this->doDelete($a_server, $export_settings);
413 }
414 }
415 // not exported yet
416 elseif ($a_export) {
417 $this->doAdd($a_server, $export_settings, $a_mids);
418 }
419 }
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 ilECSSetting\getServerId().

+ Here is the call graph for this function:

◆ handleSettingsUpdate()

ilECSObjectSettings::handleSettingsUpdate ( ilPropertyFormGUI  $form)

Update ECS Export Settings.

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

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

336 : bool
337 {
338 return $this->handleSettings(
339 (bool) $form->getInput("ecs_export"),
340 (array) $form->getInput("ecs_sid")
341 );
342 }
handleSettings(bool $ecs_export, array $selected_receivers)
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...

References ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

◆ isActive()

ilECSObjectSettings::isActive ( )
protected

Is ECS (for current object) active?

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

109 : bool
110 {
111 if (ilECSServerSettings::getInstance()->activeServerExists()) {
112 // imported objects cannot be exported => why not
113 #if(!ilECSImportManager::getInstance()->lookupServerId($this->content_obj->getId()))
114 {
115 return true;
116 }
117 }
118
119 return false;
120 }

References ilECSServerSettings\getInstance().

+ Here is the call graph for this function:

◆ saveSettingsSection()

ilECSObjectSettings::saveSettingsSection ( array  $section)

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

325 : bool
326 {
327 return $this->handleSettings($section['is_exported'], $section['values']);
328 }

◆ sendNewContentNotification()

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

send notifications about new EContent

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

600 : bool
601 {
602 if (!count($rcps = $a_server->getApprovalRecipients())) {
603 return true;
604 }
605
607 $lang->loadLanguageModule('ecs');
608
609 // @TODO: read mail
610 $mail = new ilMail(self::MAIL_SENDER);
611 $message = $lang->txt('ecs_export_created_body_a') . "\n\n";
612 $message .= $lang->txt('title') . ': ' . $this->content_obj->getTitle() . "\n";
613 if (($desc = $this->content_obj->getDescription()) !== '') {
614 $message .= $lang->txt('desc') . ': ' . $desc . "\n";
615 }
616
617 // Participant info
618 $message .= ("\n" . $lang->txt('ecs_published_for'));
619
620 try {
621 $found = false;
622
623 $receivers = null;
625 $a_server->getServerId(),
626 $a_econtent_id,
627 $this->getECSObjectType()
628 );
629 if ($details instanceof ilECSEContentDetails) {
630 $receivers = $details->getReceivers();
631 }
632 if ($receivers) {
633 foreach ($receivers as $member) {
634 $found = true;
635
636 $part = ilECSCommunityReader::getInstanceByServerId($a_server->getServerId())->getParticipantByMID($member);
637
638 $message .= ("\n\n" . $part->getParticipantName() . "\n");
639 $message .= ($part->getDescription());
640 }
641 }
642 if ($found) {
643 $message .= "\n\n";
644 } else {
645 $message .= (' ' . $lang->txt('ecs_not_published') . "\n\n");
646 }
647 } catch (ilECSConnectorException $e) {
648 $this->logger->warning(__METHOD__ . ': Cannot read approvements.');
649 return false;
650 }
651
652 $href = ilLink::_getStaticLink($this->content_obj->getRefId(), 'crs', true);
653 $message .= $lang->txt("perma_link") . ': ' . $href . "\n\n";
655
656 $mail->enqueue(
658 '',
659 '',
660 $lang->txt('ecs_new_approval_subject'),
661 $message,
662 MailAttachments::empty(),
663 );
664
665 return true;
666 }
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)

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

+ Here is the call graph for this function:

Field Documentation

◆ $content_obj

ilObject ilECSObjectSettings::$content_obj
protected

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

Referenced by getContentObject().

◆ $lng

ilLanguage ilECSObjectSettings::$lng
private

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

◆ $logger

ilLogger ilECSObjectSettings::$logger
private

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

◆ $main_tpl

ilGlobalTemplateInterface ilECSObjectSettings::$main_tpl
private

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

◆ $rbacAdmin

ilRbacAdmin ilECSObjectSettings::$rbacAdmin
private

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

◆ $tree

ilTree ilECSObjectSettings::$tree
private

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

◆ MAIL_SENDER

const ilECSObjectSettings::MAIL_SENDER = 6

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


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