ILIAS  release_7 Revision v7.30-3-g800a261c036
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, $a_export, $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 ($a_server_id, $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 ($a_etype)
 Build core json structure. More...
 
 addMetadataToJson (&$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

 $content_obj
 

Private Attributes

 $logger = null
 

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
Id
class.ilObjCourseGUI.php 31646 2011-11-14 11:39:37Z jluetzen

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

Constructor & Destructor Documentation

◆ __construct()

ilECSObjectSettings::__construct ( ilObject  $a_content_object)

Constructor.

Parameters
ilObject$a_content_object

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

References $GLOBALS.

33  {
34  $this->logger = $GLOBALS['DIC']->logger()->obj();
35  $this->content_obj = $a_content_object;
36  }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64

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
Parameters
array$a_subbtree_nodes

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

References $content_obj, $server, ilECSExport\getExportedIds(), ilECSExport\getExportServerIds(), ilECSServerSettings\getInstance(), ilObjectFactory\getInstanceByRefId(), and ilECSSetting\getInstanceByServerId().

Referenced by ilRepUtil\deleteObjects().

476  {
477  // active?
478  include_once './Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
479  if (!ilECSServerSettings::getInstance()->activeServerExists()) {
480  return;
481  }
482 
483  include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
484  include_once './Services/WebServices/ECS/classes/class.ilECSExport.php' ;
485  $exported = ilECSExport::getExportedIds();
486  foreach ($a_subbtree_nodes as $node) {
487  if (in_array($node['obj_id'], $exported)) {
488  if ($content_obj = ilObjectFactory::getInstanceByRefId($node['child'], false)) {
489  $settings = self::getInstanceByObject($content_obj);
490 
491  // Read export server ids
492  foreach (ilECSExport::getExportServerIds($node['obj_id']) as $sid) {
494  $export_settings = new ilECSExport($sid, $content_obj->getId());
495  $settings->doDelete($server, $export_settings);
496  }
497  }
498  }
499  }
500  }
static getInstanceByServerId($a_server_id)
Get singleton instance per server.
Storage of ECS exported objects.
static getInstance()
Get singleton instance.
static getExportedIds()
Get exported ids ilDB $ilDB.
static getExportServerIds($a_obj_id)
lookup server ids of exported materials ilDB $ilDB
$server
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addMetadataToJson()

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

Add advanced metadata to json (export)

Parameters
object$a_json
ilECSSetting$a_server
array$a_definition

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

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

Referenced by ilECSCourseSettings\buildJson().

659  {
660  include_once('./Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php');
661  include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
662  include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
664 
665  include_once "Services/WebServices/ECS/classes/class.ilECSUtils.php";
666  $values = ilECSUtils::getAdvancedMDValuesForObjId($this->content_obj->getId());
667 
668  foreach ($a_definition as $id => $type) {
669  if (is_array($type)) {
670  $target = $type[1];
671  $type = $type[0];
672  } else {
673  $target = $id;
674  }
675 
676  if ($field = $mappings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, $id)) {
677  $value = isset($values[$field]) ? $values[$field] : '';
678 
679  switch ($type) {
681  $a_json->$target = explode(',', $value);
682  break;
683 
685  $a_json->$target = (int) $value;
686  break;
687 
689  $a_json->$target = (string) $value;
690  break;
691 
693  if (!isset($a_json->$target)) {
694  include_once('./Services/WebServices/ECS/classes/class.ilECSTimePlace.php');
695  $a_json->$target = new ilECSTimePlace();
696  }
697  $a_json->$target->{'set' . ucfirst($id)}($value);
698  break;
699  }
700  }
701  }
702  }
static getInstanceByServerId($a_server_id)
Get singleton instance.
Representation of ECS EContent Time Place.
$type
getServerId()
Get current server id.
const TYPE_TIMEPLACE
static getAdvancedMDValuesForObjId($a_obj_id)
Get advanced metadata values for object id.
+ 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()

Parameters
ilPropertyFormGUI$a_form

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

References $DIC, $GLOBALS, $lng, ilECSExport\_isExported(), ilPropertyFormGUI\addItem(), getContentObject(), getECSObjectType(), ilECSParticipantSettings\getExportableParticipants(), ilECSExport\getExportServerIds(), ilECSEContentDetails\getInstance(), isActive(), ilFormPropertyGUI\setRequired(), ilCheckboxInputGUI\setValue(), and ilCheckboxGroupInputGUI\setValue().

120  {
121  global $DIC;
122 
123  $lng = $DIC['lng'];
124 
125  $this->logger->debug('Show ecs settings.');
126  if (!$this->isActive($a_type)) {
127  $this->logger->debug('Object type is not active. => no settings.');
128  return;
129  }
130 
131  $obj_id = $this->content_obj->getId();
132 
133  // Return if no participant is enabled for export and the current object is not released
134  include_once './Services/WebServices/ECS/classes/class.ilECSExport.php';
135  include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSettings.php';
136 
137  if (!$this->getContentObject()->withReferences()) {
138  $this->logger->debug('Called withot references. => no settings.');
139  return true;
140  }
141 
142  $exportablePart = ilECSParticipantSettings::getExportableParticipants($a_type);
143  if (!$exportablePart and !ilECSExport::_isExported($obj_id)) {
144  $this->logger->debug('Object type is not exportable. => no settings.');
145  return true;
146  }
147  if (
148  $GLOBALS['DIC']['tree']->checkForParentType($GLOBALS['DIC']['tree']->getParentId($this->getContentObject()->getRefId()), 'crs', false) or
149  $GLOBALS['DIC']['tree']->checkForParentType($GLOBALS['DIC']['tree']->getParentId($this->getContentObject()->getRefId()), 'grp', false)
150  ) {
151  $this->logger->debug('Parent crs/grp in path. => no settings.');
152  return true;
153  }
154 
155  $lng->loadLanguageModule('ecs');
156 
157  // show ecs property form section
158  $ecs = new ilFormSectionHeaderGUI();
159  $ecs->setTitle($lng->txt('ecs_' . $a_type . '_export'));
160  $a_form->addItem($ecs);
161 
162 
163  // release or not
164  $exp = new ilRadioGroupInputGUI($lng->txt('ecs_' . $a_type . '_export_obj_settings'), 'ecs_export');
165  $exp->setRequired(true);
166  $exp->setValue(ilECSExport::_isExported($obj_id) ? 1 : 0);
167  $off = new ilRadioOption($lng->txt('ecs_' . $a_type . '_export_disabled'), 0);
168  $exp->addOption($off);
169  $on = new ilRadioOption($lng->txt('ecs_' . $a_type . '_export_enabled'), 1);
170  $exp->addOption($on);
171  $a_form->addItem($exp);
172 
173  // Show all exportable participants
174  $publish_for = new ilCheckboxGroupInputGUI($lng->txt('ecs_publish_for'), 'ecs_sid');
175 
176  // @TODO: Active checkboxes for recipients
177  //$publish_for->setValue((array) $members);
178 
179  // Read receivers
180  $receivers = array();
181  include_once('./Services/WebServices/ECS/classes/class.ilECSEContentDetails.php');
182  foreach (ilECSExport::getExportServerIds($obj_id) as $sid) {
183  $exp = new ilECSExport($sid, $obj_id);
184 
185  $participants = null;
187  $sid,
188  $exp->getEContentId(),
189  $this->getECSObjectType()
190  );
191  if ($details instanceof ilECSEContentDetails) {
192  $participants = $details->getReceivers();
193  }
194  if ($participants) {
195  foreach ($participants as $mid) {
196  $receivers[] = $sid . '_' . $mid;
197  }
198  }
199  }
200  $publish_for->setValue($receivers);
201 
202  foreach ($exportablePart as $pInfo) {
203  include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
204  $partSetting = new ilECSParticipantSetting($pInfo['sid'], $pInfo['mid']);
205 
206  $com = new ilCheckboxInputGUI(
207  $partSetting->getCommunityName() . ': ' . $partSetting->getTitle(),
208  'sid_mid'
209  );
210  $com->setValue($pInfo['sid'] . '_' . $pInfo['mid']);
211  $publish_for->addOption($com);
212  }
213  $on->addSubItem($publish_for);
214  return true;
215  }
This class represents an option in a radio group.
static getExportableParticipants($a_type)
Get participants which are enabled and export is allowed.
Storage of ECS exported objects.
This class represents a section header in a property form.
isActive()
Is ECS (for current object) active?
This class represents a checkbox property in a property form.
addItem($a_item)
Add Item (Property, SectionHeader).
Presentation of ecs content details (http://...campusconnect/courselinks/id/details) ...
getECSObjectType()
Get ECS resource identifier, e.g.
getContentObject()
Get content object.
static getExportServerIds($a_obj_id)
lookup server ids of exported materials ilDB $ilDB
This class represents a property in a property form.
$lng
setValue($a_value)
Set Value.
global $DIC
Definition: goto.php:24
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
This class represents a property in a property form.
static _isExported($a_obj_id)
Check if object is exported.
withReferences()
determines wether objects are referenced or not (got ref ids or not)
static getInstance($a_server_id, $a_econtent_id, $a_resource_type)
Get data from server.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:

◆ buildJson()

ilECSObjectSettings::buildJson ( ilECSSetting  $a_server)
abstractprotected

Build resource-specific json.

Parameters
ilECSSetting$a_server
Returns
object

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.

Parameters
ilECSSetting$a_server
ilECSExport$a_export_settings
array$a_mids

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

References $DIC, buildJson(), getECSObjectType(), handlePermissionUpdate(), ilECSConnector\HEADER_MEMBERSHIPS, ilECSExport\save(), sendNewContentNotification(), ilECSExport\setEContentId(), and ilECSExport\setExported().

Referenced by handleSettingsForServer().

363  {
364  global $DIC;
365 
366  $ilLog = $DIC['ilLog'];
367 
368  $ilLog->write(__METHOD__ . ': Starting ECS add resource...');
369 
370  $json = $this->buildJson($a_server);
371 
372  include_once 'Services/WebServices/ECS/classes/class.ilECSConnector.php';
373  $connector = new ilECSConnector($a_server);
374  $connector->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, implode(',', $a_mids));
375  $econtent_id = $connector->addResource(
376  $this->getECSObjectType(),
377  json_encode($json)
378  );
379 
380  // status changed
381  $a_export_settings->setExported(true);
382  $a_export_settings->setEContentId($econtent_id);
383  $a_export_settings->save();
384 
385  $this->handlePermissionUpdate($a_server, true);
386 
387  // Send mail
388  $this->sendNewContentNotification($a_server, $econtent_id);
389  }
setExported($a_status)
Set exported.
getECSObjectType()
Get ECS resource identifier, e.g.
sendNewContentNotification(ilECSSetting $a_server, $a_econtent_id)
send notifications about new EContent
global $DIC
Definition: goto.php:24
handlePermissionUpdate(ilECSSetting $server)
Handle permission update.
buildJson(ilECSSetting $a_server)
Build resource-specific json.
setEContentId($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...

Parameters
type$a_server_id
Exceptions
ilECSConnectorException

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

References $DIC, ilECSExport\getEContentId(), getECSObjectType(), ilECSExport\isExported(), ilECSExport\save(), and ilECSExport\setExported().

Referenced by handleSettingsForServer().

439  {
440  global $DIC;
441 
442  $ilLog = $DIC['ilLog'];
443 
444  // already exported?
445  if ($a_export_settings->isExported()) {
446  include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
447  include_once './Services/WebServices/ECS/classes/class.ilECSConnector.php';
448 
449  $econtent_id = $a_export_settings->getEContentId();
450  if (!$econtent_id) {
451  $ilLog->write(__METHOD__ . ': Missing eid. Aborting.');
452  throw new ilECSConnectorException('Missing ECS content ID. Aborting.');
453  }
454  $connector = new ilECSConnector($a_server);
455 
456  $ilLog->write(__METHOD__ . ': Start deleting ECS content...');
457  $connector->deleteResource(
458  $this->getECSObjectType(),
459  $econtent_id
460  );
461 
462  // status changed
463  $a_export_settings->setExported(false);
464  $a_export_settings->save();
465  }
466  }
setExported($a_status)
Set exported.
getECSObjectType()
Get ECS resource identifier, e.g.
isExported()
check if an object is exported or not
getEContentId()
get econtent id
global $DIC
Definition: goto.php:24
+ 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 399 of file class.ilECSObjectSettings.php.

References $DIC, buildJson(), ilECSExport\getEContentId(), getECSObjectType(), getParticipants(), ilECSSetting\getServerId(), handlePermissionUpdate(), and ilECSConnector\HEADER_MEMBERSHIPS.

Referenced by handleContentUpdate(), and handleSettingsForServer().

400  {
401  global $DIC;
402 
403  $ilLog = $DIC['ilLog'];
404 
405  include_once 'Services/WebServices/ECS/classes/class.ilECSConnector.php';
406 
407  $econtent_id = $a_export_settings->getEContentId();
408  if (!$econtent_id) {
409  $ilLog->write(__METHOD__ . ': Missing eid. Aborting.');
410  throw new ilECSConnectorException('Missing ECS content ID. Aborting.');
411  }
412  $connector = new ilECSConnector($a_server);
413 
414  if (!$a_mids) {
415  $a_mids = $this->getParticipants($a_server->getServerId(), $econtent_id);
416  }
417  $ilLog->write(__METHOD__ . ': Start updating ECS content - ' . print_r($a_mids, true));
418  $connector->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, implode(',', (array) $a_mids));
419 
420  $json = $this->buildJson($a_server);
421  $connector->updateResource(
422  $this->getECSObjectType(),
423  $econtent_id,
424  json_encode($json)
425  );
426 
427  $this->handlePermissionUpdate($a_server, true);
428  }
getParticipants($a_server_id, $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
global $DIC
Definition: goto.php:24
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 80 of file class.ilECSObjectSettings.php.

References $content_obj, and getECSObjectType().

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

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

Returns
string

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.

Parameters
ilObject$a_content_obj
Returns
ilECSObjectSettings

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

References ilObject\getType().

45  {
46  switch ($a_content_obj->getType()) {
47  case 'crs':
48  include_once 'Modules/Course/classes/class.ilECSCourseSettings.php';
49  return new ilECSCourseSettings($a_content_obj);
50 
51  case 'cat':
52  include_once 'Modules/Category/classes/class.ilECSCategorySettings.php';
53  return new ilECSCategorySettings($a_content_obj);
54 
55  case 'file':
56  include_once 'Modules/File/classes/class.ilECSFileSettings.php';
57  return new ilECSFileSettings($a_content_obj);
58 
59  case 'glo':
60  return new ilECSGlossarySettings($a_content_obj);
61 
62  case 'grp':
63  include_once 'Modules/Group/classes/class.ilECSGroupSettings.php';
64  return new ilECSGroupSettings($a_content_obj);
65 
66  case 'lm':
67  include_once 'Modules/LearningModule/classes/class.ilECSLearningModuleSettings.php';
68  return new ilECSLearningModuleSettings($a_content_obj);
69 
70  case 'wiki':
71  include_once 'Modules/Wiki/classes/class.ilECSWikiSettings.php';
72  return new ilECSWikiSettings($a_content_obj);
73  }
74  }
Class ilECSFileSettings.
Class ilECSLearningModuleSettings.
Class ilECSWikiSettings.
Class ilECSGroupSettings.
getType()
get object type public
Class ilECSCategorySettings.
Class ilECSGlossarySettings.
Class ilECSCourseSettings.
+ Here is the call graph for this function:

◆ getJsonCore()

ilECSObjectSettings::getJsonCore (   $a_etype)
protected

Build core json structure.

Parameters
string$a_etype
Returns
object

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

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

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

637  {
638  $json = new stdClass();
639  $json->lang = 'en_EN'; // :TODO: obsolet?
640  $json->id = 'il_' . IL_INST_ID . '_' . $this->getContentObject()->getType() . '_' . $this->getContentObject()->getId();
641  $json->etype = $a_etype;
642  $json->title = $this->content_obj->getTitle();
643  $json->abstract = $this->content_obj->getLongDescription();
644 
645  include_once('./Services/Link/classes/class.ilLink.php');
646  $json->url = ilLink::_getLink($this->content_obj->getRefId(), $this->content_obj->getType());
647 
648  return $json;
649  }
const IL_INST_ID
Definition: constants.php:38
getContentObject()
Get content object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParticipants()

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

Get participants for server and ecs resource.

Parameters
int$a_server_id
int$a_econtent_id
Returns
array

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

References getECSObjectType(), and ilECSEContentDetails\getInstance().

Referenced by doUpdate().

510  {
511  $receivers = array();
512  include_once('./Services/WebServices/ECS/classes/class.ilECSEContentDetails.php');
513  foreach ((array) $a_server_id as $sid) {
514  $participants = null;
515  $details = ilECSEContentDetails::getInstance($sid, $a_econtent_id, $this->getECSObjectType());
516  if ($details instanceof ilECSEContentDetails) {
517  $participants = $details->getReceivers();
518  }
519  if ($participants) {
520  foreach ($participants as $mid) {
521  $receivers[] = $mid;
522  }
523  }
524  }
525  return (array) $receivers;
526  }
Presentation of ecs content details (http://...campusconnect/courselinks/id/details) ...
getECSObjectType()
Get ECS resource identifier, e.g.
static getInstance($a_server_id, $a_econtent_id, $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

Returns
bool

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

References $DIC, $server, doUpdate(), ilECSExport\getExportServerIds(), ilECSSetting\getInstanceByServerId(), and isActive().

320  {
321  global $DIC;
322 
323  $ilLog = $DIC['ilLog'];
324 
325  if (!$this->isActive()) {
326  return true;
327  }
328 
329  include_once './Services/WebServices/ECS/classes/class.ilECSExport.php';
330  $export_servers = ilECSExport::getExportServerIds($this->content_obj->getId());
331  foreach ($export_servers as $server_id) {
332  include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
334  if ($server->isEnabled()) {
335  try {
336  include_once('./Services/WebServices/ECS/classes/class.ilECSExport.php');
337  $export_settings = new ilECSExport($server_id, $this->content_obj->getId());
338 
339  // already exported, update ecs
340  if ($export_settings->isExported()) {
341  $this->doUpdate($server, $export_settings);
342  }
343  // not exported yet, nothing to do
344  else {
345  }
346  } catch (ilECSConnectorException $exc) {
347  $ilLog->write(__METHOD__ . ': Cannot handle ECS content update. ' . $exc->getMessage());
348  return false;
349  }
350  }
351  }
352  return true;
353  }
static getInstanceByServerId($a_server_id)
Get singleton instance per server.
Storage of ECS exported objects.
doUpdate(ilECSSetting $a_server, ilECSExport $a_export_settings, array $a_mids=null)
Update ECS resource.
isActive()
Is ECS (for current object) active?
static getExportServerIds($a_obj_id)
lookup server ids of exported materials ilDB $ilDB
global $DIC
Definition: goto.php:24
$server
+ Here is the call graph for this function:

◆ handlePermissionUpdate()

ilECSObjectSettings::handlePermissionUpdate ( ilECSSetting  $server)
protected

Handle permission update.

Parameters
ilECSSetting$server

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

References $GLOBALS, ilRbacReview\_getOperationIdsByName(), and ilECSSetting\getGlobalRole().

Referenced by doAdd(), and doUpdate().

616  {
617  if (
618  ($this->content_obj->getType() == 'crs') ||
619  ($this->content_obj->getType() == 'grp')
620  ) {
621  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Permission update for courses/groups');
622  $GLOBALS['DIC']['rbacadmin']->grantPermission(
623  $server->getGlobalRole(),
624  ilRbacReview::_getOperationIdsByName(array('join','visible')),
625  $this->content_obj->getRefId()
626  );
627  }
628  }
static _getOperationIdsByName($operations)
get ops_id's by name.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
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,
  $a_export,
  $a_mids 
)
protected

Save ECS settings (add- update- deleteResource)

Parameters
ilECSSetting$a_server
bool$a_export
arrayarray of participant mids
Exceptions
ilECSConnectorException

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

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

Referenced by handleSettingsUpdate().

281  {
282  try {
283  include_once('./Services/WebServices/ECS/classes/class.ilECSExport.php');
284  $export_settings = new ilECSExport($a_server->getServerId(), $this->content_obj->getId());
285 
286  // already exported?
287  if ($export_settings->isExported()) {
288  // still exportable: update ecs
289  if ((bool) $a_export) {
290  $this->doUpdate($a_server, $export_settings, $a_mids);
291  }
292  // not exportable anymore
293  else {
294  $this->doDelete($a_server, $export_settings);
295  }
296  }
297  // not exported yet
298  else {
299  // now to be exported
300  if ($a_export) {
301  $this->doAdd($a_server, $export_settings, $a_mids);
302  }
303  // was not and will not be exported
304  else {
305  }
306  }
307  } catch (ilECSConnectorException $exc) {
308  throw $exc;
309  }
310  }
getServerId()
Get current server id.
Storage of ECS exported objects.
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 225 of file class.ilECSObjectSettings.php.

References $_POST, $server, ilECSParticipantSettings\getExportServers(), ilECSSetting\getInstanceByServerId(), handleSettingsForServer(), isActive(), and ilUtil\sendFailure().

226  {
227  if (!$this->isActive()) {
228  return true;
229  }
230 
231  // Parse post data
232  $mids = array();
233  foreach ((array) $_POST['ecs_sid'] as $sid_mid) {
234  $tmp = explode('_', $sid_mid);
235  $mids[$tmp[0]][] = $tmp[1];
236  }
237 
238  try {
239  include_once './Services/WebServices/ECS/classes/class.ilECSCommunitiesCache.php';
240  include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSettings.php';
241  include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
242 
243  // Update for each server
244  foreach (ilECSParticipantSettings::getExportServers() as $server_id) {
246  if ($server->isEnabled()) {
247  // Export
248  $export = true;
249  if (!$_POST['ecs_export']) {
250  $export = false;
251  }
252  if (
253  !isset($mids[$server_id]) ||
254  !is_array($mids[$server_id]) ||
255  !count($mids[$server_id])) {
256  $export = false;
257  }
259  $server,
260  $export,
261  isset($mids[$server_id]) ? $mids[$server_id] : []
262  );
263  }
264  }
265  } catch (ilECSConnectorException $exc) {
266  ilUtil::sendFailure('Error exporting to ECS server: ' . $exc->getMessage());
267  return false;
268  }
269  return true;
270  }
static getInstanceByServerId($a_server_id)
Get singleton instance per server.
isActive()
Is ECS (for current object) active?
handleSettingsForServer(ilECSSetting $a_server, $a_export, $a_mids)
Save ECS settings (add- update- deleteResource)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$server
$_POST["username"]
static getExportServers()
Get server ids which allow an export <type> $ilDB.
+ Here is the call graph for this function:

◆ isActive()

ilECSObjectSettings::isActive ( )
protected

Is ECS (for current object) active?

Returns
boolean

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

References ilECSServerSettings\getInstance().

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

98  {
99  include_once('./Services/WebServices/ECS/classes/class.ilECSServerSettings.php');
100  if (ilECSServerSettings::getInstance()->activeServerExists()) {
101  // imported objects cannot be exported => why not
102  #include_once('./Services/WebServices/ECS/classes/class.ilECSImport.php');
103  #if(!ilECSImport::lookupServerId($this->content_obj->getId()))
104  {
105  return true;
106  }
107  }
108 
109  return false;
110  }
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

Returns
bool

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

References $DIC, Vendor\Package\$e, $lang, $message, ilMail\_getAutoGeneratedMessageString(), ilLanguageFactory\_getLanguage(), ilLink\_getStaticLink(), ilECSSetting\getApprovalRecipients(), ilECSSetting\getApprovalRecipientsAsString(), getECSObjectType(), ilECSEContentDetails\getInstance(), ilECSCommunityReader\getInstanceByServerId(), and ilECSSetting\getServerId().

Referenced by doAdd().

534  {
535  global $DIC;
536 
537  $ilLog = $DIC['ilLog'];
538 
539  if (!count($rcps = $a_server->getApprovalRecipients())) {
540  return true;
541  }
542 
543  include_once('./Services/Mail/classes/class.ilMail.php');
544  include_once('./Services/Language/classes/class.ilLanguageFactory.php');
545 
547  $lang->loadLanguageModule('ecs');
548 
549  // @TODO: read mail
550  $mail = new ilMail(self::MAIL_SENDER);
551  $message = $lang->txt('ecs_export_created_body_a') . "\n\n";
552  $message .= $lang->txt('title') . ': ' . $this->content_obj->getTitle() . "\n";
553  if (strlen($desc = $this->content_obj->getDescription())) {
554  $message .= $lang->txt('desc') . ': ' . $desc . "\n";
555  }
556 
557  // Participant info
558  $message .= ("\n" . $lang->txt('ecs_published_for'));
559 
560  try {
561  $found = false;
562 
563  $receivers = null;
564  include_once('./Services/WebServices/ECS/classes/class.ilECSEContentDetails.php');
566  $a_server->getServerId(),
567  $a_econtent_id,
568  $this->getECSObjectType()
569  );
570  if ($details instanceof ilECSEContentDetails) {
571  $receivers = $details->getReceivers();
572  }
573  if ($receivers) {
574  foreach ($receivers as $member) {
575  $found = true;
576 
577  include_once './Services/WebServices/ECS/classes/class.ilECSCommunityReader.php';
578  $part = ilECSCommunityReader::getInstanceByServerId($a_server->getServerId())->getParticipantByMID($member);
579 
580  $message .= ("\n\n" . $part->getParticipantName() . "\n");
581  $message .= ($part->getDescription());
582  }
583  }
584  if ($found) {
585  $message .= "\n\n";
586  } else {
587  $message .= (' ' . $lang->txt('ecs_not_published') . "\n\n");
588  }
589  } catch (ilECSConnectorException $e) {
590  $ilLog->write(__METHOD__ . ': Cannot read approvements.');
591  return false;
592  }
593 
594  include_once('./Services/Link/classes/class.ilLink.php');
595  $href = ilLink::_getStaticLink($this->content_obj->getRefId(), 'crs', true);
596  $message .= $lang->txt("perma_link") . ': ' . $href . "\n\n";
598 
599  $mail->enqueue(
600  $a_server->getApprovalRecipientsAsString(),
601  '',
602  '',
603  $lang->txt('ecs_new_approval_subject'),
604  $message,
605  array()
606  );
607 
608  return true;
609  }
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 getInstanceByServerId($a_server_id)
Get instance by server id.
static _getLanguage($a_lang_key='')
Get langauge object.
global $DIC
Definition: goto.php:24
$lang
Definition: xapiexit.php:8
static _getAutoGeneratedMessageString(ilLanguage $lang=null)
Get auto generated info string.
$message
Definition: xapiexit.php:14
getApprovalRecipients()
get approval recipients
static getInstance($a_server_id, $a_econtent_id, $a_resource_type)
Get data from server.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $content_obj

ilECSObjectSettings::$content_obj
protected

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

Referenced by _handleDelete(), and getContentObject().

◆ $logger

ilECSObjectSettings::$logger = null
private

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

◆ MAIL_SENDER

const ilECSObjectSettings::MAIL_SENDER = 6

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


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