ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjCertificateSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 include_once("./Services/Object/classes/class.ilObjectGUI.php");
24 
25 
38 {
43 
47  protected $access;
48 
52  protected $error;
53 
54  private static $ERROR_MESSAGE;
55 
61  public function __construct($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = true)
62  {
63  global $DIC;
64 
65  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
66  $this->type = 'cert';
67  $this->lng->loadLanguageModule("certificate");
68 
69  $this->access = $DIC['rbacsystem'];
70  $this->error = $DIC['ilErr'];
71  $this->hierarchical_access = $DIC['ilAccess'];
72  }
73 
80  public function executeCommand()
81  {
82 
83  $next_class = $this->ctrl->getNextClass($this);
84  $cmd = $this->ctrl->getCmd();
85 
86  $this->prepareOutput();
87 
88  if(!$this->hierarchical_access->checkAccess('read', '', $this->object->getRefId()))
89  {
90  $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
91  }
92 
93  switch($next_class)
94  {
95  case 'ilpermissiongui':
96  $this->tabs_gui->setTabActive('perm_settings');
97  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
98  $perm_gui = new ilPermissionGUI($this);
99  $this->ctrl->forwardCommand($perm_gui);
100  break;
101 
102  default:
103  if(!$cmd || $cmd == 'view')
104  {
105  $cmd = "settings";
106  }
107 
108  $this->$cmd();
109  break;
110  }
111  return true;
112  }
113 
117  public function getAdminTabs()
118  {
119  if($this->access->checkAccess("visible,read",$this->object->getRefId()))
120  {
121  $this->tabs_gui->addTarget("settings",
122  $this->ctrl->getLinkTarget($this, "settings"),
123  array("settings", "view"));
124  }
125 
126  if($this->access->checkAccess('edit_permission',$this->object->getRefId()))
127  {
128  $this->tabs_gui->addTarget("perm_settings",
129  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"),
130  array(),'ilpermissiongui');
131  }
132  }
133 
137  public function settings()
138  {
139  $this->tabs_gui->setTabActive('settings');
140  $form_settings = new ilSetting("certificate");
141 
142  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
143  $form = new ilPropertyFormGUI();
144  $form->setFormAction($this->ctrl->getFormAction($this));
145  $form->setTitle($this->lng->txt('certificate_settings'));
146 
147  $active = new ilCheckboxInputGUI($this->lng->txt("active"), "active");
148  $active->setChecked($form_settings->get("active"));
149  $form->addItem($active);
150 
151  $info = new ilNonEditableValueGUI($this->lng->txt("info"), "info");
152  $info->setValue($this->lng->txt("certificate_usage"));
153  $form->addItem($info);
154 
155  $bgimage = new ilImageFileInputGUI($this->lng->txt("certificate_background_image"), "background");
156  $bgimage->setRequired(FALSE);
157  if (count($_POST))
158  {
159  // handle the background upload
160  if (strlen($_FILES["background"]["tmp_name"]))
161  {
162  if ($bgimage->checkInput())
163  {
164  $result = $this->object->uploadBackgroundImage($_FILES["background"]["tmp_name"]);
165  if ($result == FALSE)
166  {
167  $bgimage->setAlert($this->lng->txt("certificate_error_upload_bgimage"));
168  }
169  }
170  }
171  }
172  if (strlen($this->object->hasBackgroundImage()))
173  {
174  require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
176  $bgimage->setImage(ilWACSignedPath::signFile($this->object->getBackgroundImageThumbPathWeb()));
177  }
178  $bgimage->setInfo($this->lng->txt("default_background_info"));
179  $form->addItem($bgimage);
180  $format = new ilSelectInputGUI($this->lng->txt("certificate_page_format"), "pageformat");
181  $defaultformats = array(
182  "a4" => $this->lng->txt("certificate_a4"), // (297 mm x 210 mm)
183  "a4landscape" => $this->lng->txt("certificate_a4_landscape"), // (210 mm x 297 mm)",
184  "a5" => $this->lng->txt("certificate_a5"), // (210 mm x 148.5 mm)
185  "a5landscape" => $this->lng->txt("certificate_a5_landscape"), // (148.5 mm x 210 mm)
186  "letter" => $this->lng->txt("certificate_letter"), // (11 inch x 8.5 inch)
187  "letterlandscape" => $this->lng->txt("certificate_letter_landscape") // (11 inch x 8.5 inch)
188  );
189  $format->setOptions($defaultformats);
190  $format->setValue($form_settings->get("pageformat"));
191  $format->setInfo($this->lng->txt("certificate_page_format_info"));
192  $form->addItem($format);
193 
194 
195  if($this->hierarchical_access->checkAccess('write','',$this->object->getRefId()))
196  {
197  $form->addCommandButton('save',$this->lng->txt('save'));
198  }
199 
200  $this->tpl->setContent($form->getHTML());
201 
202  if (strcmp($this->ctrl->getCmd(), "save") == 0)
203  {
204  if ($_POST["background_delete"])
205  {
206  $this->object->deleteBackgroundImage();
207  }
208  }
209  }
210 
211  public function save()
212  {
213  $form_settings = new ilSetting("certificate");
214  $form_settings->set("pageformat", $_POST["pageformat"]);
215  $form_settings->set("active", $_POST["active"]);
216 
217  ilUtil::sendSuccess($this->lng->txt("settings_saved"));
218  $this->settings();
219  }
220 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
ILIAS Setting Class.
This class represents a selection list property in a property form.
$result
This class represents a property form user interface.
$cmd
Definition: sahs_server.php:35
This class represents a checkbox property in a property form.
setChecked($a_checked)
Set Checked.
$info
Definition: example_052.php:80
prepareOutput($a_show_subobjects=true)
prepare output
Class ilObjectGUI Basic methods of all Output classes.
static signFile($path_to_file)
Create styles array
The data for the language used.
This class represents an image file property in a property form.
This class represents a non editable value in a property form.
Create new PHPExcel object
obj_idprivate
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
global $DIC
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
__construct($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
$_POST["username"]
setRequired($a_required)
Set Required.