ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjExerciseAdministrationGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Object/classes/class.ilObjectGUI.php");
5 
17 {
23  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
24  {
25  $this->type = "excs";
26  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
27 
28  $this->lng->loadLanguageModule("exercise");
29  }
30 
37  public function executeCommand()
38  {
39  $next_class = $this->ctrl->getNextClass($this);
40  $cmd = $this->ctrl->getCmd();
41 
42  $this->prepareOutput();
43 
44 /* if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
45  {
46  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
47  }
48 */
49  switch($next_class)
50  {
51  case 'ilpermissiongui':
52  $this->tabs_gui->setTabActive('perm_settings');
53  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
54  $perm_gui = new ilPermissionGUI($this);
55  $this->ctrl->forwardCommand($perm_gui);
56  break;
57 
58  default:
59  if(!$cmd || $cmd == 'view')
60  {
61  $cmd = "editSettings";
62  }
63 
64  $this->$cmd();
65  break;
66  }
67  return true;
68  }
69 
76  public function getAdminTabs()
77  {
78  global $rbacsystem;
79 
80  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
81  {
82  $this->tabs_gui->addTarget("settings",
83  $this->ctrl->getLinkTarget($this, "editSettings"),
84  array("editSettings", "view"));
85  }
86 
87  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
88  {
89  $this->tabs_gui->addTarget("perm_settings",
90  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"),
91  array(),'ilpermissiongui');
92  }
93  }
94 
95 
99  public function editSettings($a_form = null)
100  {
101  global $lng, $ilSetting;
102 
103  $this->tabs_gui->setTabActive('settings');
104 
105  if(!$a_form)
106  {
107  $a_form = $this->initFormSettings();
108  }
109  $this->tpl->setContent($a_form->getHTML());
110  return true;
111  }
112 
116  public function saveSettings()
117  {
118  global $ilCtrl;
119 
120  $this->checkPermission("write");
121 
122  $form = $this->initFormSettings();
123  if($form->checkInput())
124  {
125  $exc_set = new ilSetting("excs");
126  $exc_set->set("add_to_pd", (bool)$form->getInput("pd"));
127 
128  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
129  $ilCtrl->redirect($this, "editSettings");
130  }
131 
132  $form->setValuesByPost();
133  $this->editSettings($form);
134  }
135 
139  public function cancel()
140  {
141  global $ilCtrl;
142 
143  $ilCtrl->redirect($this, "view");
144  }
145 
151  protected function initFormSettings()
152  {
153  global $lng;
154 
155  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
156  $form = new ilPropertyFormGUI();
157  $form->setFormAction($this->ctrl->getFormAction($this));
158  $form->setTitle($this->lng->txt('exc_admin_settings'));
159  $form->addCommandButton('saveSettings',$this->lng->txt('save'));
160  $form->addCommandButton('cancel',$this->lng->txt('cancel'));
161 
162  $exc_set = new ilSetting("excs");
163 
164  $pd = new ilCheckboxInputGUI($lng->txt("to_desktop"), "pd");
165  $pd->setInfo($lng->txt("exc_to_desktop_info"));
166  $pd->setChecked($exc_set->get("add_to_pd", true));
167  $form->addItem($pd);
168 
169  return $form;
170  }
171 }
172 
173 ?>