ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilECSCourseMappingRule Class Reference

Description of class. More...

+ Collaboration diagram for ilECSCourseMappingRule:

Public Member Functions

 __construct ($a_rid=0)
 Constructor.
 doMapping ($course, $parent_ref)
 Do mapping.
 matches ($course)
 Check if rule matches.
 setRuleId ($a_rule_id)
 getRuleId ()
 setServerId ($a_server_id)
 getServerId ()
 setMid ($a_mid)
 getMid ()
 setAttribute ($a_att)
 getAttribute ()
 setRefId ($a_ref_id)
 getRefId ()
 enableFilter ($a_status)
 isFilterEnabled ()
 setFilter ($a_filter)
 getFilter ()
 enableSubdirCreation ($a_stat)
 isSubdirCreationEnabled ()
 setSubDirectoryType ($a_type)
 getSubDirectoryType ()
 setDirectory ($a_dir)
 getDirectory ()
 delete ()
 save ()
 Save a new rule type $ilDB.
 update ()
 Update mapping rule type $ilDB.

Static Public Member Functions

static lookupLastExistingAttribute ($a_sid, $a_mid, $a_ref_id)
 Lookup existing attributes.
static getRuleRefIds ($a_sid, $a_mid)
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 isMatching ($course, $a_sid, $a_mid, $a_ref_id)
 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 type $ilDB.

Data Fields

const SUBDIR_ATTRIBUTE_NAME = 1
const SUBDIR_VALUE = 2

Protected Member Functions

 read ()
 Read db entries.

Private Attributes

 $rid
 $sid
 $mid
 $attribute
 $ref_id
 $is_filter = false
 $filter
 $create_subdir = true
 $subdir_type = self::SUBDIR_VALUE
 $directory = ''

Detailed Description

Description of class.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 10 of file class.ilECSCourseMappingRule.php.

Constructor & Destructor Documentation

ilECSCourseMappingRule::__construct (   $a_rid = 0)

Constructor.

Parameters
int$a_rid

Definition at line 31 of file class.ilECSCourseMappingRule.php.

References read().

{
$this->rid = $a_rid;
$this->read();
}

+ Here is the call graph for this function:

Member Function Documentation

ilECSCourseMappingRule::delete ( )

Definition at line 379 of file class.ilECSCourseMappingRule.php.

References $query, and getRuleId().

{
global $ilDB;
$query = 'DELETE from ecs_cmap_rule '.
'WHERE rid = '.$ilDB->quote($this->getRuleId(),'integer');
$ilDB->manipulate($query);
return true;
}

+ Here is the call graph for this function:

ilECSCourseMappingRule::doMapping (   $course,
  $parent_ref 
)

Do mapping.

Parameters
type$course
type$parent_ref

Definition at line 189 of file class.ilECSCourseMappingRule.php.

References $GLOBALS, getAttribute(), ilECSMappingUtils\getCourseValueByMappingAttribute(), and isSubdirCreationEnabled().

{
global $tree;
{
return $parent_ref;
}
include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
$childs = $tree->getChildsByType($parent_ref,'cat');
$existing_ref = 0;
foreach((array) $childs as $child)
{
if(strcmp($child['title'], $value) === 0)
{
$existing_ref = $child['child'];
break;
}
}
if(!$existing_ref)
{
// Create category
include_once './Modules/Category/classes/class.ilObjCategory.php';
$cat = new ilObjCategory();
$cat->setTitle($value);
$cat->create();
$cat->createReference();
$cat->putInTree($parent_ref);
$cat->setPermissions($parent_ref);
$cat->deleteTranslation($GLOBALS['lng']->getDefaultLanguage());
$cat->addTranslation(
$value,
$cat->getLongDescription(),
$GLOBALS['lng']->getDefaultLanguage(),
1
);
return $cat->getRefId();
}
return $existing_ref;
}

+ Here is the call graph for this function:

static ilECSCourseMappingRule::doMappings (   $course,
  $a_sid,
  $a_mid,
  $a_ref_id 
)
static
Parameters
type$course
type$a_sid
type$a_mid
type$a_ref_id

Definition at line 159 of file class.ilECSCourseMappingRule.php.

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

Referenced by ilECSCourseCreationHandler\doAttributeMapping().

{
global $ilDB;
$query = 'SELECT rid FROM ecs_cmap_rule '.
'WHERE sid = '.$ilDB->quote($a_sid,'integer'). ' '.
'AND mid = '.$ilDB->quote($a_mid,'integer').' '.
'AND ref_id = '.$ilDB->quote($a_ref_id,'integer').' '.
'ORDER BY rid';
$res = $ilDB->query($query);
$first = true;
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$rule = new ilECSCourseMappingRule($row->rid);
if($first)
{
$parent_ref = $rule->getRefId();
}
$parent_ref = $rule->doMapping($course,$parent_ref);
$first = false;
}
return $parent_ref;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::enableFilter (   $a_status)

Definition at line 329 of file class.ilECSCourseMappingRule.php.

Referenced by read().

{
$this->is_filter = $a_status;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::enableSubdirCreation (   $a_stat)

Definition at line 349 of file class.ilECSCourseMappingRule.php.

Referenced by read().

{
$this->create_subdir = $a_stat;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::getAttribute ( )

Definition at line 314 of file class.ilECSCourseMappingRule.php.

References $attribute.

Referenced by doMapping(), matches(), save(), and update().

{
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::getDirectory ( )

Definition at line 374 of file class.ilECSCourseMappingRule.php.

References $directory.

Referenced by save(), and update().

{
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::getFilter ( )

Definition at line 344 of file class.ilECSCourseMappingRule.php.

References $filter.

Referenced by matches(), save(), and update().

{
return $this->filter;
}

+ Here is the caller graph for this function:

static ilECSCourseMappingRule::getInstanceByAttribute (   $a_sid,
  $a_mid,
  $a_ref_id,
  $a_att 
)
static

Get rule instance by attribute type $ilDB.

Parameters
type$a_sid
type$a_mid
type$a_ref_id
type$a_att
Returns

Definition at line 261 of file class.ilECSCourseMappingRule.php.

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

Referenced by ilECSMappingSettingsGUI\cInitMappingForm(), and ilECSMappingSettingsGUI\cSaveOverview().

{
global $ilDB;
$query = 'SELECT rid FROM ecs_cmap_rule '.
'WHERE sid = '.$ilDB->quote($a_sid,'integer').' '.
'AND mid = '.$ilDB->quote($a_mid,'integer').' '.
'AND ref_id = '.$ilDB->quote($a_ref_id,'integer').' '.
'AND attribute = '.$ilDB->quote($a_att,'text');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return new ilECSCourseMappingRule($row->rid);
}
return new ilECSCourseMappingRule();
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::getMid ( )

Definition at line 304 of file class.ilECSCourseMappingRule.php.

References $mid.

Referenced by save().

{
return $this->mid;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::getRefId ( )

Definition at line 324 of file class.ilECSCourseMappingRule.php.

References $ref_id.

Referenced by save(), and update().

{
return $this->ref_id;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::getRuleId ( )

Definition at line 284 of file class.ilECSCourseMappingRule.php.

References $rid.

Referenced by delete(), read(), save(), and update().

{
return $this->rid;
}

+ Here is the caller graph for this function:

static ilECSCourseMappingRule::getRuleRefIds (   $a_sid,
  $a_mid 
)
static
Parameters
type$a_sid
type$a_mid

Definition at line 66 of file class.ilECSCourseMappingRule.php.

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

Referenced by ilECSCourseCreationHandler\doAttributeMapping(), and ilECSNodeMappingLocalExplorer\initMappings().

{
global $ilDB;
$query = 'SELECT DISTINCT(ref_id) ref_id, rid FROM ecs_cmap_rule '.
'WHERE sid = '.$ilDB->quote($a_sid,'integer').' '.
'AND mid = '.$ilDB->quote($a_mid,'integer').' '.
'GROUP BY ref_id'.' '.
'ORDER BY rid';
$res = $ilDB->query($query);
$ref_ids = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$ref_ids[] = $row->ref_id;
}
return $ref_ids;
}

+ Here is the caller graph for this function:

static ilECSCourseMappingRule::getRulesOfRefId (   $a_sid,
  $a_mid,
  $a_ref_id 
)
static

Get all rule of ref_id type $ilDB.

Parameters
type$a_sid
type$a_mid
type$a_ref_id

Definition at line 92 of file class.ilECSCourseMappingRule.php.

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

Referenced by ilECSMappingSettingsGUI\cDeleteRulesOfNode().

{
global $ilDB;
$query = 'SELECT rid FROM ecs_cmap_rule '.
'WHERE sid = '.$ilDB->quote($a_sid,'integer').' '.
'AND mid = '.$ilDB->quote($a_mid,'integer').' '.
'AND ref_id = '.$ilDB->quote($a_ref_id,'integer');
$res = $ilDB->query($query);
$rids = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$rids = $row->rid;
}
return (array) $rids;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::getServerId ( )

Definition at line 294 of file class.ilECSCourseMappingRule.php.

References $sid.

Referenced by save().

{
return $this->sid;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::getSubDirectoryType ( )

Definition at line 364 of file class.ilECSCourseMappingRule.php.

References SUBDIR_VALUE.

Referenced by save(), and update().

{
}

+ Here is the caller graph for this function:

static ilECSCourseMappingRule::hasRules (   $a_sid,
  $a_mid,
  $a_ref_id 
)
static

Definition at line 109 of file class.ilECSCourseMappingRule.php.

References $query, and $res.

Referenced by ilECSMappingSettingsGUI\cInitMappingForm().

{
global $ilDB;
$query = 'SELECT ref_id FROM ecs_cmap_rule '.
'WHERE sid = '.$ilDB->quote($a_sid,'integer').' '.
'AND mid = '.$ilDB->quote($a_mid,'integer').' '.
'AND ref_id = '.$ilDB->quote($a_ref_id,'integer');
$res = $ilDB->query($query);
return $res->numRows() ? true : false;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::isFilterEnabled ( )

Definition at line 334 of file class.ilECSCourseMappingRule.php.

References $is_filter.

Referenced by matches(), save(), and update().

{
}

+ Here is the caller graph for this function:

static ilECSCourseMappingRule::isMatching (   $course,
  $a_sid,
  $a_mid,
  $a_ref_id 
)
static

Check if rule matches.

Parameters
type$course
type$a_start_rule_id

Definition at line 126 of file class.ilECSCourseMappingRule.php.

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

Referenced by ilECSCourseCreationHandler\doAttributeMapping().

{
global $ilDB;
$query = 'SELECT rid FROM ecs_cmap_rule '.
'WHERE sid = '.$ilDB->quote($a_sid,'integer'). ' '.
'AND mid = '.$ilDB->quote($a_mid,'integer').' '.
'AND ref_id = '.$ilDB->quote($a_ref_id,'integer').' '.
'ORDER BY rid';
$res = $ilDB->query($query);
$matches = false;
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$rule = new ilECSCourseMappingRule($row->rid);
if(!$rule->matches($course))
{
return false;
}
else
{
$matches = true;
}
}
return $matches;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::isSubdirCreationEnabled ( )

Definition at line 354 of file class.ilECSCourseMappingRule.php.

References $create_subdir.

Referenced by doMapping(), save(), and update().

{
}

+ Here is the caller graph for this function:

static ilECSCourseMappingRule::lookupLastExistingAttribute (   $a_sid,
  $a_mid,
  $a_ref_id 
)
static

Lookup existing attributes.

Parameters
type$a_attributes
Returns
array

Definition at line 42 of file class.ilECSCourseMappingRule.php.

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

Referenced by ilECSMappingSettingsGUI\cInitOverview().

{
global $ilDB;
$query = 'SELECT attribute FROM ecs_cmap_rule '.
'WHERE sid = '.$ilDB->quote($a_sid,'integer').' '.
'AND mid = '.$ilDB->quote($a_mid,'integer').' '.
'AND ref_id = '.$ilDB->quote($a_ref_id,'integer').' '.
'ORDER BY rid ';
$res = $ilDB->query($query);
$attributes = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$attributes = $row->attribute;
}
return $attributes;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::matches (   $course)

Check if rule matches.

Parameters
type$course
Returns
boolean

Definition at line 239 of file class.ilECSCourseMappingRule.php.

References $GLOBALS, getAttribute(), ilECSMappingUtils\getCourseValueByMappingAttribute(), getFilter(), and isFilterEnabled().

{
if($this->isFilterEnabled())
{
include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
$GLOBALS['ilLog']->write(__METHOD__.': Comparing '. $value . ' with ' . $this->getFilter());
return strcmp($value, $this->getFilter()) === 0;
}
return true;
}

+ Here is the call graph for this function:

ilECSCourseMappingRule::read ( )
protected

Read db entries.

Definition at line 441 of file class.ilECSCourseMappingRule.php.

References $query, $res, $row, DB_FETCHMODE_OBJECT, enableFilter(), enableSubdirCreation(), getRuleId(), setAttribute(), setDirectory(), setFilter(), setMid(), setRefId(), setServerId(), and setSubDirectoryType().

Referenced by __construct().

{
global $ilDB;
if(!$this->getRuleId())
{
return true;
}
$query = 'SELECT * from ecs_cmap_rule '.' '.
'WHERE rid = '.$ilDB->quote($this->getRuleId(),'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->setServerId($row->sid);
$this->setMid($row->mid);
$this->setRefId($row->ref_id);
$this->setAttribute($row->attribute);
$this->enableFilter($row->is_filter);
$this->setFilter($row->filter);
$this->enableSubdirCreation($row->create_subdir);
$this->setSubDirectoryType($row->subdir_type);
$this->setDirectory($row->directory);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSCourseMappingRule::save ( )

Save a new rule type $ilDB.

Returns
boolean

Definition at line 394 of file class.ilECSCourseMappingRule.php.

References $query, getAttribute(), getDirectory(), getFilter(), getMid(), getRefId(), getRuleId(), getServerId(), getSubDirectoryType(), isFilterEnabled(), isSubdirCreationEnabled(), and setRuleId().

{
global $ilDB;
$this->setRuleId($ilDB->nextId('ecs_cmap_rule'));
$query = 'INSERT INTO ecs_cmap_rule '.
'(rid,sid,mid,attribute,ref_id,is_filter,filter,create_subdir,subdir_type,directory) '.
'VALUES ('.
$ilDB->quote($this->getRuleId(),'integer').', '.
$ilDB->quote($this->getServerId(),'integer').', '.
$ilDB->quote($this->getMid(),'integer').', '.
$ilDB->quote($this->getAttribute(),'text').', '.
$ilDB->quote($this->getRefId(),'integer').', '.
$ilDB->quote($this->isFilterEnabled(),'integer').', '.
$ilDB->quote($this->getFilter(),'text').', '.
$ilDB->quote($this->isSubdirCreationEnabled(),'integer').', '.
$ilDB->quote($this->getSubDirectoryType(),'integer').', '.
$ilDB->quote($this->getDirectory(),'text').' '.
')';
$ilDB->manipulate($query);
return $this->getRuleId();
}

+ Here is the call graph for this function:

ilECSCourseMappingRule::setAttribute (   $a_att)

Definition at line 309 of file class.ilECSCourseMappingRule.php.

Referenced by read().

{
$this->attribute = $a_att;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::setDirectory (   $a_dir)

Definition at line 369 of file class.ilECSCourseMappingRule.php.

Referenced by read().

{
$this->directory = $a_dir;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::setFilter (   $a_filter)

Definition at line 339 of file class.ilECSCourseMappingRule.php.

Referenced by read().

{
$this->filter = $a_filter;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::setMid (   $a_mid)

Definition at line 299 of file class.ilECSCourseMappingRule.php.

Referenced by read().

{
$this->mid = $a_mid;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::setRefId (   $a_ref_id)

Definition at line 319 of file class.ilECSCourseMappingRule.php.

Referenced by read().

{
$this->ref_id = $a_ref_id;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::setRuleId (   $a_rule_id)

Definition at line 279 of file class.ilECSCourseMappingRule.php.

Referenced by save().

{
$this->rid = $a_rule_id;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::setServerId (   $a_server_id)

Definition at line 289 of file class.ilECSCourseMappingRule.php.

Referenced by read().

{
$this->sid = $a_server_id;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::setSubDirectoryType (   $a_type)

Definition at line 359 of file class.ilECSCourseMappingRule.php.

Referenced by read().

{
$this->subdir_type = $a_type;
}

+ Here is the caller graph for this function:

ilECSCourseMappingRule::update ( )

Update mapping rule type $ilDB.

Definition at line 421 of file class.ilECSCourseMappingRule.php.

References $query, getAttribute(), getDirectory(), getFilter(), getRefId(), getRuleId(), getSubDirectoryType(), isFilterEnabled(), and isSubdirCreationEnabled().

{
global $ilDB;
$query = 'UPDATE ecs_cmap_rule '.' '.
'SET '.
'attribute = '.$ilDB->quote($this->getAttribute(),'text').', '.
'ref_id = '.$ilDB->quote($this->getRefId(),'integer').', '.
'is_filter = '.$ilDB->quote($this->isFilterEnabled(),'integer').', '.
'filter = '.$ilDB->quote($this->getFilter(),'text').', '.
'create_subdir = '.$ilDB->quote($this->isSubdirCreationEnabled(),'integer').', '.
'subdir_type = '.$ilDB->quote($this->getSubDirectoryType(),'integer').', '.
'directory = '.$ilDB->quote($this->getDirectory(),'text').' '.
'WHERE rid = '.$ilDB->quote($this->getRuleId(),'integer');
$ilDB->manipulate($query);
}

+ Here is the call graph for this function:

Field Documentation

ilECSCourseMappingRule::$attribute
private

Definition at line 18 of file class.ilECSCourseMappingRule.php.

Referenced by getAttribute().

ilECSCourseMappingRule::$create_subdir = true
private

Definition at line 22 of file class.ilECSCourseMappingRule.php.

Referenced by isSubdirCreationEnabled().

ilECSCourseMappingRule::$directory = ''
private

Definition at line 24 of file class.ilECSCourseMappingRule.php.

Referenced by getDirectory().

ilECSCourseMappingRule::$filter
private

Definition at line 21 of file class.ilECSCourseMappingRule.php.

Referenced by getFilter().

ilECSCourseMappingRule::$is_filter = false
private

Definition at line 20 of file class.ilECSCourseMappingRule.php.

Referenced by isFilterEnabled().

ilECSCourseMappingRule::$mid
private

Definition at line 17 of file class.ilECSCourseMappingRule.php.

Referenced by getMid().

ilECSCourseMappingRule::$ref_id
private

Definition at line 19 of file class.ilECSCourseMappingRule.php.

Referenced by getRefId().

ilECSCourseMappingRule::$rid
private

Definition at line 15 of file class.ilECSCourseMappingRule.php.

Referenced by getRuleId().

ilECSCourseMappingRule::$sid
private

Definition at line 16 of file class.ilECSCourseMappingRule.php.

Referenced by getServerId().

ilECSCourseMappingRule::$subdir_type = self::SUBDIR_VALUE
private

Definition at line 23 of file class.ilECSCourseMappingRule.php.

const ilECSCourseMappingRule::SUBDIR_ATTRIBUTE_NAME = 1

Definition at line 12 of file class.ilECSCourseMappingRule.php.

const ilECSCourseMappingRule::SUBDIR_VALUE = 2

Definition at line 13 of file class.ilECSCourseMappingRule.php.

Referenced by getSubDirectoryType().


The documentation for this class was generated from the following file: