ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 @access public More...
 
 unlinkLast ()
 
 __readFiles ($a_dir='')
 
 __checkReadWrite ()
 check if directory is writable overwritten method from base class @access private More...
 
- Public Member Functions inherited from ilFileDataImport
 ilFileDataImport ()
 Constructor call base constructors checks if directory is writable and sets the optional obj_id. More...
 
 getPath ()
 get exercise path @access public More...
 
 __checkPath ()
 
 __checkReadWrite ()
 check if directory is writable overwritten method from base class @access private More...
 
- Public Member Functions inherited from ilFileData
 ilFileData ()
 Constructor class bas constructor and read path of directory from ilias.ini setup an mail object @access public. More...
 
 checkPath ($a_path)
 check if path exists and is writable More...
 
 getPath ()
 get Path @access public More...
 
- Public Member Functions inherited from ilFile
 ilFile ()
 Constructor get ilias object @access public. More...
 
 deleteTrailingSlash ($a_path)
 delete trailing slash of path variables More...
 

Static Public Member Functions

 _initDirectory ()
 init directory overwritten method @access public More...
 
 _initDirectory ()
 init directory overwritten method @access 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 @access public

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

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 @access public

References __readFiles(), and _initDirectory().

+ Here is the call graph for this function:

Member Function Documentation

◆ __checkReadWrite()

ilFileDataImportMail::__checkReadWrite ( )

check if directory is writable overwritten method from base class @access private

Returns
bool

Reimplemented from ilFileDataImport.

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

178 {
179 if(is_writable($this->mail_path) && is_readable($this->mail_path))
180 {
181 return true;
182 }
183 else
184 {
185 $this->ilias->raiseError("Mail import directory is not readable/writable by webserver",$this->ilias->error_obj->FATAL);
186 }
187 }
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.

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' => ilFormat::formatDate(date('Y-m-d H:i:s',filectime($a_dir.'/'.$file))));
165 }
166 closedir($dp);
167
168 return true;
169 }
print $file
getPath()
get exercise path @access public
formatDate($a_date, $a_mode="datetime", $a_omit_seconds=false, $a_relative=TRUE)
format a date according to the user language shortcut for Format::fmtDateTime @access public

References $file, ilFormat\formatDate(), and getPath().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _initDirectory()

ilFileDataImportMail::_initDirectory ( )
static

init directory overwritten method @access public

Returns
boolean

Reimplemented from ilFileDataImport.

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

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

References ilUtil\makeDir().

Referenced by __construct().

+ 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.

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 }

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

Referenced by findXMLFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFiles()

ilFileDataImportMail::getFiles ( )

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

47 {
48 return $this->files ? $this->files : array();
49 }

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

+ Here is the caller graph for this function:

◆ getPath()

ilFileDataImportMail::getPath ( )

get exercise path @access public

Returns
string path

Reimplemented from ilFileDataImport.

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

References $mail_path.

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

+ Here is the caller graph for this function:

◆ getXMLFile()

ilFileDataImportMail::getXMLFile ( )

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

52 {
53 return $this->xml_file;
54 }

References $xml_file.

◆ storeUploadedFile()

ilFileDataImportMail::storeUploadedFile (   $a_http_post_file)

store uploaded file in filesystem

Parameters
arrayHTTP_POST_FILES @access public
Returns
bool

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

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 }
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file

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

+ Here is the call graph for this function:

◆ unlinkLast()

ilFileDataImportMail::unlinkLast ( )

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

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

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

Referenced by storeUploadedFile().

+ 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.

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

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

+ 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: