ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilECSObjectSettings Class Reference

Handles object exports to ECS. More...

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

Public Member Functions

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

Static Public Member Functions

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

Data Fields

const MAIL_SENDER = 6
 

Protected Member Functions

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

Protected Attributes

ilObject $content_obj
 

Private Attributes

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

Detailed Description

Handles object exports to ECS.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilECSObjectSettings::__construct ( ilObject  $a_content_object)

Constructor.

Parameters
ilObject$a_content_object

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

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

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

Member Function Documentation

◆ _handleDelete()

static ilECSObjectSettings::_handleDelete ( array  $a_subbtree_nodes)
static

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

See also
ilRepUtil

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

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

Referenced by ilRepUtil\deleteObjects().

414  : void
415  {
416  // active?
417  if (!ilECSServerSettings::getInstance()->activeServerExists()) {
418  return;
419  }
420  $exportManager = ilECSExportManager::getInstance();
421  $exported = $exportManager->getExportedIds();
422  foreach ($a_subbtree_nodes as $node) {
423  if (in_array(
424  $node['obj_id'],
425  $exported,
426  true
427  ) && $content_obj = ilObjectFactory::getInstanceByRefId($node['child'], false)) {
428  $settings = self::getInstanceByObject($content_obj);
429 
430  // Read export server ids
431  foreach ($exportManager->getExportServerIds($node['obj_id']) as $sid) {
433  $export_settings = new ilECSExport($sid, $content_obj->getId());
434  if ($settings) {
435  $settings->doDelete($server, $export_settings);
436  }
437  }
438  }
439  }
440  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
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
+ 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 572 of file class.ilECSObjectSettings.php.

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

572  : void
573  {
575 
576  $values = ilECSUtils::getAdvancedMDValuesForObjId($this->content_obj->getId());
577 
578  foreach ($a_definition as $id => $type) {
579  if (is_array($type)) {
580  [$type , $target] = $type;
581  } else {
582  $target = $id;
583  }
584 
585  if ($field = $mappings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, $id)) {
586  $value = $values[$field] ?? '';
587 
588  switch ($type) {
590  $a_json->{$target} = explode(',', $value);
591  break;
592 
594  $a_json->{$target} = (int) $value;
595  break;
596 
598  $a_json->{$target} = (string) $value;
599  break;
600 
602  if (!isset($a_json->{$target})) {
603  $a_json->{$target} = new ilECSTimePlace();
604  }
605  $a_json->{$target}->{'set' . ucfirst($id)}($value);
606  break;
607  }
608  }
609  }
610  }
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.
$type
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 120 of file class.ilECSObjectSettings.php.

References ILIAS\LTI\ToolProvider\$details, ilPropertyFormGUI\addItem(), getContentObject(), getECSObjectType(), ilECSExportManager\getInstance(), ilECSEContentDetails\getInstanceFromServer(), isActive(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), ilFormPropertyGUI\setRequired(), ilRadioOption\setValue(), and ilCheckboxGroupInputGUI\setValue().

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

321  : void
322  {
323  $this->logger->info(__METHOD__ . ': Starting ECS add resource...');
324 
325  $json = $this->buildJson($a_server);
326 
327  $connector = new ilECSConnector($a_server);
328  $connector->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, implode(',', $a_mids));
329  $econtent_id = $connector->addResource(
330  $this->getECSObjectType(),
331  json_encode($json, JSON_THROW_ON_ERROR)
332  );
333 
334  // status changed
335  $a_export_settings->setExported(true);
336  $a_export_settings->setEContentId($econtent_id);
337  $a_export_settings->save();
338 
339  $this->handlePermissionUpdate($a_server);
340 
341  // Send mail
342  $this->sendNewContentNotification($a_server, $econtent_id);
343  }
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 385 of file class.ilECSObjectSettings.php.

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

Referenced by handleSettingsForServer().

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

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

◆ getContentObject()

ilECSObjectSettings::getContentObject ( )

Get content object.

Returns
ilObject

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

References $content_obj, and getECSObjectType().

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

