ILIAS  Release_5_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 "./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 
42 
43 
44  private $ilias;
45 
46  private $xml;
47  private $group_obj;
48  private $attach_users = true;
49 
58  {
59  global $ilias;
60 
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 
212  $this->xmlEndTag('registration');
213  }
214 
215  function __buildAdmin()
216  {
217  foreach($this->group_obj->getGroupAdminIds() as $id)
218  {
219  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
220  $attr['notification'] = $this->participants->isNotificationEnabled($id) ? 'Yes' : 'No';
221 
222  $this->xmlElement('admin',$attr);
223  }
224  return true;
225  }
226 
227  function __buildMember()
228  {
229  foreach($this->group_obj->getGroupMemberIds() as $id)
230  {
231  if(!$this->group_obj->isAdmin($id))
232  {
233  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
234 
235  $this->xmlElement('member',$attr);
236  }
237  }
238  return true;
239  }
240 
241  function __buildFooter()
242  {
243  $this->xmlEndTag('group');
244  }
245 
246  function setAttachUsers ($value) {
247  $this->attach_users = $value ? true : false;
248  }
249 
250 }
251 
252 
253 ?>