ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 "./classes/class.ilXmlWriter.php";
26 include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
27 
37 {
38  private $ilias;
39 
40  private $xml;
41  private $group_obj;
42  private $attach_users = true;
43 
52  {
53  global $ilias;
54 
56 
57  $this->EXPORT_VERSION = "3";
58 
59  $this->ilias =& $ilias;
60  $this->group_obj =& $group_obj;
61  $this->participants = ilGroupParticipants::_getInstanceByObjId($this->group_obj->getId());
62 
63  }
64 
65  function start()
66  {
67  $this->__buildHeader();
68  $this->__buildTitleDescription();
69  $this->__buildRegistration();
70  if ($this->attach_users)
71  {
72  $this->__buildAdmin();
73  $this->__buildMember();
74  }
75  $this->__buildFooter();
76 
77  }
78 
79  function getXML()
80  {
81  return $this->xmlDumpMem(FALSE);
82  }
83 
84  // PRIVATE
85  function __buildHeader()
86  {
87  $this->xmlSetDtdDef("<!DOCTYPE group PUBLIC \"-//ILIAS//DTD Group//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_group_3_10.dtd\">");
88  $this->xmlSetGenCmt("Export of ILIAS group ". $this->group_obj->getId()." of installation ".$this->ilias->getSetting('inst_id').".");
89  $this->xmlHeader();
90 
91  $attrs["exportVersion"] = $this->EXPORT_VERSION;
92  $attrs["id"] = "il_".$this->ilias->getSetting('inst_id').'_grp_'.$this->group_obj->getId();
93 
94  switch($this->group_obj->readGroupStatus())
95  {
96  case GRP_TYPE_PUBLIC:
97  $attrs['type'] = 'open';
98  break;
99 
100  case GRP_TYPE_CLOSED:
101  default:
102  $attrs['type'] = 'closed';
103  break;
104  }
105 
106  $this->xmlStartTag("group", $attrs);
107 
108  return true;
109  }
110 
112  {
113  $this->xmlElement('title',null,$this->group_obj->getTitle());
114 
115  if($desc = $this->group_obj->getDescription())
116  {
117  $this->xmlElement('description',null,$desc);
118  }
119 
120  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$this->group_obj->getOwner();
121  $this->xmlElement('owner',$attr);
122 
123  $this->xmlElement('information',null,$this->group_obj->getInformation());
124  }
125 
127  {
128 
129  // registration type
130  switch($this->group_obj->getRegistrationType())
131  {
133  $attrs['type'] = 'direct';
134  break;
136  $attrs['type'] = 'confirmation';
137  break;
139  $attrs['type'] = 'password';
140  break;
141 
142  default:
144  $attrs['type'] = 'disabled';
145  break;
146  }
147  $attrs['waitingList'] = $this->group_obj->isWaitingListEnabled() ? 'Yes' : 'No';
148 
149  $this->xmlStartTag('registration',$attrs);
150 
151  if(strlen($pwd = $this->group_obj->getPassword()))
152  {
153  $this->xmlElement('password',null,$pwd);
154  }
155  if($timest = $this->group_obj->getExpirationTimestamp())
156  {
157  $this->xmlElement('expiration',null,$timest);
158  }
159 
160 
161  // limited registration period
162  if(!$this->group_obj->isRegistrationUnlimited())
163  {
164  $this->xmlStartTag('temporarilyAvailable');
165  $this->xmlElement('start',null,$this->group_obj->getRegistrationStart()->get(IL_CAL_UNIX));
166  $this->xmlElement('end',null,$this->group_obj->getRegistrationEnd()->get(IL_CAL_UNIX));
167  $this->xmlEndTag('temporarilyAvailable');
168  }
169 
170  // max members
171  $attrs = array();
172  $attrs['enabled'] = $this->group_obj->isMembershipLimited() ? 'Yes' : 'No';
173  $this->xmlElement('maxMembers',$attrs,$this->group_obj->getMaxMembers());
174 
175  $this->xmlEndTag('registration');
176  }
177 
178  function __buildAdmin()
179  {
180  foreach($this->group_obj->getGroupAdminIds() as $id)
181  {
182  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
183  $attr['notification'] = $this->participants->isNotificationEnabled($id) ? 'Yes' : 'No';
184 
185  $this->xmlElement('admin',$attr);
186  }
187  return true;
188  }
189 
190  function __buildMember()
191  {
192  foreach($this->group_obj->getGroupMemberIds() as $id)
193  {
194  if(!$this->group_obj->isAdmin($id))
195  {
196  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
197 
198  $this->xmlElement('member',$attr);
199  }
200  }
201  return true;
202  }
203 
204  function __buildFooter()
205  {
206  $this->xmlEndTag('group');
207  }
208 
209  function setAttachUsers ($value) {
210  $this->attach_users = $value ? true : false;
211  }
212 
213 }
214 
215 
216 ?>