ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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. More...
 
 getMappingId ()
 get mapping id More...
 
 setContainerId ($a_id)
 set container id More...
 
 getContainerId ()
 get container id More...
 
 setDateRangeStart ($start)
 set date range start More...
 
 getDateRangeStart ()
 get date range start More...
 
 setDateRangeEnd ($end)
 set date range end More...
 
 getDateRangeEnd ()
 get date range end More...
 
 setFieldName ($a_field)
 set field name More...
 
 getFieldName ()
 get field name More...
 
 setMappingType ($a_type)
 set mapping type More...
 
 getMappingType ()
 get mapping type More...
 
 setMappingValue ($a_value)
 set mapping value More...
 
 getMappingValue ()
 get mapping value More...
 
 getMappingAsArray ()
 get mapping values as array More...
 
 setByType ($a_type)
 set mapping by type More...
 
 getByType ()
 get mapping by type More...
 
 delete ()
 delete rule More...
 
 update ()
 update More...
 
 save ()
 save More...
 
 validate ()
 validate rule More...
 
 conditionToString ()
 condition to string More...
 
 participantsToString ()
 get strong presentation of participants More...
 
 matches (array $a_matchable_content)
 Check if rule matches a specific econtent. More...
 

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 More...
 
 matchesValue ($a_value, $a_type)
 Check if value matches. More...
 
 read ()
 Read entries. More...
 

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

◆ __construct()

ilECSCategoryMappingRule::__construct (   $a_mapping_id = 0)

Constructor.

Parameters
intmapping id

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

References $DIC, $ilDB, and read().

