ILIAS  release_7 Revision v7.30-3-g800a261c036
ilCalendarSharedStatus Class Reference

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

+ Collaboration diagram for ilCalendarSharedStatus:

Public Member Functions

 __construct ($a_usr_id)
 Constructor. More...
 
 isAccepted ($a_cal_id)
 is accepted More...
 
 isDeclined ($a_cal_id)
 is declined More...
 
 accept ($a_calendar_id)
 accept calendar More...
 
 decline ($a_calendar_id)
 decline calendar More...
 
 getOpenInvitations ()
 Get open invitations. More...
 

Static Public Member Functions

static getAcceptedCalendars ($a_usr_id)
 get accepted shared calendars More...
 
static hasStatus ($a_usr_id, $a_calendar_id)
 check if a status is set for an calendar More...
 
static deleteUser ($a_usr_id)
 Delete by user. More...
 
static deleteCalendar ($a_calendar_id)
 Delete calendar. More...
 
static deleteStatus ($a_id, $a_calendar_id)
 delete status More...
 

Data Fields

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

Protected Member Functions

 read ()
 read More...
 

Protected Attributes

 $db = null
 

Private Attributes

 $usr_id = 0
 
 $calendars = 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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilCalendarSharedStatus::__construct (   $a_usr_id)

Constructor.

@access public

Parameters

return

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

54 {
55 global $DIC;
56
57 $ilDB = $DIC['ilDB'];
58
59 $this->usr_id = $a_usr_id;
60 $this->db = $ilDB;
61
62 $this->read();
63 }
global $DIC
Definition: goto.php:24
global $ilDB

References $DIC, $ilDB, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ accept()

ilCalendarSharedStatus::accept (   $a_calendar_id)

accept calendar

@access public

Parameters
intcalendar id
Returns

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

223 {
224 global $DIC;
225
226 $ilDB = $DIC['ilDB'];
227
228 self::deleteStatus($this->usr_id, $a_calendar_id);
229
230 $query = "INSERT INTO cal_shared_status (cal_id,usr_id,status) " .
231 "VALUES ( " .
232 $this->db->quote($a_calendar_id, 'integer') . ", " .
233 $this->db->quote($this->usr_id, 'integer') . ", " .
234 $this->db->quote(self::STATUS_ACCEPTED, 'integer') . " " .
235 ")";
236 $res = $ilDB->manipulate($query);
237
238 $this->calendars[$a_calendar_id] = self::STATUS_ACCEPTED;
239
240 return true;
241 }
static deleteStatus($a_id, $a_calendar_id)
delete status
$query
foreach($_POST as $key=> $value) $res

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

+ Here is the call graph for this function:

◆ decline()

ilCalendarSharedStatus::decline (   $a_calendar_id)

decline calendar

@access public

Parameters
intcalendar id
Returns

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

251 {
252 global $DIC;
253
254 $ilDB = $DIC['ilDB'];
255
256 self::deleteStatus($this->usr_id, $a_calendar_id);
257
258 $query = "INSERT INTO cal_shared_status (cal_id,usr_id,status) " .
259 "VALUES ( " .
260 $this->db->quote($a_calendar_id, 'integer') . ", " .
261 $this->db->quote($this->usr_id, 'integer') . ", " .
262 $this->db->quote(self::STATUS_DECLINED, 'integer') . " " .
263 ")";
264 $res = $ilDB->manipulate($query);
265
266 $this->calendars[$a_calendar_id] = self::STATUS_DECLINED;
267
268 return true;
269 }

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

+ Here is the call graph for this function:

◆ deleteCalendar()

static ilCalendarSharedStatus::deleteCalendar (   $a_calendar_id)
static

Delete calendar.

@access public

Parameters
intcalendar id
Returns
bool

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

164 {
165 global $DIC;
166
167 $ilDB = $DIC['ilDB'];
168
169 $query = "DELETE FROM cal_shared_status " .
170 "WHERE cal_id = " . $ilDB->quote($a_calendar_id, 'integer') . " ";
171 $res = $ilDB->manipulate($query);
172 return true;
173 }

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

◆ deleteStatus()

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

delete status

@access public

Parameters
intusr_id or role_id
intcalendar_id
Returns

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

185 {
186 global $DIC;
187
188 $ilDB = $DIC['ilDB'];
189 $rbacreview = $DIC['rbacreview'];
190
191
192 if (ilObject::_lookupType($a_id) == 'usr') {
193 $query = "DELETE FROM cal_shared_status " .
194 "WHERE cal_id = " . $ilDB->quote($a_calendar_id, 'integer') . " " .
195 "AND usr_id = " . $ilDB->quote($a_id, 'integer') . " ";
196 $res = $ilDB->manipulate($query);
197 } elseif (ilObject::_lookupType($a_id) == 'role') {
198 $assigned_users = $rbacreview->assignedUsers($a_id);
199
200 if (!count($assigned_users)) {
201 return true;
202 }
203
204 $query = "DELETE FROM cal_shared_status " .
205 "WHERE cal_id = " . $ilDB->quote($a_calendar_id, 'integer') . " " .
206 "AND " . $ilDB->in('usr_id', $assigned_users, false, 'integer');
207 $res = $ilDB->manipulate($query);
208 }
209
210 return true;
211 }
static _lookupType($a_id, $a_reference=false)
lookup object type

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 (   $a_usr_id)
static

