ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjGroupAccess.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./classes/class.ilObjectAccess.php");
6 
16 {
29  function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
30  {
31 
32  global $ilUser, $lng, $rbacsystem, $ilAccess;
33 
34  if ($a_user_id == "")
35  {
36  $a_user_id = $ilUser->getId();
37  }
38 
39  switch ($a_cmd)
40  {
41  case "info":
42 
43  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
44  if(ilGroupParticipants::_isParticipant($a_ref_id,$a_user_id))
45  {
46  $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("info_is_member"));
47  }
48  else
49  {
50  $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("info_is_not_member"));
51  }
52  break;
53 
54  case "join":
55 
56  include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
57  if(ilGroupWaitingList::_isOnList($ilUser->getId(), $a_obj_id))
58  {
59  return false;
60  }
61 
62  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
63  if(ilGroupParticipants::_isParticipant($a_ref_id,$a_user_id))
64  {
65  return false;
66  }
67  break;
68 
69  case 'leave':
70 
71  // Regular member
72  if($a_permission == 'leave')
73  {
74  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
75  if(!ilGroupParticipants::_isParticipant($a_ref_id, $a_user_id))
76  {
77  return false;
78  }
79  }
80  // Waiting list
81  if($a_permission == 'join')
82  {
83  include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
84  if(!ilGroupWaitingList::_isOnList($ilUser->getId(), $a_obj_id))
85  {
86  return false;
87  }
88  }
89  break;
90 
91  }
92 
93  switch ($a_permission)
94  {
95 
96  }
97  return true;
98  }
99 
112  function _getCommands()
113  {
114  $commands = array();
115  $commands[] = array("permission" => "read", "cmd" => "view", "lang_var" => "show", "default" => true);
116  $commands[] = array("permission" => "join", "cmd" => "join", "lang_var" => "join");
117 
118  // on waiting list
119  $commands[] = array('permission' => "join", "cmd" => "leave", "lang_var" => "leave_waiting_list");
120 
121  // regualar users
122  $commands[] = array('permission' => "leave", "cmd" => "leave", "lang_var" => "grp_btn_unsubscribe");
123 
124  include_once ('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
126  {
127  include_once './Services/WebDAV/classes/class.ilDAVUtils.php';
128  if(ilDAVUtils::getInstance()->isLocalPasswordInstructionRequired())
129  {
130  $commands[] = array('permission' => 'read', 'cmd' => 'showPasswordInstruction', 'lang_var' => 'mount_webfolder', 'enable_anonymous' => 'false');
131  }
132  else
133  {
134  $commands[] = array("permission" => "read", "cmd" => "mount_webfolder", "lang_var" => "mount_webfolder", "enable_anonymous" => "false");
135  }
136  }
137 
138  $commands[] = array("permission" => "write", "cmd" => "edit", "lang_var" => "edit");
139 
140  return $commands;
141  }
142 
146  function _checkGoto($a_target)
147  {
148  global $ilAccess,$ilUser;
149 
150  // registration codes
151  if(substr($t_arr[2],0,5) == 'rcode' and $ilUser->getId() != ANONYMOUS_USER_ID)
152  {
153  return true;
154  }
155 
156 
157  $t_arr = explode("_", $a_target);
158 
159  if ($t_arr[0] != "grp" || ((int) $t_arr[1]) <= 0)
160  {
161  return false;
162  }
163 
164  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
165  $ilAccess->checkAccess("visible", "", $t_arr[1]))
166  {
167  return true;
168  }
169  return false;
170  }
171 
177  public static function _registrationEnabled($a_obj_id)
178  {
179  global $ilDB;
180 
181  $query = "SELECT * FROM grp_settings ".
182  "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
183 
184  $res = $ilDB->query($query);
185 
186  $enabled = $unlimited = false;
187  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
188  {
189  $enabled = $row->registration_enabled;
190  $unlimited = $row->registration_unlimited;
191  $start = $row->registration_start;
192  $end = $row->registration_end;
193  }
194 
195  if(!$enabled)
196  {
197  return false;
198  }
199  if($unlimited)
200  {
201  return true;
202  }
203 
204  if(!$unlimited)
205  {
206  $start = new ilDateTime($start,IL_CAL_DATETIME,'UTC');
207  $end = new ilDateTime($end,IL_CAL_DATETIME,'UTC');
208  $time = new ilDateTime(time(),IL_CAL_UNIX);
209 
210  return ilDateTime::_after($time, $start) and ilDateTime::_before($time,$end);
211  }
212  return false;
213  }
214 
215 
221  function _preloadData($a_obj_ids, $a_ref_ids)
222  {
223  global $ilDB, $ilUser;
224 
225  include_once("./Modules/Group/classes/class.ilGroupWaitingList.php");
226  ilGroupWaitingList::_preloadOnListInfo($ilUser->getId(), $a_obj_ids);
227  }
228 
229 }
230 ?>