89  : \ilObject
90  {
91  return $this->content_obj;
92  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ 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(), 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 58 of file class.ilECSObjectSettings.php.

References ilObject\getType().

59  {
60  switch ($a_content_obj->getType()) {
61  case 'crs':
62  return new ilECSCourseSettings($a_content_obj);
63 
64  case 'cat':
65  return new ilECSCategorySettings($a_content_obj);
66 
67  case 'file':
68  return new ilECSFileSettings($a_content_obj);
69 
70  case 'glo':
71  return new ilECSGlossarySettings($a_content_obj);
72 
73  case 'grp':
74  return new ilECSGroupSettings($a_content_obj);
75 
76  case 'lm':
77  return new ilECSLearningModuleSettings($a_content_obj);
78 
79  case 'wiki':
80  return new ilECSWikiSettings($a_content_obj);
81  }
82  return null;
83  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getJsonCore()

ilECSObjectSettings::getJsonCore ( string  $a_etype)
protected

Build core json structure.

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

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

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

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

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

Referenced by doUpdate().

445  : array
446  {
447  $receivers = array();
448  foreach ((array) $a_server_id as $sid) {
449  $participants = null;
451  if ($details instanceof ilECSEContentDetails) {
452  $participants = $details->getReceivers();
453  }
454  if ($participants) {
455  foreach ($participants as $mid) {
456  $receivers[] = $mid;
457  }
458  }
459  }
460  return $receivers;
461  }
Presentation of ecs content details (http://...campusconnect/courselinks/id/details) ...
getECSObjectType()
Get ECS resource identifier, e.g.
array $details
Details for error message relating to last request processed.
Definition: System.php:109
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 292 of file class.ilECSObjectSettings.php.

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

292  : bool
293  {
294  if (!$this->isActive()) {
295  return true;
296  }
297  $exportManager = ilECSExportManager::getInstance();
298  $export_servers = $exportManager->getExportServerIds($this->content_obj->getId());
299  foreach ($export_servers as $server_id) {
301  if ($server->isEnabled()) {
302  try {
303  $export_settings = new ilECSExport($server_id, $this->content_obj->getId());
304 
305  // already exported, update ecs
306  if ($export_settings->isExported()) {
307  $this->doUpdate($server, $export_settings);
308  }
309  } catch (ilECSConnectorException $exc) {
310  $this->logger->warning(__METHOD__ . ': Cannot handle ECS content update. ' . $exc->getMessage());
311  return false;
312  }
313  }
314  }
315  return true;
316  }
Storage of an ECS exported object.
static getInstance()
Get the singelton instance of this ilECSExportManager.
doUpdate(ilECSSetting $a_server, ilECSExport $a_export_settings, array $a_mids=null)
Update ECS resource.
isActive()
Is ECS (for current object) active?
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.
$server
+ Here is the call graph for this function:

◆ handlePermissionUpdate()

ilECSObjectSettings::handlePermissionUpdate ( ilECSSetting  $server)
protected

Handle permission update.

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

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

Referenced by doAdd(), and doUpdate().

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

◆ handleSettingsForServer()

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

Save ECS settings (add- update- deleteResource)

Parameters
arrayarray of participant mids
Exceptions
ilECSConnectorException

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

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

Referenced by handleSettingsUpdate().

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

Update ECS Export Settings.

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

Returns
bool

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

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

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

◆ isActive()

ilECSObjectSettings::isActive ( )
protected

Is ECS (for current object) active?

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

References ilECSServerSettings\getInstance().

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

102  : bool
103  {
104  if (ilECSServerSettings::getInstance()->activeServerExists()) {
105  // imported objects cannot be exported => why not
106  #if(!ilECSImportManager::getInstance()->lookupServerId($this->content_obj->getId()))
107  {
108  return true;
109  }
110  }
111 
112  return false;
113  }
static getInstance()
Get singleton instance.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendNewContentNotification()

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

send notifications about new EContent

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

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

Referenced by doAdd().

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

Referenced by getContentObject().

◆ $lng

ilLanguage ilECSObjectSettings::$lng
private

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

◆ $logger

ilLogger ilECSObjectSettings::$logger
private

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

◆ $main_tpl

ilGlobalTemplateInterface ilECSObjectSettings::$main_tpl
private

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

◆ $rbacAdmin

ilRbacAdmin ilECSObjectSettings::$rbacAdmin
private

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

◆ $tree

ilTree ilECSObjectSettings::$tree
private

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

◆ MAIL_SENDER

const ilECSObjectSettings::MAIL_SENDER = 6

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


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