ILIAS  release_8 Revision v8.24
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.

32 {
33 global $DIC;
34
35 $this->db = $DIC['ilDB'];
36 $this->user = $a_user;
37 }
global $DIC
Definition: feed.php:28

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

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

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 }

References ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ deleteTemporaryLists()

ilMailingLists::deleteTemporaryLists ( )

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

140 : void
141 {
142 foreach ($this->getAll() as $mlist) {
143 if ($mlist->getMode() === ilMailingList::MODE_TEMPORARY) {
144 $mlist->delete();
145 }
146 }
147 }

References getAll(), and ilMailingList\MODE_TEMPORARY.

+ Here is the call graph for this function:

◆ get()

ilMailingLists::get ( int  $id = 0)

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

52 {
53 return new ilMailingList($this->user, $id);
54 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ getAll()

ilMailingLists::getAll ( )
Returns
ilMailingList[]

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

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

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

Referenced by deleteTemporaryLists().

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

136 {
137 return $this->ml;
138 }

References $ml.

Referenced by mailingListExists().

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

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 }

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

+ Here is the call graph for this function:

◆ hasAny()

ilMailingLists::hasAny ( )

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

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 }

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

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

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 }

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

+ Here is the call graph for this function:

◆ mailingListExists()

ilMailingLists::mailingListExists ( string  $a_list_name)

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

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)

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

+ Here is the call graph for this function:

◆ setCurrentMailingList()

ilMailingLists::setCurrentMailingList ( int  $id = 0)

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

129 : void
130 {
131 $this->ml = $this->get($id);
132 }

References $id.

Referenced by mailingListExists().

+ 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: