ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
PGTStorageFile Class Reference

The PGTStorageFile class is a class for PGT file storage. More...

+ Inheritance diagram for PGTStorageFile:
+ Collaboration diagram for PGTStorageFile:

Public Member Functions

 getStorageType ()
 This method returns an informational string giving the type of storage used by the object (used for debugging purposes).
 getStorageInfo ()
 This method returns an informational string giving informations on the parameters of the storage.
 PGTStorageFile ($cas_parent, $format, $path)
 The class constructor, called by CASClient::SetPGTStorageFile().
 init ()
 This method is used to initialize the storage.
 write ($pgt, $pgt_iou)
 This method stores a PGT and its corresponding PGT Iou into a file.
 read ($pgt_iou)
 This method reads a PGT corresponding to a PGT Iou and deletes the corresponding file.
 getStorageType ()
 This method returns an informational string giving the type of storage used by the object (used for debugging purposes).
 getStorageInfo ()
 This method returns an informational string giving informations on the parameters of the storage.
 PGTStorageFile ($cas_parent, $format, $path)
 The class constructor, called by CASClient::SetPGTStorageFile().
 init ()
 This method is used to initialize the storage.
 write ($pgt, $pgt_iou)
 This method stores a PGT and its corresponding PGT Iou into a file.
 read ($pgt_iou)
 This method reads a PGT corresponding to a PGT Iou and deletes the corresponding file.
- Public Member Functions inherited from PGTStorage
 getErrorMessage ()
 This method returns an error message set by PGTStorage::setErrorMessage().
 getErrorMessage ()
 This method returns an error message set by PGTStorage::setErrorMessage().

Private Member Functions

 getPath ()
 This method returns the name of the directory where PGT's should be stored on the filesystem.
 getFormat ()
 This method returns the format to use when storing PGT's on the filesystem.
 getPGTIouFilename ($pgt_iou)
 This method returns the filename corresponding to a PGT Iou.
 getPath ()
 This method returns the name of the directory where PGT's should be stored on the filesystem.
 getFormat ()
 This method returns the format to use when storing PGT's on the filesystem.
 getPGTIouFilename ($pgt_iou)
 This method returns the filename corresponding to a PGT Iou.

Private Attributes

 $_path
 a string telling where PGT's should be stored on the filesystem.
 $_format
 a string telling the format to use to store PGT's (plain or xml).

Additional Inherited Members

- Protected Member Functions inherited from PGTStorage
 PGTStorage ($cas_parent)
 The constructor of the class, should be called only by inherited classes.
 setErrorMessage ($error_message)
 This method sets en error message, which can be read later by PGTStorage::getErrorMessage().
 isInitialized ()
 This method tells if the storage has already been intialized.
 PGTStorage ($cas_parent)
 The constructor of the class, should be called only by inherited classes.
 setErrorMessage ($error_message)
 This method sets en error message, which can be read later by PGTStorage::getErrorMessage().
 isInitialized ()
 This method tells if the storage has already been intialized.

Detailed Description

The PGTStorageFile class is a class for PGT file storage.

An instance of this class is returned by CASClient::SetPGTStorageFile().

Author
Pascal Aubry <pascal.aubry at univ-rennes1.fr>

Definition at line 45 of file pgt-file.php.

Member Function Documentation

PGTStorageFile::getFormat ( )
private

This method returns the format to use when storing PGT's on the filesystem.

Returns
a string corresponding to the format used (plain or xml).

Definition at line 61 of file pgt-file.php.

References $_format.

{
}
PGTStorageFile::getPath ( )
private

This method returns the name of the directory where PGT's should be stored on the filesystem.

Returns
the name of a directory (with leading and trailing '/')

Definition at line 41 of file pgt-file.php.

References $_path.

{
return $this->_path;
}
PGTStorageFile::getPGTIouFilename (   $pgt_iou)
private

This method returns the filename corresponding to a PGT Iou.

Parameters
$pgt_iouthe PGT iou.
Returns
a filename

Definition at line 170 of file pgt-file.php.

References getFormat(), getPath(), phpCAS\traceBegin(), and phpCAS\traceEnd().

{
return $this->getPath().$pgt_iou.'.'.$this->getFormat();
}

+ Here is the call graph for this function:

PGTStorageFile::getStorageInfo ( )

This method returns an informational string giving informations on the parameters of the storage.

(used for debugging purposes).

Returns
an informational string.

Reimplemented from PGTStorage.

Definition at line 89 of file pgt-file.php.

{
return 'path=`'.$this->getPath().'\', format=`'.$this->getFormat().'\'';
}
PGTStorageFile::getStorageType ( )

This method returns an informational string giving the type of storage used by the object (used for debugging purposes).

Returns
an informational string.

Reimplemented from PGTStorage.

Definition at line 77 of file pgt-file.php.

{
return "file";
}
PGTStorageFile::init ( )

This method is used to initialize the storage.

Halts on error.

Reimplemented from PGTStorage.

Definition at line 147 of file pgt-file.php.

References init(), PGTStorage\isInitialized(), phpCAS\traceBegin(), and phpCAS\traceEnd().

{
// if the storage has already been initialized, return immediatly
if ( $this->isInitialized() )
return;
// call the ancestor's method (mark as initialized)
}

+ Here is the call graph for this function:

PGTStorageFile::PGTStorageFile (   $cas_parent,
  $format,
  $path 
)

The class constructor, called by CASClient::SetPGTStorageFile().

Parameters
$cas_parentthe CASClient instance that creates the object.
$formatthe format used to store the PGT's (`plain' and `xml' allowed).
$paththe path where the PGT's should be stored

Definition at line 107 of file pgt-file.php.

References CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT, CAS_PGT_STORAGE_FILE_DEFAULT_PATH, CAS_PGT_STORAGE_FILE_FORMAT_PLAIN, CAS_PGT_STORAGE_FILE_FORMAT_XML, phpCAS\error(), PGTStorage\PGTStorage(), phpCAS\traceBegin(), and phpCAS\traceEnd().

{
// call the ancestor's constructor
$this->PGTStorage($cas_parent);
if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
if (empty($path) ) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH;
// check that the path is an absolute path
if ( $path[0] != '/' ) {
phpCAS::error('an absolute path is needed for PGT storage to file');
}
// store the path (with a leading and trailing '/')
$path = preg_replace('|[/]*$|','/',$path);
$path = preg_replace('|^[/]*|','/',$path);
$this->_path = $path;
// check the format and store it
switch ($format) {
$this->_format = $format;
break;
default:
phpCAS::error('unknown PGT file storage format (`'.CAS_PGT_STORAGE_FILE_FORMAT_PLAIN.'\' and `'.CAS_PGT_STORAGE_FILE_FORMAT_XML.'\' allowed)');
}
}

+ Here is the call graph for this function:

PGTStorageFile::read (   $pgt_iou)

This method reads a PGT corresponding to a PGT Iou and deletes the corresponding file.

Parameters
$pgt_iouthe PGT iou
Returns
the corresponding PGT, or FALSE on error

Reimplemented from PGTStorage.

Definition at line 211 of file pgt-file.php.

References $f, getPGTIouFilename(), phpCAS\trace(), phpCAS\traceBegin(), and phpCAS\traceEnd().

{
$pgt = FALSE;
$fname = $this->getPGTIouFilename($pgt_iou);
if ( !($f=fopen($fname,"r")) ) {
phpCAS::trace('could not open `'.$fname.'\'');
} else {
if ( ($pgt=fgets($f)) === FALSE ) {
phpCAS::trace('could not read PGT from `'.$fname.'\'');
}
fclose($f);
}
// delete the PGT file
@unlink($fname);
return $pgt;
}

+ Here is the call graph for this function:

PGTStorageFile::write (   $pgt,
  $pgt_iou 
)

This method stores a PGT and its corresponding PGT Iou into a file.

Echoes a warning on error.

Parameters
$pgtthe PGT
$pgt_iouthe PGT iou

Reimplemented from PGTStorage.

Definition at line 186 of file pgt-file.php.

References $f, phpCAS\error(), getPGTIouFilename(), phpCAS\traceBegin(), and phpCAS\traceEnd().

{
$fname = $this->getPGTIouFilename($pgt_iou);
if ( $f=fopen($fname,"w") ) {
if ( fputs($f,$pgt) === FALSE ) {
phpCAS::error('could not write PGT to `'.$fname.'\'');
}
fclose($f);
} else {
phpCAS::error('could not open `'.$fname.'\'');
}
}

+ Here is the call graph for this function:


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