ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjGroupAccess.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once("./classes/class.ilObjectAccess.php");
25 
35 {
48  function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
49  {
50 
51  global $ilUser, $lng, $rbacsystem, $ilAccess;
52 
53  if ($a_user_id == "")
54  {
55  $a_user_id = $ilUser->getId();
56  }
57 
58  switch ($a_cmd)
59  {
60  case "info":
61 
62  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
63  if(ilGroupParticipants::_isParticipant($a_ref_id,$a_user_id))
64  {
65  $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("info_is_member"));
66  }
67  else
68  {
69  $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("info_is_not_member"));
70  }
71  break;
72 
73  case "join":
74 
75  include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
76  if(ilGroupWaitingList::_isOnList($ilUser->getId(), $a_obj_id))
77  {
78  return false;
79  }
80 
81  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
82  if(ilGroupParticipants::_isParticipant($a_ref_id,$a_user_id))
83  {
84  return false;
85  }
86  break;
87 
88  case 'leave':
89 
90  // Regular member
91  if($a_permission == 'leave')
92  {
93  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
94  if(!ilGroupParticipants::_isParticipant($a_ref_id, $a_user_id))
95  {
96  return false;
97  }
98  }
99  // Waiting list
100  if($a_permission == 'join')
101  {
102  include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
103  if(!ilGroupWaitingList::_isOnList($ilUser->getId(), $a_obj_id))
104  {
105  return false;
106  }
107  }
108  break;
109 
110  }
111 
112  switch ($a_permission)
113  {
114 
115  }
116  return true;
117  }
118 
131  function _getCommands()
132  {
133  $commands = array();
134  $commands[] = array("permission" => "read", "cmd" => "view", "lang_var" => "show", "default" => true);
135  $commands[] = array("permission" => "join", "cmd" => "join", "lang_var" => "join");
136 
137  // on waiting list
138  $commands[] = array('permission' => "join", "cmd" => "leave", "lang_var" => "leave_waiting_list");
139 
140  // regualar users
141  $commands[] = array('permission' => "leave", "cmd" => "leave", "lang_var" => "grp_btn_unsubscribe");
142 
143  include_once ('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
145  {
146  include_once './Services/WebDAV/classes/class.ilDAVUtils.php';
147  if(ilDAVUtils::getInstance()->isLocalPasswordInstructionRequired())
148  {
149  $commands[] = array('permission' => 'read', 'cmd' => 'showPasswordInstruction', 'lang_var' => 'mount_webfolder', 'enable_anonymous' => 'false');
150  }
151  else
152  {
153  $commands[] = array("permission" => "read", "cmd" => "mount_webfolder", "lang_var" => "mount_webfolder", "enable_anonymous" => "false");
154  }
155  }
156 
157  $commands[] = array("permission" => "write", "cmd" => "edit", "lang_var" => "edit");
158 
159  return $commands;
160  }
161 
165  function _checkGoto($a_target)
166  {
167  global $ilAccess,$ilUser;
168 
169  // registration codes
170  if(substr($t_arr[2],0,5) == 'rcode' and $ilUser->getId() != ANONYMOUS_USER_ID)
171  {
172  return true;
173  }
174 
175 
176  $t_arr = explode("_", $a_target);
177 
178  if ($t_arr[0] != "grp" || ((int) $t_arr[1]) <= 0)
179  {
180  return false;
181  }
182 
183  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
184  $ilAccess->checkAccess("visible", "", $t_arr[1]))
185  {
186  return true;
187  }
188  return false;
189  }
190 
196  public static function _registrationEnabled($a_obj_id)
197  {
198  global $ilDB;
199 
200  $query = "SELECT * FROM grp_settings ".
201  "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
202 
203  $res = $ilDB->query($query);
204 
205  $enabled = $unlimited = false;
206  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
207  {
208  $enabled = $row->registration_enabled;
209  $unlimited = $row->registration_unlimited;
210  $start = $row->registration_start;
211  $end = $row->registration_end;
212  }
213 
214  if(!$enabled)
215  {
216  return false;
217  }
218  if($unlimited)
219  {
220  return true;
221  }
222 
223  if(!$unlimited)
224  {
225  $start = new ilDateTime($start,IL_CAL_DATETIME,'UTC');
226  $end = new ilDateTime($end,IL_CAL_DATETIME,'UTC');
227  $time = new ilDateTime(time(),IL_CAL_UNIX);
228 
229  return ilDateTime::_after($time, $start) and ilDateTime::_before($time,$end);
230  }
231  return false;
232  }
233 
234 
235 }
236 ?>