ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjPortfolioAdministrationGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 include_once("./Services/Object/classes/class.ilObjectGUI.php");
4 
17 {
23  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
24  {
25  $this->type = "prfa";
26  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
27 
28  $this->lng->loadLanguageModule("prtf");
29  }
30 
37  public function executeCommand()
38  {
39  global $rbacsystem,$ilErr,$ilAccess;
40 
41  $next_class = $this->ctrl->getNextClass($this);
42  $cmd = $this->ctrl->getCmd();
43 
44  $this->prepareOutput();
45 
46 /* if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
47  {
48  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
49  }
50 */
51  switch($next_class)
52  {
53  case 'ilpermissiongui':
54  $this->tabs_gui->setTabActive('perm_settings');
55  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
56  $perm_gui =& new ilPermissionGUI($this);
57  $ret =& $this->ctrl->forwardCommand($perm_gui);
58  break;
59 
60  default:
61  if(!$cmd || $cmd == 'view')
62  {
63  $cmd = "editSettings";
64  }
65 
66  $this->$cmd();
67  break;
68  }
69  return true;
70  }
71 
78  public function getAdminTabs()
79  {
80  global $rbacsystem, $ilAccess;
81 
82  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
83  {
84  $this->tabs_gui->addTarget("settings",
85  $this->ctrl->getLinkTarget($this, "editSettings"),
86  array("editSettings", "view"));
87  }
88 
89  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
90  {
91  $this->tabs_gui->addTarget("perm_settings",
92  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"),
93  array(),'ilpermissiongui');
94  }
95  }
96 
97 
101  public function editSettings($a_form = null)
102  {
103  global $lng, $ilSetting;
104 
105  $this->tabs_gui->setTabActive('settings');
106 
107  if ($ilSetting->get('user_portfolios'))
108  {
109  ilUtil::sendInfo($lng->txt("prtf_admin_toggle_info"));
110  }
111  else
112  {
113  ilUtil::sendInfo($lng->txt("prtf_admin_inactive_info"));
114  }
115 
116  if(!$a_form)
117  {
118  $a_form = $this->initFormSettings();
119  }
120  $this->tpl->setContent($a_form->getHTML());
121  return true;
122  }
123 
127  public function saveSettings()
128  {
129  global $ilCtrl, $ilSetting;
130 
131  $this->checkPermission("write");
132 
133  $form = $this->initFormSettings();
134  if($form->checkInput())
135  {
136  $banner = (bool)$form->getInput("banner");
137 
138  $prfa_set = new ilSetting("prfa");
139  $prfa_set->set("banner", $banner);
140  $prfa_set->set("banner_width", (int)$form->getInput("width"));
141  $prfa_set->set("banner_height", (int)$form->getInput("height"));
142  $prfa_set->set("mask", (bool)$form->getInput("mask"));
143 
144  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
145  $ilCtrl->redirect($this, "editSettings");
146  }
147 
148  $form->setValuesByPost();
149  $this->editSettings($form);
150  }
151 
155  public function cancel()
156  {
157  global $ilCtrl;
158 
159  $ilCtrl->redirect($this, "view");
160  }
161 
167  protected function initFormSettings()
168  {
169  global $lng;
170 
171  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
172  $form = new ilPropertyFormGUI();
173  $form->setFormAction($this->ctrl->getFormAction($this));
174  $form->setTitle($this->lng->txt('prtf_settings'));
175  $form->addCommandButton('saveSettings',$this->lng->txt('save'));
176  $form->addCommandButton('cancel',$this->lng->txt('cancel'));
177 
178  $banner = new ilCheckboxInputGUI($lng->txt("prtf_preview_banner"), "banner");
179  $banner->setInfo($lng->txt("prtf_preview_banner_info"));
180  $form->addItem($banner);
181 
182  $width = new ilNumberInputGUI($lng->txt("prtf_preview_banner_width"), "width");
183  $width->setRequired(true);
184  $width->setSize(4);
185  $banner->addSubItem($width);
186 
187  $height = new ilNumberInputGUI($lng->txt("prtf_preview_banner_height"), "height");
188  $height->setRequired(true);
189  $height->setSize(4);
190  $banner->addSubItem($height);
191 
192  $prfa_set = new ilSetting("prfa");
193  $banner->setChecked($prfa_set->get("banner"));
194  if($prfa_set->get("banner"))
195  {
196  $width->setValue($prfa_set->get("banner_width"));
197  $height->setValue($prfa_set->get("banner_height"));
198  }
199  else
200  {
201  $width->setValue(880);
202  $height->setValue(100);
203  }
204 
205  $mask = new ilCheckboxInputGUI($lng->txt("prtf_allow_html"), "mask");
206  $mask->setInfo($lng->txt("prtf_allow_html_info"));
207  $mask->setChecked($prfa_set->get("mask", false));
208  $form->addItem($mask);
209 
210  return $form;
211  }
212 }
213 ?>