19 declare(strict_types=1);
97 $this->db = $DIC->database();
110 $cat_id = $this->cat_app_ass[$a_cal_id];
111 $cat_id = $this->cat_substitutions[$cat_id];
113 if (isset($this->appointment_colors[$cat_id])) {
114 return $this->appointment_colors[$cat_id];
115 } elseif (isset($this->cat_substitutions_colors[$cat_id])) {
116 return $this->cat_substitutions_colors[$cat_id];
125 foreach ($this->categories->getCategoriesInfo() as $c_data) {
126 if (isset($c_data[
'subitem_ids']) and count($c_data[
'subitem_ids'])) {
127 foreach ($c_data[
'subitem_ids'] as $sub_item_id) {
128 $this->cat_substitutions[$sub_item_id] = $c_data[
'cat_id'];
131 $this->cat_substitutions[$c_data[
'cat_id']] = $c_data[
'cat_id'];
133 $this->cat_substitutions_colors[$c_data[
'cat_id']] = $c_data[
'color'];
136 $query =
"SELECT cat.cat_id,cat.color, ass.cal_id FROM cal_categories cat " .
137 "JOIN cal_cat_assignments ass ON cat.cat_id = ass.cat_id " .
138 "WHERE " . $this->db->in(
'cat.cat_id', $this->categories->getCategories(
true),
false,
'integer');
140 $res = $this->db->query($query);
142 $this->appointment_colors[$row->cat_id] = $row->color;
143 $this->cat_app_ass[$row->cal_id] = $row->cat_id;
149 $random = new \Random\Randomizer();
150 return self::$colors[$a_type][$random->getInt(0, count(self::$colors[$a_type]) - 1)];
158 return self::$colors[$a_type];
class for calendar categories
ilCalendarCategories $categories
array $cat_substitutions_colors
static _getRandomColorByType(string $a_type)
getColorByAppointment($a_cal_id)
get color by appointment public
static _getInstance($a_usr_id=0)
get singleton instance
array $appointment_colors
static _getColorsByType(string $a_type)
get selectable colors