ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMailingList Class Reference
+ Collaboration diagram for ilMailingList:

Public Member Functions

 __construct (ilObjUser $user, private int $mail_id=0)
 
 insert ()
 
 update ()
 
 delete ()
 
 getAssignedEntries ()
 
 assignUser (int $usr_id=0)
 
 deleteEntry (int $a_id=0)
 
 deassignAllEntries ()
 
 setId (int $a_mail_id=0)
 
 getId ()
 
 setUserId (int $a_user_id=0)
 
 getUserId ()
 
 setTitle (string $a_title='')
 
 getTitle ()
 
 setDescription (?string $a_description='')
 
 getDescription ()
 
 setCreatedate (string $_createdate)
 
 getCreatedate ()
 
 setChangedate (?string $a_changedate)
 
 getChangedate ()
 
 setMode (int $a_mode)
 
 getMode ()
 
 doesExist ()
 

Data Fields

final const int MODE_ADDRESSBOOK = 1
 
final const int MODE_TEMPORARY = 2
 

Private Member Functions

 read ()
 

Private Attributes

int $user_id
 
string $title = ''
 
string $description = ''
 
string $createdate
 
string $changedate = null
 
readonly ilDBInterface $db
 
int $mode
 
bool $exists = false
 

Detailed Description

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

Definition at line 25 of file class.ilMailingList.php.

Constructor & Destructor Documentation

◆ __construct()

ilMailingList::__construct ( ilObjUser  $user,
private int  $mail_id = 0 
)

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

41 {
42 global $DIC;
43
44 $this->db = $DIC['ilDB'];
45 $this->user_id = $user->getId();
46
47 $this->setMode(self::MODE_ADDRESSBOOK);
48
49 $this->read();
50 }
setMode(int $a_mode)
global $DIC
Definition: shib_login.php:26

References $DIC, ilObject\getId(), read(), and setMode().

+ Here is the call graph for this function:

Member Function Documentation

◆ assignUser()

ilMailingList::assignUser ( int  $usr_id = 0)

Definition at line 195 of file class.ilMailingList.php.

195 : bool
196 {
197 $nextId = $this->db->nextId('addressbook_mlist_ass');
198 $this->db->manipulateF(
199 'INSERT INTO addressbook_mlist_ass (a_id, ml_id, usr_id) VALUES(%s, %s, %s)',
200 ['integer', 'integer', 'integer'],
201 [$nextId, $this->getId(), $usr_id]
202 );
203 return true;
204 }

References getId().

+ Here is the call graph for this function:

◆ deassignAllEntries()

ilMailingList::deassignAllEntries ( )

Definition at line 218 of file class.ilMailingList.php.

218 : bool
219 {
220 $this->db->manipulateF(
221 'DELETE FROM addressbook_mlist_ass WHERE ml_id = %s',
222 ['integer'],
223 [$this->getId()]
224 );
225 return true;
226 }

References getId().

Referenced by delete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilMailingList::delete ( )

Definition at line 129 of file class.ilMailingList.php.

129 : bool
130 {
131 if ($this->mail_id && $this->user_id) {
132 $this->deassignAllEntries();
133
134 $this->db->manipulateF(
135 'DELETE FROM addressbook_mlist WHERE ml_id = %s AND user_id = %s',
136 ['integer', 'integer'],
137 [$this->getId(), $this->getUserId()]
138 );
139 $this->exists = false;
140
141 return true;
142 }
143
144 return false;
145 }

References deassignAllEntries(), getId(), and getUserId().

+ Here is the call graph for this function:

◆ deleteEntry()

ilMailingList::deleteEntry ( int  $a_id = 0)

Definition at line 207 of file class.ilMailingList.php.

207 : bool
208 {
209 $this->db->manipulateF(
210 'DELETE FROM addressbook_mlist_ass WHERE a_id = %s',
211 ['integer'],
212 [$a_id]
213 );
214 return true;
215 }

◆ doesExist()

ilMailingList::doesExist ( )

Definition at line 299 of file class.ilMailingList.php.

299 : bool
300 {
301 return $this->exists;
302 }

References $exists.

◆ getAssignedEntries()

ilMailingList::getAssignedEntries ( )
Returns
array<int, array{a_id: int, usr_id: int}>

Definition at line 174 of file class.ilMailingList.php.

174 : array
175 {
176 $res = $this->db->queryF(
177 'SELECT a_id, usr_data.usr_id FROM addressbook_mlist_ass ' .
178 'INNER JOIN usr_data ON usr_data.usr_id = addressbook_mlist_ass.usr_id WHERE ml_id = %s',
179 ['integer'],
180 [$this->getId()]
181 );
182
183 $entries = [];
184 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
185 $entries[(int) $row->a_id] = [
186 'a_id' => (int) $row->a_id,
187 'usr_id' => (int) $row->usr_id
188 ];
189 }
190
191 return $entries;
192 }
$res
Definition: ltiservices.php:69

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

+ Here is the call graph for this function:

◆ getChangedate()

ilMailingList::getChangedate ( )

Definition at line 283 of file class.ilMailingList.php.

283 : ?string
284 {
285 return $this->changedate;
286 }

References $changedate.

Referenced by update().

+ Here is the caller graph for this function:

◆ getCreatedate()

ilMailingList::getCreatedate ( )

Definition at line 273 of file class.ilMailingList.php.

273 : string
274 {
275 return $this->createdate;
276 }

References $createdate.

Referenced by insert().

+ Here is the caller graph for this function:

◆ getDescription()

ilMailingList::getDescription ( )

Definition at line 263 of file class.ilMailingList.php.

263 : ?string
264 {
265 return $this->description;
266 }

References $description.

Referenced by insert(), and update().

+ Here is the caller graph for this function:

◆ getId()

ilMailingList::getId ( )

Definition at line 233 of file class.ilMailingList.php.

233 : int
234 {
235 return $this->mail_id;
236 }

Referenced by assignUser(), deassignAllEntries(), delete(), getAssignedEntries(), read(), and update().

+ Here is the caller graph for this function:

◆ getMode()

ilMailingList::getMode ( )

Definition at line 295 of file class.ilMailingList.php.

295 : int
296 {
297 return $this->mode;
298 }

References $mode.

Referenced by insert(), and update().

+ Here is the caller graph for this function:

◆ getTitle()

ilMailingList::getTitle ( )

Definition at line 253 of file class.ilMailingList.php.

253 : string
254 {
255 return $this->title;
256 }

References $title.

Referenced by insert(), and update().

+ Here is the caller graph for this function:

◆ getUserId()

ilMailingList::getUserId ( )

Definition at line 243 of file class.ilMailingList.php.

243 : int
244 {
245 return $this->user_id;
246 }

References $user_id.

Referenced by delete(), insert(), read(), and update().

+ Here is the caller graph for this function:

◆ insert()

ilMailingList::insert ( )

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

52 : bool
53 {
54 $nextId = $this->db->nextId('addressbook_mlist');
55 $this->db->manipulateF(
56 '
57 INSERT INTO addressbook_mlist
58 ( ml_id,
59 user_id,
60 title,
61 description,
62 createdate,
63 changedate,
64 lmode
65 )
66 VALUES(%s, %s, %s, %s, %s, %s, %s)',
67 [
68 'integer',
69 'integer',
70 'text',
71 'text',
72 'timestamp',
73 'timestamp',
74 'integer'
75 ],
76 [
77 $nextId,
78 $this->getUserId(),
79 $this->getTitle(),
80 $this->getDescription(),
81 $this->getCreatedate(),
82 null,
83 $this->getMode()
84 ]
85 );
86
87 $this->mail_id = $nextId;
88 $this->exists = true;
89
90 return true;
91 }

References getCreatedate(), getDescription(), getMode(), getTitle(), and getUserId().

+ Here is the call graph for this function:

◆ read()

ilMailingList::read ( )
private

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

147 : void
148 {
149 if ($this->getId() && $this->getUserId()) {
150 $res = $this->db->queryF(
151 'SELECT * FROM addressbook_mlist WHERE ml_id = %s AND user_id =%s',
152 ['integer', 'integer'],
153 [$this->getId(), $this->getUserId()]
154 );
155
156 $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
157
158 if (is_object($row)) {
159 $this->setId((int) $row->ml_id);
160 $this->setUserId((int) $row->user_id);
161 $this->setTitle($row->title);
162 $this->setDescription($row->description);
163 $this->setCreatedate($row->createdate);
164 $this->setChangedate($row->changedate);
165 $this->setMode((int) $row->lmode);
166 $this->exists = true;
167 }
168 }
169 }
setTitle(string $a_title='')
setCreatedate(string $_createdate)
setChangedate(?string $a_changedate)
setDescription(?string $a_description='')
setUserId(int $a_user_id=0)
setId(int $a_mail_id=0)

