ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 31 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 48 of file class.ilECSObjectSettings.php.

49 {
50 global $DIC;
51 $this->main_tpl = $DIC->ui()->mainTemplate();
52
53 $this->lng = $DIC->language();
54 $this->logger = $DIC->logger()->obj();
55 $this->tree = $DIC->repositoryTree();
56 $this->rbacAdmin = $DIC->rbac()->admin();
57
58 $this->content_obj = $a_content_object;
59 }
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 547 of file class.ilECSObjectSettings.php.

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

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

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

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

518 : void
519 {
520 // already exported?
521 if ($a_export_settings->isExported()) {
522 $econtent_id = $a_export_settings->getEContentId();
523 if (!$econtent_id) {
524 $this->logger->warning(__METHOD__ . ': Missing eid. Aborting.');
525 throw new ilECSConnectorException('Missing ECS content ID. Aborting.');
526 }
527 $connector = new ilECSConnector($a_server);
528
529 $this->logger->info(__METHOD__ . ': Start deleting ECS content...');
530 $connector->deleteResource(
531 $this->getECSObjectType(),
532 $econtent_id
533 );
534
535 // status changed
536 $a_export_settings->setExported(false);
537 $a_export_settings->save();
538 }
539 }
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 486 of file class.ilECSObjectSettings.php.

486 : void
487 {
488 $econtent_id = $a_export_settings->getEContentId();
489 if (!$econtent_id) {
490 $this->logger->warning(__METHOD__ . ': Missing eid. Aborting.');
491 throw new ilECSConnectorException('Missing ECS content ID. Aborting.');
492 }
493 $connector = new ilECSConnector($a_server);
494
495 if (!$a_mids) {
496 $a_mids = $this->getParticipants($a_server->getServerId(), $econtent_id);
497 }
498 $this->logger->info(__METHOD__ . ': Start updating ECS content - ' . print_r($a_mids, true));
499 $connector->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, implode(',', (array) $a_mids));
500
501 $json = $this->buildJson($a_server);
502 $connector->updateResource(
503 $this->getECSObjectType(),
504 $econtent_id,
505 json_encode($json, JSON_THROW_ON_ERROR)
506 );
507
508 $this->handlePermissionUpdate($a_server);
509 }
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 235 of file class.ilECSObjectSettings.php.

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

95 : \ilObject
96 {
97 return $this->content_obj;
98 }
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 64 of file class.ilECSObjectSettings.php.

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

688 : object
689 {
690 $json = new stdClass();
691 $json->lang = 'en_EN'; // :TODO: obsolet?
692 $json->id = 'il_' . IL_INST_ID . '_' . $this->getContentObject()->getType() . '_' . $this->getContentObject()->getId();
693 $json->etype = $a_etype;
694 $json->title = $this->content_obj->getTitle();
695 $json->abstract = $this->content_obj->getLongDescription();
696
697 $json->url = ilLink::_getLink($this->content_obj->getRefId(), $this->content_obj->getType());
698
699 return $json;
700 }
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 578 of file class.ilECSObjectSettings.php.

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

References ilECSEContentDetails\getInstanceFromServer().

+ Here is the call graph for this function:

◆ getSettingsSection()

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

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

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

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

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

◆ getValueForECSExportOptionalGroup()

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

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

289 : ?array {
290 $obj_id = $this->content_obj->getId();
291 $active_receivers = null;
292 foreach ($export_manager->getExportServerIds($obj_id) as $sid) {
293 $exp = new ilECSExport($sid, $obj_id);
294
295 $participants = null;
297 $sid,
298 $exp->getEContentId(),
299 $this->getECSObjectType()
300 );
301 if ($details instanceof ilECSEContentDetails) {
302 $participants = $details->getReceivers();
303 }
304 if ($participants === null) {
305 continue;
306 }
307 foreach ($participants as $mid) {
308 $active_receivers[$sid . '_' . $mid] = true;
309 }
310 }
311
312 if ($active_receivers === null) {
313 return null;
314 }
315
316 $missing_keys = (array_diff($potential_receivers, array_keys($active_receivers)));
317 foreach ($missing_keys as $key) {
318 $active_receivers[$key] = false;
319 }
320
321 return $active_receivers;
322 }
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 425 of file class.ilECSObjectSettings.php.

425 : bool
426 {
427 if (!$this->isActive()) {
428 return true;
429 }
430 $exportManager = ilECSExportManager::getInstance();
431 $export_servers = $exportManager->getExportServerIds($this->content_obj->getId());
432 foreach ($export_servers as $server_id) {
434 if ($server->isEnabled()) {
435 try {
436 $export_settings = new ilECSExport($server_id, $this->content_obj->getId());
437
438 // already exported, update ecs
439 if ($export_settings->isExported()) {
440 $this->doUpdate($server, $export_settings);
441 }
442 } catch (ilECSConnectorException $exc) {
443 $this->logger->warning(__METHOD__ . ': Cannot handle ECS content update. ' . $exc->getMessage());
444 return false;
445 }
446 }
447 }
448 return true;
449 }
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 670 of file class.ilECSObjectSettings.php.

670 : void
671 {
672 if (
673 ($this->content_obj->getType() === 'crs') ||
674 ($this->content_obj->getType() === 'grp')
675 ) {
676 $this->logger->info(__METHOD__ . ': Permission update for courses/groups');
677 $this->rbacAdmin->grantPermission(
678 $server->getGlobalRole(),
679 ilRbacReview::_getOperationIdsByName(array('join','visible')),
680 $this->content_obj->getRefId()
681 );
682 }
683 }
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 344 of file class.ilECSObjectSettings.php.

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

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

335 : bool
336 {
337 return $this->handleSettings(
338 (bool) $form->getInput("ecs_export"),
339 (array) $form->getInput("ecs_sid")
340 );
341 }
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 108 of file class.ilECSObjectSettings.php.

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

References ilECSServerSettings\getInstance().

+ Here is the call graph for this function:

◆ saveSettingsSection()

ilECSObjectSettings::saveSettingsSection ( array  $section)

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

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

◆ sendNewContentNotification()

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

send notifications about new EContent

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

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

References 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().

+ Here is the call graph for this function:

Field Documentation

◆ $content_obj

ilObject ilECSObjectSettings::$content_obj
protected

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

Referenced by getContentObject().

◆ $lng

ilLanguage ilECSObjectSettings::$lng
private

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

◆ $logger

ilLogger ilECSObjectSettings::$logger
private

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

◆ $main_tpl

ilGlobalTemplateInterface ilECSObjectSettings::$main_tpl
private

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

◆ $rbacAdmin

ilRbacAdmin ilECSObjectSettings::$rbacAdmin
private

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

◆ $tree

ilTree ilECSObjectSettings::$tree
private

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

◆ MAIL_SENDER

const ilECSObjectSettings::MAIL_SENDER = 6

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


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