ILIAS  Release_5_0_x_branch Revision 61816
 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
 setByType ($a_type)
 set mapping by type
 getByType ()
 get mapping by type
 delete ()
 delete rule
 update ()
 update
 save ()
 save
 validate ()
 validate rule
 conditionToString ()
 condition to string
 participantsToString ()
 get strong presentation of participants
 matches (array $a_matchable_content)
 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 TYPE_BY_TYPE = 2
const ERR_MISSING_VALUE = 'ecs_err_missing_value'
const ERR_INVALID_DATES = 'ecs_err_invalid_dates'
const ERR_INVALID_TYPE = 'ecs_err_invalid_type'
const ERR_MISSING_BY_TYPE = 'ecs_err_invalid_by_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
 $by_type

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 65 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 362 of file class.ilECSCategoryMappingRule.php.

References $lng, ilDatePresentation\formatPeriod(), getByType(), 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());
case self::TYPE_BY_TYPE:
return $lng->txt('type').': '.$lng->txt('obj_'.$this->getByType());
}
}

+ Here is the call graph for this function:

ilECSCategoryMappingRule::delete ( )

delete rule

Returns

Definition at line 246 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::getByType ( )

get mapping by type

Returns
string

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

References $by_type.

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

{
return $this->by_type;
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::getContainerId ( )

get container id

Returns

Definition at line 108 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 146 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 127 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 171 of file class.ilECSCategoryMappingRule.php.

References $field_name.

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

{
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::getMappingAsArray ( )

get mapping values as array

Returns

Definition at line 218 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 89 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 190 of file class.ilECSCategoryMappingRule.php.

References $mapping_type.

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

{
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::getMappingValue ( )

get mapping value

Returns

Definition at line 209 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 ( array  $a_matchable_content)

Check if rule matches a specific econtent.

Parameters
array$a_matchable_content
Returns
bool

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

References getFieldName(), and matchesValue().

{
if(isset($a_matchable_content[$this->getFieldName()]))
{
$value = $a_matchable_content[$this->getFieldName()];
return $this->matchesValue($value[0], $value[1]);
}
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 442 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 392 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 .= '"';
$part_id_arr = explode('_', $part_id);
if($name = ilECSUtils::lookupParticipantName($part_id_arr[1],$part_id_arr[0]))
{
$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 498 of file class.ilECSCategoryMappingRule.php.

References $res, $row, getMappingId(), getMappingType(), IL_CAL_UNIX, setByType(), 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->setFieldName($row->field_name);
$this->setContainerId($row->container_id);
if($this->getMappingType() == self::TYPE_BY_TYPE)
{
$this->setByType($row->mapping_value);
}
else
{
$this->setMappingValue($row->mapping_value);
}
}
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 294 of file class.ilECSCategoryMappingRule.php.

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

{
global $ilDB;
if($this->getMappingType() == self::TYPE_BY_TYPE)
{
}
else
{
}
$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->getDateRangeEnd()->get(IL_CAL_UNIX))
);
}

+ Here is the call graph for this function:

ilECSCategoryMappingRule::setByType (   $a_type)

set mapping by type

Parameters
string$typeMapping type
Returns

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

Referenced by read().

{
$this->by_type = $a_type;
}

+ Here is the caller graph for this function:

ilECSCategoryMappingRule::setContainerId (   $a_id)

set container id

Parameters
int$a_id$a_container_id
Returns

Definition at line 99 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 137 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 118 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 162 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 80 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 181 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 200 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 258 of file class.ilECSCategoryMappingRule.php.

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

{
if($this->getMappingType() == self::TYPE_BY_TYPE)
{
}
else
{
}
$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->getDateRangeEnd()->get(IL_CAL_UNIX),
$this->getMappingId())
);
}

+ Here is the call graph for this function:

ilECSCategoryMappingRule::validate ( )

validate rule

Returns

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

References ilDateTime\_after(), ilObject\_lookupObjId(), ilObject\_lookupType(), ERR_INVALID_DATES, ERR_INVALID_TYPE, ERR_MISSING_BY_TYPE, ERR_MISSING_VALUE, getContainerId(), getDateRangeEnd(), getDateRangeStart(), getFieldName(), getMappingType(), getMappingValue(), and IL_CAL_DAY.

{
{
}
{
}
if($this->getMappingType() == self::TYPE_DURATION && !in_array($this->getFieldName(), array('begin', 'end')))
{
}
// handled by form gui?
if($this->getMappingType() == self::TYPE_FIXED and !$this->getMappingValue())
{
}
if($this->getMappingType() == self::TYPE_BY_TYPE && $this->getFieldName() != 'type')
{
}
if($this->getMappingType() != self::TYPE_BY_TYPE && $this->getFieldName() == 'type')
{
}
return 0;
}

+ Here is the call graph for this function:

Field Documentation

ilECSCategoryMappingRule::$by_type
private

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

Referenced by getByType().

ilECSCategoryMappingRule::$container_id
private

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

Referenced by getContainerId().

ilECSCategoryMappingRule::$db
protected

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

ilECSCategoryMappingRule::$field_name
private

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

Referenced by getFieldName().

ilECSCategoryMappingRule::$mapping_id
private

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

Referenced by getMappingId(), and save().

ilECSCategoryMappingRule::$mapping_type
private

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

Referenced by getMappingType().

ilECSCategoryMappingRule::$mapping_value
private

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

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

ilECSCategoryMappingRule::$range_dt_end
private

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

Referenced by getDateRangeEnd().

ilECSCategoryMappingRule::$range_dt_start
private

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

const ilECSCategoryMappingRule::ATTR_ARRAY = 3

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

Referenced by ilECSUtils\getMatchableContent().

const ilECSCategoryMappingRule::ATTR_INT = 2

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

Referenced by ilECSUtils\getMatchableContent().

const ilECSCategoryMappingRule::ATTR_STRING = 1

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

Referenced by ilECSUtils\getMatchableContent().

const ilECSCategoryMappingRule::ERR_INVALID_DATES = 'ecs_err_invalid_dates'

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

Referenced by validate().

const ilECSCategoryMappingRule::ERR_INVALID_TYPE = 'ecs_err_invalid_type'

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

Referenced by validate().

const ilECSCategoryMappingRule::ERR_MISSING_BY_TYPE = 'ecs_err_invalid_by_type'

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

Referenced by validate().

const ilECSCategoryMappingRule::ERR_MISSING_VALUE = 'ecs_err_missing_value'

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

Referenced by validate().

const ilECSCategoryMappingRule::TYPE_BY_TYPE = 2
const ilECSCategoryMappingRule::TYPE_DURATION = 1

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