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 = [];
 
   98        return $checked_ref_ids;
 
  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)
 
  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)
 
  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)
 
  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');
 
  242        foreach ($values as $value) {
 
  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';
 
  295            $this->logger->dump($values);
 
  297            foreach ($values as $value) {
 
  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);
 
  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;
 
  439        $this->directory = $a_dir;
 
  447    public function delete()
 
  453        $query = 
'DELETE from ecs_cmap_rule ' .
 
  471        $query = 
'INSERT INTO ecs_cmap_rule ' .
 
  472                '(rid,sid,mid,attribute,ref_id,is_filter,filter,create_subdir,subdir_type,directory) ' .
 
  499        $query = 
'UPDATE ecs_cmap_rule ' . 
' ' .
 
  502                'ref_id = ' . 
$ilDB->quote($this->
getRefId(), 
'integer') . 
', ' .
 
  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;
 
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
static isMatching($course, $a_sid, $a_mid, $a_ref_id)
Check if rule matches.
setServerId($a_server_id)
isSubdirCreationEnabled()
enableSubdirCreation($a_stat)
static lookupLastExistingAttribute($a_sid, $a_mid, $a_ref_id)
Lookup existing attributes.
save()
Save a new rule @global type $ilDB.
__construct($a_rid=0)
Constructor.
static hasRules($a_sid, $a_mid, $a_ref_id)
doMapping($course, $parent_ref)
Do mapping.
parseFilter()
Parse filter.
static getRulesOfRefId($a_sid, $a_mid, $a_ref_id)
Get all rule of ref_id @global type $ilDB.
setSubDirectoryType($a_type)
matches($course)
Check if rule matches.
static doMappings($course, $a_sid, $a_mid, $a_ref_id)
static getInstanceByAttribute($a_sid, $a_mid, $a_ref_id, $a_att)
Get rule instance by attribute @global type $ilDB.
static getRuleRefIds($a_sid, $a_mid)
createCategory($a_title, $a_parent_ref)
Create attribute category.
update()
Update mapping rule @global type $ilDB.
const SUBDIR_ATTRIBUTE_NAME
static getCourseValueByMappingAttribute($course, $a_field)
Get course value by mapping.
foreach($_POST as $key=> $value) $res