ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjLearningResourcesSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Object/classes/class.ilObjectGUI.php");
5 include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
6 
19 {
23  protected $rbacsystem;
24 
28  protected $error;
29 
30  private static $ERROR_MESSAGE;
36  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
37  {
38  global $DIC;
39 
40  $this->rbacsystem = $DIC->rbac()->system();
41  $this->error = $DIC["ilErr"];
42  $this->access = $DIC->access();
43  $this->settings = $DIC->settings();
44  $this->ctrl = $DIC->ctrl();
45  $this->lng = $DIC->language();
46  $this->type = 'lrss';
47  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
48 
49  $this->lng->loadLanguageModule('content');
50  }
51 
58  public function executeCommand()
59  {
61  $ilAccess = $this->access;
62 
63  $next_class = $this->ctrl->getNextClass($this);
64  $cmd = $this->ctrl->getCmd();
65 
66  $this->prepareOutput();
67 
68  if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) {
69  $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
70  }
71 
72  switch ($next_class) {
73  case 'ilpermissiongui':
74  $this->tabs_gui->setTabActive('perm_settings');
75  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
76  $perm_gui = new ilPermissionGUI($this);
77  $ret = $this->ctrl->forwardCommand($perm_gui);
78  break;
79 
80  default:
81  if (!$cmd || $cmd == 'view') {
82  $cmd = "editSettings";
83  }
84 
85  $this->$cmd();
86  break;
87  }
88  return true;
89  }
90 
97  public function getAdminTabs()
98  {
100 
101  if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
102  $this->tabs_gui->addTarget(
103  "cont_edit_lrs_settings",
104  $this->ctrl->getLinkTarget($this, "editSettings"),
105  array("editSettings", "view")
106  );
107  }
108 
109  if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
110  $this->tabs_gui->addTarget(
111  "perm_settings",
112  $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
113  array(),
114  'ilpermissiongui'
115  );
116  }
117  }
118 
122  public function editSettings()
123  {
125  $lng = $this->lng;
127 
128  $lm_set = new ilSetting("lm");
129  $lng->loadLanguageModule("scormdebug");
130 
131  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
132  $form = new ilPropertyFormGUI();
133  $form->setFormAction($ilCtrl->getFormAction($this));
134  $form->setTitle($lng->txt("cont_lrs_settings"));
135 
136  // Page History
137  $cb_prop = new ilCheckboxInputGUI(
138  $lng->txt("cont_enable_page_history"),
139  "page_history"
140  );
141  $cb_prop->setInfo($lng->txt("cont_enable_page_history_info"));
142  $cb_prop->setChecked($lm_set->get("page_history", 1));
143  $form->addItem($cb_prop);
144 
145  // Time scheduled page activation
146  $cb_prop = new ilCheckboxInputGUI(
147  $lng->txt("cont_enable_time_scheduled_page_activation"),
148  "time_scheduled_page_activation"
149  );
150  $cb_prop->setInfo($lng->txt("cont_enable_time_scheduled_page_activation_info"));
151  $cb_prop->setChecked($lm_set->get("time_scheduled_page_activation"));
152  $form->addItem($cb_prop);
153 
154  // lm starting point
155  $options = array(
156  "" => $this->lng->txt("cont_last_visited_page"),
157  "first" => $this->lng->txt("cont_first_page")
158  );
159  $si = new ilSelectInputGUI($this->lng->txt("cont_lm_starting_point"), "lm_starting_point");
160  $si->setOptions($options);
161  $si->setValue($lm_set->get("lm_starting_point"));
162  $si->setInfo($this->lng->txt("cont_lm_starting_point_info"));
163  $form->addItem($si);
164 
165  // Activate replace media object function
166  $cb_prop = new ilCheckboxInputGUI(
167  $lng->txt("cont_replace_mob_feature"),
168  "replace_mob_feature"
169  );
170  $cb_prop->setInfo($lng->txt("cont_replace_mob_feature_info"));
171  $cb_prop->setChecked($lm_set->get("replace_mob_feature"));
172  $form->addItem($cb_prop);
173 
174  // Activate HTML export IDs
175  $cb_prop = new ilCheckboxInputGUI(
176  $lng->txt("cont_html_export_ids"),
177  "html_export_ids"
178  );
179  $cb_prop->setInfo($lng->txt("cont_html_export_ids_info"));
180  $cb_prop->setChecked($lm_set->get("html_export_ids"));
181  $form->addItem($cb_prop);
182 
183  // Upload dir for learning resources
184  $tx_prop = new ilTextInputGUI(
185  $lng->txt("cont_upload_dir"),
186  "cont_upload_dir"
187  );
188  $tx_prop->setInfo($lng->txt("cont_upload_dir_info"));
189  $tx_prop->setValue($lm_set->get("cont_upload_dir"));
190  $form->addItem($tx_prop);
191 
192  // scormDebugger activation
193  $cb_prop = new ilCheckboxInputGUI($lng->txt("scormdebug_global_activate"), "scormdebug_global_activate");
194  $cb_prop->setInfo($lng->txt("scormdebug_global_activate_info"));
195  $cb_prop->setChecked($lm_set->get("scormdebug_global_activate"));
196  $form->addItem($cb_prop);
197 
198  // scorm2004 disableRTECaching
199  $cb_prop = new ilCheckboxInputGUI(
200  $lng->txt("scormdebug_disable_cache"),
201  "scormdebug_disable_cache"
202  );
203  $cb_prop->setInfo($lng->txt("scormdebug_disable_cache_info"));
204  $cb_prop->setChecked($lm_set->get("scormdebug_disable_cache"));
205  $form->addItem($cb_prop);
206 
207  // scorm2004 without session
208  $cb_prop = new ilCheckboxInputGUI(
209  $lng->txt("scorm_without_session"),
210  "scorm_without_session"
211  );
212  $cb_prop->setInfo($lng->txt("scorm_without_session_info"));
213  $cb_prop->setChecked($lm_set->get("scorm_without_session"));
214  $form->addItem($cb_prop);
215 
216  $privacy = ilPrivacySettings::_getInstance();
217  $check = new ilCheckboxInputGui($lng->txt('enable_sahs_protocol_data'), 'enable_sahs_pd');
218  $check->setInfo($this->lng->txt('enable_sahs_protocol_data_desc'));
219  $check->setChecked($privacy->enabledSahsProtocolData());
220  $form->addItem($check);
221 
222  // show and export protocol data with name
223  $check = new ilCheckboxInputGui($this->lng->txt('ps_export_scorm'), 'export_scorm');
224  $check->setInfo($this->lng->txt('enable_export_scorm_desc'));
225  $check->setChecked($privacy->enabledExportSCORM());
226  $form->addItem($check);
227 
228  // scorm auto-setting for learning progress
229  $cb_prop = new ilCheckboxInputGUI($lng->txt("scorm_lp_auto_activate"), "scorm_lp_auto_activate");
230  $cb_prop->setInfo($lng->txt("scorm_lp_auto_activate_info"));
231  $cb_prop->setChecked($lm_set->get("scorm_lp_auto_activate"));
232  $form->addItem($cb_prop);
233 
234  // command buttons
235  if ($this->checkPermissionBool("write")) {
236  $form->addCommandButton("saveSettings", $lng->txt("save"));
237  $form->addCommandButton("view", $lng->txt("cancel"));
238  }
239 
240  $this->tpl->setContent($form->getHTML());
241  }
242 
246  public function saveSettings()
247  {
250 
251  $this->checkPermission("write");
252 
253  $lm_set = new ilSetting("lm");
254  $lm_set->set(
255  "time_scheduled_page_activation",
256  ilUtil::stripSlashes($_POST["time_scheduled_page_activation"])
257  );
258  $lm_set->set(
259  "lm_starting_point",
260  ilUtil::stripSlashes($_POST["lm_starting_point"])
261  );
262  $lm_set->set(
263  "page_history",
264  (int) ilUtil::stripSlashes($_POST["page_history"])
265  );
266  $lm_set->set(
267  "replace_mob_feature",
268  ilUtil::stripSlashes($_POST["replace_mob_feature"])
269  );
270  $lm_set->set(
271  "html_export_ids",
272  ilUtil::stripSlashes($_POST["html_export_ids"])
273  );
274  $lm_set->set(
275  "cont_upload_dir",
276  ilUtil::stripSlashes($_POST["cont_upload_dir"])
277  );
278  $lm_set->setScormDebug(
279  "scormdebug_global_activate",
280  ilUtil::stripSlashes($_POST["scormdebug_global_activate"])
281  );
282  $lm_set->set(
283  "scorm_login_as_learner_id",
284  ilUtil::stripSlashes($_POST["scorm_login_as_learner_id"])
285  );
286  $lm_set->set(
287  "scormdebug_disable_cache",
288  ilUtil::stripSlashes($_POST["scormdebug_disable_cache"])
289  );
290  $lm_set->set(
291  "scorm_without_session",
292  ilUtil::stripSlashes($_POST["scorm_without_session"])
293  );
294  $lm_set->set(
295  "scorm_lp_auto_activate",
296  ilUtil::stripSlashes($_POST["scorm_lp_auto_activate"])
297  );
298 
299  $privacy = ilPrivacySettings::_getInstance();
300  $privacy->enableSahsProtocolData((int) $_POST['enable_sahs_pd']);
301  $privacy->enableExportSCORM((int) $_POST['export_scorm']);
302  $privacy->save();
303 
304  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
305 
306  $ilCtrl->redirect($this, "view");
307  }
308 
309  public function addToExternalSettingsForm($a_form_id)
310  {
311  switch ($a_form_id) {
313 
314  $privacy = ilPrivacySettings::_getInstance();
315 
316  $fields = array('enable_sahs_protocol_data' => array($privacy->enabledSahsProtocolData(), ilAdministrationSettingsFormHandler::VALUE_BOOL));
317 
318  return array(array("editSettings", $fields));
319  }
320  }
321 }
settings()
Definition: settings.php:2
This class represents a selection list property in a property form.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
This class represents a checkbox property in a property form.
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
prepareOutput($a_show_subobjects=true)
prepare output
if(isset($_POST['submit'])) $form
Class ilObjectGUI Basic methods of all Output classes.
This class represents a text property in a property form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
setOptions($a_options)
Set Options.
$lm_set
global $ilSetting
Definition: privfeed.php:17
$ret
Definition: parser.php:6
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static _getInstance()
Get instance of ilPrivacySettings.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
$_POST["username"]