ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilMailingLists.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once "Services/Contact/classes/class.ilMailingList.php";
25 
32 {
36  private $db;
37 
41  private $user;
42 
46  private $ml = null;
47 
52  public function __construct(ilObjUser $a_user)
53  {
54  global $DIC;
55 
56  $this->db = $DIC['ilDB'];
57  $this->user = $a_user;
58  }
59 
60  public function get($id = 0)
61  {
62  return new ilMailingList($this->user, $id);
63  }
64 
65  public function getSelected($a_ids = array())
66  {
67  $entries = array();
68 
69  if (is_array($a_ids) && !empty($a_ids)) {
70  $counter = 0;
71  while ($id = @array_pop($a_ids)) {
72  $entries[$counter] = new ilMailingList($this->user, $id);
73 
74  ++$counter;
75  }
76  }
77 
78  return $entries;
79  }
80 
81  public function getAll()
82  {
83  $res = $this->db->queryf(
84  '
85  SELECT * FROM addressbook_mlist
86  WHERE user_id = %s',
87  array('integer'),
88  array($this->user->getId())
89  );
90 
91  $entries = array();
92 
93  $counter = 0;
94  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
95  $tmpObj = new ilMailingList($this->user, 0);
96  $tmpObj->setId($row->ml_id);
97  $tmpObj->setUserId($row->user_id);
98  $tmpObj->setTitle($row->title);
99  $tmpObj->setDescription($row->description);
100  $tmpObj->setCreatedate($row->createdate);
101  $tmpObj->setChangedate($row->changedae);
102  $tmpObj->setMode($row->lmode);
103 
104  $entries[$counter] = $tmpObj;
105 
106  unset($tmpObj);
107 
108  ++$counter;
109  }
110 
111  return $entries;
112  }
113 
114  public function mailingListExists($a_list_name)
115  {
116  $ml_id = substr($a_list_name, strrpos($a_list_name, '_') + 1);
117 
118  if (!is_numeric($ml_id) || $ml_id <= 0) {
119  return false;
120  } else {
121  $this->setCurrentMailingList($ml_id);
122  }
123 
124  return true;
125  }
126 
127  public function setCurrentMailingList($id = 0)
128  {
129  $this->ml = $this->get($id);
130  }
131 
135  public function getCurrentMailingList()
136  {
137  return $this->ml;
138  }
139 
140  public function deleteTemporaryLists()
141  {
142  foreach ($this->getAll() as $mlist) {
143  if ($mlist->getMode() == ilMailingList::MODE_TEMPORARY) {
144  $mlist->delete();
145  }
146  }
147  }
148 }
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id
mailingListExists($a_list_name)
user()
Definition: user.php:4
$counter
getSelected($a_ids=array())
foreach($_POST as $key=> $value) $res
__construct(ilObjUser $a_user)
ilMailingLists constructor.
Create styles array
The data for the language used.