ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilECSCategoryMappingRule Class Reference

Defines a rule for the assignment of ECS remote courses to categories. More...

+ Collaboration diagram for ilECSCategoryMappingRule:

Public Member Functions

 __construct ($a_mapping_id=0)
 Constructor.
 getMappingId ()
 get mapping id
 setContainerId ($a_id)
 set container id
 getContainerId ()
 get container id
 setDateRangeStart ($start)
 set date range start
 getDateRangeStart ()
 get date range start
 setDateRangeEnd ($end)
 set date range end
 getDateRangeEnd ()
 get date range end
 setFieldName ($a_field)
 set field name
 getFieldName ()
 get field name
 setMappingType ($a_type)
 set mapping type
 getMappingType ()
 get mapping type
 setMappingValue ($a_value)
 set mapping value
 getMappingValue ()
 get mapping value
 getMappingAsArray ()
 get mapping values as array
 delete ()
 delete rule
 update ()
 update
 save ()
 save
 validate ()
 validate rule
 conditionToString ()
 condition to string
 participantsToString ()
 get strong presentation of participants
 matches ($a_server_id, ilECSEcontent $econtent)
 Check if rule matches a specific econtent.

Data Fields

const ATTR_STRING = 1
const ATTR_INT = 2
const ATTR_ARRAY = 3
const TYPE_FIXED = 0
const TYPE_DURATION = 1
const ERR_MISSING_VALUE = 'ecs_err_missing_value'
const ERR_INVALID_DATES = 'ecs_err_invalid_dates'
const ERR_INVALID_TYPE = 'ecs_err_invalid_type'

Protected Member Functions

 setMappingId ($a_id)
 set mapping id
 matchesValue ($a_value, $a_type)
 Check if value matches.
 read ()
 Read entries.

Protected Attributes

 $db

Private Attributes

 $mapping_id
 $container_id
 $field_name
 $mapping_type
 $mapping_value
 $range_dt_start
 $range_dt_end

Detailed Description

Defines a rule for the assignment of ECS remote courses to categories.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 35 of file class.ilECSCategoryMappingRule.php.

Constructor & Destructor Documentation

ilECSCategoryMappingRule::__construct (   $a_mapping_id = 0)

Constructor.

Parameters
intmapping id

Definition at line 62 of file class.ilECSCategoryMappingRule.php.

References $ilDB, and read().

{
global $ilDB;
$this->mapping_id = $a_mapping_id;
$this->db = $ilDB;
$this->read();
}

+ Here is the call graph for this function:

Member Function Documentation

ilECSCategoryMappingRule::conditionToString ( )

condition to string

Returns

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

References $lng, ilDatePresentation\formatPeriod(), getDateRangeEnd(), getDateRangeStart(), getFieldName(), getMappingType(), getMappingValue(), and participantsToString().

{
global $lng;
switch($this->getMappingType())
{
case self::TYPE_FIXED:
if($this->getFieldName() == 'part_id')
{
return $lng->txt('ecs_field_'.$this->getFieldName()).': '.$this->participantsToString();
}
return $lng->txt('ecs_field_'.$this->getFieldName()).': '.$this->getMappingValue();
case self::TYPE_DURATION:
include_once './Services/Calendar/classes/class.ilDatePresentation.php';
return $lng->txt('ecs_field_'.$this->getFieldName()).': '.ilDatePresentation::formatPeriod(
$this->getDateRangeEnd());
}
}

+ Here is the call graph for this function:

ilECSCategoryMappingRule::delete ( )

delete rule

Returns

Definition at line 224 of file class.ilECSCategoryMappingRule.php.

References getMappingId().

{
$sta = $this->db->manipulateF('DELETE FROM ecs_container_mapping WHERE mapping_id = %s ',
array('integer'),
array($this->getMappingId())
);
}

+ Here is the call graph for this function:

ilECSCategoryMappingRule::getContainerId ( )

get container id

Returns

Definition at line 105 of file class.ilECSCategoryMappingRule.php.

References $container_id.

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

