ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjPollAccess.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/Object/classes/class.ilObjectAccess.php");
6 
15 {
28  function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
29  {
30  global $ilUser, $lng, $rbacsystem, $ilAccess;
31 
32  if ($a_user_id == "")
33  {
34  $a_user_id = $ilUser->getId();
35  }
36 
37  // check "global" online switch
38  if(!self::_lookupOnline($a_obj_id) &&
39  !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
40  {
41  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
42  return false;
43  }
44 
45  return true;
46  }
47 
51  public static function _lookupOnline($a_obj_id)
52  {
53  global $ilDB;
54 
55  $result = $ilDB->query("SELECT * FROM il_poll".
56  " WHERE id = ".$ilDB->quote($a_obj_id, "integer"));
57  $row = $ilDB->fetchAssoc($result);
58  return $row["online_status"];
59  }
60 
68  public static function _isActivated($a_ref_id)
69  {
70  include_once './Services/Object/classes/class.ilObjectActivation.php';
71  $item = ilObjectActivation::getItem($a_ref_id);
72  switch($item['timing_type'])
73  {
75  if(time() < $item['timing_start'] or
76  time() > $item['timing_end'])
77  {
78  return false;
79  }
80  // fallthrough
81 
82  default:
83  return true;
84  }
85  }
86 
99  function _getCommands()
100  {
101  $commands = array
102  (
103  array("permission" => "read", "cmd" => "preview", "lang_var" => "show", "default" => true),
104  array("permission" => "write", "cmd" => "render", "lang_var" => "edit"),
105  // array("permission" => "write", "cmd" => "export", "lang_var" => "export")
106  );
107 
108  return $commands;
109  }
110 
114  function _checkGoto($a_target)
115  {
116  global $ilAccess;
117 
118  $t_arr = explode("_", $a_target);
119 
120  if ($t_arr[0] != "poll" || ((int) $t_arr[1]) <= 0)
121  {
122  return false;
123  }
124 
125  if ($ilAccess->checkAccess("read", "", $t_arr[1]))
126  {
127  return true;
128  }
129  return false;
130  }
131 }
132 
133 ?>