ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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{
39 private static $ERROR_MESSAGE;
45 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
46 {
47 parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
48 $this->type = 'cert';
49 $this->lng->loadLanguageModule("certificate");
50 }
51
58 public function executeCommand()
59 {
60 global $rbacsystem,$ilErr,$ilAccess;
61
62 $next_class = $this->ctrl->getNextClass($this);
63 $cmd = $this->ctrl->getCmd();
64
65 $this->prepareOutput();
66
67 if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
68 {
69 $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
70 }
71
72 switch($next_class)
73 {
74 case 'ilpermissiongui':
75 $this->tabs_gui->setTabActive('perm_settings');
76 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
77 $perm_gui =& new ilPermissionGUI($this);
78 $ret =& $this->ctrl->forwardCommand($perm_gui);
79 break;
80
81 default:
82 if(!$cmd || $cmd == 'view')
83 {
84 $cmd = "settings";
85 }
86
87 $this->$cmd();
88 break;
89 }
90 return true;
91 }
92
96 public function getAdminTabs()
97 {
98 global $rbacsystem, $ilAccess;
99
100 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
101 {
102 $this->tabs_gui->addTarget("settings",
103 $this->ctrl->getLinkTarget($this, "settings"),
104 array("settings", "view"));
105 }
106
107 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
108 {
109 $this->tabs_gui->addTarget("perm_settings",
110 $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"),
111 array(),'ilpermissiongui');
112 }
113 }
114
118 public function settings()
119 {
120 global $lng, $ilAccess;
121
122 $this->tabs_gui->setTabActive('settings');
123 $form_settings = new ilSetting("certificate");
124
125 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
126 $form = new ilPropertyFormGUI();
127 $form->setFormAction($this->ctrl->getFormAction($this));
128 $form->setTitle($this->lng->txt('certificate_settings'));
129
130 $active = new ilCheckboxInputGUI($this->lng->txt("active"), "active");
131 $active->setChecked($form_settings->get("active"));
132 $form->addItem($active);
133
134 $info = new ilNonEditableValueGUI($this->lng->txt("info"), "info");
135 $info->setValue($this->lng->txt("certificate_usage"));
136 $form->addItem($info);
137
138 $bgimage = new ilImageFileInputGUI($this->lng->txt("certificate_background_image"), "background");
139 $bgimage->setRequired(FALSE);
140 if (count($_POST))
141 {
142 // handle the background upload
143 if (strlen($_FILES["background"]["tmp_name"]))
144 {
145 if ($bgimage->checkInput())
146 {
147 $result = $this->object->uploadBackgroundImage($_FILES["background"]["tmp_name"]);
148 if ($result == FALSE)
149 {
150 $bgimage->setAlert($this->lng->txt("certificate_error_upload_bgimage"));
151 }
152 }
153 }
154 }
155 if (strlen($this->object->hasBackgroundImage()))
156 {
157 require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
159 $bgimage->setImage(ilWACSignedPath::signFile($this->object->getBackgroundImageThumbPathWeb()));
160 }
161 $bgimage->setInfo($this->lng->txt("default_background_info"));
162 $form->addItem($bgimage);
163 $format = new ilSelectInputGUI($this->lng->txt("certificate_page_format"), "pageformat");
164 $defaultformats = array(
165 "a4" => $this->lng->txt("certificate_a4"), // (297 mm x 210 mm)
166 "a4landscape" => $this->lng->txt("certificate_a4_landscape"), // (210 mm x 297 mm)",
167 "a5" => $this->lng->txt("certificate_a5"), // (210 mm x 148.5 mm)
168 "a5landscape" => $this->lng->txt("certificate_a5_landscape"), // (148.5 mm x 210 mm)
169 "letter" => $this->lng->txt("certificate_letter"), // (11 inch x 8.5 inch)
170 "letterlandscape" => $this->lng->txt("certificate_letter_landscape") // (11 inch x 8.5 inch)
171 );
172 $format->setOptions($defaultformats);
173 $format->setValue($form_settings->get("pageformat"));
174 $format->setInfo($this->lng->txt("certificate_page_format_info"));
175 $form->addItem($format);
176
177
178 if($ilAccess->checkAccess('write','',$this->object->getRefId()))
179 {
180 $form->addCommandButton('save',$this->lng->txt('save'));
181 }
182
183 $this->tpl->setContent($form->getHTML());
184
185 if (strcmp($this->ctrl->getCmd(), "save") == 0)
186 {
187 if ($_POST["background_delete"])
188 {
189 $this->object->deleteBackgroundImage();
190 }
191 }
192 }
193
194 public function save()
195 {
196 $form_settings = new ilSetting("certificate");
197 $form_settings->set("pageformat", $_POST["pageformat"]);
198 $form_settings->set("active", $_POST["active"]);
199
200 ilUtil::sendSuccess($this->lng->txt("settings_saved"));
201 $this->settings();
202 }
203}
204?>
$result
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, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput()
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)
$_POST['username']
Definition: cron.php:12
$info
Definition: example_052.php:80
$cmd
Definition: sahs_server.php:35