Delete by user.

@access public

Parameters
intusr_id
Returns
bool

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

143 {
144 global $DIC;
145
146 $ilUser = $DIC['ilUser'];
147 $ilDB = $DIC['ilDB'];
148
149 $query = "DELETE FROM cal_shared_status " .
150 "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
151 $res = $ilDB->manipulate($query);
152 return true;
153 }
$ilUser
Definition: imgupload.php:18

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

◆ getAcceptedCalendars()

static ilCalendarSharedStatus::getAcceptedCalendars (   $a_usr_id)
static

get accepted shared calendars

@access public

Parameters
intusr_id
Returns
array int array of calendar ids

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

97 {
98 global $DIC;
99
100 $ilDB = $DIC['ilDB'];
101
102 $query = "SELECT cal_id FROM cal_shared_status " .
103 "WHERE status = " . $ilDB->quote(self::STATUS_ACCEPTED, 'integer') . " " .
104 "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
105 $res = $ilDB->query($query);
106 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
107 $cal_ids[] = $row->cal_id;
108 }
109 return $cal_ids ? $cal_ids : array();
110 }

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

Referenced by ilCalendarCategories\readPrivateCalendars().

+ Here is the caller graph for this function:

◆ getOpenInvitations()

ilCalendarSharedStatus::getOpenInvitations ( )

Get open invitations.

Returns
array

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

297 {
298 include_once('./Services/Calendar/classes/class.ilCalendarShared.php');
299 $shared = ilCalendarShared::getSharedCalendarsForUser($this->usr_id);
300
301 $invitations = array();
302
303 foreach ($shared as $data) {
304 if ($this->isDeclined($data['cal_id']) || $this->isAccepted($data['cal_id'])) {
305 continue;
306 }
307
308 $tmp_calendar = new ilCalendarCategory($data['cal_id']);
309
310 $invitations[] = array(
311 'cal_id' => $data['cal_id'],
312 'create_date' => $data['create_date'],
313 'obj_type' => $data['obj_type'],
314 'name' => $tmp_calendar->getTitle(),
315 'owner' => $tmp_calendar->getObjId(),
316 'apps' => count(ilCalendarCategoryAssignments::_getAssignedAppointments(array($data['cal_id']))),
317 'accepted' => $this->isAccepted($data['cal_id']),
318 'declined' => $this->isDeclined($data['cal_id'])
319 );
320 }
321
322 return $invitations;
323 }
static _getAssignedAppointments($a_cat_id)
Get assigned apointments.
Stores calendar categories.
static getSharedCalendarsForUser($a_usr_id=0)
get shared calendars of user
$data
Definition: storeScorm.php:23

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

+ Here is the call graph for this function:

◆ hasStatus()

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

check if a status is set for an calendar

@access public

Parameters
intusr_id
intcalendar id
Returns
bool

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

122 {
123 global $DIC;
124
125 $ilDB = $DIC['ilDB'];
126
127 $query = "SELECT * FROM cal_shared_status " .
128 "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
129 "AND cal_id = " . $ilDB->quote($a_calendar_id, 'integer') . " ";
130 $res = $ilDB->query($query);
131 return $res->numRows() ? true : false;
132 }
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.

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

◆ isAccepted()

ilCalendarSharedStatus::isAccepted (   $a_cal_id)

is accepted

@access public

Parameters
intcal_id
Returns

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

73 {
74 return isset($this->calendars[$a_cal_id]) and $this->calendars[$a_cal_id] == self::STATUS_ACCEPTED;
75 }

References STATUS_ACCEPTED.

Referenced by getOpenInvitations().

+ Here is the caller graph for this function:

◆ isDeclined()

ilCalendarSharedStatus::isDeclined (   $a_cal_id)

is declined

@access public

Parameters
intcal_id
Returns

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

85 {
86 return isset($this->calendars[$a_cal_id]) and $this->calendars[$a_cal_id] == self::STATUS_DECLINED;
87 }

References STATUS_DECLINED.

Referenced by getOpenInvitations().

+ Here is the caller graph for this function:

◆ read()

ilCalendarSharedStatus::read ( )
protected

read

@access protected

Returns

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

278 {
279 global $DIC;
280
281 $ilDB = $DIC['ilDB'];
282
283 $query = "SELECT * FROM cal_shared_status " .
284 "WHERE usr_id = " . $this->db->quote($this->usr_id, 'integer') . " ";
285 $res = $this->db->query($query);
286 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
287 $this->calendars[$row->cal_id] = $row->status;
288 }
289 }

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

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $calendars

ilCalendarSharedStatus::$calendars = array()
private

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

◆ $db

ilCalendarSharedStatus::$db = null
protected

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

◆ $usr_id

ilCalendarSharedStatus::$usr_id = 0
private

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

◆ $writable

ilCalendarSharedStatus::$writable = array()
private

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

◆ STATUS_ACCEPTED

const ilCalendarSharedStatus::STATUS_ACCEPTED = 1

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

Referenced by accept(), and isAccepted().

◆ STATUS_DECLINED

const ilCalendarSharedStatus::STATUS_DECLINED = 2

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

Referenced by decline(), and isDeclined().

◆ STATUS_DELETED

const ilCalendarSharedStatus::STATUS_DELETED = 3

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


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