ILIAS  release_7 Revision v7.30-3-g800a261c036
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
46 private $logger = null;
47
48
49 private $ilias;
50
51 private $xml;
52
56 private $group_obj;
57
58 private $attach_users = true;
59
67 public function __construct($group_obj)
68 {
69 global $DIC;
70
71 $ilias = $DIC['ilias'];
72
74
75 $this->logger = $DIC->logger()->grp();
76
77 $this->EXPORT_VERSION = "3";
78
79 $this->ilias = $ilias;
80 $this->group_obj = $group_obj;
81 $this->participants = ilGroupParticipants::_getInstanceByObjId($this->group_obj->getId());
82 }
83
84 public function setMode($a_mode)
85 {
86 $this->mode = $a_mode;
87 }
88
89 public function getMode()
90 {
91 return $this->mode;
92 }
93
94 public function start()
95 {
96 if ($this->getMode() == self::MODE_SOAP) {
97 $this->logger->debug('Using soap mode');
98 $this->__buildHeader();
99 $this->__buildGroup();
100 $this->__buildMetaData();
103 $this->__buildRegistration();
104 $this->__buildExtraSettings();
105 if ($this->attach_users) {
106 $this->__buildAdmin();
107 $this->__buildMember();
108 }
109 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
110 ilContainerSortingSettings::_exportContainerSortingSettings($this, $this->group_obj->getId());
111 ilContainer::_exportContainerSettings($this, $this->group_obj->getId());
112 $this->__buildFooter();
113 } elseif ($this->getMode() == self::MODE_EXPORT) {
114 $this->logger->debug('Using export mode');
115 $this->__buildGroup();
116 $this->__buildMetaData();
119 $this->__buildRegistration();
120 $this->__buildExtraSettings();
121 $this->__buildPeriod();
122 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
123 ilContainerSortingSettings::_exportContainerSortingSettings($this, $this->group_obj->getId());
124 ilContainer::_exportContainerSettings($this, $this->group_obj->getId());
125 $this->__buildFooter();
126 }
127 }
128
129 public function getXML()
130 {
131 return $this->xmlDumpMem(false);
132 }
133
134 // PRIVATE
135 public function __buildHeader()
136 {
137 $this->xmlSetDtdDef("<!DOCTYPE group PUBLIC \"-//ILIAS//DTD Group//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_group_3_10.dtd\">");
138 $this->xmlSetGenCmt("Export of ILIAS group " . $this->group_obj->getId() . " of installation " . $this->ilias->getSetting('inst_id') . ".");
139 $this->xmlHeader();
140
141
142 return true;
143 }
144
149 public function __buildGroup()
150 {
151 $attrs["exportVersion"] = $this->EXPORT_VERSION;
152 $attrs["id"] = "il_" . $this->ilias->getSetting('inst_id') . '_grp_' . $this->group_obj->getId();
153
154 switch ($this->group_obj->readGroupStatus()) {
155 case GRP_TYPE_OPEN:
156 $attrs['type'] = 'open';
157 break;
158
159 case GRP_TYPE_CLOSED:
160 default:
161 $attrs['type'] = 'closed';
162 break;
163 }
164
165 $this->xmlStartTag("group", $attrs);
166 }
167
172 protected function __buildMetaData()
173 {
174 $md2xml = new ilMD2XML($this->group_obj->getId(), $this->group_obj->getId(), 'grp');
175 $md2xml->startExport();
176 $this->appendXML($md2xml->getXML());
177
178 return true;
179 }
180
187 private function __buildAdvancedMetaData()
188 {
189 ilAdvancedMDValues::_appendXMLByObjId($this, $this->group_obj->getId());
190 }
191
192
193 public function __buildTitleDescription()
194 {
195 $this->xmlElement('title', null, $this->group_obj->getTitle());
196
197 if ($desc = $this->group_obj->getDescription()) {
198 $this->xmlElement('description', null, $desc);
199 }
200
201 $attr['id'] = 'il_' . $this->ilias->getSetting('inst_id') . '_usr_' . $this->group_obj->getOwner();
202 $this->xmlElement('owner', $attr);
203
204 $this->xmlElement('information', null, $this->group_obj->getInformation());
205 }
206
210 protected function __buildPeriod()
211 {
212 if (!$this->group_obj->getStart() || !$this->group_obj->getEnd()) {
213 return;
214 }
215
216 $this->xmlStartTag(
217 'period',
218 [
219 'withTime' => $this->group_obj->getStartTimeIndication()
220 ]
221 );
222 $this->xmlElement(
223 'start',
224 null,
225 $this->group_obj->getStart() ?
226 $this->group_obj->getStart()->get(IL_CAL_UNIX) :
227 null
228 );
229 $this->xmlElement(
230 'end',
231 null,
232 $this->group_obj->getEnd()->get(IL_CAL_UNIX) ?
233 $this->group_obj->getEnd()->get(IL_CAL_UNIX) :
234 null
235 );
236
237 $this->xmlEndTag('period');
238 return;
239 }
240
241 public function __buildRegistration()
242 {
243
244 // registration type
245 switch ($this->group_obj->getRegistrationType()) {
247 $attrs['type'] = 'direct';
248 break;
250 $attrs['type'] = 'confirmation';
251 break;
253 $attrs['type'] = 'password';
254 break;
255
256 default:
258 $attrs['type'] = 'disabled';
259 break;
260 }
261 $attrs['waitingList'] = $this->group_obj->isWaitingListEnabled() ? 'Yes' : 'No';
262
263 $this->xmlStartTag('registration', $attrs);
264
265 if (strlen($pwd = $this->group_obj->getPassword())) {
266 $this->xmlElement('password', null, $pwd);
267 }
268
269
270 // limited registration period
271 if (!$this->group_obj->isRegistrationUnlimited()) {
272 $this->xmlStartTag('temporarilyAvailable');
273 $this->xmlElement('start', null, $this->group_obj->getRegistrationStart()->get(IL_CAL_UNIX));
274 $this->xmlElement('end', null, $this->group_obj->getRegistrationEnd()->get(IL_CAL_UNIX));
275 $this->xmlEndTag('temporarilyAvailable');
276 }
277
278 // max members
279 $attrs = array();
280 $attrs['enabled'] = $this->group_obj->isMembershipLimited() ? 'Yes' : 'No';
281 $this->xmlElement('maxMembers', $attrs, $this->group_obj->getMaxMembers());
282 $this->xmlElement('minMembers', null, (int) $this->group_obj->getMinMembers());
283 $this->xmlElement('WaitingListAutoFill', null, (int) $this->group_obj->hasWaitingListAutoFill());
284 $this->xmlElement('CancellationEnd', null, ($this->group_obj->getCancellationEnd() && !$this->group_obj->getCancellationEnd()->isNull()) ? $this->group_obj->getCancellationEnd()->get(IL_CAL_UNIX) : null);
285
286 $this->xmlElement('mailMembersType', null, (string) $this->group_obj->getMailToMembersType());
287
288 $this->xmlElement(
289 'RegistrationAccessCode',
290 [
291 'enabled' => (int) $this->group_obj->isRegistrationAccessCodeEnabled(),
292 'code' => $this->group_obj->getRegistrationAccessCode()
293 ]
294 );
295
296 $this->xmlEndTag('registration');
297 }
298
302 public function __buildExtraSettings()
303 {
304 $this->xmlElement('showMembers', null, $this->group_obj->getShowMembers());
305 $this->xmlElement('admissionNotification', null, $this->group_obj->getAutoNotification() ? 1 : 0);
306
307 $this->xmlElement('ViewMode', null, ilObjGroup::lookupViewMode($this->group_obj->getId()));
308 $this->xmlElement(
309 'SessionLimit',
310 [
311 'active' => $this->group_obj->isSessionLimitEnabled() ? 1 : 0,
312 'previous' => $this->group_obj->getNumberOfPreviousSessions(),
313 'next' => $this->group_obj->getNumberOfNextSessions()
314 ]
315 );
316
317 $this->xmlElement('GroupMap', [
318 'enabled' => (int) $this->group_obj->getEnableGroupMap(),
319 'latitude' => $this->group_obj->getLatitude(),
320 'longitude' => $this->group_obj->getLongitude(),
321 'location_zoom' => $this->group_obj->getLocationZoom()
322 ]);
323 }
324
325 public function __buildAdmin()
326 {
327 $admins = $this->group_obj->getGroupAdminIds();
328 $admins = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
329 'manage_members',
331 $this->group_obj->getRefId(),
332 $admins
333 );
334
335 foreach ($admins as $id) {
336 $attr['id'] = 'il_' . $this->ilias->getSetting('inst_id') . '_usr_' . $id;
337 $attr['notification'] = $this->participants->isNotificationEnabled($id) ? 'Yes' : 'No';
338
339 $this->xmlElement('admin', $attr);
340 }
341 return true;
342 }
343
344 public function __buildMember()
345 {
346 $members = $this->group_obj->getGroupMemberIds();
347 $members = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
348 'manage_members',
350 $this->group_obj->getRefId(),
351 $members
352 );
353 foreach ($members as $id) {
354 if (!$this->group_obj->isAdmin($id)) {
355 $attr['id'] = 'il_' . $this->ilias->getSetting('inst_id') . '_usr_' . $id;
356
357 $this->xmlElement('member', $attr);
358 }
359 }
360 return true;
361 }
362
363 public function __buildFooter()
364 {
365 $this->xmlEndTag('group');
366 }
367
368 public function setAttachUsers($value)
369 {
370 $this->attach_users = $value ? true : false;
371 }
372}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.
const GRP_REGISTRATION_DIRECT
const GRP_REGISTRATION_PASSWORD
const GRP_TYPE_OPEN
const GRP_TYPE_CLOSED
const GRP_REGISTRATION_DEACTIVATED
const GRP_REGISTRATION_REQUEST
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)
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()
Add group period settings to xml.
static lookupViewMode($a_obj_id)
lookup view mode @global $ilDB
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.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
redirection script todo: (a better solution should control the processing via a xml file)