ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
58 {
59 global $ilias;
60
61 parent::ilXmlWriter();
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
71 public function setMode($a_mode)
72 {
73 $this->mode = $a_mode;
74 }
75
76 public function getMode()
77 {
78 return $this->mode;
79 }
80
81 function start()
82 {
83 if($this->getMode() == self::MODE_SOAP)
84 {
85 $this->__buildHeader();
86 $this->__buildGroup();
88 $this->__buildRegistration();
89 if ($this->attach_users)
90 {
91 $this->__buildAdmin();
92 $this->__buildMember();
93 }
94 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
96 ilContainer::_exportContainerSettings($this, $this->group_obj->getId());
97 $this->__buildFooter();
98 }
99 elseif($this->getMode() == self::MODE_EXPORT)
100 {
101 $this->__buildGroup();
103 $this->__buildRegistration();
104 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
106 ilContainer::_exportContainerSettings($this, $this->group_obj->getId());
107 $this->__buildFooter();
108 }
109
110 }
111
112 function getXML()
113 {
114 return $this->xmlDumpMem(FALSE);
115 }
116
117 // PRIVATE
118 function __buildHeader()
119 {
120 $this->xmlSetDtdDef("<!DOCTYPE group PUBLIC \"-//ILIAS//DTD Group//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_group_3_10.dtd\">");
121 $this->xmlSetGenCmt("Export of ILIAS group ". $this->group_obj->getId()." of installation ".$this->ilias->getSetting('inst_id').".");
122 $this->xmlHeader();
123
124
125 return true;
126 }
127
132 public function __buildGroup()
133 {
134 $attrs["exportVersion"] = $this->EXPORT_VERSION;
135 $attrs["id"] = "il_".$this->ilias->getSetting('inst_id').'_grp_'.$this->group_obj->getId();
136
137 switch($this->group_obj->readGroupStatus())
138 {
139 case GRP_TYPE_PUBLIC:
140 $attrs['type'] = 'open';
141 break;
142
143 case GRP_TYPE_CLOSED:
144 default:
145 $attrs['type'] = 'closed';
146 break;
147 }
148
149 $this->xmlStartTag("group", $attrs);
150 }
151
153 {
154 $this->xmlElement('title',null,$this->group_obj->getTitle());
155
156 if($desc = $this->group_obj->getDescription())
157 {
158 $this->xmlElement('description',null,$desc);
159 }
160
161 $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$this->group_obj->getOwner();
162 $this->xmlElement('owner',$attr);
163
164 $this->xmlElement('information',null,$this->group_obj->getInformation());
165 }
166
168 {
169
170 // registration type
171 switch($this->group_obj->getRegistrationType())
172 {
174 $attrs['type'] = 'direct';
175 break;
177 $attrs['type'] = 'confirmation';
178 break;
180 $attrs['type'] = 'password';
181 break;
182
183 default:
185 $attrs['type'] = 'disabled';
186 break;
187 }
188 $attrs['waitingList'] = $this->group_obj->isWaitingListEnabled() ? 'Yes' : 'No';
189
190 $this->xmlStartTag('registration',$attrs);
191
192 if(strlen($pwd = $this->group_obj->getPassword()))
193 {
194 $this->xmlElement('password',null,$pwd);
195 }
196
197
198 // limited registration period
199 if(!$this->group_obj->isRegistrationUnlimited())
200 {
201 $this->xmlStartTag('temporarilyAvailable');
202 $this->xmlElement('start',null,$this->group_obj->getRegistrationStart()->get(IL_CAL_UNIX));
203 $this->xmlElement('end',null,$this->group_obj->getRegistrationEnd()->get(IL_CAL_UNIX));
204 $this->xmlEndTag('temporarilyAvailable');
205 }
206
207 // max members
208 $attrs = array();
209 $attrs['enabled'] = $this->group_obj->isMembershipLimited() ? 'Yes' : 'No';
210 $this->xmlElement('maxMembers',$attrs,$this->group_obj->getMaxMembers());
211
212 $this->xmlElement('minMembers',null,(int)$this->group_obj->getMinMembers());
213 $this->xmlElement('WaitingListAutoFill',null,(int)$this->group_obj->hasWaitingListAutoFill());
214 $this->xmlElement('CancellationEnd',null,($this->group_obj->getCancellationEnd() && !$this->group_obj->getCancellationEnd()->isNull()) ? $this->group_obj->getCancellationEnd()->get(IL_CAL_UNIX) : null);
215
216 $this->xmlEndTag('registration');
217 }
218
219 function __buildAdmin()
220 {
221 foreach($this->group_obj->getGroupAdminIds() as $id)
222 {
223 $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
224 $attr['notification'] = $this->participants->isNotificationEnabled($id) ? 'Yes' : 'No';
225
226 $this->xmlElement('admin',$attr);
227 }
228 return true;
229 }
230
231 function __buildMember()
232 {
233 foreach($this->group_obj->getGroupMemberIds() as $id)
234 {
235 if(!$this->group_obj->isAdmin($id))
236 {
237 $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
238
239 $this->xmlElement('member',$attr);
240 }
241 }
242 return true;
243 }
244
245 function __buildFooter()
246 {
247 $this->xmlEndTag('group');
248 }
249
250 function setAttachUsers ($value) {
251 $this->attach_users = $value ? true : false;
252 }
253
254}
255
256
257?>
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)
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
ilGroupXMLWriter($group_obj)
constructor
XML writer class.
xmlEndTag($tag)
Writes an endtag.
xmlDumpMem($format=TRUE)
Returns xml document from memory.
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlHeader()
Writes xml header @access public.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
redirection script todo: (a better solution should control the processing via a xml file)