19 declare(strict_types=1);
44 $this->db = $DIC[
'ilDB'];
45 $this->user_id = $user->
getId();
47 $this->
setMode(self::MODE_ADDRESSBOOK);
54 $nextId = $this->db->nextId(
'addressbook_mlist');
55 $this->db->manipulateF(
57 INSERT INTO addressbook_mlist 66 VALUES(%s, %s, %s, %s, %s, %s, %s)',
87 $this->mail_id = $nextId;
95 if ($this->mail_id && $this->user_id) {
96 $this->db->manipulateF(
98 UPDATE addressbook_mlist 129 public function delete():
bool 131 if ($this->mail_id && $this->user_id) {
134 $this->db->manipulateF(
135 'DELETE FROM addressbook_mlist WHERE ml_id = %s AND user_id = %s',
136 [
'integer',
'integer'],
139 $this->exists =
false;
150 $res = $this->db->queryF(
151 'SELECT * FROM addressbook_mlist WHERE ml_id = %s AND user_id =%s',
152 [
'integer',
'integer'],
158 if (is_object($row)) {
159 $this->
setId((
int) $row->ml_id);
165 $this->
setMode((
int) $row->lmode);
166 $this->exists =
true;
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',
185 $entries[(
int) $row->a_id] = [
186 'a_id' => (
int) $row->a_id,
187 'usr_id' => (
int) $row->usr_id
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]
209 $this->db->manipulateF(
210 'DELETE FROM addressbook_mlist_ass WHERE a_id = %s',
220 $this->db->manipulateF(
221 'DELETE FROM addressbook_mlist_ass WHERE ml_id = %s',
228 public function setId(
int $a_mail_id = 0): void
230 $this->mail_id = $a_mail_id;
235 return $this->mail_id;
240 $this->user_id = $a_user_id;
248 public function setTitle(
string $a_title =
''): void
250 $this->title = $a_title;
260 $this->description = $a_description;
270 $this->createdate = $_createdate;
280 $this->changedate = $a_changedate;
290 if (in_array($a_mode, [self::MODE_ADDRESSBOOK, self::MODE_TEMPORARY],
true)) {
291 $this->mode = $a_mode;
setCreatedate(string $_createdate)
assignUser(int $usr_id=0)
setTitle(string $a_title='')
setDescription(?string $a_description='')
setChangedate(?string $a_changedate)
__construct(ilObjUser $user, private int $mail_id=0)
readonly ilDBInterface $db
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
final const MODE_TEMPORARY
final const MODE_ADDRESSBOOK
setUserId(int $a_user_id=0)