66  {
67  global $DIC;
68 
69  $ilDB = $DIC['ilDB'];
70 
71  $this->mapping_id = $a_mapping_id;
72 
73  $this->db = $ilDB;
74  $this->read();
75  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ conditionToString()

ilECSCategoryMappingRule::conditionToString ( )

condition to string

Returns

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

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

355  {
356  global $DIC;
357 
358  $lng = $DIC['lng'];
359 
360  switch ($this->getMappingType()) {
361  case self::TYPE_FIXED:
362 
363  if ($this->getFieldName() == 'part_id') {
364  return $lng->txt('ecs_field_' . $this->getFieldName()) . ': ' . $this->participantsToString();
365  }
366  return $lng->txt('ecs_field_' . $this->getFieldName()) . ': ' . $this->getMappingValue();
367 
368  case self::TYPE_DURATION:
369  return $lng->txt('ecs_field_' . $this->getFieldName()) . ': ' . ilDatePresentation::formatPeriod(
370  $this->getDateRangeStart(),
371  $this->getDateRangeEnd()
372  );
373 
374  case self::TYPE_BY_TYPE:
375  return $lng->txt('type') . ': ' . $lng->txt('obj_' . $this->getByType());
376  }
377  }
global $DIC
Definition: saml.php:7
$lng
participantsToString()
get strong presentation of participants
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
+ Here is the call graph for this function:

◆ delete()

ilECSCategoryMappingRule::delete ( )

delete rule

Returns

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

References getMappingId().

248  {
249  $sta = $this->db->manipulateF(
250  'DELETE FROM ecs_container_mapping WHERE mapping_id = %s ',
251  array('integer'),
252  array($this->getMappingId())
253  );
254  }
+ Here is the call graph for this function:

◆ getByType()

ilECSCategoryMappingRule::getByType ( )

get mapping by type

Returns
string

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

References $by_type.

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

+ Here is the caller graph for this function:

◆ getContainerId()

ilECSCategoryMappingRule::getContainerId ( )

get container id

Returns

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

References $container_id.

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

+ Here is the caller graph for this function:

◆ getDateRangeEnd()

ilECSCategoryMappingRule::getDateRangeEnd ( )

get date range end

Returns

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

References $range_dt_end, getDateRangeStart(), and IL_CAL_MONTH.

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

149  {
150  if ($this->range_dt_end) {
151  return $this->range_dt_end;
152  }
153  $this->range_dt_end = $this->getDateRangeStart();
154  $this->range_dt_end->increment(IL_CAL_MONTH, 6);
155  return $this->range_dt_end;
156  }
const IL_CAL_MONTH
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDateRangeStart()

ilECSCategoryMappingRule::getDateRangeStart ( )

get date range start

Returns

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

References IL_CAL_UNIX.

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

130  {
131  return $this->range_dt_start ? $this->range_dt_start : new ilDate(time(), IL_CAL_UNIX);
132  }
const IL_CAL_UNIX
Class for single dates.
+ Here is the caller graph for this function:

◆ getFieldName()

ilECSCategoryMappingRule::getFieldName ( )

get field name

Returns

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

References $field_name.

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

+ Here is the caller graph for this function:

◆ getMappingAsArray()

ilECSCategoryMappingRule::getMappingAsArray ( )

get mapping values as array

Returns

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

References getMappingValue().

Referenced by matchesValue().

220  {
221  return explode(',', $this->getMappingValue());
222  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMappingId()

ilECSCategoryMappingRule::getMappingId ( )

get mapping id

Returns

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

References $mapping_id.

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

+ Here is the caller graph for this function:

◆ getMappingType()

ilECSCategoryMappingRule::getMappingType ( )

get mapping type

Returns

Definition at line 191 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:

◆ getMappingValue()

ilECSCategoryMappingRule::getMappingValue ( )

get mapping value

Returns

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

References $mapping_value.

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

+ Here is the caller graph for this function:

◆ matches()

ilECSCategoryMappingRule::matches ( array  $a_matchable_content)

Check if rule matches a specific econtent.

Parameters
array$a_matchable_content
Returns
bool

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

References getFieldName(), and matchesValue().

414  {
415  if (isset($a_matchable_content[$this->getFieldName()])) {
416  $value = $a_matchable_content[$this->getFieldName()];
417  return $this->matchesValue($value[0], $value[1]);
418  }
419  return false;
420  }
matchesValue($a_value, $a_type)
Check if value matches.
+ Here is the call graph for this function:

◆ matchesValue()

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

Check if value matches.

Parameters
mixed$a_valueEcontent value
int$a_typeParameter type
Returns

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

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

Referenced by matches().

429  {
430  global $DIC;
431 
432  $ilLog = $DIC['ilLog'];
433 
434 
435  switch ($a_type) {
436  case self::ATTR_ARRAY:
437  $values = explode(',', $a_value);
438  $ilLog->write(__METHOD__ . ': Checking for value: ' . $a_value);
439  $ilLog->write(__METHOD__ . ': Checking against attribute values: ' . $this->getMappingValue());
440  break;
441 
442  case self::ATTR_INT:
443  $ilLog->write(__METHOD__ . ': Checking for value: ' . $a_value);
444  $ilLog->write(__METHOD__ . ': Checking against attribute values: ' . $this->getMappingValue());
445  $values = array($a_value);
446  break;
447 
448  case self::ATTR_STRING:
449  $values = array($a_value);
450  break;
451  }
452  $values = explode(',', $a_value);
453 
454  foreach ($values as $value) {
455  $value = trim($value);
456  switch ($this->getMappingType()) {
457  case self::TYPE_FIXED:
458 
459  foreach ($this->getMappingAsArray() as $attribute_value) {
460  $attribute_value = trim($attribute_value);
461  if (strcasecmp($attribute_value, $value) == 0) {
462  return true;
463  }
464  }
465  break;
466 
467  case self::TYPE_DURATION:
468  include_once './Services/Calendar/classes/class.ilDateTime.php';
469  $tmp_date = new ilDate($a_value, IL_CAL_UNIX);
470  return ilDateTime::_after($tmp_date, $this->getDateRangeStart()) and
471  ilDateTime::_before($tmp_date, $this->getDateRangeEnd());
472  }
473  }
474  return false;
475  }
global $DIC
Definition: saml.php:7
static _after(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
getMappingAsArray()
get mapping values as array
const IL_CAL_UNIX
$a_type
Definition: workflow.php:92
Class for single dates.
$values
Date and time handling
return['Universal Coordinated Time'=> 'UTC', 'Casablanca, Monrovia'=> 'Africa/Casablanca', 'Greenwich Mean Time:Dublin, Edinburgh, Lisbon, London'=> 'Europe/Lisbon', 'Greenwich Mean Time;Dublin, Edinburgh, London'=> 'Europe/London', 'Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna'=> 'Europe/Berlin', 'Belgrade, Pozsony, Budapest, Ljubljana, Prague'=> 'Europe/Prague', 'Brussels, Copenhagen, Madrid, Paris'=> 'Europe/Paris', 'Paris, Madrid, Brussels, Copenhagen'=> 'Europe/Paris', 'Prague, Central Europe'=> 'Europe/Prague', 'Sarajevo, Skopje, Sofija, Vilnius, Warsaw, Zagreb'=> 'Europe/Sarajevo', 'West Central Africa'=> 'Africa/Luanda', 'Athens, Istanbul, Minsk'=> 'Europe/Athens', 'Bucharest'=> 'Europe/Bucharest', 'Cairo'=> 'Africa/Cairo', 'Harare, Pretoria'=> 'Africa/Harare', 'Helsinki, Riga, Tallinn'=> 'Europe/Helsinki', 'Israel, Jerusalem Standard Time'=> 'Asia/Jerusalem', 'Baghdad'=> 'Asia/Baghdad', 'Arab, Kuwait, Riyadh'=> 'Asia/Kuwait', 'Moscow, St. Petersburg, Volgograd'=> 'Europe/Moscow', 'East Africa, Nairobi'=> 'Africa/Nairobi', 'Tehran'=> 'Asia/Tehran', 'Abu Dhabi, Muscat'=> 'Asia/Muscat', 'Baku, Tbilisi, Yerevan'=> 'Asia/Baku', 'Kabul'=> 'Asia/Kabul', 'Ekaterinburg'=> 'Asia/Yekaterinburg', 'Islamabad, Karachi, Tashkent'=> 'Asia/Karachi', 'Kolkata, Chennai, Mumbai, New Delhi, India Standard Time'=> 'Asia/Calcutta', 'Kathmandu, Nepal'=> 'Asia/Kathmandu', 'Almaty, Novosibirsk, North Central Asia'=> 'Asia/Almaty', 'Astana, Dhaka'=> 'Asia/Dhaka', 'Sri Jayawardenepura, Sri Lanka'=> 'Asia/Colombo', 'Rangoon'=> 'Asia/Rangoon', 'Bangkok, Hanoi, Jakarta'=> 'Asia/Bangkok', 'Krasnoyarsk'=> 'Asia/Krasnoyarsk', 'Beijing, Chongqing, Hong Kong SAR, Urumqi'=> 'Asia/Shanghai', 'Irkutsk, Ulaan Bataar'=> 'Asia/Irkutsk', 'Kuala Lumpur, Singapore'=> 'Asia/Singapore', 'Perth, Western Australia'=> 'Australia/Perth', 'Taipei'=> 'Asia/Taipei', 'Osaka, Sapporo, Tokyo'=> 'Asia/Tokyo', 'Seoul, Korea Standard time'=> 'Asia/Seoul', 'Yakutsk'=> 'Asia/Yakutsk', 'Adelaide, Central Australia'=> 'Australia/Adelaide', 'Darwin'=> 'Australia/Darwin', 'Brisbane, East Australia'=> 'Australia/Brisbane', 'Canberra, Melbourne, Sydney, Hobart(year 2000 only)'=> 'Australia/Sydney', 'Guam, Port Moresby'=> 'Pacific/Guam', 'Hobart, Tasmania'=> 'Australia/Hobart', 'Vladivostok'=> 'Asia/Vladivostok', 'Magadan, Solomon Is., New Caledonia'=> 'Asia/Magadan', 'Auckland, Wellington'=> 'Pacific/Auckland', 'Fiji Islands, Kamchatka, Marshall Is.'=> 'Pacific/Fiji', 'Nuku\ 'alofa, Tonga'=> 'Pacific/Tongatapu', 'Azores'=> 'Atlantic/Azores', 'Cape Verde Is.'=> 'Atlantic/Cape_Verde', 'Mid-Atlantic'=> 'America/Noronha', 'Brasilia'=> 'America/Sao_Paulo', 'Buenos Aires'=> 'America/Argentina/Buenos_Aires', 'Greenland'=> 'America/Godthab', 'Newfoundland'=> 'America/St_Johns', 'Atlantic Time(Canada)'=> 'America/Halifax', 'Caracas, La Paz'=> 'America/Caracas', 'Santiago'=> 'America/Santiago', 'Bogota, Lima, Quito'=> 'America/Bogota', 'Eastern Time(US &Canada)'=> 'America/New_York', 'Indiana(East)'=> 'America/Indiana/Indianapolis', 'Central America'=> 'America/Guatemala', 'Central Time(US &Canada)'=> 'America/Chicago', 'Mexico City, Tegucigalpa'=> 'America/Mexico_City', 'Saskatchewan'=> 'America/Edmonton', 'Arizona'=> 'America/Phoenix', 'Mountain Time(US &Canada)'=> 'America/Denver', 'Pacific Time(US &Canada)'=> 'America/Los_Angeles', 'Pacific Time(US &Canada);Tijuana'=> 'America/Los_Angeles', 'Alaska'=> 'America/Anchorage', 'Hawaii'=> 'Pacific/Honolulu', 'Midway Island, Samoa'=> 'Pacific/Midway', 'Eniwetok, Kwajalein, Dateline Time'=> 'Pacific/Kwajalein',]
Microsoft exchange timezones Source: http://msdn.microsoft.com/en-us/library/ms988620%28v=exchg.65%29.aspx.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ participantsToString()

ilECSCategoryMappingRule::participantsToString ( )

get strong presentation of participants

Parameters

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

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

Referenced by conditionToString().

385  {
386  include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php';
387 
388  $part_string = "";
389  $part = explode(',', $this->getMappingValue());
390  $counter = 0;
391  foreach ($part as $part_id) {
392  if ($counter++) {
393  $part_string .= ', ';
394  }
395  $part_string .= '"';
396 
397  $part_id_arr = explode('_', $part_id);
398  if ($name = ilECSUtils::lookupParticipantName($part_id_arr[1], $part_id_arr[0])) {
399  $part_string .= $name;
400  } else {
401  $part_string .= $part_id;
402  }
403  $part_string .= '"';
404  }
405  return $part_string;
406  }
static lookupParticipantName($a_owner, $a_server_id)
Lookup participant name.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilECSCategoryMappingRule::read ( )
protected

Read entries.

Returns

Definition at line 481 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().

482  {
483  if (!$this->getMappingId()) {
484  return false;
485  }
486  $res = $this->db->queryF(
487  'SELECT * FROM ecs_container_mapping WHERE mapping_id = %s',
488  array('integer'),
489  array($this->getMappingId())
490  );
491  while ($row = $this->db->fetchObject($res)) {
492  $this->setMappingId($row->mapping_id);
493  $this->setDateRangeStart($row->date_range_start ? new ilDate($row->date_range_start, IL_CAL_UNIX) : null);
494  $this->setDateRangeEnd($row->date_range_end ? new ilDate($row->date_range_end, IL_CAL_UNIX) : null);
495  $this->setMappingType($row->mapping_type);
496  $this->setFieldName($row->field_name);
497  $this->setContainerId($row->container_id);
498 
499  if ($this->getMappingType() == self::TYPE_BY_TYPE) {
500  $this->setByType($row->mapping_value);
501  } else {
502  $this->setMappingValue($row->mapping_value);
503  }
504  }
505  return true;
506  }
const IL_CAL_UNIX
setByType($a_type)
set mapping by type
Class for single dates.
foreach($_POST as $key=> $value) $res
setDateRangeStart($start)
set date range start
$row
setMappingValue($a_value)
set mapping value
setMappingType($a_type)
set mapping type
setDateRangeEnd($end)
set date range end
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilECSCategoryMappingRule::save ( )

save

Returns

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

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

294  {
295  global $DIC;
296 
297  $ilDB = $DIC['ilDB'];
298 
299  if ($this->getMappingType() == self::TYPE_BY_TYPE) {
300  $mapping_value = $this->getByType();
301  } else {
302  $mapping_value = $this->getMappingValue();
303  }
304 
305  $mapping_id = $ilDB->nextId('ecs_container_mapping');
306  $sta = $this->db->manipulateF(
307  'INSERT INTO ecs_container_mapping ' .
308  '(mapping_id,container_id,field_name,mapping_type,mapping_value,date_range_start,date_range_end) ' .
309  'VALUES(%s,%s,%s,%s,%s,%s,%s) ',
310  array('integer','integer','text','integer','text','integer','integer'),
311  array(
312  $mapping_id,
313  $this->getContainerId(),
314  $this->getFieldName(),
315  $this->getMappingType(),
317  $this->getDateRangeStart()->get(IL_CAL_UNIX),
318  $this->getDateRangeEnd()->get(IL_CAL_UNIX))
319  );
320  }
global $DIC
Definition: saml.php:7
const IL_CAL_UNIX
global $ilDB
+ Here is the call graph for this function:

◆ setByType()

ilECSCategoryMappingRule::setByType (   $a_type)

set mapping by type

Parameters
string$typeMapping type
Returns

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

References $a_type.

Referenced by read().

230  {
231  $this->by_type = $a_type;
232  }
$a_type
Definition: workflow.php:92
+ Here is the caller graph for this function:

◆ setContainerId()

ilECSCategoryMappingRule::setContainerId (   $a_id)

set container id

Parameters
int$a_id$a_container_id
Returns

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

Referenced by read().

102  {
103  $this->container_id = $a_id;
104  }
+ Here is the caller graph for this function:

◆ setDateRangeEnd()

ilECSCategoryMappingRule::setDateRangeEnd (   $end)

set date range end

Parameters
object$startilDate
Returns

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

References $end.

Referenced by read().

140  {
141  $this->range_dt_end = $end;
142  }
+ Here is the caller graph for this function:

◆ setDateRangeStart()

ilECSCategoryMappingRule::setDateRangeStart (   $start)

set date range start

Parameters
object$startilDate
Returns

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

References $start.

Referenced by read().

121  {
122  $this->range_dt_start = $start;
123  }
$start
Definition: bench.php:8
+ Here is the caller graph for this function:

◆ setFieldName()

ilECSCategoryMappingRule::setFieldName (   $a_field)

set field name

Parameters
string$a_fieldfield name
Returns

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

Referenced by read().

164  {
165  $this->field_name = $a_field;
166  }
+ Here is the caller graph for this function:

◆ setMappingId()

ilECSCategoryMappingRule::setMappingId (   $a_id)
protected

set mapping id

Parameters
int$a_mapping_idmapping id
Returns
void

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

Referenced by read().

83  {
84  $this->mapping_id = $a_id;
85  }
+ Here is the caller graph for this function:

◆ setMappingType()

ilECSCategoryMappingRule::setMappingType (   $a_type)

set mapping type

Parameters
int$typeMapping type
Returns

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

References $a_type.

Referenced by read().

183  {
184  $this->mapping_type = $a_type;
185  }
$a_type
Definition: workflow.php:92
+ Here is the caller graph for this function:

◆ setMappingValue()

ilECSCategoryMappingRule::setMappingValue (   $a_value)

set mapping value

Parameters
string$valMapping value
Returns

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

Referenced by read().

202  {
203  $this->mapping_value = $a_value;
204  }
+ Here is the caller graph for this function:

◆ update()

ilECSCategoryMappingRule::update ( )

update

Returns

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

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

261  {
262  if ($this->getMappingType() == self::TYPE_BY_TYPE) {
263  $mapping_value = $this->getByType();
264  } else {
265  $mapping_value = $this->getMappingValue();
266  }
267 
268  $sta = $this->db->manipulateF(
269  'UPDATE ecs_container_mapping SET ' .
270  'container_id = %s, ' .
271  'field_name = %s, ' .
272  'mapping_type = %s, ' .
273  'mapping_value = %s, ' .
274  'date_range_start = %s,' .
275  'date_range_end = %s ' .
276  'WHERE mapping_id = %s',
277  array('integer','text','integer','text','integer','integer','integer'),
278  array(
279  $this->getContainerId(),
280  $this->getFieldName(),
281  $this->getMappingType(),
283  $this->getDateRangeStart()->get(IL_CAL_UNIX),
284  $this->getDateRangeEnd()->get(IL_CAL_UNIX),
285  $this->getMappingId())
286  );
287  }
const IL_CAL_UNIX
+ Here is the call graph for this function:

◆ validate()

ilECSCategoryMappingRule::validate ( )

validate rule

Returns

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

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

327  {
329  return self::ERR_INVALID_TYPE;
330  }
332  return self::ERR_INVALID_DATES;
333  }
334  if ($this->getMappingType() == self::TYPE_DURATION && !in_array($this->getFieldName(), array('begin', 'end'))) {
335  return self::ERR_MISSING_VALUE;
336  }
337  // handled by form gui?
338  if ($this->getMappingType() == self::TYPE_FIXED and !$this->getMappingValue()) {
339  return self::ERR_MISSING_VALUE;
340  }
341  if ($this->getMappingType() == self::TYPE_BY_TYPE && $this->getFieldName() != 'type') {
342  return self::ERR_MISSING_BY_TYPE;
343  }
344  if ($this->getMappingType() != self::TYPE_BY_TYPE && $this->getFieldName() == 'type') {
345  return self::ERR_MISSING_VALUE;
346  }
347  return 0;
348  }
static _after(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
const IL_CAL_DAY
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:

Field Documentation

◆ $by_type

ilECSCategoryMappingRule::$by_type
private

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

Referenced by getByType().

◆ $container_id

ilECSCategoryMappingRule::$container_id
private

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

Referenced by getContainerId().

◆ $db

ilECSCategoryMappingRule::$db
protected

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

◆ $field_name

ilECSCategoryMappingRule::$field_name
private

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

Referenced by getFieldName().

◆ $mapping_id

ilECSCategoryMappingRule::$mapping_id
private

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

Referenced by getMappingId(), and save().

◆ $mapping_type

ilECSCategoryMappingRule::$mapping_type
private

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

Referenced by getMappingType().

◆ $mapping_value

ilECSCategoryMappingRule::$mapping_value
private

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

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

◆ $range_dt_end

ilECSCategoryMappingRule::$range_dt_end
private

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

Referenced by getDateRangeEnd().

◆ $range_dt_start

ilECSCategoryMappingRule::$range_dt_start
private

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

◆ ATTR_ARRAY

const ilECSCategoryMappingRule::ATTR_ARRAY = 3

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

Referenced by ilECSUtils\getMatchableContent().

◆ ATTR_INT

const ilECSCategoryMappingRule::ATTR_INT = 2

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

Referenced by ilECSUtils\getMatchableContent().

◆ ATTR_STRING

const ilECSCategoryMappingRule::ATTR_STRING = 1

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

Referenced by ilECSUtils\getMatchableContent().

◆ ERR_INVALID_DATES

const ilECSCategoryMappingRule::ERR_INVALID_DATES = 'ecs_err_invalid_dates'

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

◆ ERR_INVALID_TYPE

const ilECSCategoryMappingRule::ERR_INVALID_TYPE = 'ecs_err_invalid_type'

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

◆ ERR_MISSING_BY_TYPE

const ilECSCategoryMappingRule::ERR_MISSING_BY_TYPE = 'ecs_err_invalid_by_type'

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

◆ ERR_MISSING_VALUE

const ilECSCategoryMappingRule::ERR_MISSING_VALUE = 'ecs_err_missing_value'

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

◆ TYPE_BY_TYPE

const ilECSCategoryMappingRule::TYPE_BY_TYPE = 2

◆ TYPE_DURATION

const ilECSCategoryMappingRule::TYPE_DURATION = 1

◆ TYPE_FIXED


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