ILIAS  Release_4_0_x_branch Revision 61816
 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 
156 
157  // limited registration period
158  if(!$this->group_obj->isRegistrationUnlimited())
159  {
160  $this->xmlStartTag('temporarilyAvailable');
161  $this->xmlElement('start',null,$this->group_obj->getRegistrationStart()->get(IL_CAL_UNIX));
162  $this->xmlElement('end',null,$this->group_obj->getRegistrationEnd()->get(IL_CAL_UNIX));
163  $this->xmlEndTag('temporarilyAvailable');
164  }
165 
166  // max members
167  $attrs = array();
168  $attrs['enabled'] = $this->group_obj->isMembershipLimited() ? 'Yes' : 'No';
169  $this->xmlElement('maxMembers',$attrs,$this->group_obj->getMaxMembers());
170 
171  $this->xmlEndTag('registration');
172  }
173 
174  function __buildAdmin()
175  {
176  foreach($this->group_obj->getGroupAdminIds() as $id)
177  {
178  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
179  $attr['notification'] = $this->participants->isNotificationEnabled($id) ? 'Yes' : 'No';
180 
181  $this->xmlElement('admin',$attr);
182  }
183  return true;
184  }
185 
186  function __buildMember()
187  {
188  foreach($this->group_obj->getGroupMemberIds() as $id)
189  {
190  if(!$this->group_obj->isAdmin($id))
191  {
192  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
193 
194  $this->xmlElement('member',$attr);
195  }
196  }
197  return true;
198  }
199 
200  function __buildFooter()
201  {
202  $this->xmlEndTag('group');
203  }
204 
205  function setAttachUsers ($value) {
206  $this->attach_users = $value ? true : false;
207  }
208 
209 }
210 
211 
212 ?>