ILIAS  release_4-3 Revision
 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  $this->__buildFooter();
95  }
96  elseif($this->getMode() == self::MODE_EXPORT)
97  {
98  $this->__buildGroup();
99  $this->__buildTitleDescription();
100  $this->__buildRegistration();
101  $this->__buildFooter();
102  }
103 
104  }
105 
106  function getXML()
107  {
108  return $this->xmlDumpMem(FALSE);
109  }
110 
111  // PRIVATE
112  function __buildHeader()
113  {
114  $this->xmlSetDtdDef("<!DOCTYPE group PUBLIC \"-//ILIAS//DTD Group//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_group_3_10.dtd\">");
115  $this->xmlSetGenCmt("Export of ILIAS group ". $this->group_obj->getId()." of installation ".$this->ilias->getSetting('inst_id').".");
116  $this->xmlHeader();
117 
118 
119  return true;
120  }
121 
126  public function __buildGroup()
127  {
128  $attrs["exportVersion"] = $this->EXPORT_VERSION;
129  $attrs["id"] = "il_".$this->ilias->getSetting('inst_id').'_grp_'.$this->group_obj->getId();
130 
131  switch($this->group_obj->readGroupStatus())
132  {
133  case GRP_TYPE_PUBLIC:
134  $attrs['type'] = 'open';
135  break;
136 
137  case GRP_TYPE_CLOSED:
138  default:
139  $attrs['type'] = 'closed';
140  break;
141  }
142 
143  $this->xmlStartTag("group", $attrs);
144  }
145 
147  {
148  $this->xmlElement('title',null,$this->group_obj->getTitle());
149 
150  if($desc = $this->group_obj->getDescription())
151  {
152  $this->xmlElement('description',null,$desc);
153  }
154 
155  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$this->group_obj->getOwner();
156  $this->xmlElement('owner',$attr);
157 
158  $this->xmlElement('information',null,$this->group_obj->getInformation());
159  }
160 
162  {
163 
164  // registration type
165  switch($this->group_obj->getRegistrationType())
166  {
168  $attrs['type'] = 'direct';
169  break;
171  $attrs['type'] = 'confirmation';
172  break;
174  $attrs['type'] = 'password';
175  break;
176 
177  default:
179  $attrs['type'] = 'disabled';
180  break;
181  }
182  $attrs['waitingList'] = $this->group_obj->isWaitingListEnabled() ? 'Yes' : 'No';
183 
184  $this->xmlStartTag('registration',$attrs);
185 
186  if(strlen($pwd = $this->group_obj->getPassword()))
187  {
188  $this->xmlElement('password',null,$pwd);
189  }
190 
191 
192  // limited registration period
193  if(!$this->group_obj->isRegistrationUnlimited())
194  {
195  $this->xmlStartTag('temporarilyAvailable');
196  $this->xmlElement('start',null,$this->group_obj->getRegistrationStart()->get(IL_CAL_UNIX));
197  $this->xmlElement('end',null,$this->group_obj->getRegistrationEnd()->get(IL_CAL_UNIX));
198  $this->xmlEndTag('temporarilyAvailable');
199  }
200 
201  // max members
202  $attrs = array();
203  $attrs['enabled'] = $this->group_obj->isMembershipLimited() ? 'Yes' : 'No';
204  $this->xmlElement('maxMembers',$attrs,$this->group_obj->getMaxMembers());
205 
206  $this->xmlEndTag('registration');
207  }
208 
209  function __buildAdmin()
210  {
211  foreach($this->group_obj->getGroupAdminIds() as $id)
212  {
213  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
214  $attr['notification'] = $this->participants->isNotificationEnabled($id) ? 'Yes' : 'No';
215 
216  $this->xmlElement('admin',$attr);
217  }
218  return true;
219  }
220 
221  function __buildMember()
222  {
223  foreach($this->group_obj->getGroupMemberIds() as $id)
224  {
225  if(!$this->group_obj->isAdmin($id))
226  {
227  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
228 
229  $this->xmlElement('member',$attr);
230  }
231  }
232  return true;
233  }
234 
235  function __buildFooter()
236  {
237  $this->xmlEndTag('group');
238  }
239 
240  function setAttachUsers ($value) {
241  $this->attach_users = $value ? true : false;
242  }
243 
244 }
245 
246 
247 ?>