ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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...
 
 getAcceptedCalendars ($a_usr_id)
 get accepted shared calendars More...
 
 accept ($a_calendar_id)
 accept calendar More...
 
 decline ($a_calendar_id)
 decline calendar More...
 

Static Public Member Functions

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 $ilDB;
56
57 $this->usr_id = $a_usr_id;
58 $this->db = $ilDB;
59
60 $this->read();
61 }
global $ilDB

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

216 {
217 global $ilDB;
218
219 self::deleteStatus($this->usr_id,$a_calendar_id);
220
221 $query = "INSERT INTO cal_shared_status (cal_id,usr_id,status) ".
222 "VALUES ( ".
223 $this->db->quote($a_calendar_id ,'integer').", ".
224 $this->db->quote($this->usr_id ,'integer').", ".
225 $this->db->quote(self::STATUS_ACCEPTED ,'integer')." ".
226 ")";
227 $res = $ilDB->manipulate($query);
228
229 $this->calendars[$a_calendar_id] = self::STATUS_ACCEPTED;
230
231 return true;
232 }
static deleteStatus($a_id, $a_calendar_id)
delete status

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

242 {
243 global $ilDB;
244
245 self::deleteStatus($this->usr_id,$a_calendar_id);
246
247 $query = "INSERT INTO cal_shared_status (cal_id,usr_id,status) ".
248 "VALUES ( ".
249 $this->db->quote($a_calendar_id ,'integer').", ".
250 $this->db->quote($this->usr_id ,'integer').", ".
251 $this->db->quote(self::STATUS_DECLINED ,'integer')." ".
252 ")";
253 $res = $ilDB->manipulate($query);
254
255 $this->calendars[$a_calendar_id] = self::STATUS_DECLINED;
256
257 return true;
258
259 }

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

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

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

175 {
176 global $ilDB,$rbacreview;
177
178
179 if(ilObject::_lookupType($a_id) == 'usr')
180 {
181 $query = "DELETE FROM cal_shared_status ".
182 "WHERE cal_id = ".$ilDB->quote($a_calendar_id ,'integer')." ".
183 "AND usr_id = ".$ilDB->quote($a_id ,'integer')." ";
184 $res = $ilDB->manipulate($query);
185
186 }
187 elseif(ilObject::_lookupType($a_id) == 'role')
188 {
189 $assigned_users = $rbacreview->assignedUsers($a_id);
190
191 if(!count($assigned_users))
192 {
193 return true;
194 }
195
196 $query = "DELETE FROM cal_shared_status ".
197 "WHERE cal_id = ".$ilDB->quote($a_calendar_id ,'integer')." ".
198 "AND ".$ilDB->in('usr_id',$assigned_users,false,'integer');
199 $res = $ilDB->manipulate($query);
200
201 }
202
203 return true;
204 }
static _lookupType($a_id, $a_reference=false)
lookup object type

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

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

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

◆ getAcceptedCalendars()

ilCalendarSharedStatus::getAcceptedCalendars (   $a_usr_id)

get accepted shared calendars

@access public

Parameters
intusr_id
Returns
array int array of calendar ids

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

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(DB_FETCHMODE_OBJECT))
103 {
104 $cal_ids[] = $row->cal_id;
105 }
106 return $cal_ids ? $cal_ids : array();
107 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilCalendarCategories\readPrivateCalendars().

+ 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

@access public

Parameters
intusr_id
intcalendar id
Returns
bool

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

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

References $ilDB, $query, and $res.

◆ isAccepted()

ilCalendarSharedStatus::isAccepted (   $a_cal_id)

is accepted

@access public

Parameters
intcal_id
Returns

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

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

References STATUS_ACCEPTED.

◆ isDeclined()

ilCalendarSharedStatus::isDeclined (   $a_cal_id)

is declined

@access public

Parameters
intcal_id
Returns

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

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

References STATUS_DECLINED.

◆ read()

ilCalendarSharedStatus::read ( )
protected

read

@access protected

Returns

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

268 {
269 global $ilDB;
270
271 $query = "SELECT * FROM cal_shared_status ".
272 "WHERE usr_id = ".$this->db->quote($this->usr_id ,'integer')." ";
273 $res = $this->db->query($query);
274 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
275 {
276 $this->calendars[$row->cal_id] = $row->status;
277 }
278 }

References $ilDB, $query, $res, $row, and DB_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: