38 $this->logger =
$GLOBALS[
'DIC']->logger()->wsrv();
54 $query =
'SELECT attribute FROM ecs_cmap_rule ' .
55 'WHERE sid = ' .
$ilDB->quote($a_sid,
'integer') .
' ' .
56 'AND mid = ' .
$ilDB->quote($a_mid,
'integer') .
' ' .
57 'AND ref_id = ' .
$ilDB->quote($a_ref_id,
'integer') .
' ' .
79 $query =
'SELECT DISTINCT(ref_id) ref_id, rid FROM ecs_cmap_rule ' .
80 'WHERE sid = ' .
$ilDB->quote($a_sid,
'integer') .
' ' .
81 'AND mid = ' .
$ilDB->quote($a_mid,
'integer') .
' ' .
82 'GROUP BY ref_id' .
' ' .
88 $ref_ids[] =
$row->ref_id;
91 $checked_ref_ids = [];
94 $GLOBALS[
'DIC']->repositoryTree()->isInTree($ref_id)) {
98 return $checked_ref_ids;
113 $ilDB = $DIC[
'ilDB'];
115 $query =
'SELECT rid FROM ecs_cmap_rule ' .
116 'WHERE sid = ' .
$ilDB->quote($a_sid,
'integer') .
' ' .
117 'AND mid = ' .
$ilDB->quote($a_mid,
'integer') .
' ' .
118 'AND ref_id = ' .
$ilDB->quote($a_ref_id,
'integer');
124 return (array) $rids;
127 public static function hasRules($a_sid, $a_mid, $a_ref_id)
131 $ilDB = $DIC[
'ilDB'];
133 $query =
'SELECT ref_id FROM ecs_cmap_rule ' .
134 'WHERE sid = ' .
$ilDB->quote($a_sid,
'integer') .
' ' .
135 'AND mid = ' .
$ilDB->quote($a_mid,
'integer') .
' ' .
136 'AND ref_id = ' .
$ilDB->quote($a_ref_id,
'integer');
138 return $res->numRows() ? true :
false;
147 public static function isMatching($course, $a_sid, $a_mid, $a_ref_id)
151 $ilDB = $DIC[
'ilDB'];
153 $query =
'SELECT rid FROM ecs_cmap_rule ' .
154 'WHERE sid = ' .
$ilDB->quote($a_sid,
'integer') .
' ' .
155 'AND mid = ' .
$ilDB->quote($a_mid,
'integer') .
' ' .
156 'AND ref_id = ' .
$ilDB->quote($a_ref_id,
'integer') .
' ' .
161 $sortable_index =
'';
164 $matches =
$rule->matches($course);
165 if ($matches == -1) {
169 $sortable_index .= str_pad($matches, 4,
'0', STR_PAD_LEFT);
172 return $sortable_index;
185 public static function doMappings($course, $a_sid, $a_mid, $a_ref_id)
189 $ilDB = $DIC[
'ilDB'];
191 $query =
'SELECT rid FROM ecs_cmap_rule ' .
192 'WHERE sid = ' .
$ilDB->quote($a_sid,
'integer') .
' ' .
193 'AND mid = ' .
$ilDB->quote($a_mid,
'integer') .
' ' .
194 'AND ref_id = ' .
$ilDB->quote($a_ref_id,
'integer') .
' ' .
199 $last_level_category = array();
203 $last_level_category[] =
$rule->getRefId();
206 $found_new_level =
false;
207 $new_level_cats = array();
208 foreach ((array) $last_level_category as $cat_ref_id) {
209 $refs =
$rule->doMapping($course, $cat_ref_id);
210 foreach ($refs as $new_ref_id) {
211 $found_new_level =
true;
212 $new_level_cats[] = $new_ref_id;
215 if ($found_new_level) {
216 $last_level_category = $new_level_cats;
221 return (array) $last_level_category;
233 $tree = $DIC[
'tree'];
238 include_once
'./Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
241 $childs =
$tree->getChildsByType($parent_ref,
'cat');
244 foreach ((array) $childs as $child) {
246 if (strcmp($child[
'title'], $value) === 0) {
248 $category_references[] = $child[
'child'];
253 $category_references[] = $this->
createCategory($value, $parent_ref);
256 return (array) $category_references;
266 include_once
'./Modules/Category/classes/class.ilObjCategory.php';
268 $cat->setOwner(SYSTEM_USER_ID);
269 $cat->setTitle($a_title);
271 $cat->createReference();
272 $cat->putInTree($a_parent_ref);
273 $cat->setPermissions($a_parent_ref);
274 $cat->deleteTranslation(
$GLOBALS[
'DIC'][
'lng']->getDefaultLanguage());
275 $cat->addTranslation(
277 $cat->getLongDescription(),
278 $GLOBALS[
'DIC'][
'lng']->getDefaultLanguage(),
281 return $cat->getRefId();
293 include_once
'./Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
300 $this->logger->debug(
'Comparing ' . $value .
' with ' . $filter_element);
301 if (strcmp(trim($value), trim($filter_element)) === 0) {
302 $this->logger->debug($value .
' matches ' . $filter_element);
303 $this->logger->debug(
'Found index: ' .
$index);
327 $ilDB = $DIC[
'ilDB'];
329 $query =
'SELECT rid FROM ecs_cmap_rule ' .
330 'WHERE sid = ' .
$ilDB->quote($a_sid,
'integer') .
' ' .
331 'AND mid = ' .
$ilDB->quote($a_mid,
'integer') .
' ' .
332 'AND ref_id = ' .
$ilDB->quote($a_ref_id,
'integer') .
' ' .
333 'AND attribute = ' .
$ilDB->quote($a_att,
'text');
344 $this->rid = $a_rule_id;
354 $this->sid = $a_server_id;
374 $this->attribute = $a_att;
384 $this->ref_id = $a_ref_id;
394 $this->is_filter = $a_status;
404 $this->filter = $a_filter;
419 $this->create_subdir = $a_stat;
434 return self::SUBDIR_VALUE;
447 public function delete()
451 $ilDB = $DIC[
'ilDB'];
453 $query =
'DELETE from ecs_cmap_rule ' .
468 $ilDB = $DIC[
'ilDB'];
471 $query =
'INSERT INTO ecs_cmap_rule ' .
472 '(rid,sid,mid,attribute,ref_id,is_filter,filter,create_subdir,subdir_type,directory) ' .
485 $ilDB->manipulate($query);
497 $ilDB = $DIC[
'ilDB'];
499 $query =
'UPDATE ecs_cmap_rule ' .
' ' .
502 'ref_id = ' .
$ilDB->quote($this->
getRefId(),
'integer') .
', ' .
519 $ilDB = $DIC[
'ilDB'];
524 $query =
'SELECT * from ecs_cmap_rule ' .
' ' .
550 $escaped_filter = str_replace(
'\,',
'#:#',
$filter);
555 $replaced = str_replace(
'#:#',
',', $filter_element);
556 if (strlen(trim($replaced))) {
557 $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()
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)
if(array_key_exists('yes', $_REQUEST)) $attributes
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.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.