38 $this->logger =
$GLOBALS[
'DIC']->logger()->wsrv();
52 $query =
'SELECT attribute FROM ecs_cmap_rule ' .
53 'WHERE sid = ' . $ilDB->quote($a_sid,
'integer') .
' ' .
54 'AND mid = ' . $ilDB->quote($a_mid,
'integer') .
' ' .
55 'AND ref_id = ' . $ilDB->quote($a_ref_id,
'integer') .
' ' .
75 $query =
'SELECT DISTINCT(ref_id) ref_id, rid FROM ecs_cmap_rule ' .
76 'WHERE sid = ' . $ilDB->quote($a_sid,
'integer') .
' ' .
77 'AND mid = ' . $ilDB->quote($a_mid,
'integer') .
' ' .
78 'GROUP BY ref_id' .
' ' .
84 $ref_ids[] =
$row->ref_id;
87 $checked_ref_ids = [];
90 $GLOBALS[
'DIC']->repositoryTree()->isInTree($ref_id)) {
94 return $checked_ref_ids;
109 $query =
'SELECT rid FROM ecs_cmap_rule ' .
110 'WHERE sid = ' . $ilDB->quote($a_sid,
'integer') .
' ' .
111 'AND mid = ' . $ilDB->quote($a_mid,
'integer') .
' ' .
112 'AND ref_id = ' . $ilDB->quote($a_ref_id,
'integer');
118 return (
array) $rids;
121 public static function hasRules($a_sid, $a_mid, $a_ref_id)
125 $query =
'SELECT ref_id FROM ecs_cmap_rule ' .
126 'WHERE sid = ' . $ilDB->quote($a_sid,
'integer') .
' ' .
127 'AND mid = ' . $ilDB->quote($a_mid,
'integer') .
' ' .
128 'AND ref_id = ' . $ilDB->quote($a_ref_id,
'integer');
130 return $res->numRows() ? true :
false;
139 public static function isMatching($course, $a_sid, $a_mid, $a_ref_id)
143 $query =
'SELECT rid FROM ecs_cmap_rule ' .
144 'WHERE sid = ' . $ilDB->quote($a_sid,
'integer') .
' ' .
145 'AND mid = ' . $ilDB->quote($a_mid,
'integer') .
' ' .
146 'AND ref_id = ' . $ilDB->quote($a_ref_id,
'integer') .
' ' .
151 $sortable_index =
'';
154 $matches =
$rule->matches($course);
155 if ($matches == -1) {
159 $sortable_index .= str_pad($matches, 4,
'0', STR_PAD_LEFT);
162 return $sortable_index;
175 public static function doMappings($course, $a_sid, $a_mid, $a_ref_id)
179 $query =
'SELECT rid FROM ecs_cmap_rule ' .
180 'WHERE sid = ' . $ilDB->quote($a_sid,
'integer') .
' ' .
181 'AND mid = ' . $ilDB->quote($a_mid,
'integer') .
' ' .
182 'AND ref_id = ' . $ilDB->quote($a_ref_id,
'integer') .
' ' .
187 $last_level_category =
array();
191 $last_level_category[] =
$rule->getRefId();
194 $found_new_level =
false;
195 $new_level_cats =
array();
196 foreach ((
array) $last_level_category as $cat_ref_id) {
197 $refs =
$rule->doMapping($course, $cat_ref_id);
198 foreach ($refs as $new_ref_id) {
199 $found_new_level =
true;
200 $new_level_cats[] = $new_ref_id;
203 if ($found_new_level) {
204 $last_level_category = $new_level_cats;
209 return (
array) $last_level_category;
224 include_once
'./Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
227 $childs = $tree->getChildsByType($parent_ref,
'cat');
228 foreach ($values as $value) {
230 foreach ((
array) $childs as $child) {
232 if (strcmp($child[
'title'], $value) === 0) {
234 $category_references[] = $child[
'child'];
239 $category_references[] = $this->
createCategory($value, $parent_ref);
242 return (
array) $category_references;
252 include_once
'./Modules/Category/classes/class.ilObjCategory.php';
254 $cat->setOwner(SYSTEM_USER_ID);
255 $cat->setTitle($a_title);
257 $cat->createReference();
258 $cat->putInTree($a_parent_ref);
259 $cat->setPermissions($a_parent_ref);
260 $cat->deleteTranslation(
$GLOBALS[
'lng']->getDefaultLanguage());
261 $cat->addTranslation(
263 $cat->getLongDescription(),
264 $GLOBALS[
'lng']->getDefaultLanguage(),
267 return $cat->getRefId();
279 include_once
'./Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
281 $this->logger->dump($values);
283 foreach ($values as $value) {
286 $this->logger->debug(
'Comparing ' . $value .
' with ' . $filter_element);
287 if (strcmp(trim($value), trim($filter_element)) === 0) {
288 $this->logger->debug($value .
' matches ' . $filter_element);
289 $this->logger->debug(
'Found index: ' .
$index);
313 $query =
'SELECT rid FROM ecs_cmap_rule ' .
314 'WHERE sid = ' . $ilDB->quote($a_sid,
'integer') .
' ' .
315 'AND mid = ' . $ilDB->quote($a_mid,
'integer') .
' ' .
316 'AND ref_id = ' . $ilDB->quote($a_ref_id,
'integer') .
' ' .
317 'AND attribute = ' . $ilDB->quote($a_att,
'text');
328 $this->rid = $a_rule_id;
338 $this->sid = $a_server_id;
358 $this->attribute = $a_att;
368 $this->ref_id = $a_ref_id;
378 $this->is_filter = $a_status;
388 $this->filter = $a_filter;
403 $this->create_subdir = $a_stat;
418 return self::SUBDIR_VALUE;
423 $this->directory = $a_dir;
431 public function delete()
435 $query =
'DELETE from ecs_cmap_rule ' .
436 'WHERE rid = ' . $ilDB->quote($this->
getRuleId(),
'integer');
437 $ilDB->manipulate(
$query);
450 $this->
setRuleId($ilDB->nextId(
'ecs_cmap_rule'));
451 $query =
'INSERT INTO ecs_cmap_rule ' .
452 '(rid,sid,mid,attribute,ref_id,is_filter,filter,create_subdir,subdir_type,directory) ' .
454 $ilDB->quote($this->
getRuleId(),
'integer') .
', ' .
455 $ilDB->quote($this->
getServerId(),
'integer') .
', ' .
456 $ilDB->quote($this->
getMid(),
'integer') .
', ' .
458 $ilDB->quote($this->
getRefId(),
'integer') .
', ' .
460 $ilDB->quote($this->
getFilter(),
'text') .
', ' .
465 $ilDB->manipulate($query);
477 $query =
'UPDATE ecs_cmap_rule ' .
' ' .
479 'attribute = ' . $ilDB->quote($this->
getAttribute(),
'text') .
', ' .
480 'ref_id = ' . $ilDB->quote($this->
getRefId(),
'integer') .
', ' .
481 'is_filter = ' . $ilDB->quote($this->
isFilterEnabled(),
'integer') .
', ' .
482 'filter = ' . $ilDB->quote($this->
getFilter(),
'text') .
', ' .
485 'directory = ' . $ilDB->quote($this->
getDirectory(),
'text') .
' ' .
486 'WHERE rid = ' . $ilDB->quote($this->
getRuleId(),
'integer');
487 $ilDB->manipulate(
$query);
500 $query =
'SELECT * from ecs_cmap_rule ' .
' ' .
501 'WHERE rid = ' . $ilDB->quote($this->
getRuleId(),
'integer');
526 $escaped_filter = str_replace(
'\,',
'#:#',
$filter);
531 $replaced = str_replace(
'#:#',
',', $filter_element);
532 if (strlen(trim($replaced))) {
533 $this->filter_elements[] = $replaced;
static getRulesOfRefId($a_sid, $a_mid, $a_ref_id)
Get all rule of ref_id type $ilDB.
static hasRules($a_sid, $a_mid, $a_ref_id)
static doMappings($course, $a_sid, $a_mid, $a_ref_id)
createCategory($a_title, $a_parent_ref)
Create attribute category.
static isMatching($course, $a_sid, $a_mid, $a_ref_id)
Check if rule matches.
static getCourseValueByMappingAttribute($course, $a_field)
Get course value by mapping.
isSubdirCreationEnabled()
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
enableSubdirCreation($a_stat)
save()
Save a new rule type $ilDB.
matches($course)
Check if rule matches.
setServerId($a_server_id)
foreach($_POST as $key=> $value) $res
const SUBDIR_ATTRIBUTE_NAME
setSubDirectoryType($a_type)
static lookupLastExistingAttribute($a_sid, $a_mid, $a_ref_id)
Lookup existing attributes.
update()
Update mapping rule type $ilDB.
static getRuleRefIds($a_sid, $a_mid)
Create styles array
The data for the language used.
static getInstanceByAttribute($a_sid, $a_mid, $a_ref_id, $a_att)
Get rule instance by attribute type $ilDB.
__construct($a_rid=0)
Constructor.
parseFilter()
Parse filter.
doMapping($course, $parent_ref)
Do mapping.