ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages

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

Private Member Functions

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

Private Attributes

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

Additional Inherited Members

- Protected Member Functions inherited from PGTStorage
 PGTStorage ($cas_parent)
 The constructor of the class, should be called only by inherited classes. More...
 
 setErrorMessage ($error_message)
 This method sets en error message, which can be read later by PGTStorage::getErrorMessage(). More...
 
 isInitialized ()
 This method tells if the storage has already been intialized. More...
 
 init ()
 This virtual method initializes the object. More...
 
 write ($pgt, $pgt_iou)
 This virtual method stores a PGT and its corresponding PGT Iuo. More...
 
 read ($pgt_iou)
 This virtual method reads a PGT corresponding to a PGT Iou and deletes the corresponding storage entry. More...
 
 PGTStorage ($cas_parent)
 The constructor of the class, should be called only by inherited classes. More...
 
 setErrorMessage ($error_message)
 This method sets en error message, which can be read later by PGTStorage::getErrorMessage(). More...
 
 isInitialized ()
 This method tells if the storage has already been intialized. More...
 
 init ()
 This virtual method initializes the object. More...
 
 write ($pgt, $pgt_iou)
 This virtual method stores a PGT and its corresponding PGT Iuo. More...
 
 read ($pgt_iou)
 This virtual method reads a PGT corresponding to a PGT Iou and deletes the corresponding storage entry. More...
 

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

◆ getFormat()

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.

62  {
63  return $this->_format;
64  }
$_format
a string telling the format to use to store PGT&#39;s (plain or xml).
Definition: pgt-file.php:79

◆ getPath()

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 $_format, and $_path.

42  {
43  return $this->_path;
44  }
$_path
a string telling where PGT&#39;s should be stored on the filesystem.
Definition: pgt-file.php:58

◆ getPGTIouFilename()

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().

171  {
173  return $this->getPath().$pgt_iou.'.'.$this->getFormat();
174  phpCAS::traceEnd();
175  }
getPath()
This method returns the name of the directory where PGT&#39;s should be stored on the filesystem...
Definition: pgt-file.php:68
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
getFormat()
This method returns the format to use when storing PGT&#39;s on the filesystem.
Definition: pgt-file.php:88
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
+ Here is the call graph for this function:

◆ getStorageInfo()

PGTStorageFile::getStorageInfo ( )

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

(used for debugging purposes).

Returns
an informational string.

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

90  {
91  return 'path=`'.$this->getPath().'\', format=`'.$this->getFormat().'\'';
92  }

◆ getStorageType()

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.

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

78  {
79  return "file";
80  }

◆ init()

PGTStorageFile::init ( )

This method is used to initialize the storage.

Halts on error.

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

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

148  {
150  // if the storage has already been initialized, return immediatly
151  if ( $this->isInitialized() )
152  return;
153  // call the ancestor's method (mark as initialized)
154  parent::init();
155  phpCAS::traceEnd();
156  }
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
isInitialized()
This method tells if the storage has already been intialized.
Definition: pgt-main.php:160
+ Here is the call graph for this function:

◆ PGTStorageFile()

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 $path, 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().

108  {
110  // call the ancestor's constructor
111  $this->PGTStorage($cas_parent);
112 
113  if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
115 
116  // check that the path is an absolute path
117  if ( $path[0] != '/' ) {
118  phpCAS::error('an absolute path is needed for PGT storage to file');
119  }
120 
121  // store the path (with a leading and trailing '/')
122  $path = preg_replace('|[/]*$|','/',$path);
123  $path = preg_replace('|^[/]*|','/',$path);
124  $this->_path = $path;
125 
126  // check the format and store it
127  switch ($format) {
130  $this->_format = $format;
131  break;
132  default:
133  phpCAS::error('unknown PGT file storage format (`'.CAS_PGT_STORAGE_FILE_FORMAT_PLAIN.'\' and `'.CAS_PGT_STORAGE_FILE_FORMAT_XML.'\' allowed)');
134  }
135  phpCAS::traceEnd();
136  }
const CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT
Default format used when storing PGT&#39;s to file.
Definition: CAS.php:161
const CAS_PGT_STORAGE_FILE_DEFAULT_PATH
Default path used when storing PGT&#39;s to file.
Definition: CAS.php:149
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
const CAS_PGT_STORAGE_FILE_FORMAT_XML
phpCAS::setPGTStorageFile()&#39;s 2nd parameter to write xml files
Definition: CAS.php:157
PGTStorage($cas_parent)
The constructor of the class, should be called only by inherited classes.
Definition: pgt-main.php:63
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
$path
Definition: index.php:22
const CAS_PGT_STORAGE_FILE_FORMAT_PLAIN
phpCAS::setPGTStorageFile()&#39;s 2nd parameter to write plain text files
Definition: CAS.php:153
+ Here is the call graph for this function:

◆ read()

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

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

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

212  {
214  $pgt = FALSE;
215  $fname = $this->getPGTIouFilename($pgt_iou);
216  if ( !($f=fopen($fname,"r")) ) {
217  phpCAS::trace('could not open `'.$fname.'\'');
218  } else {
219  if ( ($pgt=fgets($f)) === FALSE ) {
220  phpCAS::trace('could not read PGT from `'.$fname.'\'');
221  }
222  fclose($f);
223  }
224 
225  // delete the PGT file
226  @unlink($fname);
227 
228  phpCAS::traceEnd($pgt);
229  return $pgt;
230  }
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
getPGTIouFilename($pgt_iou)
This method returns the filename corresponding to a PGT Iou.
Definition: pgt-file.php:208
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
trace($str)
This method is used to log something in debug mode.
Definition: CAS.php:569
+ Here is the call graph for this function:

◆ write()

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

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

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

187  {
189  $fname = $this->getPGTIouFilename($pgt_iou);
190  if ( $f=fopen($fname,"w") ) {
191  if ( fputs($f,$pgt) === FALSE ) {
192  phpCAS::error('could not write PGT to `'.$fname.'\'');
193  }
194  fclose($f);
195  } else {
196  phpCAS::error('could not open `'.$fname.'\'');
197  }
198  phpCAS::traceEnd();
199  }
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
getPGTIouFilename($pgt_iou)
This method returns the filename corresponding to a PGT Iou.
Definition: pgt-file.php:208
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

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