ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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*/
23include_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 $next_class = $this->ctrl->getNextClass($this);
83 $cmd = $this->ctrl->getCmd();
84
85 $this->prepareOutput();
86
87 if (!$this->hierarchical_access->checkAccess('read', '', $this->object->getRefId())) {
88 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
89 }
90
91 switch ($next_class) {
92 case 'ilpermissiongui':
93 $this->tabs_gui->setTabActive('perm_settings');
94 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
95 $perm_gui = new ilPermissionGUI($this);
96 $this->ctrl->forwardCommand($perm_gui);
97 break;
98
99 default:
100 if (!$cmd || $cmd == 'view') {
101 $cmd = "settings";
102 }
103
104 $this->$cmd();
105 break;
106 }
107 return true;
108 }
109
113 public function getAdminTabs()
114 {
115 if ($this->access->checkAccess("visible,read", $this->object->getRefId())) {
116 $this->tabs_gui->addTarget(
117 "settings",
118 $this->ctrl->getLinkTarget($this, "settings"),
119 array("settings", "view")
120 );
121 }
122
123 if ($this->access->checkAccess('edit_permission', $this->object->getRefId())) {
124 $this->tabs_gui->addTarget(
125 "perm_settings",
126 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
127 array(),
128 'ilpermissiongui'
129 );
130 }
131 }
132
136 public function settings()
137 {
138 $this->tabs_gui->setTabActive('settings');
139 $form_settings = new ilSetting("certificate");
140
141 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
142 $form = new ilPropertyFormGUI();
143 $form->setFormAction($this->ctrl->getFormAction($this));
144 $form->setTitle($this->lng->txt('certificate_settings'));
145
146 $active = new ilCheckboxInputGUI($this->lng->txt("active"), "active");
147 $active->setChecked($form_settings->get("active"));
148 $form->addItem($active);
149
150 $info = new ilNonEditableValueGUI($this->lng->txt("info"), "info");
151 $info->setValue($this->lng->txt("certificate_usage"));
152 $form->addItem($info);
153
154 $bgimage = new ilImageFileInputGUI($this->lng->txt("certificate_background_image"), "background");
155 $bgimage->setRequired(false);
156 if (count($_POST)) {
157 // handle the background upload
158 if (strlen($_FILES["background"]["tmp_name"])) {
159 if ($bgimage->checkInput()) {
160 $result = $this->object->uploadBackgroundImage($_FILES["background"]["tmp_name"]);
161 if ($result == false) {
162 $bgimage->setAlert($this->lng->txt("certificate_error_upload_bgimage"));
163 }
164 }
165 }
166 }
167 if (strlen($this->object->hasBackgroundImage())) {
168 require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
170 $bgimage->setImage(ilWACSignedPath::signFile($this->object->getBackgroundImageThumbPathWeb()));
171 }
172 $bgimage->setInfo($this->lng->txt("default_background_info"));
173 $form->addItem($bgimage);
174 $format = new ilSelectInputGUI($this->lng->txt("certificate_page_format"), "pageformat");
175 $defaultformats = array(
176 "a4" => $this->lng->txt("certificate_a4"), // (297 mm x 210 mm)
177 "a4landscape" => $this->lng->txt("certificate_a4_landscape"), // (210 mm x 297 mm)",
178 "a5" => $this->lng->txt("certificate_a5"), // (210 mm x 148.5 mm)
179 "a5landscape" => $this->lng->txt("certificate_a5_landscape"), // (148.5 mm x 210 mm)
180 "letter" => $this->lng->txt("certificate_letter"), // (11 inch x 8.5 inch)
181 "letterlandscape" => $this->lng->txt("certificate_letter_landscape") // (11 inch x 8.5 inch)
182 );
183 $format->setOptions($defaultformats);
184 $format->setValue($form_settings->get("pageformat"));
185 $format->setInfo($this->lng->txt("certificate_page_format_info"));
186 $form->addItem($format);
187
188
189 if ($this->hierarchical_access->checkAccess('write', '', $this->object->getRefId())) {
190 $form->addCommandButton('save', $this->lng->txt('save'));
191 }
192
193 $this->tpl->setContent($form->getHTML());
194
195 if (strcmp($this->ctrl->getCmd(), "save") == 0) {
196 if ($_POST["background_delete"]) {
197 $this->object->deleteBackgroundImage();
198 }
199 }
200 }
201
202 public function save()
203 {
204 $form_settings = new ilSetting("certificate");
205 $form_settings->set("pageformat", $_POST["pageformat"]);
206 $form_settings->set("active", $_POST["active"]);
207
208 ilUtil::sendSuccess($this->lng->txt("settings_saved"));
209 $this->settings();
210 }
211}
$result
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
This class represents a checkbox property in a property form.
This class represents an image file property in a property form.
This class represents a non editable value in a property form.
__construct($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput($a_show_subobjects=true)
prepare output
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
This class represents a selection list property in a property form.
ILIAS Setting Class.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static signFile($path_to_file)
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
$format
Definition: metadata.php:141
$info
Definition: index.php:5
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7