ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  $this->lng->loadLanguageModule("trac");
69 
70  $this->access = $DIC['rbacsystem'];
71  $this->error = $DIC['ilErr'];
72  $this->hierarchical_access = $DIC['ilAccess'];
73  }
74 
81  public function executeCommand()
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  $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
90  }
91 
92  switch ($next_class) {
93  case 'ilpermissiongui':
94  $this->tabs_gui->setTabActive('perm_settings');
95  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
96  $perm_gui = new ilPermissionGUI($this);
97  $this->ctrl->forwardCommand($perm_gui);
98  break;
99 
100  default:
101  if (!$cmd || $cmd == 'view') {
102  $cmd = "settings";
103  }
104 
105  $this->$cmd();
106  break;
107  }
108  return true;
109  }
110 
114  public function getAdminTabs()
115  {
116  if ($this->access->checkAccess("visible,read", $this->object->getRefId())) {
117  $this->tabs_gui->addTarget(
118  "settings",
119  $this->ctrl->getLinkTarget($this, "settings"),
120  array("settings", "view")
121  );
122  }
123 
124  if ($this->access->checkAccess('edit_permission', $this->object->getRefId())) {
125  $this->tabs_gui->addTarget(
126  "perm_settings",
127  $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
128  array(),
129  'ilpermissiongui'
130  );
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  // handle the background upload
159  if (strlen($_FILES["background"]["tmp_name"])) {
160  if ($bgimage->checkInput()) {
161  $result = $this->object->uploadBackgroundImage($_FILES["background"]["tmp_name"]);
162  if ($result == false) {
163  $bgimage->setAlert($this->lng->txt("certificate_error_upload_bgimage"));
164  }
165  }
166  }
167  }
168  if (strlen($this->object->hasBackgroundImage())) {
169  require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
171  $bgimage->setImage(ilWACSignedPath::signFile($this->object->getBackgroundImageThumbPathWeb()));
172  }
173  $bgimage->setInfo($this->lng->txt("default_background_info"));
174  $form->addItem($bgimage);
175  $format = new ilSelectInputGUI($this->lng->txt("certificate_page_format"), "pageformat");
176  $defaultformats = array(
177  "a4" => $this->lng->txt("certificate_a4"), // (297 mm x 210 mm)
178  "a4landscape" => $this->lng->txt("certificate_a4_landscape"), // (210 mm x 297 mm)",
179  "a5" => $this->lng->txt("certificate_a5"), // (210 mm x 148.5 mm)
180  "a5landscape" => $this->lng->txt("certificate_a5_landscape"), // (148.5 mm x 210 mm)
181  "letter" => $this->lng->txt("certificate_letter"), // (11 inch x 8.5 inch)
182  "letterlandscape" => $this->lng->txt("certificate_letter_landscape") // (11 inch x 8.5 inch)
183  );
184  $format->setOptions($defaultformats);
185  $format->setValue($form_settings->get("pageformat"));
186  $format->setInfo($this->lng->txt("certificate_page_format_info"));
187  $form->addItem($format);
188 
189 
190  if ($this->hierarchical_access->checkAccess('write', '', $this->object->getRefId())) {
191  $form->addCommandButton('save', $this->lng->txt('save'));
192  }
193 
197  $form,
198  $this
199  );
200  }
201 
202  $persistentCertificateMode = new ilRadioGroupInputGUI($this->lng->txt('persistent_certificate_mode'), 'persistent_certificate_mode');
203  $persistentCertificateMode->setRequired(true);
204 
205  $cronJobMode = new ilRadioOption($this->lng->txt('persistent_certificate_mode_cron'), 'persistent_certificate_mode_cron');
206  $cronJobMode->setInfo($this->lng->txt('persistent_certificate_mode_cron_info'));
207 
208  $instantMode = new ilRadioOption($this->lng->txt('persistent_certificate_mode_instant'), 'persistent_certificate_mode_instant');
209  $instantMode->setInfo($this->lng->txt('persistent_certificate_mode_instant_info'));
210 
211  $persistentCertificateMode->addOption($cronJobMode);
212  $persistentCertificateMode->addOption($instantMode);
213 
214  $persistentCertificateMode->setValue($form_settings->get('persistent_certificate_mode', 'persistent_certificate_mode_cron'));
215 
216  $form->addItem($persistentCertificateMode);
217 
218 
219  $this->tpl->setContent($form->getHTML());
220 
221  if (strcmp($this->ctrl->getCmd(), "save") == 0) {
222  if ($_POST["background_delete"]) {
223  $this->object->deleteBackgroundImage();
224  }
225  }
226  }
227 
228  public function save()
229  {
230  $form_settings = new ilSetting("certificate");
231 
232  $mode = $_POST["persistent_certificate_mode"];
233  $previousMode = $form_settings->get('persistent_certificate_mode', 'persistent_certificate_mode_cron');
234  if ($mode !== $previousMode && $mode === 'persistent_certificate_mode_instant') {
235  $cron = new ilCertificateCron();
236  $cron->init();
237  $cron->run();
238  }
239 
240  $form_settings->set("pageformat", $_POST["pageformat"]);
241  $form_settings->set("active", $_POST["active"]);
242  $form_settings->set("persistent_certificate_mode", $mode);
243 
244  ilUtil::sendSuccess($this->lng->txt("settings_saved"));
245  $this->settings();
246  }
247 }
This class represents an option in a radio group.
$format
Definition: metadata.php:141
This class represents a selection list property in a property form.
$result
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
This class represents a checkbox property in a property form.
setInfo($a_info)
Set Info.
$cron
Definition: cron.php:16
static addFieldsToForm($a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
setChecked($a_checked)
Set Checked.
prepareOutput($a_show_subobjects=true)
prepare output
static _enabledLearningProgress()
check wether learing progress is enabled or not
This class represents a property in a property form.
if(isset($_POST['submit'])) $form
Class ilObjectGUI Basic methods of all Output classes.
static signFile($path_to_file)
This class represents an image file property in a property form.
This class represents a non editable value in a property form.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
$info
Definition: index.php:5
__construct($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
$_POST["username"]
setRequired($a_required)
Set Required.