ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCalendarAppointmentColors Class Reference
+ Collaboration diagram for ilCalendarAppointmentColors:

Public Member Functions

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

Static Public Member Functions

static _getRandomColorByType ($a_type)
 get random color entry for type More...
 
static dumpColors ()
 public More...
 
static _getColorsByType ($a_type)
 get selectable colors More...
 

Protected Attributes

 $db
 
 $user_id
 
 $appointment_colors
 

Static Protected Attributes

static $colors
 

Private Member Functions

 read ()
 read More...
 

Detailed Description

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilCalendarAppointmentColors::__construct (   $a_user_id)

Constructor.

public

Parameters
intuser_id
Returns

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

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

91  {
92  global $DIC;
93 
94  $this->db = $DIC->database();
95  $this->logger = $DIC->logger()->cal();
96 
97  $this->user_id = $a_user_id;
98 
99  $this->categories = ilCalendarCategories::_getInstance();
100  $this->read();
101  }
global $DIC
Definition: saml.php:7
static _getInstance($a_usr_id=0)
get singleton instance
+ Here is the call graph for this function:

Member Function Documentation

◆ _getColorsByType()

static ilCalendarAppointmentColors::_getColorsByType (   $a_type)
static

get selectable colors

public

Parameters

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

References $a_type.

Referenced by ilObjBookingPoolGUI\renderSlots().

209  {
210  return self::$colors[$a_type];
211  }
$a_type
Definition: workflow.php:92
+ Here is the caller graph for this function:

◆ _getRandomColorByType()

static ilCalendarAppointmentColors::_getRandomColorByType (   $a_type)
static

get random color entry for type

public

Parameters

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

References $a_type.

Referenced by ilCalendarAppEventListener\createCategory().

177  {
178  $random = new \ilRandom();
179  return self::$colors[$a_type][$random->int(0, count(self::$colors[$a_type]) - 1)];
180  }
$a_type
Definition: workflow.php:92
+ Here is the caller graph for this function:

◆ dumpColors()

static ilCalendarAppointmentColors::dumpColors ( )
static

public

Parameters

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

191  {
192  foreach (self::$colors['grp'] as $color) {
193  echo '<font color="' . $color . '">HALLO</font><br/>';
194  }
195  foreach (self::$colors['crs'] as $color) {
196  echo '<font color="' . $color . '">HALLO</font><br/>';
197  }
198  }

◆ getColorByAppointment()

ilCalendarAppointmentColors::getColorByAppointment (   $a_cal_id)

get color by appointment

public

Parameters
intcalendar appointment id
Returns

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

111  {
112  //$this->logger->debug("calendar_id = ".$a_cal_id);
113 
114  $cat_id = $this->cat_app_ass[$a_cal_id];
115  //$this->logger->debug("first cat_id ==> ".$cat_id);
116  //$this->logger->debug("color first _cat_id => ".$this->appointment_colors[$cat_id]);
117 
118  $cat_id = $this->cat_substitutions[$cat_id];
119  //$this->logger->debug("second cat_id ==> ".$cat_id);
120  //$this->logger->debug("second color_cat_id => ".$this->appointment_colors[$cat_id]);
121 
122  #21078
123  if (isset($this->appointment_colors[$cat_id])) {
124  return $this->appointment_colors[$cat_id];
125  } elseif (isset($this->cat_substitutions_colors[$cat_id])) {
126  return $this->cat_substitutions_colors[$cat_id];
127  } else {
128  return 'red';
129  }
130  }

◆ read()

ilCalendarAppointmentColors::read ( )
private

read

private

Parameters

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

References $DIC, $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by __construct().

140  {
141  global $DIC;
142 
143  $ilDB = $DIC['ilDB'];
144 
145  // Store assignment of subitem categories
146  foreach ($this->categories->getCategoriesInfo() as $c_data) {
147  if (isset($c_data['subitem_ids']) and count($c_data['subitem_ids'])) {
148  foreach ($c_data['subitem_ids'] as $sub_item_id) {
149  $this->cat_substitutions[$sub_item_id] = $c_data['cat_id'];
150  }
151  }
152  $this->cat_substitutions[$c_data['cat_id']] = $c_data['cat_id'];
153  #21078
154  $this->cat_substitutions_colors[$c_data['cat_id']] = $c_data['color'];
155  }
156 
157  $query = "SELECT cat.cat_id,cat.color, ass.cal_id FROM cal_categories cat " .
158  "JOIN cal_cat_assignments ass ON cat.cat_id = ass.cat_id " .
159  "WHERE " . $ilDB->in('cat.cat_id', $this->categories->getCategories(true), false, 'integer');
160 
161  $res = $this->db->query($query);
162  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
163  $this->appointment_colors[$row->cat_id] = $row->color;
164  $this->cat_app_ass[$row->cal_id] = $row->cat_id;
165  }
166  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

Field Documentation

◆ $appointment_colors

ilCalendarAppointmentColors::$appointment_colors
protected

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

◆ $colors

ilCalendarAppointmentColors::$colors
staticprotected

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

◆ $db

ilCalendarAppointmentColors::$db
protected

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

◆ $user_id

ilCalendarAppointmentColors::$user_id
protected

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


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