ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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("./classes/class.ilObjectGUI.php");
5 
19 {
20  private static $ERROR_MESSAGE;
26  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
27  {
28  $this->type = 'lrss';
29  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
30 
31  $this->lng->loadLanguageModule('content');
32  }
33 
40  public function executeCommand()
41  {
42  global $rbacsystem,$ilErr,$ilAccess;
43 
44  $next_class = $this->ctrl->getNextClass($this);
45  $cmd = $this->ctrl->getCmd();
46 
47  $this->prepareOutput();
48 
49  if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
50  {
51  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
52  }
53 
54  switch($next_class)
55  {
56  case 'illicenseoverviewgui':
57  include_once("./Services/License/classes/class.ilLicenseOverviewGUI.php");
58  $license_gui =& new ilLicenseOverviewGUI($this,LIC_MODE_ADMINISTRATION);
59  $ret =& $this->ctrl->forwardCommand($license_gui);
60  break;
61 
62  case 'ilpermissiongui':
63  $this->tabs_gui->setTabActive('perm_settings');
64  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
65  $perm_gui =& new ilPermissionGUI($this);
66  $ret =& $this->ctrl->forwardCommand($perm_gui);
67  break;
68 
69  default:
70  if(!$cmd || $cmd == 'view')
71  {
72  $cmd = "editSettings";
73  }
74 
75  $this->$cmd();
76  break;
77  }
78  return true;
79  }
80 
87  public function getAdminTabs()
88  {
89  global $rbacsystem, $ilAccess, $ilSetting;
90 
91  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
92  {
93  $this->tabs_gui->addTarget("cont_edit_lrs_settings",
94  $this->ctrl->getLinkTarget($this, "editSettings"),
95  array("editSettings", "view"));
96 
97  include_once("Services/License/classes/class.ilLicenseAccess.php");
99  {
100  $this->tabs_gui->addTarget("licenses",
101  $this->ctrl->getLinkTargetByClass('illicenseoverviewgui', ''),
102  "", "illicenseoverviewgui");
103  }
104  }
105 
106  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
107  {
108  $this->tabs_gui->addTarget("perm_settings",
109  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"),
110  array(),'ilpermissiongui');
111  }
112  }
113 
117  public function editSettings()
118  {
119  global $ilCtrl, $lng, $ilSetting;
120 
121  $lm_set = new ilSetting("lm");
122  $lic_set = new ilSetting("license");
123  $lng->loadLanguageModule("license");
124 
125  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
126  $form = new ilPropertyFormGUI();
127  $form->setFormAction($ilCtrl->getFormAction($this));
128  $form->setTitle($lng->txt("cont_lrs_settings"));
129 
130  // Time scheduled page activation
131  $cb_prop = new ilCheckboxInputGUI($lng->txt("cont_enable_time_scheduled_page_activation"),
132  "time_scheduled_page_activation");
133  $cb_prop->setInfo($lng->txt("cont_enable_time_scheduled_page_activation_info"));
134  $cb_prop->setChecked($lm_set->get("time_scheduled_page_activation"));
135  $form->addItem($cb_prop);
136 
137  // Activate replace media object function
138  $cb_prop = new ilCheckboxInputGUI($lng->txt("cont_replace_mob_feature"),
139  "replace_mob_feature");
140  $cb_prop->setInfo($lng->txt("cont_replace_mob_feature_info"));
141  $cb_prop->setChecked($lm_set->get("replace_mob_feature"));
142  $form->addItem($cb_prop);
143 
144  // Upload dir for learning resources
145  $tx_prop = new ilTextInputGUI($lng->txt("cont_upload_dir"),
146  "cont_upload_dir");
147  $tx_prop->setInfo($lng->txt("cont_upload_dir_info"));
148  $tx_prop->setValue($lm_set->get("cont_upload_dir"));
149  $form->addItem($tx_prop);
150 
151 
152  // license activation
153  $cb_prop = new ilCheckboxInputGUI($lng->txt("license_counter"),
154  "license_counter");
155  $cb_prop->setInfo($lng->txt("license_counter_info"));
156  $cb_prop->setChecked($lic_set->get("license_counter"));
157  $form->addItem($cb_prop);
158 
159  // license warning
160  $tx_prop = new ilTextInputGUI($lng->txt("license_warning"),
161  "license_warning");
162  $tx_prop->setSize(5);
163  $tx_prop->setInfo($lng->txt("license_warning_info"));
164  $tx_prop->setValue($lic_set->get("license_warning"));
165  $form->addItem($tx_prop);
166 
167  // command buttons
168  $form->addCommandButton("saveSettings", $lng->txt("save"));
169  $form->addCommandButton("view", $lng->txt("cancel"));
170 
171  $this->tpl->setContent($form->getHTML());
172  }
173 
177  public function saveSettings()
178  {
179  global $ilCtrl, $ilSetting;
180 
181  $lm_set = new ilSetting("lm");
182  $lm_set->set("time_scheduled_page_activation",
183  ilUtil::stripSlashes($_POST["time_scheduled_page_activation"]));
184  $lm_set->set("replace_mob_feature",
185  ilUtil::stripSlashes($_POST["replace_mob_feature"]));
186  $lm_set->set("cont_upload_dir",
187  ilUtil::stripSlashes($_POST["cont_upload_dir"]));
188 
189  $lic_set = new ilSetting("license");
190  $lic_set->set("license_counter",
191  ilUtil::stripSlashes($_POST["license_counter"]));
192  $lic_set->set("license_warning",
193  ilUtil::stripSlashes($_POST["license_warning"]));
194 
195  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
196 
197  $ilCtrl->redirect($this, "view");
198  }
199 }
200 ?>