ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilGroupXMLWriter.php
Go to the documentation of this file.
1<?php
2
3/*
4 +-----------------------------------------------------------------------------+
5 | ILIAS open source |
6 +-----------------------------------------------------------------------------+
7 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
8 | |
9 | This program is free software; you can redistribute it and/or |
10 | modify it under the terms of the GNU General Public License |
11 | as published by the Free Software Foundation; either version 2 |
12 | of the License, or (at your option) any later version. |
13 | |
14 | This program is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | GNU General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU General Public License |
20 | along with this program; if not, write to the Free Software |
21 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22 +-----------------------------------------------------------------------------+
23*/
24
25include_once "./Services/Xml/classes/class.ilXmlWriter.php";
26include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
27
37{
38 const MODE_SOAP = 1;
39 const MODE_EXPORT = 2;
40
42
43
44 private $ilias;
45
46 private $xml;
47 private $group_obj;
48 private $attach_users = true;
49
57 public function __construct($group_obj)
58 {
59 global $ilias;
60
61 parent::__construct();
62
63 $this->EXPORT_VERSION = "3";
64
65 $this->ilias =&$ilias;
66 $this->group_obj =&$group_obj;
67 $this->participants = ilGroupParticipants::_getInstanceByObjId($this->group_obj->getId());
68 }
69
70 public function setMode($a_mode)
71 {
72 $this->mode = $a_mode;
73 }
74
75 public function getMode()
76 {
77 return $this->mode;
78 }
79
80 public function start()
81 {
82 if ($this->getMode() == self::MODE_SOAP) {
83 $this->__buildHeader();
84 $this->__buildGroup();
86 $this->__buildRegistration();
87 $this->__buildExtraSettings();
88 if ($this->attach_users) {
89 $this->__buildAdmin();
90 $this->__buildMember();
91 }
92 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
94 ilContainer::_exportContainerSettings($this, $this->group_obj->getId());
95 $this->__buildFooter();
96 } elseif ($this->getMode() == self::MODE_EXPORT) {
97 $this->__buildGroup();
99 $this->__buildRegistration();
100 $this->__buildExtraSettings();
101 $this->__buildPeriod();
102 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
103 ilContainerSortingSettings::_exportContainerSortingSettings($this, $this->group_obj->getId());
104 ilContainer::_exportContainerSettings($this, $this->group_obj->getId());
105 $this->__buildFooter();
106 }
107 }
108
109 public function getXML()
110 {
111 return $this->xmlDumpMem(false);
112 }
113
114 // PRIVATE
115 public function __buildHeader()
116 {
117 $this->xmlSetDtdDef("<!DOCTYPE group PUBLIC \"-//ILIAS//DTD Group//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_group_3_10.dtd\">");
118 $this->xmlSetGenCmt("Export of ILIAS group " . $this->group_obj->getId() . " of installation " . $this->ilias->getSetting('inst_id') . ".");
119 $this->xmlHeader();
120
121
122 return true;
123 }
124
129 public function __buildGroup()
130 {
131 $attrs["exportVersion"] = $this->EXPORT_VERSION;
132 $attrs["id"] = "il_" . $this->ilias->getSetting('inst_id') . '_grp_' . $this->group_obj->getId();
133
134 switch ($this->group_obj->readGroupStatus()) {
135 case GRP_TYPE_PUBLIC:
136 $attrs['type'] = 'open';
137 break;
138
139 case GRP_TYPE_CLOSED:
140 default:
141 $attrs['type'] = 'closed';
142 break;
143 }
144
145 $this->xmlStartTag("group", $attrs);
146 }
147
148 public function __buildTitleDescription()
149 {
150 $this->xmlElement('title', null, $this->group_obj->getTitle());
151
152 if ($desc = $this->group_obj->getDescription()) {
153 $this->xmlElement('description', null, $desc);
154 }
155
156 $attr['id'] = 'il_' . $this->ilias->getSetting('inst_id') . '_usr_' . $this->group_obj->getOwner();
157 $this->xmlElement('owner', $attr);
158
159 $this->xmlElement('information', null, $this->group_obj->getInformation());
160 }
161
165 protected function __buildPeriod()
166 {
167 if (
168 $this->group_obj->getStart() instanceof ilDate &&
169 $this->group_obj->getEnd() instanceof ilDate
170 ) {
171 $this->xmlStartTag('period');
172 $this->xmlElement('start', null, $this->group_obj->getStart()->get(IL_CAL_UNIX));
173 $this->xmlElement('end', null, $this->group_obj->getEnd()->get(IL_CAL_UNIX));
174 $this->xmlEndTag('period');
175 }
176 return;
177 }
178
179 public function __buildRegistration()
180 {
181
182 // registration type
183 switch ($this->group_obj->getRegistrationType()) {
185 $attrs['type'] = 'direct';
186 break;
188 $attrs['type'] = 'confirmation';
189 break;
191 $attrs['type'] = 'password';
192 break;
193
194 default:
196 $attrs['type'] = 'disabled';
197 break;
198 }
199 $attrs['waitingList'] = $this->group_obj->isWaitingListEnabled() ? 'Yes' : 'No';
200
201 $this->xmlStartTag('registration', $attrs);
202
203 if (strlen($pwd = $this->group_obj->getPassword())) {
204 $this->xmlElement('password', null, $pwd);
205 }
206
207
208 // limited registration period
209 if (!$this->group_obj->isRegistrationUnlimited()) {
210 $this->xmlStartTag('temporarilyAvailable');
211 $this->xmlElement('start', null, $this->group_obj->getRegistrationStart()->get(IL_CAL_UNIX));
212 $this->xmlElement('end', null, $this->group_obj->getRegistrationEnd()->get(IL_CAL_UNIX));
213 $this->xmlEndTag('temporarilyAvailable');
214 }
215
216 // max members
217 $attrs = array();
218 $attrs['enabled'] = $this->group_obj->isMembershipLimited() ? 'Yes' : 'No';
219 $this->xmlElement('maxMembers', $attrs, $this->group_obj->getMaxMembers());
220 $this->xmlElement('minMembers', null, (int) $this->group_obj->getMinMembers());
221 $this->xmlElement('WaitingListAutoFill', null, (int) $this->group_obj->hasWaitingListAutoFill());
222 $this->xmlElement('CancellationEnd', null, ($this->group_obj->getCancellationEnd() && !$this->group_obj->getCancellationEnd()->isNull()) ? $this->group_obj->getCancellationEnd()->get(IL_CAL_UNIX) : null);
223
224 $this->xmlElement('mailMembersType', null, (string) $this->group_obj->getMailToMembersType());
225
226 $this->xmlEndTag('registration');
227 }
228
232 public function __buildExtraSettings()
233 {
234 $this->xmlElement('showMembers', null, $this->group_obj->getShowMembers());
235 }
236
237 public function __buildAdmin()
238 {
239 $admins = $this->group_obj->getGroupAdminIds();
240 $admins = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
241 'manage_members',
243 $this->group_obj->getRefId(),
244 $admins
245 );
246
247 foreach ($admins as $id) {
248 $attr['id'] = 'il_' . $this->ilias->getSetting('inst_id') . '_usr_' . $id;
249 $attr['notification'] = $this->participants->isNotificationEnabled($id) ? 'Yes' : 'No';
250
251 $this->xmlElement('admin', $attr);
252 }
253 return true;
254 }
255
256 public function __buildMember()
257 {
258 $members = $this->group_obj->getGroupMemberIds();
259 $members = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
260 'manage_members',
262 $this->group_obj->getRefId(),
263 $members
264 );
265 foreach ($members as $id) {
266 if (!$this->group_obj->isAdmin($id)) {
267 $attr['id'] = 'il_' . $this->ilias->getSetting('inst_id') . '_usr_' . $id;
268
269 $this->xmlElement('member', $attr);
270 }
271 }
272 return true;
273 }
274
275 public function __buildFooter()
276 {
277 $this->xmlEndTag('group');
278 }
279
280 public function setAttachUsers($value)
281 {
282 $this->attach_users = $value ? true : false;
283 }
284}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
const GRP_REGISTRATION_DIRECT
const GRP_REGISTRATION_PASSWORD
const GRP_TYPE_CLOSED
const GRP_REGISTRATION_DEACTIVATED
const GRP_REGISTRATION_REQUEST
const GRP_TYPE_PUBLIC
static _exportContainerSortingSettings(ilXmlWriter $xml, $obj_id)
sorting XML-export for all container objects
static _exportContainerSettings(ilXmlWriter $a_xml, $a_obj_id)
Class for single dates.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
__construct($group_obj)
constructor
__buildExtraSettings()
Build extra settings, like "show member list".
__buildPeriod()
Build group period.
XML writer class.
xmlEndTag($tag)
Writes an endtag.
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlDumpMem($format=true)
Returns xml document from memory.
xmlHeader()
Writes xml header @access public.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
if(!array_key_exists('StateId', $_REQUEST)) $id
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
redirection script todo: (a better solution should control the processing via a xml file)