ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCalendarActions.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 protected static ?ilCalendarActions $instance = null;
28
30 private int $user_id;
31
35 protected function __construct()
36 {
37 global $DIC;
38
39 $this->user_id = $DIC->user()->getId();
40 $this->cats = ilCalendarCategories::_getInstance($this->user_id);
41 if ($this->cats->getMode() == ilCalendarCategories::MODE_UNDEFINED) {
43 "ilCalendarActions needs ilCalendarCategories to be initialized for user " . $this->user_id
44 );
45 }
46 }
47
51 public static function getInstance(): ilCalendarActions
52 {
53 if (!self::$instance instanceof self) {
54 self::$instance = new self();
55 }
56 return self::$instance;
57 }
58
62 public function checkSettingsCal(int $a_cat_id): bool
63 {
64 $info = $this->cats->getCategoryInfo($a_cat_id);
65 return (bool) ($info['settings'] ?? false);
66 }
67
71 public function checkShareCal(int $a_cat_id): bool
72 {
73 $info = $this->cats->getCategoryInfo($a_cat_id);
74 return
75 ($info['type'] ?? 0) == ilCalendarCategory::TYPE_USR &&
76 ($info['obj_id'] ?? '') == $this->user_id;
77 }
78
82 public function checkUnshareCal(int $a_cat_id): bool
83 {
84 $info = $this->cats->getCategoryInfo($a_cat_id);
85 if ($info['accepted'] ?? false) {
86 return true;
87 }
88 return false;
89 }
90
94 public function checkSynchronizeCal(int $a_cat_id): bool
95 {
96 $info = $this->cats->getCategoryInfo($a_cat_id);
97 if ($info['remote'] ?? false) {
98 return true;
99 }
100 return false;
101 }
102
106 public function checkAddEvent(int $a_cat_id): bool
107 {
108 $info = $this->cats->getCategoryInfo($a_cat_id);
109 return $info['editable'] ?? false;
110 }
111
115 public function checkDeleteCal(int $a_cat_id): bool
116 {
117 $info = $this->cats->getCategoryInfo($a_cat_id);
118 if (($info['type'] ?? 0) == ilCalendarCategory::TYPE_USR && ($info['obj_id'] ?? 0) == $this->user_id) {
119 return true;
120 }
121 if (($info['type'] ?? 0) == ilCalendarCategory::TYPE_GLOBAL && ($info['settings'] ?? false)) {
122 return true;
123 }
124 return false;
125 }
126}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Checks if certain actions can be performed.
checkDeleteCal(int $a_cat_id)
Check if adding an event is possible.
checkShareCal(int $a_cat_id)
Check sharing (own) calendar.
checkSynchronizeCal(int $a_cat_id)
Check synchronize remote calendar.
ilCalendarCategories $cats
checkSettingsCal(int $a_cat_id)
Check calendar editing.
checkUnshareCal(int $a_cat_id)
Check un-sharing (other users) calendar.
static getInstance()
Get instance.
checkAddEvent(int $a_cat_id)
Check if adding an event is possible.
static ilCalendarActions $instance
class for calendar categories
static _getInstance($a_usr_id=0)
get singleton instance
$info
Definition: entry_point.php:21
global $DIC
Definition: shib_login.php:26