46 $query =
'SELECT attribute FROM ecs_cmap_rule '.
47 'WHERE sid = '.$ilDB->quote($a_sid,
'integer').
' '.
48 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
49 'AND ref_id = '.$ilDB->quote($a_ref_id,
'integer').
' '.
53 $attributes = array();
56 $attributes =
$row->attribute;
70 $query =
'SELECT DISTINCT(ref_id) ref_id, rid FROM ecs_cmap_rule '.
71 'WHERE sid = '.$ilDB->quote($a_sid,
'integer').
' '.
72 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
73 'GROUP BY ref_id'.
' '.
80 $ref_ids[] =
$row->ref_id;
96 $query =
'SELECT rid FROM ecs_cmap_rule '.
97 'WHERE sid = '.$ilDB->quote($a_sid,
'integer').
' '.
98 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
99 'AND ref_id = '.$ilDB->quote($a_ref_id,
'integer');
106 return (array) $rids;
109 public static function hasRules($a_sid, $a_mid, $a_ref_id)
113 $query =
'SELECT ref_id FROM ecs_cmap_rule '.
114 'WHERE sid = '.$ilDB->quote($a_sid,
'integer').
' '.
115 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
116 'AND ref_id = '.$ilDB->quote($a_ref_id,
'integer');
118 return $res->numRows() ?
true :
false;
126 public static function isMatching($course, $a_sid, $a_mid, $a_ref_id)
130 $query =
'SELECT rid FROM ecs_cmap_rule '.
131 'WHERE sid = '.$ilDB->quote($a_sid,
'integer').
' '.
132 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
133 'AND ref_id = '.$ilDB->quote($a_ref_id,
'integer').
' '.
140 if(!$rule->matches($course))
159 public static function doMappings($course,$a_sid,$a_mid, $a_ref_id)
163 $query =
'SELECT rid FROM ecs_cmap_rule '.
164 'WHERE sid = '.$ilDB->quote($a_sid,
'integer').
' '.
165 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
166 'AND ref_id = '.$ilDB->quote($a_ref_id,
'integer').
' '.
176 $parent_ref = $rule->getRefId();
178 $parent_ref = $rule->doMapping($course,$parent_ref);
197 include_once
'./Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
200 $childs = $tree->getChildsByType($parent_ref,
'cat');
203 foreach((array) $childs as $child)
205 if(strcmp($child[
'title'], $value) === 0)
207 $existing_ref = $child[
'child'];
214 include_once
'./Modules/Category/classes/class.ilObjCategory.php';
216 $cat->setTitle($value);
218 $cat->createReference();
219 $cat->putInTree($parent_ref);
220 $cat->setPermissions($parent_ref);
221 $cat->deleteTranslation(
$GLOBALS[
'lng']->getDefaultLanguage());
222 $cat->addTranslation(
224 $cat->getLongDescription(),
225 $GLOBALS[
'lng']->getDefaultLanguage(),
228 return $cat->getRefId();
230 return $existing_ref;
243 include_once
'./Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
245 $GLOBALS[
'ilLog']->write(__METHOD__.
': Comparing '. $value .
' with ' . $this->getFilter());
246 return strcmp($value, $this->
getFilter()) === 0;
265 $query =
'SELECT rid FROM ecs_cmap_rule '.
266 'WHERE sid = '.$ilDB->quote($a_sid,
'integer').
' '.
267 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
268 'AND ref_id = '.$ilDB->quote($a_ref_id,
'integer').
' '.
269 'AND attribute = '.$ilDB->quote($a_att,
'text');
281 $this->rid = $a_rule_id;
291 $this->sid = $a_server_id;
311 $this->attribute = $a_att;
321 $this->ref_id = $a_ref_id;
331 $this->is_filter = $a_status;
341 $this->filter = $a_filter;
351 $this->create_subdir = $a_stat;
361 $this->subdir_type = $a_type;
371 $this->directory = $a_dir;
379 public function delete()
383 $query =
'DELETE from ecs_cmap_rule '.
384 'WHERE rid = '.$ilDB->quote($this->
getRuleId(),
'integer');
385 $ilDB->manipulate(
$query);
398 $this->
setRuleId($ilDB->nextId(
'ecs_cmap_rule'));
399 $query =
'INSERT INTO ecs_cmap_rule '.
400 '(rid,sid,mid,attribute,ref_id,is_filter,filter,create_subdir,subdir_type,directory) '.
402 $ilDB->quote($this->
getRuleId(),
'integer').
', '.
404 $ilDB->quote($this->
getMid(),
'integer').
', '.
406 $ilDB->quote($this->
getRefId(),
'integer').
', '.
408 $ilDB->quote($this->
getFilter(),
'text').
', '.
413 $ilDB->manipulate($query);
425 $query =
'UPDATE ecs_cmap_rule '.
' '.
427 'attribute = '.$ilDB->quote($this->
getAttribute(),
'text').
', '.
428 'ref_id = '.$ilDB->quote($this->
getRefId(),
'integer').
', '.
430 'filter = '.$ilDB->quote($this->
getFilter(),
'text').
', '.
433 'directory = '.$ilDB->quote($this->
getDirectory(),
'text').
' '.
434 'WHERE rid = '.$ilDB->quote($this->
getRuleId(),
'integer');
435 $ilDB->manipulate(
$query);
449 $query =
'SELECT * from ecs_cmap_rule '.
' '.
450 'WHERE rid = '.$ilDB->quote($this->
getRuleId(),
'integer');