ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 206 of file class.ilCalendarAppointmentColors.php.

References $a_type.

Referenced by ilObjBookingPoolGUI\renderSlots().

207  {
208  return self::$colors[$a_type];
209  }
$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 174 of file class.ilCalendarAppointmentColors.php.

References $a_type.

Referenced by ilCalendarAppEventListener\createCategory().

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

◆ dumpColors()

static ilCalendarAppointmentColors::dumpColors ( )
static

public

Parameters

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

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

◆ 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 $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by __construct().

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