ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjBlogAdministrationGUI.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("./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 = "blga";
26  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
27 
28  $this->lng->loadLanguageModule("blog");
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("disable_wsp_blogs"))
108  {
109  ilUtil::sendInfo($lng->txt("blog_admin_toggle_info"));
110  }
111  else
112  {
113  ilUtil::sendInfo($lng->txt("blog_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  $blga_set = new ilSetting("blga");
139  $blga_set->set("banner", $banner);
140  $blga_set->set("banner_width", (int)$form->getInput("width"));
141  $blga_set->set("banner_height", (int)$form->getInput("height"));
142 
143  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
144  $ilCtrl->redirect($this, "editSettings");
145  }
146 
147  $form->setValuesByPost();
148  $this->editSettings($form);
149  }
150 
154  public function cancel()
155  {
156  global $ilCtrl;
157 
158  $ilCtrl->redirect($this, "view");
159  }
160 
166  protected function initFormSettings()
167  {
168  global $lng;
169 
170  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
171  $form = new ilPropertyFormGUI();
172  $form->setFormAction($this->ctrl->getFormAction($this));
173  $form->setTitle($this->lng->txt('blog_settings'));
174  $form->addCommandButton('saveSettings',$this->lng->txt('save'));
175  $form->addCommandButton('cancel',$this->lng->txt('cancel'));
176 
177  $banner = new ilCheckboxInputGUI($lng->txt("blog_preview_banner"), "banner");
178  $banner->setInfo($lng->txt("blog_preview_banner_info"));
179  $form->addItem($banner);
180 
181  $width = new ilNumberInputGUI($lng->txt("blog_preview_banner_width"), "width");
182  $width->setRequired(true);
183  $width->setSize(4);
184  $banner->addSubItem($width);
185 
186  $height = new ilNumberInputGUI($lng->txt("blog_preview_banner_height"), "height");
187  $height->setRequired(true);
188  $height->setSize(4);
189  $banner->addSubItem($height);
190 
191  $blga_set = new ilSetting("blga");
192  $banner->setChecked($blga_set->get("banner"));
193  if($blga_set->get("banner"))
194  {
195  $width->setValue($blga_set->get("banner_width"));
196  $height->setValue($blga_set->get("banner_height"));
197  }
198  else
199  {
200  $width->setValue(880);
201  $height->setValue(100);
202  }
203 
204  return $form;
205  }
206 }
207 ?>