ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC, $ilDB, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilECSSettingsGUI\showRulesTable().

46  {
47  global $DIC;
48 
49  $ilDB = $DIC['ilDB'];
50 
51  $res = $ilDB->query('SELECT mapping_id FROM ecs_container_mapping');
52  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
53  $rules[] = new ilECSCategoryMappingRule($row->mapping_id);
54  }
55  return $rules ? $rules : array();
56  }
global $DIC
Definition: saml.php:7
Defines a rule for the assignment of ECS remote courses to categories.
foreach($_POST as $key=> $value) $res
$row
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 65 of file class.ilECSCategoryMapping.php.

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

Referenced by ilRemoteObjectBase\createFromECSEContent().

66  {
67  global $DIC;
68 
69  $ilLog = $DIC['ilLog'];
70 
71  if (is_null(self::$cached_active_rules)) {
72  self::$cached_active_rules = self::getActiveRules();
73  }
74  foreach (self::$cached_active_rules as $rule) {
75  if ($rule->matches($a_matchable_content)) {
76  $ilLog->write(__METHOD__ . ': Found assignment for field type: ' . $rule->getFieldName());
77  return $rule->getContainerId();
78  }
79  $ilLog->write(__METHOD__ . ': Category assignment failed for field: ' . $rule->getFieldName());
80  }
81  // Return default container
82  $ilLog->write(__METHOD__ . ': Using default container');
83 
84  return ilECSSetting::getInstanceByServerId($a_server_id)->getImportId();
85  }
static getInstanceByServerId($a_server_id)
Get singleton instance per server.
global $DIC
Definition: saml.php:7
$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 167 of file class.ilECSCategoryMapping.php.

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

Referenced by ilECSSettingsGUI\initCategoryMappingForm().

168  {
169  global $DIC;
170 
171  $lng = $DIC['lng'];
172 
173  $options = array(
174  "community" => $lng->txt("ecs_field_community"),
175  "part_id" => $lng->txt("ecs_field_part_id"),
176  "type" => $lng->txt("type")
177  );
178 
179  // will be handled by server soon?
180 
181  // only courses for now
182  include_once('./Services/WebServices/ECS/classes/class.ilECSUtils.php');
183  $course_fields = ilECSUtils::_getOptionalECourseFields();
184  foreach ($course_fields as $field) {
185  $options[$field] = $lng->txt("obj_rcrs") . " - " . $lng->txt("ecs_field_" . $field);
186  }
187 
188  return $options;
189  }
global $DIC
Definition: saml.php:7
$lng
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 93 of file class.ilECSCategoryMapping.php.

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

Referenced by ilRemoteObjectBase\updateFromECSContent().

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

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

149  {
150  global $DIC;
151 
152  $ilDB = $DIC['ilDB'];
153 
154  $res = $ilDB->query("SELECT container_id FROM ecs_container_mapping ");
155  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
156  $ref_ids[] = $row->container_id;
157  }
158  return $ref_ids ? $ref_ids : array();
159  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$row
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: