ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
60
61 $ilias = $DIC['ilias'];
62
63 parent::__construct();
64
65 $this->EXPORT_VERSION = "3";
66
67 $this->ilias = $ilias;
68 $this->group_obj = $group_obj;
69 $this->participants = ilGroupParticipants::_getInstanceByObjId($this->group_obj->getId());
70 }
71
72 public function setMode($a_mode)
73 {
74 $this->mode = $a_mode;
75 }
76
77 public function getMode()
78 {
79 return $this->mode;
80 }
81
82 public function start()
83 {
84 if ($this->getMode() == self::MODE_SOAP) {
85 $this->__buildHeader();
86 $this->__buildGroup();
87 $this->__buildMetaData();
90 $this->__buildRegistration();
91 $this->__buildExtraSettings();
92 if ($this->attach_users) {
93 $this->__buildAdmin();
94 $this->__buildMember();
95 }
96 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
98 ilContainer::_exportContainerSettings($this, $this->group_obj->getId());
99 $this->__buildFooter();
100 } elseif ($this->getMode() == self::MODE_EXPORT) {
101 $this->__buildGroup();
102 $this->__buildMetaData();
105 $this->__buildRegistration();
106 $this->__buildExtraSettings();
107 $this->__buildPeriod();
108 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
109 ilContainerSortingSettings::_exportContainerSortingSettings($this, $this->group_obj->getId());
110 ilContainer::_exportContainerSettings($this, $this->group_obj->getId());
111 $this->__buildFooter();
112 }
113 }
114
115 public function getXML()
116 {
117 return $this->xmlDumpMem(false);
118 }
119
120 // PRIVATE
121 public function __buildHeader()
122 {
123 $this->xmlSetDtdDef("<!DOCTYPE group PUBLIC \"-//ILIAS//DTD Group//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_group_3_10.dtd\">");
124 $this->xmlSetGenCmt("Export of ILIAS group " . $this->group_obj->getId() . " of installation " . $this->ilias->getSetting('inst_id') . ".");
125 $this->xmlHeader();
126
127
128 return true;
129 }
130
135 public function __buildGroup()
136 {
137 $attrs["exportVersion"] = $this->EXPORT_VERSION;
138 $attrs["id"] = "il_" . $this->ilias->getSetting('inst_id') . '_grp_' . $this->group_obj->getId();
139
140 switch ($this->group_obj->readGroupStatus()) {
141 case GRP_TYPE_PUBLIC:
142 $attrs['type'] = 'open';
143 break;
144
145 case GRP_TYPE_CLOSED:
146 default:
147 $attrs['type'] = 'closed';
148 break;
149 }
150
151 $this->xmlStartTag("group", $attrs);
152 }
153
158 protected function __buildMetaData()
159 {
160 $md2xml = new ilMD2XML($this->group_obj->getId(), $this->group_obj->getId(), 'grp');
161 $md2xml->startExport();
162 $this->appendXML($md2xml->getXML());
163
164 return true;
165 }
166
173 private function __buildAdvancedMetaData()
174 {
175 ilAdvancedMDValues::_appendXMLByObjId($this, $this->group_obj->getId());
176 }
177
178
179 public function __buildTitleDescription()
180 {
181 $this->xmlElement('title', null, $this->group_obj->getTitle());
182
183 if ($desc = $this->group_obj->getDescription()) {
184 $this->xmlElement('description', null, $desc);
185 }
186
187 $attr['id'] = 'il_' . $this->ilias->getSetting('inst_id') . '_usr_' . $this->group_obj->getOwner();
188 $this->xmlElement('owner', $attr);
189
190 $this->xmlElement('information', null, $this->group_obj->getInformation());
191 }
192
196 protected function __buildPeriod()
197 {
198 if (
199 $this->group_obj->getStart() instanceof ilDate &&
200 $this->group_obj->getEnd() instanceof ilDate
201 ) {
202 $this->xmlStartTag('period');
203 $this->xmlElement('start', null, $this->group_obj->getStart()->get(IL_CAL_UNIX));
204 $this->xmlElement('end', null, $this->group_obj->getEnd()->get(IL_CAL_UNIX));
205 $this->xmlEndTag('period');
206 }
207 return;
208 }
209
210 public function __buildRegistration()
211 {
212
213 // registration type
214 switch ($this->group_obj->getRegistrationType()) {
216 $attrs['type'] = 'direct';
217 break;
219 $attrs['type'] = 'confirmation';
220 break;
222 $attrs['type'] = 'password';
223 break;
224
225 default:
227 $attrs['type'] = 'disabled';
228 break;
229 }
230 $attrs['waitingList'] = $this->group_obj->isWaitingListEnabled() ? 'Yes' : 'No';
231
232 $this->xmlStartTag('registration', $attrs);
233
234 if (strlen($pwd = $this->group_obj->getPassword())) {
235 $this->xmlElement('password', null, $pwd);
236 }
237
238
239 // limited registration period
240 if (!$this->group_obj->isRegistrationUnlimited()) {
241 $this->xmlStartTag('temporarilyAvailable');
242 $this->xmlElement('start', null, $this->group_obj->getRegistrationStart()->get(IL_CAL_UNIX));
243 $this->xmlElement('end', null, $this->group_obj->getRegistrationEnd()->get(IL_CAL_UNIX));
244 $this->xmlEndTag('temporarilyAvailable');
245 }
246
247 // max members
248 $attrs = array();
249 $attrs['enabled'] = $this->group_obj->isMembershipLimited() ? 'Yes' : 'No';
250 $this->xmlElement('maxMembers', $attrs, $this->group_obj->getMaxMembers());
251 $this->xmlElement('minMembers', null, (int) $this->group_obj->getMinMembers());
252 $this->xmlElement('WaitingListAutoFill', null, (int) $this->group_obj->hasWaitingListAutoFill());
253 $this->xmlElement('CancellationEnd', null, ($this->group_obj->getCancellationEnd() && !$this->group_obj->getCancellationEnd()->isNull()) ? $this->group_obj->getCancellationEnd()->get(IL_CAL_UNIX) : null);
254
255 $this->xmlElement('mailMembersType', null, (string) $this->group_obj->getMailToMembersType());
256
257 $this->xmlEndTag('registration');
258 }
259
263 public function __buildExtraSettings()
264 {
265 $this->xmlElement('showMembers', null, $this->group_obj->getShowMembers());
266 }
267
268 public function __buildAdmin()
269 {
270 $admins = $this->group_obj->getGroupAdminIds();
271 $admins = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
272 'manage_members',
274 $this->group_obj->getRefId(),
275 $admins
276 );
277
278 foreach ($admins as $id) {
279 $attr['id'] = 'il_' . $this->ilias->getSetting('inst_id') . '_usr_' . $id;
280 $attr['notification'] = $this->participants->isNotificationEnabled($id) ? 'Yes' : 'No';
281
282 $this->xmlElement('admin', $attr);
283 }
284 return true;
285 }
286
287 public function __buildMember()
288 {
289 $members = $this->group_obj->getGroupMemberIds();
290 $members = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
291 'manage_members',
293 $this->group_obj->getRefId(),
294 $members
295 );
296 foreach ($members as $id) {
297 if (!$this->group_obj->isAdmin($id)) {
298 $attr['id'] = 'il_' . $this->ilias->getSetting('inst_id') . '_usr_' . $id;
299
300 $this->xmlElement('member', $attr);
301 }
302 }
303 return true;
304 }
305
306 public function __buildFooter()
307 {
308 $this->xmlEndTag('group');
309 }
310
311 public function setAttachUsers($value)
312 {
313 $this->attach_users = $value ? true : false;
314 }
315}
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 _appendXMLByObjId(ilXmlWriter $a_xml_writer, $a_obj_id)
Get xml of object values.
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".
__buildMetaData()
write lom meta data
__buildAdvancedMetaData()
Build advanced meta data.
__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)
appendXML($a_str)
append xml string to document
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['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
redirection script todo: (a better solution should control the processing via a xml file)
global $DIC
Definition: saml.php:7