ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilFileDataImportMail Class Reference

This class handles all operations on files for the exercise object. More...

+ Inheritance diagram for ilFileDataImportMail:
+ Collaboration diagram for ilFileDataImportMail:

Public Member Functions

 __construct ()
 Constructor call base constructors checks if directory is writable and sets the optional obj_id. More...
 
 getFiles ()
 
 getXMLFile ()
 
 storeUploadedFile ($a_http_post_file)
 store uploaded file in filesystem More...
 
 findXMLFile ($a_dir='')
 
 unzip ()
 
 getPath ()
 get exercise path public More...
 
 unlinkLast ()
 
 __readFiles ($a_dir='')
 
 __checkReadWrite ()
 check if directory is writable overwritten method from base class private More...
 
- Public Member Functions inherited from ilFileDataImport
 __construct ()
 Constructor call base constructors. More...
 
 getPath ()
 get exercise path public More...
 
 __checkPath ()
 
 __checkReadWrite ()
 check if directory is writable overwritten method from base class private More...
 
- Public Member Functions inherited from ilFileData
 __construct ()
 Constructor class bas constructor and read path of directory from ilias.ini setup an mail object public. More...
 
 checkPath ($a_path)
 check if path exists and is writable More...
 
 getPath ()
 get Path public More...
 
- Public Member Functions inherited from ilFile
 __construct ()
 Constructor get ilias object public. More...
 
 deleteTrailingSlash ($a_path)
 delete trailing slash of path variables More...
 

Static Public Member Functions

 _initDirectory ()
 init directory overwritten method public More...
 
- Static Public Member Functions inherited from ilFileDataImport
 _initDirectory ()
 init directory overwritten method public More...
 

Data Fields

 $mail_path
 
 $files
 
 $xml_file
 
- Data Fields inherited from ilFileDataImport
 $import_path
 
- Data Fields inherited from ilFile
 $path
 
 $ilias
 

Detailed Description

This class handles all operations on files for the exercise object.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id
Id
class.ilFileDataImportMail.php,v 1.1 2004/03/31 13:42:19 smeyer Exp

Definition at line 14 of file class.ilFileDataImportMail.php.

Constructor & Destructor Documentation

◆ __construct()

ilFileDataImportMail::__construct ( )

Constructor call base constructors checks if directory is writable and sets the optional obj_id.

Parameters
integeregerobj_id public

Definition at line 34 of file class.ilFileDataImportMail.php.

References __readFiles(), and _initDirectory().

35  {
36  define('MAIL_IMPORT_PATH','mail');
37  parent::__construct();
38  $this->mail_path = parent::getPath()."/".MAIL_IMPORT_PATH;
39 
40  // IF DIRECTORY ISN'T CREATED CREATE IT
41  // CALL STTIC TO AVOID OVERWRITE PROBLEMS
43  $this->__readFiles();
44  }
_initDirectory()
init directory overwritten method public
+ Here is the call graph for this function:

Member Function Documentation

◆ __checkReadWrite()

ilFileDataImportMail::__checkReadWrite ( )

check if directory is writable overwritten method from base class private

Returns
bool

Definition at line 178 of file class.ilFileDataImportMail.php.

179  {
180  if(is_writable($this->mail_path) && is_readable($this->mail_path))
181  {
182  return true;
183  }
184  else
185  {
186  $this->ilias->raiseError("Mail import directory is not readable/writable by webserver",$this->ilias->error_obj->FATAL);
187  }
188  }
redirection script todo: (a better solution should control the processing via a xml file) ...

◆ __readFiles()

ilFileDataImportMail::__readFiles (   $a_dir = '')

Definition at line 147 of file class.ilFileDataImportMail.php.

References $file, array, and getPath().

Referenced by __construct(), findXMLFile(), and storeUploadedFile().

148  {
149  $a_dir = $a_dir ? $a_dir : $this->getPath();
150 
151  $this->files = array();
152  $dp = opendir($a_dir);
153 
154  while($file = readdir($dp))
155  {
156  if($file == "." or $file == "..")
157  {
158  continue;
159  }
160  $this->files[] = array(
161  'name' => $file,
162  'abs_path' => $a_dir."/".$file,
163  'size' => filesize($a_dir."/".$file),
164  'ctime' => filectime($a_dir.'/'.$file)
165  );
166  }
167  closedir($dp);
168 
169  return true;
170  }
getPath()
get exercise path public
Create styles array
The data for the language used.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _initDirectory()

ilFileDataImportMail::_initDirectory ( )
static

init directory overwritten method public

