ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 167 of file class.ilFileDataImportMail.php.

168  {
169  if (is_writable($this->mail_path) && is_readable($this->mail_path)) {
170  return true;
171  } else {
172  $this->ilias->raiseError("Mail import directory is not readable/writable by webserver", $this->ilias->error_obj->FATAL);
173  }
174  }
redirection script todo: (a better solution should control the processing via a xml file) ...

◆ __readFiles()

ilFileDataImportMail::__readFiles (   $a_dir = '')

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

References $file, array, files, and getPath().

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

139  {
140  $a_dir = $a_dir ? $a_dir : $this->getPath();
141 
142  $this->files = array();
143  $dp = opendir($a_dir);
144 
145  while ($file = readdir($dp)) {
146  if ($file == "." or $file == "..") {
147  continue;
148  }
149  $this->files[] = array(
150  'name' => $file,
151  'abs_path' => $a_dir . "/" . $file,
152  'size' => filesize($a_dir . "/" . $file),
153  'ctime' => filectime($a_dir . '/' . $file)
154  );
155  }
156  closedir($dp);
157 
158  return true;
159  }
getPath()
get exercise path public
Create styles array
The data for the language used.
Done writing files
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 182 of file class.ilFileDataImportMail.php.

References ilUtil\makeDir().

Referenced by __construct().

183  {
184  if (!@file_exists($this->mail_path)) {
185  ilUtil::makeDir($this->mail_path);
186  }
187  return true;
188  }
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  if (is_dir($file_data["abs_path"])) {
95  $this->findXMLFile($file_data["abs_path"]);
96  }
97  if (($tmp = explode(".", $file_data["name"])) !== false) {
98  if ($tmp[count($tmp) - 1] == "xml") {
99  return $this->xml_file = $file_data["abs_path"];
100  }
101  }
102  }
103  return $this->xml_file;
104  }
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 121 of file class.ilFileDataImportMail.php.

References $mail_path.

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

122  {
123  return $this->mail_path;
124  }
+ 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(), and unlinkLast().

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

◆ unlinkLast()

ilFileDataImportMail::unlinkLast ( )

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

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

Referenced by storeUploadedFile().

127  {
128  foreach ($this->getFiles() as $file_data) {
129  if (is_dir($file_data["abs_path"])) {
130  ilUtil::delDir($file_data["abs_path"]);
131  } else {
132  unlink($file_data["abs_path"]);
133  }
134  }
135  return true;
136  }
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 106 of file class.ilFileDataImportMail.php.

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

107  {
108  foreach ($this->getFiles() as $file_data) {
109  ilUtil::unzip($file_data["abs_path"]);
110 
111  return true;
112  }
113  return false;
114  }
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: