ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilECSCategoryMapping Class Reference
+ Collaboration diagram for ilECSCategoryMapping:

Static Public Member Functions

static getActiveRules ()
 get active rules
static getMatchingCategory ($a_server_id, $a_matchable_content)
 get matching category
static handleUpdate ($a_obj_id, $a_server_id, $a_matchable_content)
 Handle update of ecs content and create references.
static lookupHandledCategories ()
static getPossibleFields ()

Static Private Attributes

static $cached_active_rules = null

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

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

Member Function Documentation

static ilECSCategoryMapping::getActiveRules ( )
static

get active rules

Returns
array

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

References $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by getMatchingCategory(), and ilECSSettingsGUI\showRulesTable().

{
global $ilDB;
$res = $ilDB->query('SELECT mapping_id FROM ecs_container_mapping');
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$rules[] = new ilECSCategoryMappingRule($row->mapping_id);
}
return $rules ? $rules : array();
}

+ Here is the caller graph for this function:

static ilECSCategoryMapping::getMatchingCategory (   $a_server_id,
  $a_matchable_content 
)
static

get matching category

Parameters
object$econtentilECSEcontent
Returns

Definition at line 64 of file class.ilECSCategoryMapping.php.

References $ilLog, getActiveRules(), and ilECSSetting\getInstanceByServerId().

Referenced by ilRemoteObjectBase\createFromECSEContent(), and handleUpdate().

{
global $ilLog;
if(is_null(self::$cached_active_rules))
{
self::$cached_active_rules = self::getActiveRules();
}
foreach(self::$cached_active_rules as $rule)
{
if($rule->matches($a_matchable_content))
{
$ilLog->write(__METHOD__.': Found assignment for field type: '.$rule->getFieldName());
return $rule->getContainerId();
}
$ilLog->write(__METHOD__.': Category assignment failed for field: '.$rule->getFieldName());
}
// Return default container
$ilLog->write(__METHOD__.': Using default container');
return ilECSSetting::getInstanceByServerId($a_server_id)->getImportId();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilECSCategoryMapping::getPossibleFields ( )
static
Returns

Definition at line 171 of file class.ilECSCategoryMapping.php.

References $lng, and ilECSUtils\_getOptionalECourseFields().

Referenced by ilECSSettingsGUI\initCategoryMappingForm().

{
global $lng;
$options = array(
"community" => $lng->txt("ecs_field_community"),
"part_id" => $lng->txt("ecs_field_part_id"),
"type" => $lng->txt("type")
);
// will be handled by server soon?
// only courses for now
include_once('./Services/WebServices/ECS/classes/class.ilECSUtils.php');
foreach($course_fields as $field)
{
$options[$field] = $lng->txt("obj_rcrs")." - ".$lng->txt("ecs_field_".$field);
}
return $options;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilECSCategoryMapping::handleUpdate (   $a_obj_id,
  $a_server_id,
  $a_matchable_content 
)
static

Handle update of ecs content and create references.

Returns

Definition at line 93 of file class.ilECSCategoryMapping.php.

References $ilLog, $ref_id, ilObject\_getAllReferences(), ilObject\_lookupObjId(), ilObjectFactory\getInstanceByRefId(), getMatchingCategory(), and lookupHandledCategories().

{
global $tree,$ilLog;
$cat = self::getMatchingCategory($a_server_id, $a_matchable_content);
$a_ref_id = current(ilObject::_getAllReferences($a_obj_id));
$exists = false;
foreach($references as $ref_id => $null)
{
if($tree->getParentId($ref_id) == $cat)
{
$exists = true;
}
}
$ilLog->write(__METHOD__.': Creating/Deleting references...');
include_once './Services/Object/classes/class.ilObjectFactory.php';
if(!$exists)
{
$ilLog->write(__METHOD__.': Add new reference. STEP 1');
if($obj_data = ilObjectFactory::getInstanceByRefId($a_ref_id,false))
{
$new_ref_id = $obj_data->createReference();
$obj_data->putInTree($cat);
$obj_data->setPermissions($cat);
$ilLog->write(__METHOD__.': Add new reference.');
}
}
// Now delete old references
foreach($references as $ref_id => $null)
{
$parent = $tree->getParentId($ref_id);
if($parent == $cat)
{
continue;
}
if(!in_array($parent,$all_cats))
{
continue;
}
{
$to_delete->delete();
$ilLog->write(__METHOD__.': Deleted deprecated reference.');
}
}
return true;
}

+ Here is the call graph for this function:

static ilECSCategoryMapping::lookupHandledCategories ( )
static
Returns

Definition at line 153 of file class.ilECSCategoryMapping.php.

References $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by handleUpdate().

{
global $ilDB;
$res = $ilDB->query("SELECT container_id FROM ecs_container_mapping ");
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$ref_ids[] = $row->container_id;
}
return $ref_ids ? $ref_ids : array();
}

+ Here is the caller graph for this function:

Field Documentation

ilECSCategoryMapping::$cached_active_rules = null
staticprivate

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


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