ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjCertificateSettings.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 
24 require_once "./Services/Object/classes/class.ilObject.php";
25 
35 {
36 
43  function ilObjCertificateSettings($a_id = 0,$a_call_by_reference = true)
44  {
45  $this->ilObject($a_id,$a_call_by_reference);
46  $this->type = "cert";
47  }
48 
49  public function hasBackgroundImage()
50  {
51  if (@file_exists($this->getBackgroundImagePath()) && (@filesize($this->getBackgroundImagePath()) > 0))
52  {
53  return TRUE;
54  }
55  else
56  {
57  return FALSE;
58  }
59  }
60 
62  {
63  return CLIENT_WEB_DIR . "/certificates/default/";
64  }
65 
71  public function getBackgroundImagePath()
72  {
74  }
75 
81  public function getBackgroundImageName()
82  {
83  return "background.jpg";
84  }
85 
91  public function getBackgroundImageThumbPath()
92  {
93  return $this->getBackgroundImageDefaultFolder() . $this->getBackgroundImageName() . ".thumb.jpg";
94  }
95 
102  {
103  return $this->getBackgroundImageDefaultFolder() . "background_upload";
104  }
105 
111  public function getBackgroundImagePathWeb()
112  {
113  include_once "./Services/Utilities/classes/class.ilUtil.php";
115  }
116 
123  {
124  include_once "./Services/Utilities/classes/class.ilUtil.php";
126  }
127 
135  public function uploadBackgroundImage($image_tempfilename)
136  {
137  if (!empty($image_tempfilename))
138  {
139  $image_filename = "background_upload";
140  $convert_filename = $this->getBackgroundImageName();
141  $imagepath = $this->getBackgroundImageDefaultFolder();
142  if (!file_exists($imagepath))
143  {
144  ilUtil::makeDirParents($imagepath);
145  }
146  // upload the file
147  if (!ilUtil::moveUploadedFile($image_tempfilename, $image_filename, $this->getBackgroundImageTempfilePath()))
148  {
149  return FALSE;
150  }
151  // convert the uploaded file to JPEG
154  if (!file_exists($this->getBackgroundImagePath()))
155  {
156  // something went wrong converting the file. use the original file and hope, that PDF can work with it
157  if (!ilUtil::moveUploadedFile($this->getBackgroundImageTempfilePath(), $convert_filename, $this->getBackgroundImagePath()))
158  {
159  return FALSE;
160  }
161  }
162  unlink($this->getBackgroundImageTempfilePath());
163  if (file_exists($this->getBackgroundImagePath()) && (filesize($this->getBackgroundImagePath()) > 0))
164  {
165  return TRUE;
166  }
167  }
168  return FALSE;
169  }
170 
176  public function deleteBackgroundImage()
177  {
178  $result = TRUE;
179  if (file_exists($this->getBackgroundImageThumbPath()))
180  {
181  $result = $result & unlink($this->getBackgroundImageThumbPath());
182  }
183  if (file_exists($this->getBackgroundImagePath()))
184  {
185  $result = $result & unlink($this->getBackgroundImagePath());
186  }
187  if (file_exists($this->getBackgroundImageTempfilePath()))
188  {
189  $result = $result & unlink($this->getBackgroundImageTempfilePath());
190  }
191  return $result;
192  }
193 
194 } // END class.ilObjCertificateSettings
195 ?>