ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCalendarVisibility Class Reference

Stores selection of hidden calendars for a specific user. More...

+ Collaboration diagram for ilCalendarVisibility:

Public Member Functions

 filterHidden ($categories, $category_info)
 Filter hidden categories (and hidden subitem categories) from category array. More...
 
 isAppointmentVisible ($a_cal_id)
 check whether an appoinment is visible or not More...
 
 getHidden ()
 get hidden categories More...
 
 getVisible ()
 get visible categories More...
 
 hideSelected ($a_hidden)
 hide selected More...
 
 showSelected ($a_visible)
 Show selected. More...
 
 save ()
 save hidden selection More...
 
 delete ($a_cat_id=null)
 delete More...
 
 forceVisibility ($a_cat_id)
 Force visibility. More...
 

Static Public Member Functions

static _getInstanceByUserId ($a_user_id, $a_ref_id=0)
 get instance by user id More...
 
static _deleteCategories ($a_cat_id)
 delete by category More...
 
static _deleteUser ($a_user_id)
 Delete by user. More...
 

Data Fields

const HIDDEN = 0
 
const VISIBLE = 1
 

Protected Member Functions

 isHidden ($a_cat_id, $info)
 Check if category is hidden. More...
 
 read ()
 read user selection More...
 

Protected Attributes

 $user_id
 
 $hidden = array()
 
 $visible = array()
 
 $db
 

Static Protected Attributes

static $instances = array()
 

Private Member Functions

 __construct ($a_user_id, $a_ref_id=0)
 Constructor. More...
 

Detailed Description

Stores selection of hidden calendars for a specific user.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilCalendarVisibility::__construct (   $a_user_id,
  $a_ref_id = 0 
)
private

Constructor.

Parameters
int$a_user_iduser id
int$a_ref_idobject ref id
intuser id

Definition at line 69 of file class.ilCalendarVisibility.php.

References $DIC, ilObject\_lookupObjId(), and read().

70  {
71  global $DIC;
72  $this->db = $DIC->database();
73  $this->user_id = $a_user_id;
74  $this->ref_id = $a_ref_id;
75  $this->obj_id = ilObject::_lookupObjId($a_ref_id);
76  $this->read();
77  }
global $DIC
Definition: saml.php:7
static _lookupObjId($a_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteCategories()

static ilCalendarVisibility::_deleteCategories (   $a_cat_id)
static

delete by category

public

Parameters
intcategory id

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

References $DIC, $ilDB, and $query.

Referenced by ilCalendarCategory\delete().

102  {
103  global $DIC;
104 
105  $ilDB = $DIC->database();
106 
107  $query = "DELETE FROM cal_cat_visibility " .
108  "WHERE cat_id = " . $ilDB->quote($a_cat_id, 'integer') . " ";
109  $ilDB->manipulate($query);
110  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _deleteUser()

static ilCalendarVisibility::_deleteUser (   $a_user_id)
static

Delete by user.

public

Parameters
int$a_user_iduser_id

Definition at line 119 of file class.ilCalendarVisibility.php.

References $DIC, $ilDB, and $query.

120  {
121  global $DIC;
122 
123  $ilDB = $DIC->database();
124 
125  $query = "DELETE FROM cal_cat_visibility " .
126  "WHERE user_id = " . $ilDB->quote($a_user_id, 'integer') . " ";
127  $ilDB->manipulate($query);
128  }
global $DIC
Definition: saml.php:7
$query
global $ilDB

◆ _getInstanceByUserId()

static ilCalendarVisibility::_getInstanceByUserId (   $a_user_id,
  $a_ref_id = 0 
)
static

get instance by user id

Parameters
int$a_user_iduser id
int$a_ref_idobject ref id
Returns
ilCalendarVisibility

Definition at line 86 of file class.ilCalendarVisibility.php.

Referenced by ilCalendarScheduleFilterHidden\__construct(), ilCalendarPresentationGUI\__construct(), ilCalendarSelectionBlockGUI\getCalendars(), ilCalendarPresentationGUI\initAndRedirectToConsultationHours(), ilCalendarCategoryTableGUI\parse(), and ilCalendarCategoryGUI\saveSelection().

87  {
88  if (!isset(self::$instances[$a_user_id][$a_ref_id])) {
89  self::$instances[$a_user_id][$a_ref_id] = new ilCalendarVisibility($a_user_id, $a_ref_id);
90  }
91  return self::$instances[$a_user_id][$a_ref_id];
92  }
Stores selection of hidden calendars for a specific user.
+ Here is the caller graph for this function:

◆ delete()

ilCalendarVisibility::delete (   $a_cat_id = null)

delete

public

Parameters
int$a_cat_idcat id (if empty all categories are deleted)
Returns
bool

Definition at line 279 of file class.ilCalendarVisibility.php.

References $query.

280  {
281  if ($a_cat_id) {
282  $query = "DELETE FROM cal_cat_visibility " .
283  "WHERE user_id = " . $this->db->quote($this->user_id, 'integer') . " " .
284  "AND obj_id = " . $this->db->quote($this->obj_id, 'integer') . " " .
285  "AND cat_id = " . $this->db->quote($a_cat_id, 'integer') . " ";
286  } else {
287  $query = "DELETE FROM cal_cat_visibility " .
288  "WHERE user_id = " . $this->db->quote($this->user_id, 'integer') . " " .
289  "AND obj_id = " . $this->db->quote($this->obj_id, 'integer');
290  }
291  $this->db->manipulate($query);
292  return true;
293  }
$query

◆ filterHidden()

ilCalendarVisibility::filterHidden (   $categories,
  $category_info 
)

Filter hidden categories (and hidden subitem categories) from category array.

Parameters
object$categories
object$category_info
Returns

Definition at line 136 of file class.ilCalendarVisibility.php.

References $hidden, $info, array, and isHidden().

137  {
138  $hidden = array();
139  foreach ($category_info as $cat_id => $info) {
140  if ($this->isHidden($cat_id, $info)) {
141  $hidden = array_merge((array) $hidden, (array) $info['subitem_ids'], array($cat_id));
142  }
143  }
144  return array_diff((array) $categories, $hidden);
145  }
isHidden($a_cat_id, $info)
Check if category is hidden.
Create styles array
The data for the language used.
$info
Definition: index.php:5
+ Here is the call graph for this function:

◆ forceVisibility()

ilCalendarVisibility::forceVisibility (   $a_cat_id)

Force visibility.

Parameters

Definition at line 323 of file class.ilCalendarVisibility.php.

References $key.

324  {
325  if (($key = array_search($a_cat_id, $this->hidden)) !== false) {
326  unset($this->hidden[$key]);
327  }
328  if (!in_array($a_cat_id, $this->visible)) {
329  $this->visible[] = $a_cat_id;
330  }
331  }
$key
Definition: croninfo.php:18

◆ getHidden()

ilCalendarVisibility::getHidden ( )

get hidden categories

public

Returns
array array of category ids

Definition at line 194 of file class.ilCalendarVisibility.php.

References array.

195  {
196  return $this->hidden ? $this->hidden : array();
197  }
Create styles array
The data for the language used.

◆ getVisible()

ilCalendarVisibility::getVisible ( )

get visible categories

public

Returns
array array of category ids

Definition at line 205 of file class.ilCalendarVisibility.php.

References array.

206  {
207  return $this->visible ? $this->visible : array();
208  }
Create styles array
The data for the language used.

◆ hideSelected()

ilCalendarVisibility::hideSelected (   $a_hidden)

hide selected

public

Parameters
arrayarray of hidden categories
Returns
bool

Definition at line 217 of file class.ilCalendarVisibility.php.

218  {
219  $this->hidden = $a_hidden;
220  return true;
221  }

◆ isAppointmentVisible()

ilCalendarVisibility::isAppointmentVisible (   $a_cal_id)

check whether an appoinment is visible or not

public

Parameters

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

References ilCalendarCategoryAssignments\_lookupCategories().

177  {
178  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
179 
180  foreach (ilCalendarCategoryAssignments::_lookupCategories($a_cal_id) as $cat_id) {
181  if (in_array($cat_id, $this->hidden)) {
182  return true;
183  }
184  }
185  return false;
186  }
static _lookupCategories($a_cal_id)
lookup categories
+ Here is the call graph for this function:

◆ isHidden()

ilCalendarVisibility::isHidden (   $a_cat_id,
  $info 
)
protected

Check if category is hidden.

Parameters
object$a_cat_id
Returns

Definition at line 152 of file class.ilCalendarVisibility.php.

References $info, and ilCalendarCategory\TYPE_OBJ.

Referenced by filterHidden().

153  {
154  // personal desktop
155  if ($this->obj_id == 0) {
156  return in_array($a_cat_id, $this->hidden);
157  }
158 
159  // crs/grp, always show current object and objects that have been selected due to
160  // current container ref id
161  if ($info["type"] == ilCalendarCategory::TYPE_OBJ && ($info["obj_id"] == $this->obj_id
162  || $info["source_ref_id"] == $this->ref_id)) {
163  return false;
164  }
165 
166  return !in_array($a_cat_id, $this->visible);
167  }
$info
Definition: index.php:5
+ Here is the caller graph for this function:

◆ read()

ilCalendarVisibility::read ( )
protected

read user selection

protected

Returns
bool

Definition at line 301 of file class.ilCalendarVisibility.php.

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

Referenced by __construct().

302  {
303  $query = "SELECT * FROM cal_cat_visibility " .
304  "WHERE user_id = " . $this->db->quote($this->user_id, 'integer') . " " .
305  " AND obj_id = " . $this->db->quote($this->obj_id, 'integer');
306  $res = $this->db->query($query);
307  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
308  if ($row->visible == self::HIDDEN) {
309  $this->hidden[] = $row->cat_id;
310  }
311  if ($row->visible == self::VISIBLE) {
312  $this->visible[] = $row->cat_id;
313  }
314  }
315  return true;
316  }
foreach($_POST as $key=> $value) $res
$query
+ Here is the caller graph for this function:

◆ save()

ilCalendarVisibility::save ( )

save hidden selection

public

Returns
bool

Definition at line 242 of file class.ilCalendarVisibility.php.

References $DIC, $hidden, $ilDB, $query, and $visible.

243  {
244  global $DIC;
245 
246  $ilDB = $DIC->database();
247 
248  $this->delete();
249  foreach ($this->hidden as $hidden) {
250  $query = "INSERT INTO cal_cat_visibility (user_id, cat_id, obj_id, visible) " .
251  "VALUES ( " .
252  $this->db->quote($this->user_id, 'integer') . ", " .
253  $this->db->quote($hidden, 'integer') . ", " .
254  $this->db->quote($this->obj_id, 'integer') . ", " .
255  $this->db->quote(self::HIDDEN, 'integer') .
256  ")";
257  $ilDB->manipulate($query);
258  }
259  foreach ($this->visible as $visible) {
260  $query = "INSERT INTO cal_cat_visibility (user_id, cat_id, obj_id, visible) " .
261  "VALUES ( " .
262  $this->db->quote($this->user_id, 'integer') . ", " .
263  $this->db->quote($visible, 'integer') . ", " .
264  $this->db->quote($this->obj_id, 'integer') . ", " .
265  $this->db->quote(self::VISIBLE, 'integer') .
266  ")";
267  $ilDB->manipulate($query);
268  }
269  return true;
270  }
global $DIC
Definition: saml.php:7
$query
global $ilDB

◆ showSelected()

ilCalendarVisibility::showSelected (   $a_visible)

Show selected.

public

Parameters
arrayarray of visible categories
Returns
bool

Definition at line 230 of file class.ilCalendarVisibility.php.

231  {
232  $this->visible = $a_visible;
233  return true;
234  }

Field Documentation

◆ $db

ilCalendarVisibility::$db
protected

Definition at line 60 of file class.ilCalendarVisibility.php.

◆ $hidden

ilCalendarVisibility::$hidden = array()
protected

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

Referenced by filterHidden(), and save().

◆ $instances

ilCalendarVisibility::$instances = array()
staticprotected

Definition at line 40 of file class.ilCalendarVisibility.php.

◆ $user_id

ilCalendarVisibility::$user_id
protected

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

◆ $visible

ilCalendarVisibility::$visible = array()
protected

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

Referenced by save().

◆ HIDDEN

const ilCalendarVisibility::HIDDEN = 0

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

◆ VISIBLE

const ilCalendarVisibility::VISIBLE = 1

Definition at line 35 of file class.ilCalendarVisibility.php.


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