ILIAS  Release_4_1_x_branch Revision 61804
 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("./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  $info = new ilNonEditableValueGUI($this->lng->txt("info"), "info");
131  $info->setValue($this->lng->txt("certificate_usage"));
132  $form->addItem($info);
133 
134  $bgimage = new ilImageFileInputGUI($this->lng->txt("certificate_background_image"), "background");
135  $bgimage->setRequired(FALSE);
136  if (count($_POST))
137  {
138  // handle the background upload
139  if (strlen($_FILES["background"]["tmp_name"]))
140  {
141  if ($bgimage->checkInput())
142  {
143  $result = $this->object->uploadBackgroundImage($_FILES["background"]["tmp_name"]);
144  if ($result == FALSE)
145  {
146  $bgimage->setAlert($this->lng->txt("certificate_error_upload_bgimage"));
147  }
148  }
149  }
150  }
151  if (strlen($this->object->hasBackgroundImage())) $bgimage->setImage($this->object->getBackgroundImageThumbPathWeb());
152  $bgimage->setInfo($this->lng->txt("default_background_info"));
153  $form->addItem($bgimage);
154  $format = new ilSelectInputGUI($this->lng->txt("certificate_page_format"), "pageformat");
155  $defaultformats = array(
156  "a4" => $this->lng->txt("certificate_a4"), // (297 mm x 210 mm)
157  "a4landscape" => $this->lng->txt("certificate_a4_landscape"), // (210 mm x 297 mm)",
158  "a5" => $this->lng->txt("certificate_a5"), // (210 mm x 148.5 mm)
159  "a5landscape" => $this->lng->txt("certificate_a5_landscape"), // (148.5 mm x 210 mm)
160  "letter" => $this->lng->txt("certificate_letter"), // (11 inch x 8.5 inch)
161  "letterlandscape" => $this->lng->txt("certificate_letter_landscape") // (11 inch x 8.5 inch)
162  );
163  $format->setOptions($defaultformats);
164  $format->setValue($form_settings->get("pageformat"));
165  $format->setInfo($this->lng->txt("certificate_page_format_info"));
166  $form->addItem($format);
167 
168 
169  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
170  {
171  $form->addCommandButton('save',$this->lng->txt('save'));
172  }
173 
174  $this->tpl->setContent($form->getHTML());
175 
176  if (strcmp($this->ctrl->getCmd(), "save") == 0)
177  {
178  if ($_POST["background_delete"])
179  {
180  $this->object->deleteBackgroundImage();
181  }
182  }
183  }
184 
185  public function save()
186  {
187  $form_settings = new ilSetting("certificate");
188  $form_settings->set("pageformat", $_POST["pageformat"]);
189  $this->settings();
190  }
191 }
192 ?>