ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

public

Parameters

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

References $ilDB, and read().

54  {
55  global $ilDB;
56 
57  $this->usr_id = $a_usr_id;
58  $this->db = $ilDB;
59 
60  $this->read();
61  }
global $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ accept()

ilCalendarSharedStatus::accept (   $a_calendar_id)

accept calendar

public

Parameters
intcalendar id
Returns

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

References $ilDB, $query, and $res.

209  {
210  global $ilDB;
211 
212  self::deleteStatus($this->usr_id, $a_calendar_id);
213 
214  $query = "INSERT INTO cal_shared_status (cal_id,usr_id,status) " .
215  "VALUES ( " .
216  $this->db->quote($a_calendar_id, 'integer') . ", " .
217  $this->db->quote($this->usr_id, 'integer') . ", " .
218  $this->db->quote(self::STATUS_ACCEPTED, 'integer') . " " .
219  ")";
220  $res = $ilDB->manipulate($query);
221 
222  $this->calendars[$a_calendar_id] = self::STATUS_ACCEPTED;
223 
224  return true;
225  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ decline()

ilCalendarSharedStatus::decline (   $a_calendar_id)

decline calendar

public

Parameters
intcalendar id
Returns

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

References $ilDB, $query, and $res.

235  {
236  global $ilDB;
237 
238  self::deleteStatus($this->usr_id, $a_calendar_id);
239 
240  $query = "INSERT INTO cal_shared_status (cal_id,usr_id,status) " .
241  "VALUES ( " .
242  $this->db->quote($a_calendar_id, 'integer') . ", " .
243  $this->db->quote($this->usr_id, 'integer') . ", " .
244  $this->db->quote(self::STATUS_DECLINED, 'integer') . " " .
245  ")";
246  $res = $ilDB->manipulate($query);
247 
248  $this->calendars[$a_calendar_id] = self::STATUS_DECLINED;
249 
250  return true;
251  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ deleteCalendar()

static ilCalendarSharedStatus::deleteCalendar (   $a_calendar_id)
static

Delete calendar.

public

Parameters
intcalendar id
Returns
bool

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

References $ilDB, $query, and $res.

155  {
156  global $ilDB;
157 
158  $query = "DELETE FROM cal_shared_status " .
159  "WHERE cal_id = " . $ilDB->quote($a_calendar_id, 'integer') . " ";
160  $res = $ilDB->manipulate($query);
161  return true;
162  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ deleteStatus()

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

delete status

public

Parameters
intusr_id or role_id
intcalendar_id
Returns

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

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

Referenced by ilCalendarShared\stopSharing().

174  {
175  global $ilDB,$rbacreview;
176 
177 
178  if (ilObject::_lookupType($a_id) == 'usr') {
179  $query = "DELETE FROM cal_shared_status " .
180  "WHERE cal_id = " . $ilDB->quote($a_calendar_id, 'integer') . " " .
181  "AND usr_id = " . $ilDB->quote($a_id, 'integer') . " ";
182  $res = $ilDB->manipulate($query);
183  } elseif (ilObject::_lookupType($a_id) == 'role') {
184  $assigned_users = $rbacreview->assignedUsers($a_id);
185 
186  if (!count($assigned_users)) {
187  return true;
188  }
189 
190  $query = "DELETE FROM cal_shared_status " .
191  "WHERE cal_id = " . $ilDB->quote($a_calendar_id, 'integer') . " " .
192  "AND " . $ilDB->in('usr_id', $assigned_users, false, 'integer');
193  $res = $ilDB->manipulate($query);
194  }
195 
196  return true;
197  }
foreach($_POST as $key=> $value) $res
$query
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilDB
+ 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.

public

Parameters
intusr_id
Returns
bool

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

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

137  {
138  global $ilUser,$ilDB;
139 
140  $query = "DELETE FROM cal_shared_status " .
141  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
142  $res = $ilDB->manipulate($query);
143  return true;
144  }
foreach($_POST as $key=> $value) $res
$ilUser
Definition: imgupload.php:18
$query
global $ilDB

◆ getAcceptedCalendars()

static ilCalendarSharedStatus::getAcceptedCalendars (   $a_usr_id)
static

get accepted shared calendars

public

Parameters
intusr_id
Returns
array int array of calendar ids

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

References $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilCalendarCategories\readPrivateCalendars().

95  {
96  global $ilDB;
97 
98  $query = "SELECT cal_id FROM cal_shared_status " .
99  "WHERE status = " . $ilDB->quote(self::STATUS_ACCEPTED, 'integer') . " " .
100  "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
101  $res = $ilDB->query($query);
102  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
103  $cal_ids[] = $row->cal_id;
104  }
105  return $cal_ids ? $cal_ids : array();
106  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getOpenInvitations()

ilCalendarSharedStatus::getOpenInvitations ( )

Get open invitations.

Returns
array

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

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

Referenced by ilCalendarInboxSharedTableGUI\parse().

277  {
278  include_once('./Services/Calendar/classes/class.ilCalendarShared.php');
279  $shared = ilCalendarShared::getSharedCalendarsForUser($this->usr_id);
280 
281  $invitations = array();
282 
283  foreach ($shared as $data) {
284  if ($this->isDeclined($data['cal_id']) || $this->isAccepted($data['cal_id'])) {
285  continue;
286  }
287 
288  $tmp_calendar = new ilCalendarCategory($data['cal_id']);
289 
290  $invitations[] = array(
291  'cal_id' => $data['cal_id'],
292  'create_date' => $data['create_date'],
293  'obj_type' => $data['obj_type'],
294  'name' => $tmp_calendar->getTitle(),
295  'owner' => $tmp_calendar->getObjId(),
296  'apps' => count(ilCalendarCategoryAssignments::_getAssignedAppointments(array($data['cal_id']))),
297  'accepted' => $this->isAccepted($data['cal_id']),
298  'declined' => $this->isDeclined($data['cal_id'])
299  );
300  }
301 
302  return $invitations;
303  }
static getSharedCalendarsForUser($a_usr_id=0)
get shared calendars of user
Stores calendar categories.
Create styles array
The data for the language used.
static _getAssignedAppointments($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 (   $a_usr_id,
  $a_calendar_id 
)
static

check if a status is set for an calendar

public

Parameters
intusr_id
intcalendar id
Returns
bool

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

References $ilDB, $query, and $res.

118  {
119  global $ilDB;
120 
121  $query = "SELECT * FROM cal_shared_status " .
122  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
123  "AND cal_id = " . $ilDB->quote($a_calendar_id, 'integer') . " ";
124  $res = $ilDB->query($query);
125  return $res->numRows() ? true : false;
126  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ isAccepted()

ilCalendarSharedStatus::isAccepted (   $a_cal_id)

is accepted

public

Parameters
intcal_id
Returns

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

Referenced by getOpenInvitations().

71  {
72  return isset($this->calendars[$a_cal_id]) and $this->calendars[$a_cal_id] == self::STATUS_ACCEPTED;
73  }
+ Here is the caller graph for this function:

◆ isDeclined()

ilCalendarSharedStatus::isDeclined (   $a_cal_id)

is declined

public

Parameters
intcal_id
Returns

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

Referenced by getOpenInvitations().

83  {
84  return isset($this->calendars[$a_cal_id]) and $this->calendars[$a_cal_id] == self::STATUS_DECLINED;
85  }
+ Here is the caller graph for this function:

◆ read()

ilCalendarSharedStatus::read ( )
protected

read

protected

Returns

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

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

Referenced by __construct().

260  {
261  global $ilDB;
262 
263  $query = "SELECT * FROM cal_shared_status " .
264  "WHERE usr_id = " . $this->db->quote($this->usr_id, 'integer') . " ";
265  $res = $this->db->query($query);
266  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
267  $this->calendars[$row->cal_id] = $row->status;
268  }
269  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ 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.

◆ STATUS_DECLINED

const ilCalendarSharedStatus::STATUS_DECLINED = 2

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

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