ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
37 {
41  private $type;
42 
50  protected $access;
54  protected $error;
55  private static $ERROR_MESSAGE;
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->type = 'cert';
69  $this->lng->loadLanguageModule("certificate");
70  $this->lng->loadLanguageModule("trac");
71 
72  $this->access = $DIC['rbacsystem'];
73  $this->error = $DIC['ilErr'];
74  $this->hierarchical_access = $DIC['ilAccess'];
75  }
76 
77 
84  public function executeCommand()
85  {
86  $next_class = $this->ctrl->getNextClass($this);
87  $cmd = $this->ctrl->getCmd();
88 
89  $this->prepareOutput();
90 
91  if (!$this->hierarchical_access->checkAccess('read', '', $this->object->getRefId())) {
92  $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
93  }
94 
95  switch ($next_class) {
96  case 'ilpermissiongui':
97  $this->tabs_gui->setTabActive('perm_settings');
98  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
99  $perm_gui = new ilPermissionGUI($this);
100  $this->ctrl->forwardCommand($perm_gui);
101  break;
102 
103  default:
104  if (!$cmd || $cmd == 'view') {
105  $cmd = "settings";
106  }
107 
108  $this->$cmd();
109  break;
110  }
111 
112  return true;
113  }
114 
115 
119  public function getAdminTabs()
120  {
121  if ($this->access->checkAccess("visible,read", $this->object->getRefId())) {
122  $this->tabs_gui->addTarget(
123  "settings",
124  $this->ctrl->getLinkTarget($this, "settings"),
125  array("settings", "view")
126  );
127  }
128 
129  if ($this->access->checkAccess('edit_permission', $this->object->getRefId())) {
130  $this->tabs_gui->addTarget(
131  "perm_settings",
132  $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
133  array(),
134  'ilpermissiongui'
135  );
136  }
137  }
138 
139 
143  public function settings()
144  {
145  $this->tabs_gui->setTabActive('settings');
146  $form_settings = new ilSetting("certificate");
147 
148  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
149  $form = new ilPropertyFormGUI();
150  $form->setFormAction($this->ctrl->getFormAction($this));
151  $form->setTitle($this->lng->txt('certificate_settings'));
152 
153  $active = new ilCheckboxInputGUI($this->lng->txt("active"), "active");
154  $active->setChecked($form_settings->get("active"));
155  $form->addItem($active);
156 
157  $info = new ilNonEditableValueGUI($this->lng->txt("info"), "info");
158  $info->setValue($this->lng->txt("certificate_usage"));
159  $form->addItem($info);
160 
161  $bgimage = new ilImageFileInputGUI($this->lng->txt("certificate_background_image"), "background");
162  $bgimage->setRequired(false);
163  if (count($_POST)) {
164  // handle the background upload
165  if (strlen($_FILES["background"]["tmp_name"])) {
166  if ($bgimage->checkInput()) {
167  $result = $this->object->uploadBackgroundImage($_FILES["background"]["tmp_name"]);
168  if ($result == false) {
169  $bgimage->setAlert($this->lng->txt("certificate_error_upload_bgimage"));
170  }
171  }
172  }
173  }
174  if (strlen($this->object->hasBackgroundImage())) {
175  require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
177  $bgimage->setImage(ilWACSignedPath::signFile($this->object->getDefaultBackgroundImagePathWeb()));
178  }
179  $bgimage->setInfo($this->lng->txt("default_background_info"));
180  $form->addItem($bgimage);
181  $format = new ilSelectInputGUI($this->lng->txt("certificate_page_format"), "pageformat");
182  $defaultformats = array(
183  "a4" => $this->lng->txt("certificate_a4"), // (297 mm x 210 mm)
184  "a4landscape" => $this->lng->txt("certificate_a4_landscape"), // (210 mm x 297 mm)",
185  "a5" => $this->lng->txt("certificate_a5"), // (210 mm x 148.5 mm)
186  "a5landscape" => $this->lng->txt("certificate_a5_landscape"), // (148.5 mm x 210 mm)
187  "letter" => $this->lng->txt("certificate_letter"), // (11 inch x 8.5 inch)
188  "letterlandscape" => $this->lng->txt("certificate_letter_landscape") // (11 inch x 8.5 inch)
189  );
190  $format->setOptions($defaultformats);
191  $format->setValue($form_settings->get("pageformat"));
192  $format->setInfo($this->lng->txt("certificate_page_format_info"));
193  $form->addItem($format);
194 
195  if ($this->hierarchical_access->checkAccess('write', '', $this->object->getRefId())) {
196  $form->addCommandButton('save', $this->lng->txt('save'));
197  }
198 
202  $form,
203  $this
204  );
205  }
206 
207  $persistentCertificateMode = new ilRadioGroupInputGUI($this->lng->txt('persistent_certificate_mode'), 'persistent_certificate_mode');
208  $persistentCertificateMode->setRequired(true);
209 
210  $cronJobMode = new ilRadioOption($this->lng->txt('persistent_certificate_mode_cron'), 'persistent_certificate_mode_cron');
211  $cronJobMode->setInfo($this->lng->txt('persistent_certificate_mode_cron_info'));
212 
213  $instantMode = new ilRadioOption($this->lng->txt('persistent_certificate_mode_instant'), 'persistent_certificate_mode_instant');
214  $instantMode->setInfo($this->lng->txt('persistent_certificate_mode_instant_info'));
215 
216  $persistentCertificateMode->addOption($cronJobMode);
217  $persistentCertificateMode->addOption($instantMode);
218 
219  $persistentCertificateMode->setValue($form_settings->get('persistent_certificate_mode', 'persistent_certificate_mode_cron'));
220 
221  $form->addItem($persistentCertificateMode);
222 
223  $this->tpl->setContent($form->getHTML());
224 
225  if (strcmp($this->ctrl->getCmd(), "save") == 0) {
226  if ($_POST["background_delete"]) {
227  $this->object->deleteBackgroundImage();
228  }
229  }
230  }
231 
232  public function save()
233  {
234  $form_settings = new ilSetting("certificate");
235 
236  $mode = $_POST["persistent_certificate_mode"];
237  $previousMode = $form_settings->get('persistent_certificate_mode', 'persistent_certificate_mode_cron');
238  if ($mode !== $previousMode && $mode === 'persistent_certificate_mode_instant') {
239  $cron = new ilCertificateCron();
240  $cron->init();
241  $cron->run();
242  }
243 
244  $form_settings->set("pageformat", $_POST["pageformat"]);
245  $form_settings->set("active", $_POST["active"]);
246  $form_settings->set("persistent_certificate_mode", $mode);
247 
248  ilUtil::sendSuccess($this->lng->txt("settings_saved"));
249  $this->settings();
250  }
251 }
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.
$format
Definition: metadata.php:218
$cron
Definition: cron.php:16
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)
$DIC
Definition: xapitoken.php:46
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.