ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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.

References $DIC, and read().

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
+ 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.

References $query, and $res.

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  }
$res
Definition: ltiservices.php:69
$query

◆ decline()

ilCalendarSharedStatus::decline ( int  $a_calendar_id)

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

References $query, and $res.

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  }
$res
Definition: ltiservices.php:69
$query

◆ deleteCalendar()

static ilCalendarSharedStatus::deleteCalendar ( int  $a_calendar_id)
static

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

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

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  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query

◆ deleteStatus()

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

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

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

Referenced by ilCalendarShared\stopSharing().

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  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
static _lookupType(int $id, bool $reference=false)
+ 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.

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

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  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query

◆ getAcceptedCalendars()

static ilCalendarSharedStatus::getAcceptedCalendars ( int  $a_usr_id)
static

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

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

Referenced by ilCalendarCategories\readPrivateCalendars().

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  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
+ Here is the caller graph for this function:

◆ getOpenInvitations()

ilCalendarSharedStatus::getOpenInvitations ( )

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

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

Referenced by ilCalendarInboxSharedTableGUI\parse().

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  }
Stores calendar categories.
static getSharedCalendarsForUser(int $a_usr_id=0)
static _getAssignedAppointments(array $a_cat_id)
Get assigned apointments.
+ Here is the call graph for this function:
+ Here is the caller 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.

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

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  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query

◆ isAccepted()

ilCalendarSharedStatus::isAccepted ( int  $a_cal_id)

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

Referenced by getOpenInvitations().

52  : bool
53  {
54  return
55  isset($this->calendars[$a_cal_id]) &&
56  $this->calendars[$a_cal_id] == self::STATUS_ACCEPTED;
57  }
+ Here is the caller graph for this function:

◆ isDeclined()

ilCalendarSharedStatus::isDeclined ( int  $a_cal_id)

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

Referenced by getOpenInvitations().

59  : bool
60  {
61  return
62  isset($this->calendars[$a_cal_id]) &&
63  $this->calendars[$a_cal_id] == self::STATUS_DECLINED;
64  }
+ Here is the caller graph for this function:

◆ read()

ilCalendarSharedStatus::read ( )
protected

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

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

Referenced by __construct().

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  }
$res
Definition: ltiservices.php:69
$query
+ 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.

◆ STATUS_DECLINED

const ilCalendarSharedStatus::STATUS_DECLINED = 2

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

◆ 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: