ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjCertificateSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 
19 include_once("./Services/Object/classes/class.ilObjectGUI.php");
20 
33 {
37  private $type;
38 
46  protected $access;
50  protected $error;
51  private static $ERROR_MESSAGE;
53  protected $httpState;
55  protected $upload;
56 
57 
63  public function __construct($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = true)
64  {
65  global $DIC;
66 
67  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
68  $this->httpState = $DIC->http();
69  $this->upload = $DIC->upload();
70  $this->type = 'cert';
71  $this->lng->loadLanguageModule("certificate");
72  $this->lng->loadLanguageModule("trac");
73 
74  $this->access = $DIC['rbacsystem'];
75  $this->error = $DIC['ilErr'];
76  $this->hierarchical_access = $DIC['ilAccess'];
77  }
78 
79 
86  public function executeCommand()
87  {
88  $next_class = $this->ctrl->getNextClass($this);
89  $cmd = $this->ctrl->getCmd();
90 
91  $this->prepareOutput();
92 
93  if (!$this->hierarchical_access->checkAccess('read', '', $this->object->getRefId())) {
94  $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
95  }
96 
97  switch ($next_class) {
98  case 'ilpermissiongui':
99  $this->tabs_gui->setTabActive('perm_settings');
100  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
101  $perm_gui = new ilPermissionGUI($this);
102  $this->ctrl->forwardCommand($perm_gui);
103  break;
104 
105  default:
106  if (!$cmd || $cmd == 'view') {
107  $cmd = "settings";
108  }
109 
110  $this->$cmd();
111  break;
112  }
113 
114  return true;
115  }
116 
117 
121  public function getAdminTabs()
122  {
123  if ($this->access->checkAccess("visible,read", $this->object->getRefId())) {
124  $this->tabs_gui->addTarget(
125  "settings",
126  $this->ctrl->getLinkTarget($this, "settings"),
127  array("settings", "view")
128  );
129  }
130 
131  if ($this->access->checkAccess('edit_permission', $this->object->getRefId())) {
132  $this->tabs_gui->addTarget(
133  "perm_settings",
134  $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
135  array(),
136  'ilpermissiongui'
137  );
138  }
139  }
140 
141 
145  public function settings()
146  {
147  $this->tabs_gui->setTabActive('settings');
148  $form_settings = new ilSetting("certificate");
149 
150  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
151  $form = new ilPropertyFormGUI();
152  $form->setFormAction($this->ctrl->getFormAction($this));
153  $form->setTitle($this->lng->txt('certificate_settings'));
154 
155  $active = new ilCheckboxInputGUI($this->lng->txt("active"), "active");
156  $active->setChecked($form_settings->get("active"));
157  $form->addItem($active);
158 
159  $info = new ilNonEditableValueGUI($this->lng->txt("info"), "info");
160  $info->setValue($this->lng->txt("certificate_usage"));
161  $form->addItem($info);
162 
163  $bgimage = new ilImageFileInputGUI($this->lng->txt("certificate_background_image"), "background");
164  $bgimage->setRequired(false);
165 
166  if (strcmp($this->ctrl->getCmd(), "save") == 0) {
167  if ($_POST["background_delete"]) {
168  $this->object->deleteBackgroundImage();
169  }
170  }
171 
172  if (
173  $this->upload->hasUploads() &&
174  $this->httpState->request()->getMethod() === 'POST' &&
175  $bgimage->checkInput()
176  ) {
177  if (!$this->upload->hasBeenProcessed()) {
178  $this->upload->process();
179  }
180 
181  if (is_array($this->upload->getResults()) && $this->upload->getResults() !== []) {
182  $results = $this->upload->getResults();
183  $file = array_pop($results);
184  if ($file->isOK()) {
185  $result = $this->object->uploadBackgroundImage($file->getPath());
186  if ($result === false) {
187  $bgimage->setAlert($this->lng->txt('certificate_error_upload_bgimage'));
188  }
189  }
190  }
191  }
192 
193  if (strlen($this->object->hasBackgroundImage())) {
194  require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
196  $bgimage->setImage(ilWACSignedPath::signFile($this->object->getDefaultBackgroundImagePathWeb()));
197  }
198  $bgimage->setInfo($this->lng->txt("default_background_info"));
199  $form->addItem($bgimage);
200  $format = new ilSelectInputGUI($this->lng->txt("certificate_page_format"), "pageformat");
201  $defaultformats = array(
202  "a4" => $this->lng->txt("certificate_a4"), // (297 mm x 210 mm)
203  "a4landscape" => $this->lng->txt("certificate_a4_landscape"), // (210 mm x 297 mm)",
204  "a5" => $this->lng->txt("certificate_a5"), // (210 mm x 148.5 mm)
205  "a5landscape" => $this->lng->txt("certificate_a5_landscape"), // (148.5 mm x 210 mm)
206  "letter" => $this->lng->txt("certificate_letter"), // (11 inch x 8.5 inch)
207  "letterlandscape" => $this->lng->txt("certificate_letter_landscape") // (11 inch x 8.5 inch)
208  );
209  $format->setOptions($defaultformats);
210  $format->setValue($form_settings->get("pageformat"));
211  $format->setInfo($this->lng->txt("certificate_page_format_info"));
212  $form->addItem($format);
213 
214  if ($this->hierarchical_access->checkAccess('write', '', $this->object->getRefId())) {
215  $form->addCommandButton('save', $this->lng->txt('save'));
216  }
217 
221  $form,
222  $this
223  );
224  }
225 
226  $persistentCertificateMode = new ilRadioGroupInputGUI($this->lng->txt('persistent_certificate_mode'), 'persistent_certificate_mode');
227  $persistentCertificateMode->setRequired(true);
228 
229  $cronJobMode = new ilRadioOption($this->lng->txt('persistent_certificate_mode_cron'), 'persistent_certificate_mode_cron');
230  $cronJobMode->setInfo($this->lng->txt('persistent_certificate_mode_cron_info'));
231 
232  $instantMode = new ilRadioOption($this->lng->txt('persistent_certificate_mode_instant'), 'persistent_certificate_mode_instant');
233  $instantMode->setInfo($this->lng->txt('persistent_certificate_mode_instant_info'));
234 
235  $persistentCertificateMode->addOption($cronJobMode);
236  $persistentCertificateMode->addOption($instantMode);
237 
238  $persistentCertificateMode->setValue($form_settings->get('persistent_certificate_mode', 'persistent_certificate_mode_cron'));
239 
240  $form->addItem($persistentCertificateMode);
241 
242  $this->tpl->setContent($form->getHTML());
243  }
244 
245  public function save()
246  {
247  $form_settings = new ilSetting("certificate");
248 
249  $mode = $_POST["persistent_certificate_mode"];
250  $previousMode = $form_settings->get('persistent_certificate_mode', 'persistent_certificate_mode_cron');
251  if ($mode !== $previousMode && $mode === 'persistent_certificate_mode_instant') {
252  $cron = new ilCertificateCron();
253  $cron->init();
254  $cron->run();
255  }
256 
257  $form_settings->set("pageformat", $_POST["pageformat"]);
258  $form_settings->set("active", $_POST["active"]);
259  $form_settings->set("persistent_certificate_mode", $mode);
260 
261  ilUtil::sendSuccess($this->lng->txt("settings_saved"));
262  $this->settings();
263  }
264 }
This class represents an option in a radio group.
$result
This class represents a property form user interface.
This class represents a checkbox property in a property form.
setInfo($a_info)
Set Info.
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.
Class ilObjectGUI Basic methods of all Output classes.
global $DIC
Definition: goto.php:24
$format
Definition: metadata.php:218
$cron
Definition: cron.php:16
$results
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.
__construct(Container $dic, ilPlugin $plugin)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
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.