ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilMailingLists Class Reference
+ Collaboration diagram for ilMailingLists:

Public Member Functions

 __construct (private readonly ilObjUser $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

readonly ilDBInterface $db
 
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 ( private readonly ilObjUser  $user)

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

References $DIC.

31  {
32  global $DIC;
33 
34  $this->db = $DIC['ilDB'];
35  }
global $DIC
Definition: shib_login.php:22

Member Function Documentation

◆ deleteAssignments()

ilMailingLists::deleteAssignments ( )

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

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

◆ deleteLists()

ilMailingLists::deleteLists ( )

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

References ILIAS\Repository\user().

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

◆ deleteTemporaryLists()

ilMailingLists::deleteTemporaryLists ( )

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

References getAll(), and ilMailingList\MODE_TEMPORARY.

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

◆ get()

ilMailingLists::get ( int  $id = 0)

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

References ILIAS\Repository\user().

50  {
51  return new ilMailingList($this->user, $id);
52  }
$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 84 of file class.ilMailingLists.php.

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

Referenced by deleteTemporaryLists().

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

◆ getCurrentMailingList()

ilMailingLists::getCurrentMailingList ( )

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

References $ml.

Referenced by mailingListExists().

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

◆ getSelected()

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

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

References ILIAS\Repository\user().

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

◆ hasAny()

ilMailingLists::hasAny ( )

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

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

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

◆ isOwner()

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

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

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

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

◆ mailingListExists()

ilMailingLists::mailingListExists ( string  $a_list_name)

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

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

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

◆ setCurrentMailingList()

ilMailingLists::setCurrentMailingList ( int  $id = 0)

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

References $id.

Referenced by mailingListExists().

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

Field Documentation

◆ $db

readonly ilDBInterface ilMailingLists::$db
private

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

◆ $ml

ilMailingList ilMailingLists::$ml = null
private

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

Referenced by getCurrentMailingList().


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