Returns
boolean

Definition at line 196 of file class.ilFileDataImportMail.php.

References ilUtil\makeDir().

Referenced by __construct().

197  {
198  if(!@file_exists($this->mail_path))
199  {
200  ilUtil::makeDir($this->mail_path);
201  }
202  return true;
203  }
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findXMLFile()

ilFileDataImportMail::findXMLFile (   $a_dir = '')

Definition at line 87 of file class.ilFileDataImportMail.php.

References $xml_file, __readFiles(), getFiles(), and getPath().

88  {
89  $a_dir = $a_dir ? $a_dir : $this->getPath();
90 
91  $this->__readFiles($a_dir);
92 
93  foreach($this->getFiles() as $file_data)
94  {
95  if(is_dir($file_data["abs_path"]))
96  {
97  $this->findXMLFile($file_data["abs_path"]);
98  }
99  if(($tmp = explode(".",$file_data["name"])) !== false)
100  {
101  if($tmp[count($tmp) - 1] == "xml")
102  {
103  return $this->xml_file = $file_data["abs_path"];
104  }
105  }
106  }
107  return $this->xml_file;
108  }
getPath()
get exercise path public
+ Here is the call graph for this function:

◆ getFiles()

ilFileDataImportMail::getFiles ( )

Definition at line 46 of file class.ilFileDataImportMail.php.

References array, and files.

Referenced by findXMLFile(), unlinkLast(), and unzip().

47  {
48  return $this->files ? $this->files : array();
49  }
Create styles array
The data for the language used.
Done writing files
+ Here is the caller graph for this function:

◆ getPath()

ilFileDataImportMail::getPath ( )

get exercise path public

Returns
string path

Definition at line 126 of file class.ilFileDataImportMail.php.

References $mail_path.

Referenced by __readFiles(), findXMLFile(), and storeUploadedFile().

127  {
128  return $this->mail_path;
129  }
+ Here is the caller graph for this function:

◆ getXMLFile()

ilFileDataImportMail::getXMLFile ( )

Definition at line 51 of file class.ilFileDataImportMail.php.

References $xml_file.

◆ storeUploadedFile()

ilFileDataImportMail::storeUploadedFile (   $a_http_post_file)

store uploaded file in filesystem

Parameters
arrayHTTP_POST_FILES public
Returns
bool

Definition at line 62 of file class.ilFileDataImportMail.php.

References __readFiles(), getPath(), ilUtil\moveUploadedFile(), and unlinkLast().

63  {
64  // TODO:
65  // CHECK UPLOAD LIMIT
66  //
67 
68  if(isset($a_http_post_file) && $a_http_post_file['size'])
69  {
70  // DELETE OLD FILES
71  $this->unlinkLast();
72 
73  // CHECK IF FILE WITH SAME NAME EXISTS
74  ilUtil::moveUploadedFile($a_http_post_file['tmp_name'], $a_http_post_file['name'],
75  $this->getPath().'/'.$a_http_post_file['name']);
76  //move_uploaded_file($a_http_post_file['tmp_name'],$this->getPath().'/'.$a_http_post_file['name']);
77 
78  // UPDATE FILES LIST
79  $this->__readFiles();
80  return true;
81  }
82  else
83  {
84  return false;
85  }
86  }
getPath()
get exercise path public
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
+ Here is the call graph for this function:

◆ unlinkLast()

ilFileDataImportMail::unlinkLast ( )

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

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

Referenced by storeUploadedFile().

132  {
133  foreach($this->getFiles() as $file_data)
134  {
135  if(is_dir($file_data["abs_path"]))
136  {
137  ilUtil::delDir($file_data["abs_path"]);
138  }
139  else
140  {
141  unlink($file_data["abs_path"]);
142  }
143  }
144  return true;
145  }
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unzip()

ilFileDataImportMail::unzip ( )

Definition at line 110 of file class.ilFileDataImportMail.php.

References getFiles(), and ilUtil\unzip().

111  {
112  foreach($this->getFiles() as $file_data)
113  {
114  ilUtil::unzip($file_data["abs_path"]);
115 
116  return true;
117  }
118  return false;
119  }
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
+ Here is the call graph for this function:

Field Documentation

◆ $files

ilFileDataImportMail::$files

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

◆ $mail_path

ilFileDataImportMail::$mail_path

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

Referenced by getPath().

◆ $xml_file

ilFileDataImportMail::$xml_file

Definition at line 24 of file class.ilFileDataImportMail.php.

Referenced by findXMLFile(), and getXMLFile().


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