ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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

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

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

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
+ 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.

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

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

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)) {
561  $settings = self::getInstanceByObject($content_obj);
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  }
Storage of an ECS exported object.
static getInstance()
Get the singelton instance of this ilECSExportManager.
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
+ 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.

References $id, buildJson(), 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().

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  }
static getAdvancedMDValuesForObjId(int $a_obj_id)
Get advanced metadata values for object id.
static getInstanceByServerId(int $a_server_id)
Get singleton instance.
Representation of ECS EContent Time Place.
getServerId()
Get current server id.
const TYPE_TIMEPLACE
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ 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.

References ilPropertyFormGUI\addItem(), ecsCanBeActivatedForObject(), getECSObjectType(), ilECSExportManager\getInstance(), ilECSEContentDetails\getInstanceFromServer(), ILIAS\Repository\lng(), null, ilFormPropertyGUI\setRequired(), ilRadioOption\setValue(), and ilCheckboxGroupInputGUI\setValue().

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 an option in a radio group.
This class represents an option in a checkbox group.
Storage of an ECS exported object.
static getInstance()
Get the singelton instance of this ilECSExportManager.
Presentation of ecs content details (http://...campusconnect/courselinks/id/details) ...
getECSObjectType()
Get ECS resource identifier, e.g.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This class represents a property in a property form.
ecsCanBeActivatedForObject(ilECSExportManager $export_manager, array $exportable_participants)
setValue(string $a_value)
This class represents a property in a property form.
setRequired(bool $a_required)
static getInstanceFromServer(int $a_server_id, int $a_econtent_id, string $a_resource_type)
Get data from server.
+ Here is the call graph for this function:

◆ buildJson()

ilECSObjectSettings::buildJson ( ilECSSetting  $a_server)
abstractprotected

Build resource-specific json.

Returns
mixed

Referenced by addMetadataToJson(), 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 454 of file class.ilECSObjectSettings.php.

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

Referenced by handleSettingsForServer().

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  }
setExported(bool $a_status)
Set exported.
getECSObjectType()
Get ECS resource identifier, e.g.
sendNewContentNotification(ilECSSetting $a_server, $a_econtent_id)
send notifications about new EContent
handlePermissionUpdate(ilECSSetting $server)
Handle permission update.
buildJson(ilECSSetting $a_server)
Build resource-specific json.
setEContentId(int $a_id)
set econtent id
+ 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 518 of file class.ilECSObjectSettings.php.

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

Referenced by handleSettingsForServer().

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  }
setExported(bool $a_status)
Set exported.
getECSObjectType()
Get ECS resource identifier, e.g.
isExported()
check if an object is exported or not
getEContentId()
get econtent id
+ 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 486 of file class.ilECSObjectSettings.php.

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

Referenced by handleContentUpdate(), and handleSettingsForServer().

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.
getServerId()
Get current server id.
getECSObjectType()
Get ECS resource identifier, e.g.
getEContentId()
get econtent id
handlePermissionUpdate(ilECSSetting $server)
Handle permission update.
buildJson(ilECSSetting $a_server)
Build resource-specific json.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ecsCanBeActivatedForObject()

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

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

References ilECSExportManager\_isExported(), getContentObject(), isActive(), and ILIAS\Repository\logger().

Referenced by addSettingsToForm(), and getSettingsSection().

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  }
isActive()
Is ECS (for current object) active?
getContentObject()
Get content object.
_isExported(int $a_obj_id)
Check if object is exported.
+ 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.

References $content_obj, and getECSObjectType().

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

95  : \ilObject
96  {
97  return $this->content_obj;
98  }
Class ilObject Basic functions for all objects.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getECSObjectType()

ilECSObjectSettings::getECSObjectType ( )
abstractprotected

Get ECS resource identifier, e.g.

"/campusconnect/courselinks"

Referenced by addSettingsToForm(), doAdd(), doDelete(), doUpdate(), getContentObject(), getParticipants(), getValueForECSExportOptionalGroup(), and sendNewContentNotification().

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

References ilObject\getType(), and null.

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  }
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...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilECSGroupSettings.
Class ilECSCategorySettings.
Handles object exports to ECS.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilECSCourseSettings.
+ 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.

References getContentObject(), and IL_INST_ID.

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

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
getContentObject()
Get content object.
+ 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 578 of file class.ilECSObjectSettings.php.

References getECSObjectType(), ilECSEContentDetails\getInstanceFromServer(), and null.

