ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

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

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

Referenced by ilRepUtil\deleteObjects().

497  {
498  // active?
499  include_once './Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
500  if(!ilECSServerSettings::getInstance()->activeServerExists())
501  {
502  return;
503  }
504 
505  include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
506  include_once './Services/WebServices/ECS/classes/class.ilECSExport.php' ;
507  $exported = ilECSExport::getExportedIds();
508  foreach($a_subbtree_nodes as $node)
509  {
510  if(in_array($node['obj_id'],$exported))
511  {
512  if($content_obj = ilObjectFactory::getInstanceByRefId($node['child'],false))
513  {
514  $settings = self::getInstanceByObject($content_obj);
515 
516  // Read export server ids
517  foreach(ilECSExport::getExportServerIds($node['obj_id']) as $sid)
518  {
520  $export_settings = new ilECSExport($sid, $content_obj->getId());
521  $settings->doDelete($server, $export_settings);
522  }
523  }
524  }
525  }
526  }
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 691 of file class.ilECSObjectSettings.php.

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

Referenced by ilECSCourseSettings\buildJson().

692  {
693  include_once('./Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php');
694  include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
695  include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
697 
698  include_once "Services/WebServices/ECS/classes/class.ilECSUtils.php";
699  $values = ilECSUtils::getAdvancedMDValuesForObjId($this->content_obj->getId());
700 
701  foreach($a_definition as $id => $type)
702  {
703  if(is_array($type))
704  {
705  $target = $type[1];
706  $type = $type[0];
707  }
708  else
709  {
710  $target = $id;
711  }
712 
713  if($field = $mappings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, $id))
714  {
715  $value = isset($values[$field]) ? $values[$field] : '';
716 
717  switch($type)
718  {
720  $a_json->$target = explode(',', $value);
721  break;
722 
724  $a_json->$target = (int)$value;
725  break;
726 
728  $a_json->$target = (string)$value;
729  break;
730 
732  if(!isset($a_json->$target))
733  {
734  include_once('./Services/WebServices/ECS/classes/class.ilECSTimePlace.php');
735  $a_json->$target = new ilECSTimePlace();
736  }
737  $a_json->$target->{'set'.ucfirst($id)}($value);
738  break;
739  }
740  }
741  }
742  }
static getInstanceByServerId($a_server_id)
Get singleton instance.
Representation of ECS EContent Time Place.
getServerId()
Get current server id.
Add rich text string
The name of the decorator.
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 122 of file class.ilECSObjectSettings.php.

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

123  {
124  global $lng;
125 
126  $this->logger->debug('Show ecs settings.');
127  if(!$this->isActive($a_type))
128  {
129  $this->logger->debug('Object type is not active. => no settings.');
130  return;
131  }
132 
133  $obj_id = $this->content_obj->getId();
134 
135  // Return if no participant is enabled for export and the current object is not released
136  include_once './Services/WebServices/ECS/classes/class.ilECSExport.php';
137  include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSettings.php';
138 
139  if(!$this->getContentObject()->withReferences())
140  {
141  $this->logger->debug('Called withot references. => no settings.');
142  return TRUE;
143  }
144 
146  if(!$exportablePart and !ilECSExport::_isExported($obj_id))
147  {
148  $this->logger->debug('Object type is not exportable. => no settings.');
149  return true;
150  }
151  if(
152  $GLOBALS['tree']->checkForParentType($GLOBALS['tree']->getParentId($this->getContentObject()->getRefId()),'crs',false) or
153  $GLOBALS['tree']->checkForParentType($GLOBALS['tree']->getParentId($this->getContentObject()->getRefId()),'grp',false)
154  )
155  {
156  $this->logger->debug('Parent crs/grp in path. => no settings.');
157  return true;
158  }
159 
160  $lng->loadLanguageModule('ecs');
161 
162  // show ecs property form section
163  $ecs = new ilFormSectionHeaderGUI();
164  $ecs->setTitle($lng->txt('ecs_'.$a_type.'_export'));
165  $a_form->addItem($ecs);
166 
167 
168  // release or not
169  $exp = new ilRadioGroupInputGUI($lng->txt('ecs_'.$a_type.'_export_obj_settings'),'ecs_export');
170  $exp->setRequired(true);
171  $exp->setValue(ilECSExport::_isExported($obj_id) ? 1 : 0);
172  $off = new ilRadioOption($lng->txt('ecs_'.$a_type.'_export_disabled'),0);
173  $exp->addOption($off);
174  $on = new ilRadioOption($lng->txt('ecs_'.$a_type.'_export_enabled'),1);
175  $exp->addOption($on);
176  $a_form->addItem($exp);
177 
178  // Show all exportable participants
179  $publish_for = new ilCheckboxGroupInputGUI($lng->txt('ecs_publish_for'),'ecs_sid');
180 
181  // @TODO: Active checkboxes for recipients
182  //$publish_for->setValue((array) $members);
183 
184  // Read receivers
185  $receivers = array();
186  include_once('./Services/WebServices/ECS/classes/class.ilECSEContentDetails.php');
187  foreach(ilECSExport::getExportServerIds($obj_id) as $sid)
188  {
189  $exp = new ilECSExport($sid, $obj_id);
190 
191  $participants = null;
192  $details = ilECSEContentDetails::getInstance($sid, $exp->getEContentId(),
193  $this->getECSObjectType());
194  if($details instanceof ilECSEContentDetails)
195  {
196  $participants = $details->getReceivers();
197  }
198  if($participants)
199  {
200  foreach($participants as $mid)
201  {
202  $receivers[] = $sid.'_'.$mid;
203  }
204  }
205  }
206  $publish_for->setValue($receivers);
207 
208  foreach($exportablePart as $pInfo)
209  {
210  include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
211  $partSetting = new ilECSParticipantSetting($pInfo['sid'], $pInfo['mid']);
212 
213  $com = new ilCheckboxInputGUI(
214  $partSetting->getCommunityName().': '.$partSetting->getTitle(),
215  'sid_mid'
216  );
217  $com->setValue($pInfo['sid'].'_'.$pInfo['mid']);
218  $publish_for->addOption($com);
219  }
220  $on->addSubItem($publish_for);
221  return true;
222  }
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?
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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.
$a_type
Definition: workflow.php:93
static getExportServerIds($a_obj_id)
lookup server ids of exported materials ilDB $ilDB
This class represents a property in a property form.
setValue($a_value)
Set Value.
This class represents a property in a property form.
static _isExported($a_obj_id)
Check if object is exported.
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
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 392 of file class.ilECSObjectSettings.php.

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

Referenced by handleSettingsForServer().

393  {
394  global $ilLog;
395 
396  $ilLog->write(__METHOD__.': Starting ECS add resource...');
397 
398  $json = $this->buildJson($a_server);
399 
400  include_once 'Services/WebServices/ECS/classes/class.ilECSConnector.php';
401  $connector = new ilECSConnector($a_server);
402  $connector->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, implode(',',$a_mids));
403  $econtent_id = $connector->addResource($this->getECSObjectType(),
404  json_encode($json));
405 
406  // status changed
407  $a_export_settings->setExported(true);
408  $a_export_settings->setEContentId($econtent_id);
409  $a_export_settings->save();
410 
411  $this->handlePermissionUpdate($a_server,true);
412 
413  // Send mail
414  $this->sendNewContentNotification($a_server, $econtent_id);
415  }
setExported($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($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 461 of file class.ilECSObjectSettings.php.

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

Referenced by handleSettingsForServer().

462  {
463  global $ilLog;
464 
465  // already exported?
466  if($a_export_settings->isExported())
467  {
468  include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
469  include_once './Services/WebServices/ECS/classes/class.ilECSConnector.php';
470 
471  $econtent_id = $a_export_settings->getEContentId();
472  if(!$econtent_id)
473  {
474  $ilLog->write(__METHOD__.': Missing eid. Aborting.');
475  throw new ilECSConnectorException('Missing ECS content ID. Aborting.');
476  }
477  $connector = new ilECSConnector($a_server);
478 
479  $ilLog->write(__METHOD__.': Start deleting ECS content...');
480  $connector->deleteResource($this->getECSObjectType(),
481  $econtent_id);
482 
483  // status changed
484  $a_export_settings->setExported(false);
485  $a_export_settings->save();
486  }
487  }
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
+ 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 425 of file class.ilECSObjectSettings.php.

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

Referenced by handleContentUpdate(), and handleSettingsForServer().

426  {
427  global $ilLog;
428 
429  include_once 'Services/WebServices/ECS/classes/class.ilECSConnector.php';
430 
431  $econtent_id = $a_export_settings->getEContentId();
432  if(!$econtent_id)
433  {
434  $ilLog->write(__METHOD__.': Missing eid. Aborting.');
435  throw new ilECSConnectorException('Missing ECS content ID. Aborting.');
436  }
437  $connector = new ilECSConnector($a_server);
438 
439  if(!$a_mids)
440  {
441  $a_mids = $this->getParticipants($a_server->getServerId(), $econtent_id);
442  }
443  $ilLog->write(__METHOD__.': Start updating ECS content - '.print_r($a_mids,true));
444  $connector->addHeader(ilECSConnector::HEADER_MEMBERSHIPS,implode(',',(array) $a_mids));
445 
446  $json = $this->buildJson($a_server);
447  $connector->updateResource($this->getECSObjectType(),
448  $econtent_id, json_encode($json));
449 
450  $this->handlePermissionUpdate($a_server,true);
451  }
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
handlePermissionUpdate(ilECSSetting $server)
Handle permission update.
buildJson(ilECSSetting $a_server)
Build resource-specific json.
Create styles array
The data for the language used.
+ 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 82 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  {
48  case 'crs':
49  include_once 'Modules/Course/classes/class.ilECSCourseSettings.php';
50  return new ilECSCourseSettings($a_content_obj);
51 
52  case 'cat':
53  include_once 'Modules/Category/classes/class.ilECSCategorySettings.php';
54  return new ilECSCategorySettings($a_content_obj);
55 
56  case 'file':
57  include_once 'Modules/File/classes/class.ilECSFileSettings.php';
58  return new ilECSFileSettings($a_content_obj);
59 
60  case 'glo':
61  include_once 'Modules/Glossary/classes/class.ilECSGlossarySettings.php';
62  return new ilECSGlossarySettings($a_content_obj);
63 
64  case 'grp':
65  include_once 'Modules/Group/classes/class.ilECSGroupSettings.php';
66  return new ilECSGroupSettings($a_content_obj);
67 
68  case 'lm':
69  include_once 'Modules/LearningModule/classes/class.ilECSLearningModuleSettings.php';
70  return new ilECSLearningModuleSettings($a_content_obj);
71 
72  case 'wiki':
73  include_once 'Modules/Wiki/classes/class.ilECSWikiSettings.php';
74  return new ilECSWikiSettings($a_content_obj);
75  }
76  }
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 669 of file class.ilECSObjectSettings.php.

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

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

670  {
671  $json = new stdClass();
672  $json->lang = 'en_EN'; // :TODO: obsolet?
673  $json->id = 'il_'.IL_INST_ID.'_'.$this->getContentObject()->getType().'_'.$this->getContentObject()->getId();
674  $json->etype = $a_etype;
675  $json->title = $this->content_obj->getTitle();
676  $json->abstract = $this->content_obj->getLongDescription();
677 
678  include_once('./Services/Link/classes/class.ilLink.php');
679  $json->url = ilLink::_getLink($this->content_obj->getRefId(),$this->content_obj->getType());
680 
681  return $json;
682  }
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 535 of file class.ilECSObjectSettings.php.

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

Referenced by doUpdate().

536  {
537  $receivers = array();
538  include_once('./Services/WebServices/ECS/classes/class.ilECSEContentDetails.php');
539  foreach((array) $a_server_id as $sid)
540  {
541  $participants = null;
542  $details = ilECSEContentDetails::getInstance($sid, $a_econtent_id,$this->getECSObjectType());
543  if($details instanceof ilECSEContentDetails)
544  {
545  $participants = $details->getReceivers();
546  }
547  if($participants)
548  {
549  foreach($participants as $mid)
550  {
551  $receivers[] = $mid;
552  }
553  }
554  }
555  return (array) $receivers;
556  }
Presentation of ecs content details (http://...campusconnect/courselinks/id/details) ...
getECSObjectType()
Get ECS resource identifier, e.g.
Create styles array
The data for the language used.
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 342 of file class.ilECSObjectSettings.php.

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

343  {
344  global $ilLog;
345 
346  if(!$this->isActive())
347  {
348  return true;
349  }
350 
351  include_once './Services/WebServices/ECS/classes/class.ilECSExport.php';
352  $export_servers = ilECSExport::getExportServerIds($this->content_obj->getId());
353  foreach($export_servers as $server_id)
354  {
355  include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
357  if($server->isEnabled())
358  {
359  try
360  {
361  include_once('./Services/WebServices/ECS/classes/class.ilECSExport.php');
362  $export_settings = new ilECSExport($server_id, $this->content_obj->getId());
363 
364  // already exported, update ecs
365  if($export_settings->isExported())
366  {
367  $this->doUpdate($server, $export_settings);
368  }
369  // not exported yet, nothing to do
370  else
371  {
372 
373  }
374  }
375  catch(ilECSConnectorException $exc)
376  {
377  $ilLog->write(__METHOD__.': Cannot handle ECS content update. '.$exc->getMessage());
378  return false;
379  }
380  }
381  }
382  return true;
383  }
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
$server
+ Here is the call graph for this function:

◆ handlePermissionUpdate()

ilECSObjectSettings::handlePermissionUpdate ( ilECSSetting  $server)
protected

Handle permission update.

Parameters
ilECSSetting$server

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

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

Referenced by doAdd(), and doUpdate().

648  {
649  if(
650  ($this->content_obj->getType() == 'crs') ||
651  ($this->content_obj->getType() == 'grp')
652  )
653  {
654  $GLOBALS['ilLog']->write(__METHOD__.': Permission update for courses/groups');
655  $GLOBALS['rbacadmin']->grantPermission(
656  $server->getGlobalRole(),
657  ilRbacReview::_getOperationIdsByName(array('join','visible')),
658  $this->content_obj->getRefId()
659  );
660  }
661  }
static _getOperationIdsByName($operations)
get ops_id's by name.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Create styles array
The data for the language used.
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 293 of file class.ilECSObjectSettings.php.

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

Referenced by handleSettingsUpdate().

294  {
295  try
296  {
297  include_once('./Services/WebServices/ECS/classes/class.ilECSExport.php');
298  $export_settings = new ilECSExport($a_server->getServerId(), $this->content_obj->getId());
299 
300  // already exported?
301  if($export_settings->isExported())
302  {
303  // still exportable: update ecs
304  if((bool)$a_export)
305  {
306  $this->doUpdate($a_server, $export_settings, $a_mids);
307  }
308  // not exportable anymore
309  else
310  {
311  $this->doDelete($a_server, $export_settings);
312  }
313  }
314  // not exported yet
315  else
316  {
317  // now to be exported
318  if($a_export)
319  {
320  $this->doAdd($a_server, $export_settings, $a_mids);
321  }
322  // was not and will not be exported
323  else
324  {
325 
326  }
327  }
328  }
329  catch(ilECSConnectorException $exc)
330  {
331  throw $exc;
332  }
333  }
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 232 of file class.ilECSObjectSettings.php.

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

233  {
234  if(!$this->isActive())
235  {
236  return true;
237  }
238 
239  // Parse post data
240  $mids = array();
241  foreach((array) $_POST['ecs_sid'] as $sid_mid)
242  {
243  $tmp = explode('_',$sid_mid);
244  $mids[$tmp[0]][] = $tmp[1];
245  }
246 
247  try
248  {
249  include_once './Services/WebServices/ECS/classes/class.ilECSCommunitiesCache.php';
250  include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSettings.php';
251  include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
252 
253  // Update for each server
254  foreach(ilECSParticipantSettings::getExportServers() as $server_id)
255  {
257  if($server->isEnabled())
258  {
259  // Export
260  $export = true;
261  if(!$_POST['ecs_export'])
262  {
263  $export = false;
264  }
265  if(!count($mids[$server_id]))
266  {
267  $export = false;
268  }
269  $this->handleSettingsForServer(
270  $server,
271  $export,
272  $mids[$server_id]
273  );
274  }
275  }
276  }
277  catch(ilECSConnectorException $exc)
278  {
279  ilUtil::sendFailure('Error exporting to ECS server: '.$exc->getMessage());
280  return false;
281  }
282  return true;
283  }
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)
Create styles array
The data for the language used.
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 99 of file class.ilECSObjectSettings.php.

References ilECSServerSettings\getInstance().

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

100  {
101  include_once('./Services/WebServices/ECS/classes/class.ilECSServerSettings.php');
102  if(ilECSServerSettings::getInstance()->activeServerExists())
103  {
104  // imported objects cannot be exported => why not
105  #include_once('./Services/WebServices/ECS/classes/class.ilECSImport.php');
106  #if(!ilECSImport::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

Returns
bool

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

References $ilLog, $lang, ilLanguageFactory\_getLanguage(), ilLink\_getStaticLink(), array, ilECSSetting\getApprovalRecipients(), ilECSSetting\getApprovalRecipientsAsString(), getECSObjectType(), ilECSEContentDetails\getInstance(), ilECSCommunityReader\getInstanceByServerId(), and ilECSSetting\getServerId().

Referenced by doAdd().

564  {
565  global $ilLog;
566 
567  if(!count($rcps = $a_server->getApprovalRecipients()))
568  {
569  return true;
570  }
571 
572  include_once('./Services/Mail/classes/class.ilMail.php');
573  include_once('./Services/Language/classes/class.ilLanguageFactory.php');
574 
576  $lang->loadLanguageModule('ecs');
577 
578  // @TODO: read mail
579  $mail = new ilMail(self::MAIL_SENDER);
580  $message = $lang->txt('ecs_export_created_body_a')."\n\n";
581  $message .= $lang->txt('title').': '.$this->content_obj->getTitle()."\n";
582  if(strlen($desc = $this->content_obj->getDescription()))
583  {
584  $message .= $lang->txt('desc').': '.$desc."\n";
585  }
586 
587  // Participant info
588  $message .= ("\n".$lang->txt('ecs_published_for'));
589 
590  try
591  {
592  $found = false;
593 
594  $receivers = null;
595  include_once('./Services/WebServices/ECS/classes/class.ilECSEContentDetails.php');
596  $details = ilECSEContentDetails::getInstance($a_server->getServerId(),
597  $a_econtent_id, $this->getECSObjectType());
598  if($details instanceof ilECSEContentDetails)
599  {
600  $receivers = $details->getReceivers();
601  }
602  if($receivers)
603  {
604  foreach($receivers as $member)
605  {
606  $found = true;
607 
608  include_once './Services/WebServices/ECS/classes/class.ilECSCommunityReader.php';
609  $part = ilECSCommunityReader::getInstanceByServerId($a_server->getServerId())->getParticipantByMID($member);
610 
611  $message .= ("\n\n".$part->getParticipantName()."\n");
612  $message .= ($part->getDescription());
613  }
614  }
615  if($found)
616  {
617  $message .= "\n\n";
618  }
619  else
620  {
621  $message .= (' '.$lang->txt('ecs_not_published')."\n\n");
622  }
623  }
624  catch(ilECSConnectorException $e)
625  {
626  $ilLog->write(__METHOD__.': Cannot read approvements.');
627  return false;
628  }
629 
630  include_once('./Services/Link/classes/class.ilLink.php');
631  $href = ilLink::_getStaticLink($this->content_obj->getRefId(),'crs',true);
632  $message .= $lang->txt("perma_link").': '.$href."\n\n";
633  $message .= ilMail::_getAutoGeneratedMessageString();
634 
635  $mail->sendMail($a_server->getApprovalRecipientsAsString(),
636  '','',
637  $lang->txt('ecs_new_approval_subject'),
638  $message,array(),array('normal'));
639 
640  return true;
641  }
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.
This class handles base functions for mail handling.
Create styles array
The data for the language used.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
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: