ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 MODE_ADDRESSBOOK = 1
 
final const 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.

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

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  }
global $DIC
Definition: shib_login.php:22
setMode(int $a_mode)
+ 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.

References getId().

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  }
+ Here is the call graph for this function:

◆ deassignAllEntries()

ilMailingList::deassignAllEntries ( )

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

References getId().

Referenced by delete().

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

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

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

References $exists.

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

◆ getAssignedEntries()

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

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

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

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:66
+ Here is the call graph for this function:

◆ getChangedate()

ilMailingList::getChangedate ( )

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

References $changedate.

Referenced by update().

283  : ?string
284  {
285  return $this->changedate;
286  }
+ Here is the caller graph for this function:

◆ getCreatedate()

ilMailingList::getCreatedate ( )

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

References $createdate.

Referenced by insert().

273  : string
274  {
275  return $this->createdate;
276  }
+ Here is the caller graph for this function:

◆ getDescription()

ilMailingList::getDescription ( )

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

References $description.

Referenced by insert(), and update().

263  : ?string
264  {
265  return $this->description;
266  }
+ Here is the caller graph for this function:

◆ getId()

ilMailingList::getId ( )

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

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

233  : int
234  {
235  return $this->mail_id;
236  }
+ Here is the caller graph for this function:

◆ getMode()

ilMailingList::getMode ( )

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

References $mode.

Referenced by insert(), and update().

295  : int
296  {
297  return $this->mode;
298  }
+ Here is the caller graph for this function:

◆ getTitle()

ilMailingList::getTitle ( )

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

References $title.

Referenced by insert(), and update().

253  : string
254  {
255  return $this->title;
256  }
+ Here is the caller graph for this function:

◆ getUserId()

ilMailingList::getUserId ( )

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

References $user_id.

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

243  : int
244  {
245  return $this->user_id;
246  }
+ Here is the caller graph for this function:

◆ insert()

ilMailingList::insert ( )

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

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

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ read()

ilMailingList::read ( )
private

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

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

Referenced by __construct().

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  }
setCreatedate(string $_createdate)
$res
Definition: ltiservices.php:66
setId(int $a_mail_id=0)
setTitle(string $a_title='')
setDescription(?string $a_description='')
setChangedate(?string $a_changedate)
setUserId(int $a_user_id=0)
setMode(int $a_mode)
+ 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.

Referenced by read().

278  : void
279  {
280  $this->changedate = $a_changedate;
281  }
+ Here is the caller graph for this function:

◆ setCreatedate()

ilMailingList::setCreatedate ( string  $_createdate)

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

Referenced by read().

268  : void
269  {
270  $this->createdate = $_createdate;
271  }
+ Here is the caller graph for this function:

◆ setDescription()

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

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

Referenced by read().

258  : void
259  {
260  $this->description = $a_description;
261  }
+ 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.

Referenced by read().

228  : void
229  {
230  $this->mail_id = $a_mail_id;
231  }
+ Here is the caller graph for this function:

◆ setMode()

ilMailingList::setMode ( int  $a_mode)

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

Referenced by __construct(), and read().

288  : void
289  {
290  if (in_array($a_mode, [self::MODE_ADDRESSBOOK, self::MODE_TEMPORARY], true)) {
291  $this->mode = $a_mode;
292  }
293  }
+ Here is the caller graph for this function:

◆ setTitle()

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

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

Referenced by read().

248  : void
249  {
250  $this->title = $a_title;
251  }
+ 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.

Referenced by read().

238  : void
239  {
240  $this->user_id = $a_user_id;
241  }
+ Here is the caller graph for this function:

◆ update()

ilMailingList::update ( )

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

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

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  }
+ 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 ilMailingList::MODE_ADDRESSBOOK = 1

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

◆ MODE_TEMPORARY

final const ilMailingList::MODE_TEMPORARY = 2

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