19 declare(strict_types=1);
41 $this->usr_id = $a_usr_id;
42 $this->db = $DIC->database();
49 isset($this->calendars[$a_cal_id]) &&
50 $this->calendars[$a_cal_id] == self::STATUS_ACCEPTED;
56 isset($this->calendars[$a_cal_id]) &&
57 $this->calendars[$a_cal_id] == self::STATUS_DECLINED;
65 $query =
"SELECT cal_id FROM cal_shared_status " .
66 "WHERE status = " .
$ilDB->quote(self::STATUS_ACCEPTED,
'integer') .
" " .
67 "AND usr_id = " .
$ilDB->quote($a_usr_id,
'integer') .
" ";
70 $cal_ids[] = $row->cal_id;
72 return $cal_ids ?? [];
75 public static function hasStatus(
int $a_usr_id,
int $a_calendar_id): bool
80 $query =
"SELECT * FROM cal_shared_status " .
81 "WHERE usr_id = " .
$ilDB->quote($a_usr_id,
'integer') .
" " .
82 "AND cal_id = " .
$ilDB->quote($a_calendar_id,
'integer') .
" ";
84 return (
bool)
$res->numRows();
92 $query =
"DELETE FROM cal_shared_status " .
93 "WHERE usr_id = " .
$ilDB->quote($a_usr_id,
'integer') .
" ";
101 $ilDB = $DIC[
'ilDB'];
102 $query =
"DELETE FROM cal_shared_status " .
103 "WHERE cal_id = " .
$ilDB->quote($a_calendar_id,
'integer') .
" ";
107 public static function deleteStatus(
int $a_id,
int $a_calendar_id): void
111 $ilDB = $DIC[
'ilDB'];
112 $rbacreview = $DIC[
'rbacreview'];
115 $query =
"DELETE FROM cal_shared_status " .
116 "WHERE cal_id = " .
$ilDB->quote($a_calendar_id,
'integer') .
" " .
117 "AND usr_id = " .
$ilDB->quote($a_id,
'integer') .
" ";
120 $assigned_users = $rbacreview->assignedUsers($a_id);
122 if (!count($assigned_users)) {
126 $query =
"DELETE FROM cal_shared_status " .
127 "WHERE cal_id = " .
$ilDB->quote($a_calendar_id,
'integer') .
" " .
128 "AND " .
$ilDB->in(
'usr_id', $assigned_users,
false,
'integer');
133 public function accept(
int $a_calendar_id): void
135 self::deleteStatus($this->usr_id, $a_calendar_id);
136 $query =
"INSERT INTO cal_shared_status (cal_id,usr_id,status) " .
138 $this->db->quote($a_calendar_id,
'integer') .
", " .
139 $this->db->quote($this->usr_id,
'integer') .
", " .
140 $this->db->quote(self::STATUS_ACCEPTED,
'integer') .
" " .
142 $res = $this->db->manipulate($query);
144 $this->calendars[$a_calendar_id] = self::STATUS_ACCEPTED;
147 public function decline(
int $a_calendar_id): void
149 self::deleteStatus($this->usr_id, $a_calendar_id);
150 $query =
"INSERT INTO cal_shared_status (cal_id,usr_id,status) " .
152 $this->db->quote($a_calendar_id,
'integer') .
", " .
153 $this->db->quote($this->usr_id,
'integer') .
", " .
154 $this->db->quote(self::STATUS_DECLINED,
'integer') .
" " .
156 $res = $this->db->manipulate($query);
157 $this->calendars[$a_calendar_id] = self::STATUS_DECLINED;
162 $query =
"SELECT * FROM cal_shared_status " .
163 "WHERE usr_id = " . $this->db->quote($this->usr_id,
'integer') .
" ";
164 $res = $this->db->query($query);
166 $this->calendars[(
int) $row->cal_id] = (
int) $row->status;
174 $invitations = array();
175 foreach ($shared as
$data) {
182 $invitations[] = array(
183 'cal_id' => (
int) $data[
'cal_id'],
184 'create_date' => $data[
'create_date'],
185 'obj_type' => $data[
'obj_type'],
186 'name' => $tmp_calendar->getTitle(),
187 'owner' => $tmp_calendar->getObjId(),
189 'accepted' => $this->
isAccepted((
int) $data[
'cal_id']),
190 '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)