ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
33{
34 private $db = null;
35 private $user = null;
36 private $ml = null;
37
38 public function __construct(ilObjUser $a_user)
39 {
40 global $ilDB;
41
42 $this->db = $ilDB;
43 $this->user = $a_user;
44 }
45
46 public function get($id = 0)
47 {
48 return new ilMailingList($this->user, $id);
49 }
50
51 public function getSelected($a_ids = array())
52 {
53 $entries = array();
54
55 if (is_array($a_ids) && !empty($a_ids))
56 {
57 $counter = 0;
58 while($id = @array_pop($a_ids))
59 {
60 $entries[$counter] = new ilMailingList($this->user, $id);
61
62 ++$counter;
63 }
64 }
65
66 return $entries;
67 }
68
69 public function getAll()
70 {
71 $res = $this->db->queryf('
72 SELECT * FROM addressbook_mlist
73 WHERE user_id = %s',
74 array('integer'), array($this->user->getId()));
75
76 $entries = array();
77
78 $counter = 0;
79 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
80 {
81 $tmpObj = new ilMailingList($this->user, 0);
82 $tmpObj->setId($row->ml_id);
83 $tmpObj->setUserId($row->user_id);
84 $tmpObj->setTitle($row->title);
85 $tmpObj->setDescription($row->description);
86 $tmpObj->setCreatedate($row->createdate);
87 $tmpObj->setChangedate($row->changedae);
88 $tmpObj->setMode($row->lmode);
89
90 $entries[$counter] = $tmpObj;
91
92 unset($tmpObj);
93
94 ++$counter;
95 }
96
97 return $entries;
98 }
99
100 public function mailingListExists($a_list_name)
101 {
102 $ml_id = substr($a_list_name, strrpos($a_list_name, '_') + 1);
103
104 if (!is_numeric($ml_id) || $ml_id <= 0)
105 {
106 return false;
107 }
108 else
109 {
110 $this->setCurrentMailingList($ml_id);
111 if ($this->getCurrentMailingList()->getCreateDate() == '0000-00-00 00:00:00') return false;
112 }
113
114 return true;
115 }
116
117 public function setCurrentMailingList($id = 0)
118 {
119 $this->ml = $this->get($id);
120 }
121
125 public function getCurrentMailingList()
126 {
127 return $this->ml;
128 }
129
130 public function deleteTemporaryLists()
131 {
132 foreach($this->getAll() as $mlist)
133 {
134 if($mlist->getMode() == ilMailingList::MODE_TEMPORARY)
135 {
136 $mlist->delete();
137 }
138 }
139 }
140}
141?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
getSelected($a_ids=array())
__construct(ilObjUser $a_user)
mailingListExists($a_list_name)
global $ilDB