ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilECSCategoryMapping Class Reference
+ Collaboration diagram for ilECSCategoryMapping:

Static Public Member Functions

static getActiveRules ()
 get active rules More...
 
static getMatchingCategory ($a_server_id, $a_matchable_content)
 get matching category More...
 
static handleUpdate ($a_obj_id, $a_server_id, $a_matchable_content)
 Handle update of ecs content and create references. More...
 
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

◆ getActiveRules()

static ilECSCategoryMapping::getActiveRules ( )
static

get active rules

Returns
array

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

References $ilDB, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilECSSettingsGUI\showRulesTable().

46  {
47  global $ilDB;
48 
49  $res = $ilDB->query('SELECT mapping_id FROM ecs_container_mapping');
50  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
51  $rules[] = new ilECSCategoryMappingRule($row->mapping_id);
52  }
53  return $rules ? $rules : array();
54  }
Defines a rule for the assignment of ECS remote courses to categories.
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getMatchingCategory()

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

get matching category

Parameters
object$econtentilECSEcontent
Returns

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

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

Referenced by ilRemoteObjectBase\createFromECSEContent().

64  {
65  global $ilLog;
66 
67  if (is_null(self::$cached_active_rules)) {
68  self::$cached_active_rules = self::getActiveRules();
69  }
70  foreach (self::$cached_active_rules as $rule) {
71  if ($rule->matches($a_matchable_content)) {
72  $ilLog->write(__METHOD__ . ': Found assignment for field type: ' . $rule->getFieldName());
73  return $rule->getContainerId();
74  }
75  $ilLog->write(__METHOD__ . ': Category assignment failed for field: ' . $rule->getFieldName());
76  }
77  // Return default container
78  $ilLog->write(__METHOD__ . ': Using default container');
79 
80  return ilECSSetting::getInstanceByServerId($a_server_id)->getImportId();
81  }
static getInstanceByServerId($a_server_id)
Get singleton instance per server.
$rule
Definition: showstats.php:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPossibleFields()

static ilECSCategoryMapping::getPossibleFields ( )
static
Returns

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

References $lng, $options, ilECSUtils\_getOptionalECourseFields(), and array.

Referenced by ilECSSettingsGUI\initCategoryMappingForm().

159  {
160  global $lng;
161 
162  $options = array(
163  "community" => $lng->txt("ecs_field_community"),
164  "part_id" => $lng->txt("ecs_field_part_id"),
165  "type" => $lng->txt("type")
166  );
167 
168  // will be handled by server soon?
169 
170  // only courses for now
171  include_once('./Services/WebServices/ECS/classes/class.ilECSUtils.php');
172  $course_fields = ilECSUtils::_getOptionalECourseFields();
173  foreach ($course_fields as $field) {
174  $options[$field] = $lng->txt("obj_rcrs") . " - " . $lng->txt("ecs_field_" . $field);
175  }
176 
177  return $options;
178  }
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
static _getOptionalECourseFields()
get optional econtent fields These fields might be mapped against AdvancedMetaData field definitions ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleUpdate()

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 89 of file class.ilECSCategoryMapping.php.

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

Referenced by ilRemoteObjectBase\updateFromECSContent().

90  {
91  global $tree,$ilLog;
92 
93  $cat = self::getMatchingCategory($a_server_id, $a_matchable_content);
94 
95  $a_ref_id = current(ilObject::_getAllReferences($a_obj_id));
96  $references = ilObject::_getAllReferences(ilObject::_lookupObjId($a_ref_id));
97  $all_cats = self::lookupHandledCategories();
98 
99  $exists = false;
100  foreach ($references as $ref_id => $null) {
101  if ($tree->getParentId($ref_id) == $cat) {
102  $exists = true;
103  }
104  }
105  $ilLog->write(__METHOD__ . ': Creating/Deleting references...');
106  include_once './Services/Object/classes/class.ilObjectFactory.php';
107 
108  if (!$exists) {
109  $ilLog->write(__METHOD__ . ': Add new reference. STEP 1');
110 
111  if ($obj_data = ilObjectFactory::getInstanceByRefId($a_ref_id, false)) {
112  $new_ref_id = $obj_data->createReference();
113  $obj_data->putInTree($cat);
114  $obj_data->setPermissions($cat);
115  $ilLog->write(__METHOD__ . ': Add new reference.');
116  }
117  }
118  // Now delete old references
119  foreach ($references as $ref_id => $null) {
120  $parent = $tree->getParentId($ref_id);
121  if ($parent == $cat) {
122  continue;
123  }
124  if (!in_array($parent, $all_cats)) {
125  continue;
126  }
127  if ($to_delete = ilObjectFactory::getInstanceByRefId($ref_id)) {
128  $to_delete->delete();
129  $ilLog->write(__METHOD__ . ': Deleted deprecated reference.');
130  }
131  }
132  return true;
133  }
static _getAllReferences($a_id)
get all reference ids of object
static _lookupObjId($a_id)
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:

◆ lookupHandledCategories()

static ilECSCategoryMapping::lookupHandledCategories ( )
static
Returns

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

References $ilDB, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

142  {
143  global $ilDB;
144 
145  $res = $ilDB->query("SELECT container_id FROM ecs_container_mapping ");
146  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
147  $ref_ids[] = $row->container_id;
148  }
149  return $ref_ids ? $ref_ids : array();
150  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
global $ilDB

Field Documentation

◆ $cached_active_rules

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: