ILIAS  release_8 Revision v8.24
ilCalendarSharedStatus Class Reference

Stores status (accepted/declined) of shared calendars. More...

+ Collaboration diagram for ilCalendarSharedStatus:

Public Member Functions

 __construct (int $a_usr_id)
 
 isAccepted (int $a_cal_id)
 
 isDeclined (int $a_cal_id)
 
 accept (int $a_calendar_id)
 
 decline (int $a_calendar_id)
 
 getOpenInvitations ()
 

Static Public Member Functions

static getAcceptedCalendars (int $a_usr_id)
 
static hasStatus (int $a_usr_id, int $a_calendar_id)
 
static deleteUser (int $a_usr_id)
 
static deleteCalendar (int $a_calendar_id)
 
static deleteStatus (int $a_id, int $a_calendar_id)
 

Data Fields

const STATUS_ACCEPTED = 1
 
const STATUS_DECLINED = 2
 
const STATUS_DELETED = 3
 

Protected Member Functions

 read ()
 

Protected Attributes

ilDBInterface $db
 

Private Attributes

int $usr_id = 0
 
array $calendars = array()
 
array $writable = array()
 

Detailed Description

Stores status (accepted/declined) of shared calendars.

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

Definition at line 31 of file class.ilCalendarSharedStatus.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarSharedStatus::__construct ( int  $a_usr_id)

Definition at line 44 of file class.ilCalendarSharedStatus.php.

45 {
46 global $DIC;
47 $this->usr_id = $a_usr_id;
48 $this->db = $DIC->database();
49 $this->read();
50 }
global $DIC
Definition: feed.php:28

References $DIC, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ accept()

ilCalendarSharedStatus::accept ( int  $a_calendar_id)

Definition at line 139 of file class.ilCalendarSharedStatus.php.

139 : void
140 {
141 self::deleteStatus($this->usr_id, $a_calendar_id);
142 $query = "INSERT INTO cal_shared_status (cal_id,usr_id,status) " .
143 "VALUES ( " .
144 $this->db->quote($a_calendar_id, 'integer') . ", " .
145 $this->db->quote($this->usr_id, 'integer') . ", " .
146 $this->db->quote(self::STATUS_ACCEPTED, 'integer') . " " .
147 ")";
148 $res = $this->db->manipulate($query);
149
150 $this->calendars[$a_calendar_id] = self::STATUS_ACCEPTED;
151 }
static deleteStatus(int $a_id, int $a_calendar_id)
$res
Definition: ltiservices.php:69
$query

References $query, $res, deleteStatus(), and STATUS_ACCEPTED.

+ Here is the call graph for this function:

◆ decline()

ilCalendarSharedStatus::decline ( int  $a_calendar_id)

Definition at line 153 of file class.ilCalendarSharedStatus.php.

153 : void
154 {
155 self::deleteStatus($this->usr_id, $a_calendar_id);
156 $query = "INSERT INTO cal_shared_status (cal_id,usr_id,status) " .
157 "VALUES ( " .
158 $this->db->quote($a_calendar_id, 'integer') . ", " .
159 $this->db->quote($this->usr_id, 'integer') . ", " .
160 $this->db->quote(self::STATUS_DECLINED, 'integer') . " " .
161 ")";
162 $res = $this->db->manipulate($query);
163 $this->calendars[$a_calendar_id] = self::STATUS_DECLINED;
164 }

References $query, $res, deleteStatus(), and STATUS_DECLINED.

+ Here is the call graph for this function:

◆ deleteCalendar()

static ilCalendarSharedStatus::deleteCalendar ( int  $a_calendar_id)
static

Definition at line 103 of file class.ilCalendarSharedStatus.php.

103 : void
104 {
105 global $DIC;
106
107 $ilDB = $DIC['ilDB'];
108 $query = "DELETE FROM cal_shared_status " .
109 "WHERE cal_id = " . $ilDB->quote($a_calendar_id, 'integer') . " ";
110 $res = $ilDB->manipulate($query);
111 }

References $DIC, $ilDB, $query, and $res.

◆ deleteStatus()

static ilCalendarSharedStatus::deleteStatus ( int  $a_id,
int  $a_calendar_id 
)
static

Definition at line 113 of file class.ilCalendarSharedStatus.php.

113 : void
114 {
115 global $DIC;
116
117 $ilDB = $DIC['ilDB'];
118 $rbacreview = $DIC['rbacreview'];
119
120 if (ilObject::_lookupType($a_id) == 'usr') {
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') . " ";
124 $res = $ilDB->manipulate($query);
125 } elseif (ilObject::_lookupType($a_id) == 'role') {
126 $assigned_users = $rbacreview->assignedUsers($a_id);
127
128 if (!count($assigned_users)) {
129 return;
130 }
131
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');
135 $res = $ilDB->manipulate($query);
136 }
137 }
static _lookupType(int $id, bool $reference=false)

References $DIC, $ilDB, $query, $res, and ilObject\_lookupType().

Referenced by accept(), decline(), and ilCalendarShared\stopSharing().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteUser()

static ilCalendarSharedStatus::deleteUser ( int  $a_usr_id)
static