Referenced by doUpdate().

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  }
Presentation of ecs content details (http://...campusconnect/courselinks/id/details) ...
getECSObjectType()
Get ECS resource identifier, e.g.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getInstanceFromServer(int $a_server_id, int $a_econtent_id, string $a_resource_type)
Get data from server.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSettingsSection()

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

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

References ILIAS\UI\Implementation\Component\Input\$inputs, ecsCanBeActivatedForObject(), ilECSExportManager\getInstance(), getTrafoForECSExportSection(), getValueForECSExportOptionalGroup(), ILIAS\Repository\lng(), null, ILIAS\UI\Implementation\Component\Input\ViewControl\withAdditionalTransformation(), and ILIAS\UI\Implementation\Component\Input\withValue().

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'))
233  }
getTrafoForECSExportSection(Refinery $refinery)
static getInstance()
Get the singelton instance of this ilECSExportManager.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
ecsCanBeActivatedForObject(ilECSExportManager $export_manager, array $exportable_participants)
getValueForECSExportOptionalGroup(ilECSExportManager $export_manager, array $potential_receivers)
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61
+ Here is the call graph for this function:

◆ getTrafoForECSExportSection()

ilECSObjectSettings::getTrafoForECSExportSection ( Refinery  $refinery)
protected

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

References null.

Referenced by getSettingsSection().

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
A transformation is a function from one datatype to another.
+ Here is the caller graph for this function:

◆ getValueForECSExportOptionalGroup()

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

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

References getECSObjectType(), ilECSExportManager\getExportServerIds(), ilECSEContentDetails\getInstanceFromServer(), and null.

Referenced by getSettingsSection().

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  }
Storage of an ECS exported object.
Presentation of ecs content details (http://...campusconnect/courselinks/id/details) ...
getECSObjectType()
Get ECS resource identifier, e.g.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getExportServerIds(int $a_obj_id)
lookup server ids of exported materials
static getInstanceFromServer(int $a_server_id, int $a_econtent_id, string $a_resource_type)
Get data from server.
+ 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 425 of file class.ilECSObjectSettings.php.

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

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  }
Storage of an ECS exported object.
static getInstance()
Get the singelton instance of this ilECSExportManager.
isActive()
Is ECS (for current object) active?
doUpdate(ilECSSetting $a_server, ilECSExport $a_export_settings, ?array $a_mids=null)
Update ECS resource.
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.
$server
Definition: shib_login.php:28
+ 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.

References ilRbacReview\_getOperationIdsByName(), ilECSSetting\getGlobalRole(), and ILIAS\Repository\logger().

Referenced by doAdd(), and doUpdate().

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.
getGlobalRole()
get global role
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleSettings()

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

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

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

Referenced by handleSettingsUpdate(), and saveSettingsSection().

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  }
isActive()
Is ECS (for current object) active?
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.
handleSettingsForServer(ilECSSetting $a_server, bool $a_export, array $a_mids)
Save ECS settings (add- update- deleteResource)
$server
Definition: shib_login.php:28
+ 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 399 of file class.ilECSObjectSettings.php.

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

Referenced by handleSettings().

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  }
getServerId()
Get current server id.
Storage of an ECS exported object.
doUpdate(ilECSSetting $a_server, ilECSExport $a_export_settings, ?array $a_mids=null)
Update ECS resource.
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.
+ Here is the call graph for this function:
+ Here is the caller 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.

References ilPropertyFormGUI\getInput(), and handleSettings().

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

References ilECSServerSettings\getInstance().

Referenced by ecsCanBeActivatedForObject(), handleContentUpdate(), and handleSettings().

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  }
static getInstance()
Get singleton instance.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveSettingsSection()

ilECSObjectSettings::saveSettingsSection ( array  $section)

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

References handleSettings().

324  : bool
325  {
326  return $this->handleSettings($section['is_exported'], $section['values']);
327  }
handleSettings(bool $ecs_export, array $selected_receivers)
+ Here is the call graph for this function:

◆ sendNewContentNotification()

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

send notifications about new EContent

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

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

Referenced by doAdd().

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(
656  $a_server->getApprovalRecipientsAsString(),
657  '',
658  '',
659  $lang->txt('ecs_new_approval_subject'),
660  $message,
661  array()
662  );
663 
664  return true;
665  }
getServerId()
Get current server id.
getApprovalRecipientsAsString()
get approval recipients as string
Presentation of ecs content details (http://...campusconnect/courselinks/id/details) ...
getECSObjectType()
Get ECS resource identifier, e.g.
static _getAutoGeneratedMessageString(?ilLanguage $lang=null)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
static _getLanguage(string $a_lang_key='')
Get language object.
$lang
Definition: xapiexit.php:25
static getInstanceFromServer(int $a_server_id, int $a_econtent_id, string $a_resource_type)
Get data from server.
$message
Definition: xapiexit.php:31
getApprovalRecipients()
get approval recipients
+ 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 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: