ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilECSContentWriter Class Reference

Handles request like update delete addEContent. More...

+ Collaboration diagram for ilECSContentWriter:

Public Member Functions

 __construct ($a_cont_obj)
 Constructor.
 setExportable ($a_status)
 set exportable
 isExportable ()
 is exportable
 setOwnerId ($a_id)
 set owner mid
 getOwnerId ()
 get owner id
 setParticipantIds ($a_mids)
 set participant ids
 getParticipantIds ()
 get participant ids
 refresh ()
 Refresh (add- update- delete Econtent)
 refreshSettings ()
 Refresh Settings.
 deleteECSContent ()
 delete ecs content
 addECSContent ()
 Add ECSContent.
 updateECSContent ()
 update ECS content

Static Public Member Functions

static _handleDelete ($a_subbtree_nodes)
 handle delete Objects that are moved to the trash call ECS-Remove

Data Fields

const UPDATE_ALL = 1
const UPDATE_SETTINGS_ONLY = 2

Protected Attributes

 $log
 $content_obj = null
 $export_settings = null
 $exportable = true
 $owner = 0
 $mids = array()

Private Member Functions

 sendNewContentNotification ()
 send notifications about new EContent
 createJSON ()
 Create new JSON object.
 updateJSON ()
 update json object (read settings from content object)

Private Attributes

 $mode = 0

Detailed Description

Handles request like update delete addEContent.

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

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

Constructor & Destructor Documentation

ilECSContentWriter::__construct (   $a_cont_obj)

Constructor.

public

Parameters
objectcontent obj (e.g course_obj)

Definition at line 58 of file class.ilECSContentWriter.php.

References $ilLog.

{
global $ilLog;
$this->log = $ilLog;
$this->content_obj = $a_cont_obj;
include_once('./Services/WebServices/ECS/classes/class.ilECSExport.php');
$this->export_settings = new ilECSExport($this->content_obj->getId());
}

Member Function Documentation

static ilECSContentWriter::_handleDelete (   $a_subbtree_nodes)
static

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

public

Parameters
intobj_id
Returns
bool

Definition at line 79 of file class.ilECSContentWriter.php.

References $content_obj, ilECSExport\_getExportedIDs(), ilECSSettings\_getInstance(), and ilObjectFactory\getInstanceByRefId().

Referenced by ilRepUtil\deleteObjects().

{
include_once('./Services/WebServices/ECS/classes/class.ilECSSettings.php');
if(!ilECSSettings::_getInstance()->isEnabled())
{
return false;
}
include_once('./Services/WebServices/ECS/classes/class.ilECSExport.php');
foreach($a_subbtree_nodes as $node)
{
if(in_array($node['obj_id'],$exported))
{
{
try
{
$writer->deleteECSContent();
}
{
continue;
}
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSContentWriter::addECSContent ( )

Add ECSContent.

public

Exceptions
ilConnectorException,ilECSContentWriterException

Definition at line 303 of file class.ilECSContentWriter.php.

References createJSON(), sendNewContentNotification(), and updateJSON().

Referenced by refresh().

{
include_once('./Services/WebServices/ECS/classes/class.ilECSConnector.php');
include_once('./Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
try
{
$this->log->write(__METHOD__.': Starting course export...');
// construct new json object and set settings from content obj
$this->createJSON();
$this->updateJSON();
$connector = new ilECSConnector();
$econtent_id = $connector->addResource(json_encode($this->json));
$this->export_settings->setExported(true);
$this->export_settings->setEContentId($econtent_id);
$this->export_settings->save();
// Send mail
}
{
throw $exc;
}
{
throw $exc;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSContentWriter::createJSON ( )
private

Create new JSON object.

private

Definition at line 460 of file class.ilECSContentWriter.php.

Referenced by addECSContent().

{
include_once('./Services/WebServices/ECS/classes/class.ilECSEContent.php');
$this->json = new ilECSEContent();
return true;
}

+ Here is the caller graph for this function:

ilECSContentWriter::deleteECSContent ( )

delete ecs content

public

Exceptions
ilECSContentWriterException

Definition at line 271 of file class.ilECSContentWriter.php.

Referenced by refresh().

{
include_once('./Services/WebServices/ECS/classes/class.ilECSConnector.php');
include_once('./Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
try
{
$this->log->write(__METHOD__.': Start deleting ECS content...');
$connector = new ilECSConnector();
if(!$this->export_settings->getEContentId())
{
$this->log->write(__METHOD__.': Missing eid. Aborting.');
throw new ilECSContentWriterException('Missing ECS content ID. Aborting.');
}
$connector->deleteResource($this->export_settings->getEContentId());
$this->export_settings->setExported(false);
$this->export_settings->save();
}
{
throw $exc;
}
return true;
}

+ Here is the caller graph for this function:

ilECSContentWriter::getOwnerId ( )

get owner id

public

Definition at line 152 of file class.ilECSContentWriter.php.

References $owner.

Referenced by updateJSON().

{
return $this->owner;
}

+ Here is the caller graph for this function:

ilECSContentWriter::getParticipantIds ( )

get participant ids

public

Definition at line 175 of file class.ilECSContentWriter.php.

References $mids.

Referenced by updateJSON().

{
return $this->mids;
}

+ Here is the caller graph for this function:

ilECSContentWriter::isExportable ( )

is exportable

public

Parameters

Definition at line 129 of file class.ilECSContentWriter.php.

References $exportable.

Referenced by refresh().

{
}

+ Here is the caller graph for this function:

ilECSContentWriter::refresh ( )

Refresh (add- update- delete Econtent)

public

Exceptions
ilConnectorException,ilECSContentWriterException

Definition at line 186 of file class.ilECSContentWriter.php.

References addECSContent(), deleteECSContent(), isExportable(), UPDATE_ALL, and updateECSContent().

{
$this->mode = self::UPDATE_ALL;
try
{
if($this->export_settings->isExported())
{
if($this->isExportable())
{
// Update Econtent
return $this->updateECSContent();
}
else
{
// Delete EContent
return $this->deleteECSContent();
}
}
else
{
if($this->isExportable())
{
// Add Econtent
return $this->addECSContent();
}
else
{
// Nothing to do
}
}
return true;
}
{
$this->log->write(__METHOD__.': Error connecting to ECS server. '.$exc->getMessage());
throw $exc;
}
{
$this->log->write(__METHOD__.': Cannot update ECS content. '.$exc->getMessage());
throw $exc;
}
}

+ Here is the call graph for this function:

ilECSContentWriter::refreshSettings ( )

Refresh Settings.

public

Exceptions
il

Definition at line 236 of file class.ilECSContentWriter.php.

References UPDATE_SETTINGS_ONLY, and updateECSContent().

{
try
{
if($this->export_settings->isExported())
{
// Update Econtent
return $this->updateECSContent();
}
else
{
// Nothing to do
return true;
}
}
{
$this->log->write(__METHOD__.': Error connecting to ECS server. '.$exc->getMessage());
throw $exc;
}
{
$this->log->write(__METHOD__.': Cannot update ECS content. '.$exc->getMessage());
throw $exc;
}
}

+ Here is the call graph for this function:

ilECSContentWriter::sendNewContentNotification ( )
private

send notifications about new EContent

private

Returns
bool

Definition at line 376 of file class.ilECSContentWriter.php.

References $desc, $error, $GLOBALS, $lang, $reader, ilMail\_getAutoGeneratedMessageString(), ilECSCommunityReader\_getInstance(), ilECSSettings\_getInstance(), ilLanguageFactory\_getLanguage(), and ilLink\_getStaticLink().

Referenced by addECSContent().

{
include_once('Services/WebServices/ECS/classes/class.ilECSSettings.php');
if(!count($rcps = $settings->getApprovalRecipients()))
{
return true;
}
include_once('./Services/Mail/classes/class.ilMail.php');
include_once('./Services/Language/classes/class.ilLanguageFactory.php');
$lang->loadLanguageModule('ecs');
$mail = new ilMail(6);
$message = $lang->txt('ecs_export_created_body_a')."\n\n";
$message .= $lang->txt('title').': '.$this->content_obj->getTitle()."\n";
if(strlen($desc = $this->content_obj->getDescription()))
{
$message .= $lang->txt('desc').': '.$desc."\n";
}
// Participant info
$message .= ("\n".$lang->txt('ecs_published_for'));
$export = new ilECSExport($this->content_obj->getId());
try
{
include_once './Services/WebServices/ECS/classes/class.ilECSEContentReader.php';
$reader = new ilECSEContentReader($export->getEContentId());
$reader->read();
$found = false;
foreach($reader->getEContent() as $econ)
{
foreach($econ->getEligibleMembers() as $member)
{
$found = true;
include_once './Services/WebServices/ECS/classes/class.ilECSCommunityReader.php';
$part = ilECSCommunityReader::_getInstance()->getParticipantByMID($member);
$message .= ("\n\n".$part->getParticipantName()."\n");
$message .= ($part->getDescription());
}
}
if($found)
{
$message .= "\n\n";
}
else
{
$message .= (' '.$lang->txt('ecs_not_published')."\n\n");
}
}
{
$GLOBALS['ilLog']->write(__METHOD__.': Cannot read approvements.');
}
{
$GLOBALS['ilLog']->write(__METHOD__.': Cannot read approvements.');
}
include_once('classes/class.ilLink.php');
$href = ilLink::_getStaticLink($this->content_obj->getRefId(),'crs',true);
$message .= $lang->txt("perma_link").': '.$href."\n\n";
$error = $mail->sendMail($settings->getApprovalRecipientsAsString(),
'','',
$lang->txt('ecs_new_approval_subject'),
$message,array(),array('normal'));
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSContentWriter::setExportable (   $a_status)

set exportable

public

Parameters
boolstatus

Definition at line 117 of file class.ilECSContentWriter.php.

{
$this->exportable = $a_status;
}
ilECSContentWriter::setOwnerId (   $a_id)

set owner mid

public

Parameters
intowner mid

Definition at line 141 of file class.ilECSContentWriter.php.

{
$this->owner = $a_id;
}
ilECSContentWriter::setParticipantIds (   $a_mids)

set participant ids

public

Parameters
arrayarray of participant mids

Definition at line 164 of file class.ilECSContentWriter.php.

{
$this->mids = $a_mids;
}
ilECSContentWriter::updateECSContent ( )

update ECS content

public

Exceptions
ilECSConnectorException,ilECSContentWriterException

Definition at line 343 of file class.ilECSContentWriter.php.

References $reader, and updateJSON().

Referenced by refresh(), and refreshSettings().

{
try
{
include_once('./Services/WebServices/ECS/classes/class.ilECSEContentReader.php');
$reader = new ilECSEContentReader($this->export_settings->getEContentId());
$reader->read();
$content = $reader->getEContent();
if(!is_array($content) or !is_object($content[0]))
{
$this->log->write(__METHOD__.': Error reading EContent with id: '.$this->export_settings->getEContentId());
include_once('./Services/WebServices/ECS/classes/class.ilECSContentWriterException.php');
throw new ilECSContentWriterException('Error reading EContent. Aborting');
}
$this->json = $content[0];
$this->updateJSON();
$connector = new ilECSConnector();
#var_dump("<pre>",json_encode($this->json),"</pre>");
$connector->updateResource($this->export_settings->getEContentId(),json_encode($this->json));
}
{
throw $exc;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSContentWriter::updateJSON ( )
private

update json object (read settings from content object)

private

Exceptions
ilECSContentWriterException

Definition at line 473 of file class.ilECSContentWriter.php.

References ilECSDataMappingSettings\_getInstance(), ilLink\_getLink(), ilAdvancedMDValues\_getValuesByObjId(), ilMDLanguage\_lookupFirstLanguage(), getOwnerId(), and getParticipantIds().

Referenced by addECSContent(), and updateECSContent().

{
// General fields
######################################################
include_once('./classes/class.ilLink.php');
$this->json->setURL(ilLink::_getLink($this->content_obj->getRefId(),$this->content_obj->getType()));
$this->json->setTitle($this->content_obj->getTitle());
// Ownership EligibleMembers
######################################################
if($this->mode == self::UPDATE_ALL)
{
// Eligible members [0] is owner
if(!$this->getOwnerId())
{
throw new ilECSContentWriterException('Missing ECS owner id.');
}
$this->json->setOwner($this->getOwnerId());
$members = array_unique($this->getParticipantIds());
$this->json->setEligibleMembers($members);
}
// meta language
include_once('./Services/MetaData/classes/class.ilMDLanguage.php');
$this->json->setLanguage(ilMDLanguage::_lookupFirstLanguage($this->content_obj->getId(),$this->content_obj->getId(),$this->content_obj->getType()));
$this->json->setStatus($this->content_obj->isActivated() ? 'online' : 'offline');
$this->json->setInfo($this->content_obj->getDescription());
// Optional fields
######################################################
include_once('./Services/WebServices/ECS/classes/class.ilECSUtils.php');
include_once('./Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php');
include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
$values = ilAdvancedMDValues::_getValuesByObjId($this->content_obj->getId());
// Study courses
if($field = $mappings->getMappingByECSName('study_courses'))
{
$value = isset($values[$field]) ? $values[$field] : '';
$this->json->setStudyCourses($value);
}
// Lecturer
if($field = $mappings->getMappingByECSName('lecturer'))
{
$value = isset($values[$field]) ? $values[$field] : '';
$this->json->setLecturers($value);
}
// CourseType
if($field = $mappings->getMappingByECSName('courseType'))
{
$value = isset($values[$field]) ? $values[$field] : '';
$this->json->setCourseType($value);
}
// Course ID
if($field = $mappings->getMappingByECSName('courseID'))
{
$value = isset($values[$field]) ? $values[$field] : '';
$this->json->setCourseID($value);
}
// Credits
if($field = $mappings->getMappingByECSName('credits'))
{
$value = isset($values[$field]) ? $values[$field] : '';
$this->json->setCredits($value);
}
// SWS
if($field = $mappings->getMappingByECSName('semester_hours'))
{
$value = isset($values[$field]) ? $values[$field] : '';
$this->json->setSemesterHours($value);
}
// Term
if($field = $mappings->getMappingByECSName('term'))
{
$value = isset($values[$field]) ? $values[$field] : '';
$this->json->setTerm($value);
}
// TIME PLACE OBJECT ########################
if($field = $mappings->getMappingByECSName('begin'))
{
$value = isset($values[$field]) ? $values[$field] : '';
$this->json->getTimePlace()->setBegin($value);
}
if($field = $mappings->getMappingByECSName('end'))
{
$value = isset($values[$field]) ? $values[$field] : '';
$this->json->getTimePlace()->setEnd($value);
}
if($field = $mappings->getMappingByECSName('room'))
{
$value = isset($values[$field]) ? $values[$field] : '';
$this->json->getTimePlace()->setRoom($value);
}
if($field = $mappings->getMappingByECSName('cycle'))
{
$value = isset($values[$field]) ? $values[$field] : '';
$this->json->getTimePlace()->setCycle($value);
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilECSContentWriter::$content_obj = null
protected

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

Referenced by _handleDelete().

ilECSContentWriter::$export_settings = null
protected

Definition at line 45 of file class.ilECSContentWriter.php.

ilECSContentWriter::$exportable = true
protected

Definition at line 47 of file class.ilECSContentWriter.php.

Referenced by isExportable().

ilECSContentWriter::$log
protected

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

ilECSContentWriter::$mids = array()
protected

Definition at line 49 of file class.ilECSContentWriter.php.

Referenced by getParticipantIds().

ilECSContentWriter::$mode = 0
private

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

ilECSContentWriter::$owner = 0
protected

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

Referenced by getOwnerId().

const ilECSContentWriter::UPDATE_ALL = 1

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

Referenced by refresh().

const ilECSContentWriter::UPDATE_SETTINGS_ONLY = 2

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

Referenced by refreshSettings().


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