{
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::getDateRangeEnd ( )

get date range end

Returns

Definition at line 143 of file class.ilECSCategoryMappingRule.php.

References $range_dt_end, getDateRangeStart(), and IL_CAL_MONTH.

Referenced by conditionToString(), matchesValue(), save(), update(), and validate().

{
if($this->range_dt_end)
{
}
$this->range_dt_end = $this->getDateRangeStart();
$this->range_dt_end->increment(IL_CAL_MONTH,6);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::getDateRangeStart ( )

get date range start

Returns

Definition at line 124 of file class.ilECSCategoryMappingRule.php.

References IL_CAL_UNIX.

Referenced by conditionToString(), getDateRangeEnd(), matchesValue(), save(), update(), and validate().

{
return $this->range_dt_start ? $this->range_dt_start : new ilDate(time(),IL_CAL_UNIX);
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::getFieldName ( )

get field name

Returns

Definition at line 168 of file class.ilECSCategoryMappingRule.php.

References $field_name.

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

{
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::getMappingAsArray ( )

get mapping values as array

Returns

Definition at line 215 of file class.ilECSCategoryMappingRule.php.

References getMappingValue().

Referenced by matchesValue().

{
return explode(',',$this->getMappingValue());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::getMappingId ( )

get mapping id

Returns

Definition at line 86 of file class.ilECSCategoryMappingRule.php.

References $mapping_id.

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

{
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::getMappingType ( )

get mapping type

Returns

Definition at line 187 of file class.ilECSCategoryMappingRule.php.

References $mapping_type.

Referenced by conditionToString(), matchesValue(), save(), update(), and validate().

{
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::getMappingValue ( )

get mapping value

Returns

Definition at line 206 of file class.ilECSCategoryMappingRule.php.

References $mapping_value.

Referenced by conditionToString(), getMappingAsArray(), participantsToString(), save(), update(), and validate().

{
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::matches (   $a_server_id,
ilECSEcontent  $econtent 
)

Check if rule matches a specific econtent.

Parameters
object$econtentilECSEContent
Returns
bool

Definition at line 368 of file class.ilECSCategoryMappingRule.php.

References $ilLog, ATTR_ARRAY, ATTR_INT, ATTR_STRING, getFieldName(), ilECSCommunitiesCache\getInstance(), and matchesValue().

{
global $ilLog;
switch($this->getFieldName())
{
case 'study_courses':
return $this->matchesValue($econtent->getStudyCourses(),self::ATTR_ARRAY);
case 'part_id':
return $this->matchesValue($econtent->getOwner(),self::ATTR_INT);
case 'begin':
if(!is_object($econtent->getTimePlace()))
{
return false;
}
return $this->matchesValue($econtent->getTimePlace()->getUTBegin(),self::ATTR_INT);
case 'courseType':
return $this->matchesValue($econtent->getCourseType(),self::ATTR_STRING);
case 'term':
return $this->matchesValue($econtent->getTerm(),self::ATTR_STRING);
case 'credits':
return $this->matchesValue($econtent->getCredits(),self::ATTR_STRING);
case 'community':
include_once './Services/WebServices/ECS/classes/class.ilECSCommunitiesCache.php';
return $this->matchesValue(
ilECSCommunitiesCache::getInstance()->lookupTitle($a_server_id, $econtent->getOwner()),
self::ATTR_STRING
);
}
return false;
}

+ Here is the call graph for this function:

ilECSCategoryMappingRule::matchesValue (   $a_value,
  $a_type 
)
protected

Check if value matches.

Parameters
mixed$a_valueEcontent value
int$a_typeParameter type
Returns

Definition at line 412 of file class.ilECSCategoryMappingRule.php.

References $ilLog, ilDateTime\_after(), ilDateTime\_before(), getDateRangeEnd(), getDateRangeStart(), getMappingAsArray(), getMappingType(), and IL_CAL_UNIX.

Referenced by matches().

{
global $ilLog;
switch($a_type)
{
case self::ATTR_ARRAY:
$values = explode(',',$a_value);
$ilLog->write(__METHOD__.': Checking for value: '. $a_value);
$ilLog->write(__METHOD__.': Checking against attribute values: '. $this->getMappingValue());
break;
case self::ATTR_INT:
$ilLog->write(__METHOD__.': Checking for value: '. $a_value);
$ilLog->write(__METHOD__.': Checking against attribute values: '. $this->getMappingValue());
$values = array($a_value);
break;
case self::ATTR_STRING:
$values = array($a_value);
break;
}
$values = explode(',',$a_value);
foreach($values as $value)
{
$value = trim($value);
switch($this->getMappingType())
{
case self::TYPE_FIXED:
foreach($this->getMappingAsArray() as $attribute_value)
{
$attribute_value = trim($attribute_value);
if(strcasecmp($attribute_value,$value) == 0)
{
return true;
}
}
break;
case self::TYPE_DURATION:
include_once './Services/Calendar/classes/class.ilDateTime.php';
$tmp_date = new ilDate($a_value,IL_CAL_UNIX);
return ilDateTime::_after($tmp_date,$this->getDateRangeStart()) and
ilDateTime::_before($tmp_date,$this->getDateRangeEnd());
}
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::participantsToString ( )

get strong presentation of participants

Parameters
@return

Definition at line 336 of file class.ilECSCategoryMappingRule.php.

References getMappingValue(), and ilECSUtils\lookupParticipantName().

Referenced by conditionToString().

{
include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php';
$part_string = "";
$part = explode(',',$this->getMappingValue());
$counter = 0;
foreach($part as $part_id)
{
if($counter++)
{
$part_string .= ', ';
}
$part_string .= '"';
if($name = ilECSUtils::lookupParticipantName($part_id))
{
$part_string .= $name;
}
else
{
$part_string .= $part_id;
}
$part_string .= '"';
}
return $part_string;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::read ( )
protected

Read entries.

Returns

Definition at line 468 of file class.ilECSCategoryMappingRule.php.

References $res, $row, getMappingId(), IL_CAL_UNIX, setContainerId(), setDateRangeEnd(), setDateRangeStart(), setFieldName(), setMappingId(), setMappingType(), and setMappingValue().

Referenced by __construct().

{
if(!$this->getMappingId())
{
return false;
}
$res = $this->db->queryF('SELECT * FROM ecs_container_mapping WHERE mapping_id = %s',
array('integer'),
array($this->getMappingId())
);
while($row = $this->db->fetchObject($res))
{
$this->setMappingId($row->mapping_id);
$this->setDateRangeStart($row->date_range_start ? new ilDate($row->date_range_start,IL_CAL_UNIX) : null);
$this->setDateRangeEnd($row->date_range_end ? new ilDate($row->date_range_end,IL_CAL_UNIX) : null);
$this->setMappingType($row->mapping_type);
$this->setMappingValue($row->mapping_value);
$this->setFieldName($row->field_name);
$this->setContainerId($row->container_id);
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::save ( )

save

Returns

Definition at line 263 of file class.ilECSCategoryMappingRule.php.

References $ilDB, $mapping_id, getContainerId(), getDateRangeEnd(), getDateRangeStart(), getFieldName(), getMappingType(), getMappingValue(), and IL_CAL_UNIX.

{
global $ilDB;
$mapping_id = $ilDB->nextId('ecs_container_mapping');
$sta = $this->db->manipulateF(
'INSERT INTO ecs_container_mapping '.
'(mapping_id,container_id,field_name,mapping_type,mapping_value,date_range_start,date_range_end) '.
'VALUES(%s,%s,%s,%s,%s,%s,%s) ',
array('integer','integer','text','integer','text','integer','integer'),
array(
$this->getContainerId(),
$this->getFieldName(),
$this->getMappingType(),
$this->getMappingValue(),
$this->getDateRangeEnd()->get(IL_CAL_UNIX))
);
}

+ Here is the call graph for this function:

ilECSCategoryMappingRule::setContainerId (   $a_id)

set container id

Parameters
int$a_id$a_container_id
Returns

Definition at line 96 of file class.ilECSCategoryMappingRule.php.

Referenced by read().

{
$this->container_id = $a_id;
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::setDateRangeEnd (   $end)

set date range end

Parameters
object$startilDate
Returns

Definition at line 134 of file class.ilECSCategoryMappingRule.php.

Referenced by read().

{
$this->range_dt_end = $end;
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::setDateRangeStart (   $start)

set date range start

Parameters
object$startilDate
Returns

Definition at line 115 of file class.ilECSCategoryMappingRule.php.

Referenced by read().

{
$this->range_dt_start = $start;
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::setFieldName (   $a_field)

set field name

Parameters
string$a_fieldfield name
Returns

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

Referenced by read().

{
$this->field_name = $a_field;
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::setMappingId (   $a_id)
protected

set mapping id

Parameters
int$a_mapping_idmapping id
Returns
void

Definition at line 77 of file class.ilECSCategoryMappingRule.php.

Referenced by read().

{
$this->mapping_id = $a_id;
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::setMappingType (   $a_type)

set mapping type

Parameters
int$typeMapping type
Returns

Definition at line 178 of file class.ilECSCategoryMappingRule.php.

Referenced by read().

{
$this->mapping_type = $a_type;
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::setMappingValue (   $a_value)

set mapping value

Parameters
string$valMapping value
Returns

Definition at line 197 of file class.ilECSCategoryMappingRule.php.

Referenced by read().

{
$this->mapping_value = $a_value;
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::update ( )

update

Returns

Definition at line 236 of file class.ilECSCategoryMappingRule.php.

References getContainerId(), getDateRangeEnd(), getDateRangeStart(), getFieldName(), getMappingId(), getMappingType(), getMappingValue(), and IL_CAL_UNIX.

{
$sta = $this->db->manipulateF(
'UPDATE ecs_container_mapping SET '.
'container_id = %s, '.
'field_name = %s, '.
'mapping_type = %s, '.
'mapping_value = %s, '.
'date_range_start = %s,'.
'date_range_end = %s '.
'WHERE mapping_id = %s',
array('integer','text','integer','text','integer','integer','integer'),
array(
$this->getContainerId(),
$this->getFieldName(),
$this->getMappingType(),
$this->getMappingValue(),
$this->getDateRangeEnd()->get(IL_CAL_UNIX),
$this->getMappingId())
);
}

+ Here is the call graph for this function:

ilECSCategoryMappingRule::validate ( )

Field Documentation

ilECSCategoryMappingRule::$container_id
private

Definition at line 51 of file class.ilECSCategoryMappingRule.php.

Referenced by getContainerId().

ilECSCategoryMappingRule::$db
protected

Definition at line 48 of file class.ilECSCategoryMappingRule.php.

ilECSCategoryMappingRule::$field_name
private

Definition at line 52 of file class.ilECSCategoryMappingRule.php.

Referenced by getFieldName().

ilECSCategoryMappingRule::$mapping_id
private

Definition at line 50 of file class.ilECSCategoryMappingRule.php.

Referenced by getMappingId(), and save().

ilECSCategoryMappingRule::$mapping_type
private

Definition at line 53 of file class.ilECSCategoryMappingRule.php.

Referenced by getMappingType().

ilECSCategoryMappingRule::$mapping_value
private

Definition at line 54 of file class.ilECSCategoryMappingRule.php.

Referenced by getMappingValue().

ilECSCategoryMappingRule::$range_dt_end
private

Definition at line 56 of file class.ilECSCategoryMappingRule.php.

Referenced by getDateRangeEnd().

ilECSCategoryMappingRule::$range_dt_start
private

Definition at line 55 of file class.ilECSCategoryMappingRule.php.

const ilECSCategoryMappingRule::ATTR_ARRAY = 3

Definition at line 39 of file class.ilECSCategoryMappingRule.php.

Referenced by matches().

const ilECSCategoryMappingRule::ATTR_INT = 2

Definition at line 38 of file class.ilECSCategoryMappingRule.php.

Referenced by matches().

const ilECSCategoryMappingRule::ATTR_STRING = 1

Definition at line 37 of file class.ilECSCategoryMappingRule.php.

Referenced by matches().

const ilECSCategoryMappingRule::ERR_INVALID_DATES = 'ecs_err_invalid_dates'

Definition at line 45 of file class.ilECSCategoryMappingRule.php.

Referenced by validate().

const ilECSCategoryMappingRule::ERR_INVALID_TYPE = 'ecs_err_invalid_type'

Definition at line 46 of file class.ilECSCategoryMappingRule.php.

Referenced by validate().

const ilECSCategoryMappingRule::ERR_MISSING_VALUE = 'ecs_err_missing_value'

Definition at line 44 of file class.ilECSCategoryMappingRule.php.

Referenced by validate().

const ilECSCategoryMappingRule::TYPE_DURATION = 1
const ilECSCategoryMappingRule::TYPE_FIXED = 0

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