3 declare(strict_types=1);
47 $this->usr_id = $a_usr_id;
48 $this->db = $DIC->database();
55 isset($this->calendars[$a_cal_id]) &&
56 $this->calendars[$a_cal_id] == self::STATUS_ACCEPTED;
62 isset($this->calendars[$a_cal_id]) &&
63 $this->calendars[$a_cal_id] == self::STATUS_DECLINED;
71 $query =
"SELECT cal_id FROM cal_shared_status " .
72 "WHERE status = " .
$ilDB->quote(self::STATUS_ACCEPTED,
'integer') .
" " .
73 "AND usr_id = " .
$ilDB->quote($a_usr_id,
'integer') .
" ";
76 $cal_ids[] = $row->cal_id;
78 return $cal_ids ?? [];
81 public static function hasStatus(
int $a_usr_id,
int $a_calendar_id): bool
86 $query =
"SELECT * FROM cal_shared_status " .
87 "WHERE usr_id = " .
$ilDB->quote($a_usr_id,
'integer') .
" " .
88 "AND cal_id = " .
$ilDB->quote($a_calendar_id,
'integer') .
" ";
90 return (
bool)
$res->numRows();
98 $query =
"DELETE FROM cal_shared_status " .
99 "WHERE usr_id = " .
$ilDB->quote($a_usr_id,
'integer') .
" ";
107 $ilDB = $DIC[
'ilDB'];
108 $query =
"DELETE FROM cal_shared_status " .
109 "WHERE cal_id = " .
$ilDB->quote($a_calendar_id,
'integer') .
" ";
113 public static function deleteStatus(
int $a_id,
int $a_calendar_id): void
117 $ilDB = $DIC[
'ilDB'];
118 $rbacreview = $DIC[
'rbacreview'];
121 $query =
"DELETE FROM cal_shared_status " .
122 "WHERE cal_id = " .
$ilDB->quote($a_calendar_id,
'integer') .
" " .
123 "AND usr_id = " .
$ilDB->quote($a_id,
'integer') .
" ";
126 $assigned_users = $rbacreview->assignedUsers($a_id);
128 if (!count($assigned_users)) {
132 $query =
"DELETE FROM cal_shared_status " .
133 "WHERE cal_id = " .
$ilDB->quote($a_calendar_id,
'integer') .
" " .
134 "AND " .
$ilDB->in(
'usr_id', $assigned_users,
false,
'integer');
139 public function accept(
int $a_calendar_id): void
141 self::deleteStatus($this->usr_id, $a_calendar_id);
142 $query =
"INSERT INTO cal_shared_status (cal_id,usr_id,status) " .
144 $this->db->quote($a_calendar_id,
'integer') .
", " .
145 $this->db->quote($this->usr_id,
'integer') .
", " .
146 $this->db->quote(self::STATUS_ACCEPTED,
'integer') .
" " .
150 $this->calendars[$a_calendar_id] = self::STATUS_ACCEPTED;
153 public function decline(
int $a_calendar_id): void
155 self::deleteStatus($this->usr_id, $a_calendar_id);
156 $query =
"INSERT INTO cal_shared_status (cal_id,usr_id,status) " .
158 $this->db->quote($a_calendar_id,
'integer') .
", " .
159 $this->db->quote($this->usr_id,
'integer') .
", " .
160 $this->db->quote(self::STATUS_DECLINED,
'integer') .
" " .
163 $this->calendars[$a_calendar_id] = self::STATUS_DECLINED;
168 $query =
"SELECT * FROM cal_shared_status " .
169 "WHERE usr_id = " . $this->db->quote($this->usr_id,
'integer') .
" ";
172 $this->calendars[(
int) $row->cal_id] = (
int) $row->status;
180 $invitations = array();
181 foreach ($shared as
$data) {
188 $invitations[] = array(
189 'cal_id' => (
int) $data[
'cal_id'],
190 'create_date' => $data[
'create_date'],
191 'obj_type' => $data[
'obj_type'],
192 'name' => $tmp_calendar->getTitle(),
193 'owner' => $tmp_calendar->getObjId(),
195 'accepted' => $this->
isAccepted((
int) $data[
'cal_id']),
196 'declined' => $this->
isDeclined((
int) $data[
'cal_id'])
decline(int $a_calendar_id)
static getAcceptedCalendars(int $a_usr_id)
Stores status (accepted/declined) of shared calendars.
Stores calendar categories.
isAccepted(int $a_cal_id)
static deleteCalendar(int $a_calendar_id)
__construct(int $a_usr_id)
static deleteUser(int $a_usr_id)
accept(int $a_calendar_id)
static hasStatus(int $a_usr_id, int $a_calendar_id)
static getSharedCalendarsForUser(int $a_usr_id=0)
static deleteStatus(int $a_id, int $a_calendar_id)
static _getAssignedAppointments(array $a_cat_id)
Get assigned apointments.
static _lookupType(int $id, bool $reference=false)
isDeclined(int $a_cal_id)