ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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.

46 {
47 global $ilDB;
48
49 $res = $ilDB->query('SELECT mapping_id FROM ecs_container_mapping');
50 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
51 {
52 $rules[] = new ilECSCategoryMappingRule($row->mapping_id);
53 }
54 return $rules ? $rules : array();
55 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
Defines a rule for the assignment of ECS remote courses to categories.
global $ilDB

References $ilDB, $res, $row, and DB_FETCHMODE_OBJECT.

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

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

65 {
66 global $ilLog;
67
68 if(is_null(self::$cached_active_rules))
69 {
70 self::$cached_active_rules = self::getActiveRules();
71 }
72 foreach(self::$cached_active_rules as $rule)
73 {
74 if($rule->matches($a_matchable_content))
75 {
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 getActiveRules()
get active rules
static getInstanceByServerId($a_server_id)
Get singleton instance per server.

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

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

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

172 {
173 global $lng;
174
175 $options = array(
176 "community" => $lng->txt("ecs_field_community"),
177 "part_id" => $lng->txt("ecs_field_part_id"),
178 "type" => $lng->txt("type")
179 );
180
181 // will be handled by server soon?
182
183 // only courses for now
184 include_once('./Services/WebServices/ECS/classes/class.ilECSUtils.php');
185 $course_fields = ilECSUtils::_getOptionalECourseFields();
186 foreach($course_fields as $field)
187 {
188 $options[$field] = $lng->txt("obj_rcrs")." - ".$lng->txt("ecs_field_".$field);
189 }
190
191 return $options;
192 }
static _getOptionalECourseFields()
get optional econtent fields These fields might be mapped against AdvancedMetaData field definitions
global $lng
Definition: privfeed.php:40
if(!is_array($argv)) $options

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

Referenced by ilECSSettingsGUI\initCategoryMappingForm().

+ 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.

94 {
95 global $tree,$ilLog;
96
97 $cat = self::getMatchingCategory($a_server_id, $a_matchable_content);
98
99 $a_ref_id = current(ilObject::_getAllReferences($a_obj_id));
100 $references = ilObject::_getAllReferences(ilObject::_lookupObjId($a_ref_id));
101 $all_cats = self::lookupHandledCategories();
102
103 $exists = false;
104 foreach($references as $ref_id => $null)
105 {
106 if($tree->getParentId($ref_id) == $cat)
107 {
108 $exists = true;
109 }
110 }
111 $ilLog->write(__METHOD__.': Creating/Deleting references...');
112 include_once './Services/Object/classes/class.ilObjectFactory.php';
113
114 if(!$exists)
115 {
116 $ilLog->write(__METHOD__.': Add new reference. STEP 1');
117
118 if($obj_data = ilObjectFactory::getInstanceByRefId($a_ref_id,false))
119 {
120 $new_ref_id = $obj_data->createReference();
121 $obj_data->putInTree($cat);
122 $obj_data->setPermissions($cat);
123 $ilLog->write(__METHOD__.': Add new reference.');
124 }
125 }
126 // Now delete old references
127 foreach($references as $ref_id => $null)
128 {
129 $parent = $tree->getParentId($ref_id);
130 if($parent == $cat)
131 {
132 continue;
133 }
134 if(!in_array($parent,$all_cats))
135 {
136 continue;
137 }
139 {
140 $to_delete->delete();
141 $ilLog->write(__METHOD__.': Deleted deprecated reference.');
142 }
143 }
144 return true;
145 }
static getMatchingCategory($a_server_id, $a_matchable_content)
get matching category
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object
$ref_id
Definition: sahs_server.php:39

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

Referenced by ilRemoteObjectBase\updateFromECSContent().

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

154 {
155 global $ilDB;
156
157 $res = $ilDB->query("SELECT container_id FROM ecs_container_mapping ");
158 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
159 {
160 $ref_ids[] = $row->container_id;
161 }
162 return $ref_ids ? $ref_ids : array();
163 }

References $ilDB, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by handleUpdate().

+ Here is the caller graph for this function:

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: