ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 25 of file class.ilCalendarSharedStatus.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarSharedStatus::__construct ( int  $a_usr_id)

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

39 {
40 global $DIC;
41 $this->usr_id = $a_usr_id;
42 $this->db = $DIC->database();
43 $this->read();
44 }
global $DIC
Definition: shib_login.php:26

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 133 of file class.ilCalendarSharedStatus.php.

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

References $res, deleteStatus(), and STATUS_ACCEPTED.

+ Here is the call graph for this function:

◆ decline()

ilCalendarSharedStatus::decline ( int  $a_calendar_id)

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

147 : void
148 {
149 self::deleteStatus($this->usr_id, $a_calendar_id);
150 $query = "INSERT INTO cal_shared_status (cal_id,usr_id,status) " .
151 "VALUES ( " .
152 $this->db->quote($a_calendar_id, 'integer') . ", " .
153 $this->db->quote($this->usr_id, 'integer') . ", " .
154 $this->db->quote(self::STATUS_DECLINED, 'integer') . " " .
155 ")";
156 $res = $this->db->manipulate($query);
157 $this->calendars[$a_calendar_id] = self::STATUS_DECLINED;
158 }

References $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 97 of file class.ilCalendarSharedStatus.php.

97 : void
98 {
99 global $DIC;
100
101 $ilDB = $DIC['ilDB'];
102 $query = "DELETE FROM cal_shared_status " .
103 "WHERE cal_id = " . $ilDB->quote($a_calendar_id, 'integer') . " ";
104 $res = $ilDB->manipulate($query);
105 }

References $DIC, $ilDB, and $res.

◆ deleteStatus()

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

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

107 : void
108 {
109 global $DIC;
110
111 $ilDB = $DIC['ilDB'];
112 $rbacreview = $DIC['rbacreview'];
113
114 if (ilObject::_lookupType($a_id) == 'usr') {
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') . " ";
118 $res = $ilDB->manipulate($query);
119 } elseif (ilObject::_lookupType($a_id) == 'role') {
120 $assigned_users = $rbacreview->assignedUsers($a_id);
121
122 if (!count($assigned_users)) {
123 return;
124 }
125
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');
129 $res = $ilDB->manipulate($query);
130 }
131 }
static _lookupType(int $id, bool $reference=false)

References $DIC, $ilDB, $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 87 of file class.ilCalendarSharedStatus.php.

87 : void
88 {
89 global $DIC;
90
91 $ilDB = $DIC['ilDB'];
92 $query = "DELETE FROM cal_shared_status " .
93 "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
94 $res = $ilDB->manipulate($query);
95 }

References $DIC, $ilDB, and $res.

◆ getAcceptedCalendars()

static ilCalendarSharedStatus::getAcceptedCalendars ( int  $a_usr_id)
static

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

60 : array
61 {
62 global $DIC;
63
64 $ilDB = $DIC['ilDB'];
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') . " ";
68 $res = $ilDB->query($query);
69 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
70 $cal_ids[] = $row->cal_id;
71 }
72 return $cal_ids ?? [];
73 }

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

Referenced by ilCalendarCategories\readPrivateCalendars().

+ Here is the caller graph for this function:

◆ getOpenInvitations()

ilCalendarSharedStatus::getOpenInvitations ( )

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

170 : array
171 {
172 $shared = ilCalendarShared::getSharedCalendarsForUser($this->usr_id);
173
174 $invitations = array();
175 foreach ($shared as $data) {
176 if ($this->isDeclined($data['cal_id']) || $this->isAccepted($data['cal_id'])) {
177 continue;
178 }
179
180 $tmp_calendar = new ilCalendarCategory($data['cal_id']);
181
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(),
188 'apps' => count(ilCalendarCategoryAssignments::_getAssignedAppointments(array((int) $data['cal_id']))),
189 'accepted' => $this->isAccepted((int) $data['cal_id']),
190 'declined' => $this->isDeclined((int) $data['cal_id'])
191 );
192 }
193 return $invitations;
194 }
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 75 of file class.ilCalendarSharedStatus.php.

75 : bool
76 {
77 global $DIC;
78
79 $ilDB = $DIC['ilDB'];
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') . " ";
83 $res = $ilDB->query($query);
84 return (bool) $res->numRows();
85 }

References $DIC, $ilDB, and $res.

◆ isAccepted()

ilCalendarSharedStatus::isAccepted ( int  $a_cal_id)

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

46 : bool
47 {
48 return
49 isset($this->calendars[$a_cal_id]) &&
50 $this->calendars[$a_cal_id] == self::STATUS_ACCEPTED;
51 }

References STATUS_ACCEPTED.

Referenced by getOpenInvitations().

+ Here is the caller graph for this function:

◆ isDeclined()

ilCalendarSharedStatus::isDeclined ( int  $a_cal_id)

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

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

References STATUS_DECLINED.

Referenced by getOpenInvitations().

+ Here is the caller graph for this function:

◆ read()

ilCalendarSharedStatus::read ( )
protected

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

161 {
162 $query = "SELECT * FROM cal_shared_status " .
163 "WHERE usr_id = " . $this->db->quote($this->usr_id, 'integer') . " ";
164 $res = $this->db->query($query);
165 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
166 $this->calendars[(int) $row->cal_id] = (int) $row->status;
167 }
168 }

References $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 35 of file class.ilCalendarSharedStatus.php.

◆ $db

ilDBInterface ilCalendarSharedStatus::$db
protected

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

◆ $usr_id

int ilCalendarSharedStatus::$usr_id = 0
private

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

◆ $writable

array ilCalendarSharedStatus::$writable = array()
private

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

◆ STATUS_ACCEPTED

const ilCalendarSharedStatus::STATUS_ACCEPTED = 1

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

Referenced by accept(), and isAccepted().

◆ STATUS_DECLINED

const ilCalendarSharedStatus::STATUS_DECLINED = 2

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

Referenced by decline(), and isDeclined().

◆ STATUS_DELETED

const ilCalendarSharedStatus::STATUS_DELETED = 3

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


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