ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups 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 
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())) $bgimage->setImage($this->object->getBackgroundImageThumbPathWeb());
156  $bgimage->setInfo($this->lng->txt("default_background_info"));
157  $form->addItem($bgimage);
158  $format = new ilSelectInputGUI($this->lng->txt("certificate_page_format"), "pageformat");
159  $defaultformats = array(
160  "a4" => $this->lng->txt("certificate_a4"), // (297 mm x 210 mm)
161  "a4landscape" => $this->lng->txt("certificate_a4_landscape"), // (210 mm x 297 mm)",
162  "a5" => $this->lng->txt("certificate_a5"), // (210 mm x 148.5 mm)
163  "a5landscape" => $this->lng->txt("certificate_a5_landscape"), // (148.5 mm x 210 mm)
164  "letter" => $this->lng->txt("certificate_letter"), // (11 inch x 8.5 inch)
165  "letterlandscape" => $this->lng->txt("certificate_letter_landscape") // (11 inch x 8.5 inch)
166  );
167  $format->setOptions($defaultformats);
168  $format->setValue($form_settings->get("pageformat"));
169  $format->setInfo($this->lng->txt("certificate_page_format_info"));
170  $form->addItem($format);
171 
172 
173  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
174  {
175  $form->addCommandButton('save',$this->lng->txt('save'));
176  }
177 
178  $this->tpl->setContent($form->getHTML());
179 
180  if (strcmp($this->ctrl->getCmd(), "save") == 0)
181  {
182  if ($_POST["background_delete"])
183  {
184  $this->object->deleteBackgroundImage();
185  }
186  }
187  }
188 
189  public function save()
190  {
191  $form_settings = new ilSetting("certificate");
192  $form_settings->set("pageformat", $_POST["pageformat"]);
193  $form_settings->set("active", $_POST["active"]);
194 
195  ilUtil::sendSuccess($this->lng->txt("settings_saved"));
196  $this->settings();
197  }
198 }
199 ?>