ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMailingLists Class Reference
+ Collaboration diagram for ilMailingLists:

Public Member Functions

 __construct (ilObjUser $a_user)
 
 isOwner (int $a_ml_id, int $a_usr_id)
 
 get (int $id=0)
 
 getSelected (array $a_ids=[])
 
 hasAny ()
 
 getAll ()
 
 mailingListExists (string $a_list_name)
 
 setCurrentMailingList (int $id=0)
 
 getCurrentMailingList ()
 
 deleteTemporaryLists ()
 
 deleteLists ()
 
 deleteAssignments ()
 

Private Attributes

ilDBInterface $db
 
ilObjUser $user
 
ilMailingList $ml = null
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ __construct()

ilMailingLists::__construct ( ilObjUser  $a_user)

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

References $DIC, and ILIAS\Repository\user().

32  {
33  global $DIC;
34 
35  $this->db = $DIC['ilDB'];
36  $this->user = $a_user;
37  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ deleteAssignments()

ilMailingLists::deleteAssignments ( )

Definition at line 163 of file class.ilMailingLists.php.

163  : void
164  {
165  $this->db->manipulate(
166  'DELETE FROM addressbook_mlist_ass WHERE usr_id = ' . $this->db->quote($this->user->getId(), 'integer')
167  );
168  }

◆ deleteLists()

ilMailingLists::deleteLists ( )

Definition at line 149 of file class.ilMailingLists.php.

References ILIAS\Repository\user().

149  : void
150  {
151  $this->db->manipulateF(
152  'DELETE ass FROM addressbook_mlist_ass ass INNER JOIN addressbook_mlist list ON ass.ml_id = list.ml_id WHERE list.user_id = %s',
153  ['integer'],
154  [$this->user->getId()]
155  );
156  $this->db->manipulateF(
157  'DELETE FROM addressbook_mlist WHERE user_id = %s',
158  ['integer'],
159  [$this->user->getId()]
160  );
161  }
+ Here is the call graph for this function:

◆ deleteTemporaryLists()

ilMailingLists::deleteTemporaryLists ( )

Definition at line 140 of file class.ilMailingLists.php.

References getAll(), and ilMailingList\MODE_TEMPORARY.

140  : void
141  {
142  foreach ($this->getAll() as $mlist) {
143  if ($mlist->getMode() === ilMailingList::MODE_TEMPORARY) {
144  $mlist->delete();
145  }
146  }
147  }
+ Here is the call graph for this function:

◆ get()

ilMailingLists::get ( int  $id = 0)

Definition at line 51 of file class.ilMailingLists.php.

References ILIAS\Repository\user().

52  {
53  return new ilMailingList($this->user, $id);
54  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getAll()

ilMailingLists::getAll ( )
Returns
ilMailingList[]

Definition at line 86 of file class.ilMailingLists.php.

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

Referenced by deleteTemporaryLists().

86  : array
87  {
88  $res = $this->db->queryF(
89  'SELECT * FROM addressbook_mlist WHERE user_id = %s',
90  ['integer'],
91  [$this->user->getId()]
92  );
93 
94  $entries = [];
95 
96  $counter = 0;
97  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
98  $tmpObj = new ilMailingList($this->user, 0);
99  $tmpObj->setId((int) $row->ml_id);
100  $tmpObj->setUserId((int) $row->user_id);
101  $tmpObj->setTitle($row->title);
102  $tmpObj->setDescription($row->description);
103  $tmpObj->setCreatedate($row->createdate);
104  $tmpObj->setChangedate($row->changedate);
105  $tmpObj->setMode((int) $row->lmode);
106 
107  $entries[$counter] = $tmpObj;
108 
109  unset($tmpObj);
110 
111  ++$counter;
112  }
113 
114  return $entries;
115  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCurrentMailingList()

ilMailingLists::getCurrentMailingList ( )

Definition at line 135 of file class.ilMailingLists.php.

References $ml.

Referenced by mailingListExists().

135  : ?ilMailingList
136  {
137  return $this->ml;
138  }
+ Here is the caller graph for this function:

◆ getSelected()

ilMailingLists::getSelected ( array  $a_ids = [])
Parameters
int[]$a_ids
Returns
ilMailingList[]

Definition at line 60 of file class.ilMailingLists.php.

References ILIAS\Repository\user().

60  : array
61  {
62  $entries = [];
63 
64  foreach ($a_ids as $id) {
65  $entries[] = new ilMailingList($this->user, (int) $id);
66  }
67 
68  return $entries;
69  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ hasAny()

ilMailingLists::hasAny ( )

Definition at line 71 of file class.ilMailingLists.php.

References $res, and ILIAS\Repository\user().

71  : bool
72  {
73  $res = $this->db->queryF(
74  'SELECT EXISTS(SELECT 1 FROM addressbook_mlist WHERE user_id = %s) cnt',
75  ['integer'],
76  [$this->user->getId()]
77  );
78  $row = $this->db->fetchAssoc($res);
79 
80  return (is_array($row) && (int) $row['cnt'] === 1);
81  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:

◆ isOwner()

ilMailingLists::isOwner ( int  $a_ml_id,
int  $a_usr_id 
)

Definition at line 39 of file class.ilMailingLists.php.

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

39  : bool
40  {
41  $res = $this->db->queryF(
42  'SELECT EXISTS(SELECT 1 FROM addressbook_mlist WHERE ml_id = %s AND user_id = %s) cnt',
43  ['integer', 'integer'],
44  [$a_ml_id, $a_usr_id]
45  );
46  $row = $this->db->fetchAssoc($res);
47 
48  return is_array($row) && (int) $row['cnt'] === 1;
49  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:

◆ mailingListExists()

ilMailingLists::mailingListExists ( string  $a_list_name)

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

References getCurrentMailingList(), ILIAS\Repository\int(), and setCurrentMailingList().

117  : bool
118  {
119  $ml_id = (int) substr($a_list_name, strrpos($a_list_name, '_') + 1);
120  if (!is_numeric($ml_id) || $ml_id <= 0) {
121  return false;
122  }
123 
124  $this->setCurrentMailingList($ml_id);
125 
126  return $this->getCurrentMailingList()->doesExist();
127  }
setCurrentMailingList(int $id=0)
+ Here is the call graph for this function:

◆ setCurrentMailingList()

ilMailingLists::setCurrentMailingList ( int  $id = 0)

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

References $id.

Referenced by mailingListExists().

129  : void
130  {
131  $this->ml = $this->get($id);
132  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilDBInterface ilMailingLists::$db
private

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

◆ $ml

ilMailingList ilMailingLists::$ml = null
private

Definition at line 29 of file class.ilMailingLists.php.

Referenced by getCurrentMailingList().

◆ $user

ilObjUser ilMailingLists::$user
private

Definition at line 28 of file class.ilMailingLists.php.


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