ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilFileDataShop Class Reference

This class handles all operations on files in directory data/shop. More...

+ Inheritance diagram for ilFileDataShop:
+ Collaboration diagram for ilFileDataShop:

Public Member Functions

 __construct ($a_pobject_id)
 getCurrentImageWebPath ()
 getCurrentImageServerPath ()
 storeUploadedFile ($a_http_post_file)
 assignFileToPaymentObject ()
 deassignFileFromPaymentObject ()
 unlinkFile ($a_filename)
 checkFilesExist ($a_files)
- Public Member Functions inherited from ilFileData
 ilFileData ()
 Constructor class bas constructor and read path of directory from ilias.ini setup an mail object public.
 checkPath ($a_path)
 check if path exists and is writable
 getPath ()
 get Path public
- Public Member Functions inherited from ilFile
 ilFile ()
 Constructor get ilias object public.
 deleteTrailingSlash ($a_path)
 delete trailing slash of path variables

Data Fields

const SHOPPATH = 'shop'

Private Member Functions

 __read ()
 initDirectory ()
 checkReadWrite ()

Private Attributes

 $pobject_id = 0
 $shop_path = ''
 $image_current = ''
 $image_new = ''
 $db = null

Detailed Description

This class handles all operations on files in directory data/shop.

Currently it handles only one image per shop object...

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

Definition at line 13 of file class.ilFileDataShop.php.

Constructor & Destructor Documentation

ilFileDataShop::__construct (   $a_pobject_id)

Definition at line 23 of file class.ilFileDataShop.php.

References $pobject_id, __read(), checkReadWrite(), ilUtil\getWebspaceDir(), and initDirectory().

{
global $ilDB;
$this->db = $ilDB;
$this->pobject_id = $a_pobject_id;
$this->shop_path = ilUtil::getWebspaceDir().'/'.self::SHOPPATH.'/'.$this->pobject_id;
$this->initDirectory();
$this->checkReadWrite();
$this->__read();
}

+ Here is the call graph for this function:

Member Function Documentation

ilFileDataShop::__read ( )
private

Definition at line 38 of file class.ilFileDataShop.php.

References $result.

Referenced by __construct().

{
$result = $this->db->queryf('SELECT image FROM payment_objects WHERE pobject_id = %s',
array('integer'),array($this->pobject_id));
while($record = $this->db->fetchAssoc($result))
{
$this->image_current = $record['image'];
break;
}
}

+ Here is the caller graph for this function:

ilFileDataShop::assignFileToPaymentObject ( )

Definition at line 115 of file class.ilFileDataShop.php.

References $image_new.

{
$statement = $this->db->manipulateF(
'UPDATE payment_objects
SET
image = %s
WHERE pobject_id = %s',
array('text', 'integer'),
array($this->image_new, $this->pobject_id));
$this->image_current = $this->image_new;
return true;
}
ilFileDataShop::checkFilesExist (   $a_files)

Definition at line 158 of file class.ilFileDataShop.php.

References $file.

Referenced by getCurrentImageServerPath(), and getCurrentImageWebPath().

{
if($a_files)
{
foreach($a_files as $file)
{
if(!file_exists($this->shop_path.'/'.$file))
{
return false;
}
}
return true;
}
return true;
}

+ Here is the caller graph for this function:

ilFileDataShop::checkReadWrite ( )
private

Definition at line 85 of file class.ilFileDataShop.php.

Referenced by __construct().

{
if(is_writable($this->shop_path) && is_readable($this->shop_path))
{
return true;
}
else
{
$this->ilias->raiseError('Shop directory is not readable/writable by webserver', $this->ilias->error_obj->FATAL);
}
}

+ Here is the caller graph for this function:

ilFileDataShop::deassignFileFromPaymentObject ( )

Definition at line 131 of file class.ilFileDataShop.php.

References ilUtil\delDir(), and unlinkFile().

{
$statement = $this->db->manipulateF(
'UPDATE payment_objects
SET
image = %s
WHERE pobject_id = %s',
array('text', 'integer'),
//array('', $this->pobject_id));
array(NULL, $this->pobject_id));
if($this->image_current != '') $this->unlinkFile($this->image_current);
ilUtil::delDir($this->shop_path);
$this->image_current = '';
return true;
}

+ Here is the call graph for this function:

ilFileDataShop::getCurrentImageServerPath ( )

Definition at line 61 of file class.ilFileDataShop.php.

References $image_current, and checkFilesExist().

{
if($this->image_current != "" &&
$this->checkFilesExist(array($this->image_current)))
{
return $this->shop_path.'/'.$this->image_current;
}
return false;
}

+ Here is the call graph for this function:

ilFileDataShop::getCurrentImageWebPath ( )

Definition at line 50 of file class.ilFileDataShop.php.

References $image_current, checkFilesExist(), and ilUtil\getWebspaceDir().

{
if($this->image_current != '' &&
$this->checkFilesExist(array($this->image_current)))
{
return ilUtil::getWebspaceDir('output').'/'.self::SHOPPATH.'/'.$this->pobject_id.'/'.$this->image_current;
}
return false;
}

+ Here is the call graph for this function:

ilFileDataShop::initDirectory ( )
private

Definition at line 72 of file class.ilFileDataShop.php.

References ilFileData\getPath(), and ilUtil\makeDirParents().

Referenced by __construct().

{
if(is_writable($this->getPath()))
{
if(ilUtil::makeDirParents($this->shop_path))
{
return true;
}
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilFileDataShop::storeUploadedFile (   $a_http_post_file)

Definition at line 97 of file class.ilFileDataShop.php.

References ilUtil\moveUploadedFile(), ilUtil\resizeImage(), and unlinkFile().

{
if($this->image_current != '') $this->unlinkFile($this->image_current);
if(isset($a_http_post_file) && $a_http_post_file['size'])
{
if(ilUtil::moveUploadedFile($a_http_post_file['tmp_name'], $a_http_post_file['name'],
$this->shop_path.'/'.$a_http_post_file['name']))
{
ilUtil::resizeImage('"'.$this->shop_path.'/'.$a_http_post_file['name'].'"', '"'.$this->shop_path.'/'.$a_http_post_file['name'].'"', 100, 75);
return $this->image_new = $a_http_post_file['name'];
}
}
return false;
}

+ Here is the call graph for this function:

ilFileDataShop::unlinkFile (   $a_filename)

Definition at line 150 of file class.ilFileDataShop.php.

Referenced by deassignFileFromPaymentObject(), and storeUploadedFile().

{
if(file_exists($this->shop_path.'/'.$a_filename))
{
return unlink($this->shop_path.'/'.$a_filename);
}
}

+ Here is the caller graph for this function:

Field Documentation

ilFileDataShop::$db = null
private

Definition at line 21 of file class.ilFileDataShop.php.

ilFileDataShop::$image_current = ''
private

Definition at line 19 of file class.ilFileDataShop.php.

Referenced by getCurrentImageServerPath(), and getCurrentImageWebPath().

ilFileDataShop::$image_new = ''
private

Definition at line 20 of file class.ilFileDataShop.php.

Referenced by assignFileToPaymentObject().

ilFileDataShop::$pobject_id = 0
private

Definition at line 17 of file class.ilFileDataShop.php.

Referenced by __construct().

ilFileDataShop::$shop_path = ''
private

Definition at line 18 of file class.ilFileDataShop.php.

const ilFileDataShop::SHOPPATH = 'shop'

Definition at line 15 of file class.ilFileDataShop.php.


The documentation for this class was generated from the following file: