ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
25 include_once "./Services/Xml/classes/class.ilXmlWriter.php";
26 include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
27 
37 {
38  const MODE_SOAP = 1;
39  const MODE_EXPORT = 2;
40 
41  private $mode = self::MODE_SOAP;
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::__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 
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();
87  $this->__buildTitleDescription();
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';
95  ilContainerSortingSettings::_exportContainerSortingSettings($this,$this->group_obj->getId());
96  ilContainer::_exportContainerSettings($this, $this->group_obj->getId());
97  $this->__buildFooter();
98  }
99  elseif($this->getMode() == self::MODE_EXPORT)
100  {
101  $this->__buildGroup();
102  $this->__buildTitleDescription();
103  $this->__buildRegistration();
104  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
105  ilContainerSortingSettings::_exportContainerSortingSettings($this,$this->group_obj->getId());
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  $this->xmlElement('minMembers',null,(int)$this->group_obj->getMinMembers());
212  $this->xmlElement('WaitingListAutoFill',null,(int)$this->group_obj->hasWaitingListAutoFill());
213  $this->xmlElement('CancellationEnd',null,($this->group_obj->getCancellationEnd() && !$this->group_obj->getCancellationEnd()->isNull()) ? $this->group_obj->getCancellationEnd()->get(IL_CAL_UNIX) : null);
214 
215  $this->xmlElement('mailMembersType', null, (string) $this->group_obj->getMailToMembersType());
216 
217  $this->xmlEndTag('registration');
218  }
219 
220  function __buildAdmin()
221  {
222  foreach($this->group_obj->getGroupAdminIds() as $id)
223  {
224  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
225  $attr['notification'] = $this->participants->isNotificationEnabled($id) ? 'Yes' : 'No';
226 
227  $this->xmlElement('admin',$attr);
228  }
229  return true;
230  }
231 
232  function __buildMember()
233  {
234  foreach($this->group_obj->getGroupMemberIds() as $id)
235  {
236  if(!$this->group_obj->isAdmin($id))
237  {
238  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
239 
240  $this->xmlElement('member',$attr);
241  }
242  }
243  return true;
244  }
245 
246  function __buildFooter()
247  {
248  $this->xmlEndTag('group');
249  }
250 
251  function setAttachUsers ($value) {
252  $this->attach_users = $value ? true : false;
253  }
254 
255 }
256 
257 
258 ?>
static _exportContainerSettings(ilXmlWriter $a_xml, $a_obj_id)
__construct($group_obj)
constructor
xmlSetGenCmt($genCmt)
Sets generated comment.
const GRP_REGISTRATION_DEACTIVATED
xmlSetDtdDef($dtdDef)
Sets dtd definition.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
XML writer class.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
const IL_CAL_UNIX
const GRP_REGISTRATION_PASSWORD
const GRP_REGISTRATION_REQUEST
xmlEndTag($tag)
Writes an endtag.
const GRP_TYPE_PUBLIC
const GRP_TYPE_CLOSED
redirection script todo: (a better solution should control the processing via a xml file) ...
xmlHeader()
Writes xml header public.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Create styles array
The data for the language used.
XML writer class.
static _exportContainerSortingSettings(ilXmlWriter $xml, $obj_id)
sorting XML-export for all container objects
const GRP_REGISTRATION_DIRECT
xmlDumpMem($format=TRUE)
Returns xml document from memory.