ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
24require_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 {
71 $counter = 0;
72 while($id = @array_pop($a_ids))
73 {
74 $entries[$counter] = new ilMailingList($this->user, $id);
75
76 ++$counter;
77 }
78 }
79
80 return $entries;
81 }
82
83 public function getAll()
84 {
85 $res = $this->db->queryf('
86 SELECT * FROM addressbook_mlist
87 WHERE user_id = %s',
88 array('integer'), array($this->user->getId()));
89
90 $entries = array();
91
92 $counter = 0;
93 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
94 {
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 {
120 return false;
121 }
122 else
123 {
124 $this->setCurrentMailingList($ml_id);
125 }
126
127 return true;
128 }
129
130 public function setCurrentMailingList($id = 0)
131 {
132 $this->ml = $this->get($id);
133 }
134
138 public function getCurrentMailingList()
139 {
140 return $this->ml;
141 }
142
143 public function deleteTemporaryLists()
144 {
145 foreach($this->getAll() as $mlist)
146 {
147 if($mlist->getMode() == ilMailingList::MODE_TEMPORARY)
148 {
149 $mlist->delete();
150 }
151 }
152 }
153}
154?>
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
getSelected($a_ids=array())
__construct(ilObjUser $a_user)
ilMailingLists constructor.
mailingListExists($a_list_name)
$counter
global $DIC