ILIAS  release_8 Revision v8.23
ilCalendarAppointmentColors Class Reference
+ Collaboration diagram for ilCalendarAppointmentColors:

Public Member Functions

 __construct ($a_user_id)
 
 getColorByAppointment ($a_cal_id)
 get color by appointment public More...
 

Static Public Member Functions

static _getRandomColorByType (string $a_type)
 
static _getColorsByType (string $a_type)
 get selectable colors More...
 

Protected Attributes

ilDBInterface $db
 
ilCalendarCategories $categories
 

Static Protected Attributes

static array $colors
 

Private Member Functions

 read ()
 

Private Attributes

array $appointment_colors = []
 
array $cat_substitutions_colors = []
 
array $cat_substitutions = []
 
array $cat_app_ass = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCalendarAppointmentColors::__construct (   $a_user_id)

Definition at line 99 of file class.ilCalendarAppointmentColors.php.

References $DIC, ilCalendarCategories\_getInstance(), and read().

100  {
101  global $DIC;
102 
103  $this->db = $DIC->database();
104  $this->categories = ilCalendarCategories::_getInstance();
105  $this->read();
106  }
global $DIC
Definition: feed.php:28
static _getInstance($a_usr_id=0)
get singleton instance
+ Here is the call graph for this function:

Member Function Documentation

◆ _getColorsByType()

static ilCalendarAppointmentColors::_getColorsByType ( string  $a_type)
static

get selectable colors

Definition at line 162 of file class.ilCalendarAppointmentColors.php.

Referenced by ilBookingProcessGUI\book().

162  : array
163  {
164  return self::$colors[$a_type];
165  }
+ Here is the caller graph for this function:

◆ _getRandomColorByType()

static ilCalendarAppointmentColors::_getRandomColorByType ( string  $a_type)
static

Definition at line 153 of file class.ilCalendarAppointmentColors.php.

Referenced by ilCalendarAppEventListener\createCategory().

153  : string
154  {
155  $random = new \ilRandom();
156  return self::$colors[$a_type][$random->int(0, count(self::$colors[$a_type]) - 1)];
157  }
+ Here is the caller graph for this function:

◆ getColorByAppointment()

ilCalendarAppointmentColors::getColorByAppointment (   $a_cal_id)

get color by appointment public

Parameters
intcalendar appointment id
Returns

Definition at line 114 of file class.ilCalendarAppointmentColors.php.

115  {
116  $cat_id = $this->cat_app_ass[$a_cal_id];
117  $cat_id = $this->cat_substitutions[$cat_id];
118  #21078
119  if (isset($this->appointment_colors[$cat_id])) {
120  return $this->appointment_colors[$cat_id];
121  } elseif (isset($this->cat_substitutions_colors[$cat_id])) {
122  return $this->cat_substitutions_colors[$cat_id];
123  } else {
124  return 'red';
125  }
126  }

◆ read()

ilCalendarAppointmentColors::read ( )
private

Definition at line 128 of file class.ilCalendarAppointmentColors.php.

References $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by __construct().

129  {
130  // Store assignment of subitem categories
131  foreach ($this->categories->getCategoriesInfo() as $c_data) {
132  if (isset($c_data['subitem_ids']) and count($c_data['subitem_ids'])) {
133  foreach ($c_data['subitem_ids'] as $sub_item_id) {
134  $this->cat_substitutions[$sub_item_id] = $c_data['cat_id'];
135  }
136  }
137  $this->cat_substitutions[$c_data['cat_id']] = $c_data['cat_id'];
138  #21078
139  $this->cat_substitutions_colors[$c_data['cat_id']] = $c_data['color'];
140  }
141 
142  $query = "SELECT cat.cat_id,cat.color, ass.cal_id FROM cal_categories cat " .
143  "JOIN cal_cat_assignments ass ON cat.cat_id = ass.cat_id " .
144  "WHERE " . $this->db->in('cat.cat_id', $this->categories->getCategories(true), false, 'integer');
145 
146  $res = $this->db->query($query);
147  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
148  $this->appointment_colors[$row->cat_id] = $row->color;
149  $this->cat_app_ass[$row->cal_id] = $row->cat_id;
150  }
151  }
$res
Definition: ltiservices.php:69
$query
+ Here is the caller graph for this function:

Field Documentation

◆ $appointment_colors

array ilCalendarAppointmentColors::$appointment_colors = []
private

Definition at line 94 of file class.ilCalendarAppointmentColors.php.

◆ $cat_app_ass

array ilCalendarAppointmentColors::$cat_app_ass = []
private

Definition at line 97 of file class.ilCalendarAppointmentColors.php.

◆ $cat_substitutions

array ilCalendarAppointmentColors::$cat_substitutions = []
private

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

◆ $cat_substitutions_colors

array ilCalendarAppointmentColors::$cat_substitutions_colors = []
private

Definition at line 95 of file class.ilCalendarAppointmentColors.php.

◆ $categories

ilCalendarCategories ilCalendarAppointmentColors::$categories
protected

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

◆ $colors

array ilCalendarAppointmentColors::$colors
staticprotected

Definition at line 32 of file class.ilCalendarAppointmentColors.php.

◆ $db

ilDBInterface ilCalendarAppointmentColors::$db
protected

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


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