Definition at line 93 of file class.ilCalendarSharedStatus.php.

93 : void
94 {
95 global $DIC;
96
97 $ilDB = $DIC['ilDB'];
98 $query = "DELETE FROM cal_shared_status " .
99 "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
100 $res = $ilDB->manipulate($query);
101 }

References $DIC, $ilDB, $query, and $res.

◆ getAcceptedCalendars()

static ilCalendarSharedStatus::getAcceptedCalendars ( int  $a_usr_id)
static

Definition at line 66 of file class.ilCalendarSharedStatus.php.

66 : array
67 {
68 global $DIC;
69
70 $ilDB = $DIC['ilDB'];
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') . " ";
74 $res = $ilDB->query($query);
75 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
76 $cal_ids[] = $row->cal_id;
77 }
78 return $cal_ids ?? [];
79 }

References $DIC, $ilDB, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilCalendarCategories\readPrivateCalendars().

+ Here is the caller graph for this function:

◆ getOpenInvitations()

ilCalendarSharedStatus::getOpenInvitations ( )

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

176 : array
177 {
178 $shared = ilCalendarShared::getSharedCalendarsForUser($this->usr_id);
179
180 $invitations = array();
181 foreach ($shared as $data) {
182 if ($this->isDeclined($data['cal_id']) || $this->isAccepted($data['cal_id'])) {
183 continue;
184 }
185
186 $tmp_calendar = new ilCalendarCategory($data['cal_id']);
187
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(),
194 'apps' => count(ilCalendarCategoryAssignments::_getAssignedAppointments(array((int) $data['cal_id']))),
195 'accepted' => $this->isAccepted((int) $data['cal_id']),
196 'declined' => $this->isDeclined((int) $data['cal_id'])
197 );
198 }
199 return $invitations;
200 }
static _getAssignedAppointments(array $a_cat_id)
Get assigned apointments.
Stores calendar categories.
static getSharedCalendarsForUser(int $a_usr_id=0)

References $data, ilCalendarCategoryAssignments\_getAssignedAppointments(), ilCalendarShared\getSharedCalendarsForUser(), isAccepted(), and isDeclined().

+ Here is the call graph for this function:

◆ hasStatus()

static ilCalendarSharedStatus::hasStatus ( int  $a_usr_id,
int  $a_calendar_id 
)
static

Definition at line 81 of file class.ilCalendarSharedStatus.php.

81 : bool
82 {
83 global $DIC;
84
85 $ilDB = $DIC['ilDB'];
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') . " ";
89 $res = $ilDB->query($query);
90 return (bool) $res->numRows();
91 }

References $DIC, $ilDB, $query, and $res.

◆ isAccepted()

ilCalendarSharedStatus::isAccepted ( int  $a_cal_id)

Definition at line 52 of file class.ilCalendarSharedStatus.php.

52 : bool
53 {
54 return
55 isset($this->calendars[$a_cal_id]) &&
56 $this->calendars[$a_cal_id] == self::STATUS_ACCEPTED;
57 }

References STATUS_ACCEPTED.

Referenced by getOpenInvitations().

+ Here is the caller graph for this function:

◆ isDeclined()

ilCalendarSharedStatus::isDeclined ( int  $a_cal_id)

Definition at line 59 of file class.ilCalendarSharedStatus.php.

59 : bool
60 {
61 return
62 isset($this->calendars[$a_cal_id]) &&
63 $this->calendars[$a_cal_id] == self::STATUS_DECLINED;
64 }

References STATUS_DECLINED.

Referenced by getOpenInvitations().

+ Here is the caller graph for this function:

◆ read()

ilCalendarSharedStatus::read ( )
protected

Definition at line 166 of file class.ilCalendarSharedStatus.php.

167 {
168 $query = "SELECT * FROM cal_shared_status " .
169 "WHERE usr_id = " . $this->db->quote($this->usr_id, 'integer') . " ";
170 $res = $this->db->query($query);
171 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
172 $this->calendars[(int) $row->cal_id] = (int) $row->status;
173 }
174 }

References $query, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $calendars

array ilCalendarSharedStatus::$calendars = array()
private

Definition at line 41 of file class.ilCalendarSharedStatus.php.

◆ $db

ilDBInterface ilCalendarSharedStatus::$db
protected

Definition at line 37 of file class.ilCalendarSharedStatus.php.

◆ $usr_id

int ilCalendarSharedStatus::$usr_id = 0
private

Definition at line 39 of file class.ilCalendarSharedStatus.php.

◆ $writable

array ilCalendarSharedStatus::$writable = array()
private

Definition at line 42 of file class.ilCalendarSharedStatus.php.

◆ STATUS_ACCEPTED

const ilCalendarSharedStatus::STATUS_ACCEPTED = 1

Definition at line 33 of file class.ilCalendarSharedStatus.php.

Referenced by accept(), and isAccepted().

◆ STATUS_DECLINED

const ilCalendarSharedStatus::STATUS_DECLINED = 2

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

Referenced by decline(), and isDeclined().

◆ STATUS_DELETED

const ilCalendarSharedStatus::STATUS_DELETED = 3

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


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