References $res, ilDBConstants\FETCHMODE_OBJECT, getId(), getUserId(), setChangedate(), setCreatedate(), setDescription(), setId(), setMode(), setTitle(), and setUserId().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setChangedate()

ilMailingList::setChangedate ( ?string  $a_changedate)

Definition at line 278 of file class.ilMailingList.php.

278 : void
279 {
280 $this->changedate = $a_changedate;
281 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setCreatedate()

ilMailingList::setCreatedate ( string  $_createdate)

Definition at line 268 of file class.ilMailingList.php.

268 : void
269 {
270 $this->createdate = $_createdate;
271 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setDescription()

ilMailingList::setDescription ( ?string  $a_description = '')

Definition at line 258 of file class.ilMailingList.php.

258 : void
259 {
260 $this->description = $a_description;
261 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setId()

ilMailingList::setId ( int  $a_mail_id = 0)

Definition at line 228 of file class.ilMailingList.php.

228 : void
229 {
230 $this->mail_id = $a_mail_id;
231 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setMode()

ilMailingList::setMode ( int  $a_mode)

Definition at line 288 of file class.ilMailingList.php.

288 : void
289 {
290 if (in_array($a_mode, [self::MODE_ADDRESSBOOK, self::MODE_TEMPORARY], true)) {
291 $this->mode = $a_mode;
292 }
293 }

Referenced by __construct(), and read().

+ Here is the caller graph for this function:

◆ setTitle()

ilMailingList::setTitle ( string  $a_title = '')

Definition at line 248 of file class.ilMailingList.php.

248 : void
249 {
250 $this->title = $a_title;
251 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setUserId()

ilMailingList::setUserId ( int  $a_user_id = 0)

Definition at line 238 of file class.ilMailingList.php.

238 : void
239 {
240 $this->user_id = $a_user_id;
241 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilMailingList::update ( )

Definition at line 93 of file class.ilMailingList.php.

93 : bool
94 {
95 if ($this->mail_id && $this->user_id) {
96 $this->db->manipulateF(
97 '
98 UPDATE addressbook_mlist
99 SET title = %s,
100 description = %s,
101 changedate = %s,
102 lmode = %s
103 WHERE ml_id = %s
104 AND user_id = %s',
105 [
106 'text',
107 'text',
108 'timestamp',
109 'integer',
110 'integer',
111 'integer'
112 ],
113 [
114 $this->getTitle(),
115 $this->getDescription(),
116 $this->getChangedate(),
117 $this->getMode(),
118 $this->getId(),
119 $this->getUserId()
120 ]
121 );
122
123 return true;
124 }
125
126 return false;
127 }

References getChangedate(), getDescription(), getId(), getMode(), getTitle(), and getUserId().

+ Here is the call graph for this function:

Field Documentation

◆ $changedate

string ilMailingList::$changedate = null
private

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

Referenced by getChangedate().

◆ $createdate

string ilMailingList::$createdate
private

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

Referenced by getCreatedate().

◆ $db

readonly ilDBInterface ilMailingList::$db
private

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

◆ $description

string ilMailingList::$description = ''
private

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

Referenced by getDescription().

◆ $exists

bool ilMailingList::$exists = false
private

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

Referenced by doesExist().

◆ $mode

int ilMailingList::$mode
private

Definition at line 37 of file class.ilMailingList.php.

Referenced by getMode().

◆ $title

string ilMailingList::$title = ''
private

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

Referenced by getTitle().

◆ $user_id

int ilMailingList::$user_id
private

Definition at line 30 of file class.ilMailingList.php.

Referenced by getUserId().

◆ MODE_ADDRESSBOOK

final const int ilMailingList::MODE_ADDRESSBOOK = 1

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

◆ MODE_TEMPORARY

final const int ilMailingList::MODE_TEMPORARY = 2

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