ILIAS  Release_5_0_x_branch Revision 61816
 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("./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 = "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  $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 (!$ilSetting->get("disable_wsp_blogs"))
106  {
107  ilUtil::sendInfo($lng->txt("blog_admin_toggle_info"));
108  }
109  else
110  {
111  ilUtil::sendInfo($lng->txt("blog_admin_inactive_info"));
112  }
113 
114  if(!$a_form)
115  {
116  $a_form = $this->initFormSettings();
117  }
118  $this->tpl->setContent($a_form->getHTML());
119  return true;
120  }
121 
125  public function saveSettings()
126  {
127  global $ilCtrl;
128 
129  $this->checkPermission("write");
130 
131  $form = $this->initFormSettings();
132  if($form->checkInput())
133  {
134  $banner = (bool)$form->getInput("banner");
135 
136  $blga_set = new ilSetting("blga");
137  $blga_set->set("banner", $banner);
138  $blga_set->set("banner_width", (int)$form->getInput("width"));
139  $blga_set->set("banner_height", (int)$form->getInput("height"));
140  $blga_set->set("mask", (bool)$form->getInput("mask"));
141 
142  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
143  $ilCtrl->redirect($this, "editSettings");
144  }
145 
146  $form->setValuesByPost();
147  $this->editSettings($form);
148  }
149 
153  public function cancel()
154  {
155  global $ilCtrl;
156 
157  $ilCtrl->redirect($this, "view");
158  }
159 
165  protected function initFormSettings()
166  {
167  global $lng;
168 
169  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
170  $form = new ilPropertyFormGUI();
171  $form->setFormAction($this->ctrl->getFormAction($this));
172  $form->setTitle($this->lng->txt('blog_settings'));
173  $form->addCommandButton('saveSettings',$this->lng->txt('save'));
174  $form->addCommandButton('cancel',$this->lng->txt('cancel'));
175 
176  $banner = new ilCheckboxInputGUI($lng->txt("blog_preview_banner"), "banner");
177  $banner->setInfo($lng->txt("blog_preview_banner_info"));
178  $form->addItem($banner);
179 
180  $width = new ilNumberInputGUI($lng->txt("blog_preview_banner_width"), "width");
181  $width->setRequired(true);
182  $width->setSize(4);
183  $banner->addSubItem($width);
184 
185  $height = new ilNumberInputGUI($lng->txt("blog_preview_banner_height"), "height");
186  $height->setRequired(true);
187  $height->setSize(4);
188  $banner->addSubItem($height);
189 
190  $blga_set = new ilSetting("blga");
191  $banner->setChecked($blga_set->get("banner", false));
192  if($blga_set->get("banner"))
193  {
194  $width->setValue($blga_set->get("banner_width"));
195  $height->setValue($blga_set->get("banner_height"));
196  }
197  else
198  {
199  $width->setValue(1370);
200  $height->setValue(100);
201  }
202 
203  $mask = new ilCheckboxInputGUI($lng->txt("blog_allow_html"), "mask");
204  $mask->setInfo($lng->txt("blog_allow_html_info"));
205  $mask->setChecked($blga_set->get("mask", false));
206  $form->addItem($mask);
207 
208  return $form;
209  }
210 }
211 ?>