ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilFileDataMail Class Reference

This class handles all operations on files (attachments) in directory ilias_data/mail. More...

+ Inheritance diagram for ilFileDataMail:
+ Collaboration diagram for ilFileDataMail:

Public Member Functions

 __construct ($a_user_id=0)
 Constructor call base constructors checks if directory is writable and sets the optional user_id. More...
 
 initDirectory ()
 init directory overwritten method public More...
 
 getUploadLimit ()
 
 getAttachmentsTotalSizeLimit ()
 
 getMailPath ()
 get mail path public More...
 
 getAttachmentPathByMD5Filename ($a_filename, $a_mail_id)
 get the path of a specific attachment More...
 
 getAttachmentPath ($a_filename, $a_mail_id)
 get the path of a specific attachment More...
 
 adoptAttachments ($a_attachments, $a_mail_id)
 adopt attachments (in case of forwarding a mail) More...
 
 checkReadWrite ()
 check if directory is writable overwritten method from base class private More...
 
 getUserFilesData ()
 get all attachments of a specific user public More...
 
 getUnsentFiles ()
 get all files which are not sent find them in directory data/mail/ private More...
 
 storeAsAttachment ($a_filename, $a_content)
 Store content as attachment. More...
 
 storeUploadedFile ($file)
 
 copyAttachmentFile ($a_abs_path, $a_new_name)
 Copy files in mail directory. More...
 
 rotateFiles ($a_path)
 rotate files with same name recursive method More...
 
 unlinkFiles ($a_filenames)
 unlink files: expects an array of filenames e.g. More...
 
 unlinkFile ($a_filename)
 unlink one uploaded file expects a filename e.g 'foo' More...
 
 getAbsolutePath ($a_path)
 get absolute path of filename More...
 
 saveFiles ($a_mail_id, $a_attachments)
 save all attachment files in a specific mail directory .../mail/<calculated_path>/mail_<mail_id>_<user_id>/... More...
 
 saveFile ($a_mail_id, $a_attachment)
 save attachment file in a specific mail directory .../mail/<calculated_path>/mail_<mail_id>_<user_id>/... More...
 
 checkFilesExist ($a_files)
 check if files exist More...
 
 assignAttachmentsToDirectory ($a_mail_id, $a_sent_mail_id)
 assign attachments to mail directory More...
 
 deassignAttachmentFromDirectory ($a_mail_id)
 dassign attachments from mail directory More...
 
 __deleteAttachmentDirectory ($a_rel_path)
 
 _lookupDiskUsageOfUser ($user_id)
 Returns the number of bytes used on the harddisk for mail attachments, by the user with the specified user id. More...
 
- Public Member Functions inherited from ilFileData
 ilFileData ()
 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
 ilFile ()
 Constructor get ilias object public. More...
 
 deleteTrailingSlash ($a_path)
 delete trailing slash of path variables More...
 

Static Public Member Functions

static getStorage ($a_mail_id, $a_usr_id)
 

Data Fields

 $user_id
 
 $mail_path
 
- Data Fields inherited from ilFile
 $path
 
 $ilias
 

Protected Member Functions

 initAttachmentMaxUploadSize ()
 

Protected Attributes

 $mail_max_upload_file_size
 

Detailed Description

This class handles all operations on files (attachments) in directory ilias_data/mail.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$ Class ilFileDataMail

Definition at line 17 of file class.ilFileDataMail.php.

Constructor & Destructor Documentation

◆ __construct()

ilFileDataMail::__construct (   $a_user_id = 0)

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

Parameters
integeregeruser_id public

Definition at line 45 of file class.ilFileDataMail.php.

References checkReadWrite(), and initAttachmentMaxUploadSize().

46  {
47  define('MAILPATH','mail');
48  parent::__construct();
49  $this->mail_path = parent::getPath()."/".MAILPATH;
50  $this->checkReadWrite();
51  $this->user_id = $a_user_id;
52 
54  }
checkReadWrite()
check if directory is writable overwritten method from base class private
+ Here is the call graph for this function:

Member Function Documentation

◆ __deleteAttachmentDirectory()

ilFileDataMail::__deleteAttachmentDirectory (   $a_rel_path)

Definition at line 548 of file class.ilFileDataMail.php.

References ilUtil\delDir().

Referenced by deassignAttachmentFromDirectory().

549  {
550  ilUtil::delDir($this->mail_path."/".$a_rel_path);
551 
552  return true;
553  }
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:

◆ _lookupDiskUsageOfUser()

ilFileDataMail::_lookupDiskUsageOfUser (   $user_id)

Returns the number of bytes used on the harddisk for mail attachments, by the user with the specified user id.

Parameters
intuser id.
Returns
array{'count'=>integer,'size'=>integer} // an associative array with the disk // usage in bytes and the count of attachments.

Definition at line 600 of file class.ilFileDataMail.php.

References $file, $ilDB, $lng, ilFile\$path, $query, $res, $row, $size, DB_FETCHMODE_ASSOC, ilUtil\dirsize(), ilUtil\getDataDir(), and getMailPath().

Referenced by ilObjMailAccess\_lookupDiskUsageOfUser().

601  {
602  // XXX - This method is extremely slow. We should
603  // use a cache to speed it up, for example, we should
604  // store the disk space used in table mail_attachment.
605  global $ilDB, $lng;
606 
607  $mail_data_dir = ilUtil::getDataDir('filesystem').DIRECTORY_SEPARATOR."mail";
608 
609  $q = "SELECT path ".
610  "FROM mail_attachment ma ".
611  "JOIN mail m ON ma.mail_id=m.mail_id ".
612  "WHERE m.user_id = ".$ilDB->quote($user_id);
613  $result_set = $ilDB->query($q);
614  $size = 0;
615  $count = 0;
616  while($row = $result_set->fetchRow(DB_FETCHMODE_ASSOC))
617  {
618  $attachment_path = $mail_data_dir.DIRECTORY_SEPARATOR.$row['path'];
619  $attachment_size = ilUtil::dirsize($attachment_path);
620  if ($attachment_size != -1)
621  {
622  $size += $attachment_size;
623  }
624  $count++;
625  }
626  return array('count'=>$count, 'size'=>$size);
627  }
$size
Definition: RandomTest.php:79
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
static dirsize($directory)
get size of a directory or a file.
static getDataDir()
get data directory (outside webspace)
global $lng
Definition: privfeed.php:40
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adoptAttachments()

ilFileDataMail::adoptAttachments (   $a_attachments,
  $a_mail_id 
)

adopt attachments (in case of forwarding a mail)

Parameters
arrayattachments
integermail_id public
Returns
string error message

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

References $file, ilFile\$path, getAttachmentPath(), and getMailPath().

196  {
197  if(is_array($a_attachments))
198  {
199  foreach($a_attachments as $file)
200  {
201  $path = $this->getAttachmentPath($file,$a_mail_id);
202  if(!copy($path,$this->getMailPath().'/'.$this->user_id.'_'.$file))
203  {
204  return "ERROR: $this->getMailPath().'/'.$this->user_id.'_'.$file cannot be created";
205  }
206  }
207  }
208  else
209  {
210  return "ARRAY REQUIRED";
211  }
212  return '';
213  }
print $file
getAttachmentPath($a_filename, $a_mail_id)
get the path of a specific attachment
getMailPath()
get mail path public
+ Here is the call graph for this function:

◆ assignAttachmentsToDirectory()

ilFileDataMail::assignAttachmentsToDirectory (   $a_mail_id,
  $a_sent_mail_id 
)

assign attachments to mail directory

Parameters
integermail_id
integerkey for directory assignment public
Returns
bool

Definition at line 490 of file class.ilFileDataMail.php.

References $ilDB, and $res.

491  {
492  global $ilDB;
493 
494 /* $query = "INSERT INTO mail_attachment ".
495  "SET mail_id = ".$ilDB->quote($a_mail_id).", ".
496  "path = ".$ilDB->quote($this->user_id."_".$a_sent_mail_id)." ";
497  $res = $this->ilias->db->query($query);
498 */
499 
500  $oStorage = self::getStorage($a_sent_mail_id, $this->user_id);
501  $res = $ilDB->manipulateF('
502  INSERT INTO mail_attachment
503  ( mail_id, path) VALUES (%s, %s)',
504  array('integer', 'text'),
505  array($a_mail_id, $oStorage->getRelativePathExMailDirectory())
506  );
507 
508  }
global $ilDB

◆ checkFilesExist()

ilFileDataMail::checkFilesExist (   $a_files)

check if files exist

Parameters
arrayfilenames to check public
Returns
bool

Definition at line 468 of file class.ilFileDataMail.php.

References $file.

469  {
470  if($a_files)
471  {
472  foreach($a_files as $file)
473  {
474  if(!file_exists($this->mail_path.'/'.$this->user_id.'_'.$file))
475  {
476  return false;
477  }
478  }
479  return true;
480  }
481  return true;
482  }
print $file

◆ checkReadWrite()

ilFileDataMail::checkReadWrite ( )

check if directory is writable overwritten method from base class private

Returns
bool

Definition at line 221 of file class.ilFileDataMail.php.

Referenced by __construct().

222  {
223  if(is_writable($this->mail_path) && is_readable($this->mail_path))
224  {
225  return true;
226  }
227  else
228  {
229  $this->ilias->raiseError("Mail directory is not readable/writable by webserver: ".$this->mail_path,$this->ilias->error_obj->FATAL);
230  }
231  }
redirection script todo: (a better solution should control the processing via a xml file) ...
+ Here is the caller graph for this function:

◆ copyAttachmentFile()

ilFileDataMail::copyAttachmentFile (   $a_abs_path,
  $a_new_name 
)

Copy files in mail directory.

This is used for sending ILIAS generated mails with attachments

Parameters
arrayArray with files. Absolute path required public
Returns

Definition at line 329 of file class.ilFileDataMail.php.

References getMailPath().

330  {
331  @copy($a_abs_path,$this->getMailPath()."/".$this->user_id."_".$a_new_name);
332 
333  return true;
334  }
getMailPath()
get mail path public
+ Here is the call graph for this function:

◆ deassignAttachmentFromDirectory()

ilFileDataMail::deassignAttachmentFromDirectory (   $a_mail_id)

dassign attachments from mail directory

Parameters
integermail_id public
Returns
bool

Definition at line 515 of file class.ilFileDataMail.php.

References $ilDB, ilFile\$path, $res, $row, __deleteAttachmentDirectory(), and DB_FETCHMODE_OBJECT.

516  {
517  global $ilDB;
518  // IF IT'S THE LAST MAIL CONTAINING THESE ATTACHMENTS => DELETE ATTACHMENTS
519  $res = $ilDB->query("SELECT path FROM mail_attachment
520  WHERE mail_id = ".$ilDB->quote($a_mail_id,'integer'));
521 
522  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
523  {
524  $path = $row->path;
525  }
526  if($path)
527  {
528  $res = $ilDB->query("SELECT COUNT(mail_id) count_mail_id FROM mail_attachment
529  WHERE path = ".$ilDB->quote($path,'text')) ;
530 
531  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
532  {
533  $cnt_mail_id = $row->count_mail_id;
534  }
535  if($cnt_mail_id == 1)
536  {
538  }
539  }
540 
541  $res = $ilDB->manipulateF("DELETE FROM mail_attachment
542  WHERE mail_id = %s",
543  array('integer'),
544  array($a_mail_id));
545  return true;
546  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
__deleteAttachmentDirectory($a_rel_path)
+ Here is the call graph for this function:

◆ getAbsolutePath()

ilFileDataMail::getAbsolutePath (   $a_path)

get absolute path of filename

Parameters
stringrelative path public
Returns
string absolute path

Definition at line 393 of file class.ilFileDataMail.php.

394  {
395  return $this->mail_path.'/'.$this->user_id.'_'.$a_path;
396  }

◆ getAttachmentPath()

ilFileDataMail::getAttachmentPath (   $a_filename,
  $a_mail_id 
)

get the path of a specific attachment

Parameters
stringfilename
integermail_id public
Returns
string path

Definition at line 160 of file class.ilFileDataMail.php.

References $ilDB, ilFile\$path, $query, $row, and getMailPath().

Referenced by adoptAttachments().

161  {
162  global $ilDB;
163 
164 /* $query = "SELECT path FROM mail_attachment ".
165  "WHERE mail_id = ".$ilDB->quote($a_mail_id)."";
166 
167  $row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
168  $path = $this->getMailPath().'/'.$row->path.'/'.$a_filename;
169 */
170  $query = $ilDB->query("SELECT path FROM mail_attachment ".
171  "WHERE mail_id = ".$ilDB->quote($a_mail_id, 'integer')."");
172 
173  while($row = $ilDB->fetchObject($query))
174  {
175  $path = $this->getMailPath().'/'.$row->path.'/'.$a_filename;
176  }
177 
178  if(file_exists($path))
179  {
180  if(is_readable($path))
181  {
182  return $path;
183  }
184  return '';
185  }
186  return '';
187  }
getMailPath()
get mail path public
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAttachmentPathByMD5Filename()

ilFileDataMail::getAttachmentPathByMD5Filename (   $a_filename,
  $a_mail_id 
)

get the path of a specific attachment

Parameters
stringmd5 encrypted filename
integermail_id public
Returns
string path

Definition at line 117 of file class.ilFileDataMail.php.

References $file, $ilDB, ilFile\$path, $query, $row, ilUtil\getDir(), and getMailPath().

118  {
119  global $ilDB;
120 
121 /* $query = "SELECT path FROM mail_attachment ".
122  "WHERE mail_id = ".$ilDB->quote($a_mail_id)."";
123 
124  $row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
125  $path = $this->getMailPath().'/'.$row->path;
126 */
127  $query = $ilDB->query("SELECT path FROM mail_attachment
128  WHERE mail_id = ".$ilDB->quote($a_mail_id,'integer')."");
129 
130  $rel_path = "";
131  while($row = $ilDB->fetchObject($query))
132  {
133  $rel_path = $row->path;
134  $path = $this->getMailPath().'/'.$row->path;
135 
136  }
137 
138  $files = ilUtil::getDir($path);
139  foreach((array)$files as $file)
140  {
141  if($file['type'] == 'file' && md5($file['entry']) == $a_filename)
142  {
143  return array(
144  'path' => $this->getMailPath().'/'.$rel_path.'/'.$file['entry'],
145  'filename' => $file['entry']
146  );
147  }
148  }
149  return '';
150  }
print $file
getMailPath()
get mail path public
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
global $ilDB
+ Here is the call graph for this function:

◆ getAttachmentsTotalSizeLimit()

ilFileDataMail::getAttachmentsTotalSizeLimit ( )
Returns
float|null

Definition at line 89 of file class.ilFileDataMail.php.

90  {
91  $max_size = $this->ilias->getSetting('mail_maxsize_attach', '');
92  if(!strlen($max_size))
93  {
94  return null;
95  }
96 
97  return (float)$this->ilias->getSetting('mail_maxsize_attach', 0) * 1024;
98  }
redirection script todo: (a better solution should control the processing via a xml file) ...

◆ getMailPath()

ilFileDataMail::getMailPath ( )

get mail path public

Returns
string path

Definition at line 105 of file class.ilFileDataMail.php.

References $mail_path.

Referenced by _lookupDiskUsageOfUser(), adoptAttachments(), copyAttachmentFile(), getAttachmentPath(), getAttachmentPathByMD5Filename(), storeAsAttachment(), and storeUploadedFile().

106  {
107  return $this->mail_path;
108  }
+ Here is the caller graph for this function:

◆ getStorage()

static ilFileDataMail::getStorage (   $a_mail_id,
  $a_usr_id 
)
static

Definition at line 428 of file class.ilFileDataMail.php.

429  {
430  static $fsstorage_cache = array();
431 
432  if(!is_object($fsstorage_cache[$a_mail_id][$a_usr_id]))
433  {
434  include_once 'Services/Mail/classes/class.ilFSStorageMail.php';
435  $fsstorage_cache[$a_mail_id][$a_usr_id] = new ilFSStorageMail($a_mail_id, $a_usr_id);
436  }
437 
438  return $fsstorage_cache[$a_mail_id][$a_usr_id];
439  }

◆ getUnsentFiles()

ilFileDataMail::getUnsentFiles ( )

get all files which are not sent find them in directory data/mail/ private

Returns
array

Definition at line 248 of file class.ilFileDataMail.php.

References $file, and $rest.

Referenced by getUserFilesData().

249  {
250  $files = array();
251  $dp = opendir($this->mail_path);
252 
253  while($file = readdir($dp))
254  {
255  if(is_dir($file))
256  {
257  continue;
258  }
259  list($uid,$rest) = explode('_',$file,2);
260  if($uid == $this->user_id)
261  {
262  if(!is_dir($this->mail_path.'/'.$file))
263  {
264  $files[] = array(
265  'name' => $rest,
266  'size' => filesize($this->mail_path.'/'.$file),
267  'ctime' => filectime($this->mail_path.'/'.$file)
268  );
269  }
270  }
271  }
272  closedir($dp);
273  return $files;
274  }
print $file
$rest
Definition: goto.php:85
+ Here is the caller graph for this function:

◆ getUploadLimit()

ilFileDataMail::getUploadLimit ( )
Returns
int

Definition at line 81 of file class.ilFileDataMail.php.

References $mail_max_upload_file_size.

Referenced by storeAsAttachment().

82  {
84  }
+ Here is the caller graph for this function:

◆ getUserFilesData()

ilFileDataMail::getUserFilesData ( )

get all attachments of a specific user public

Returns
array

Definition at line 237 of file class.ilFileDataMail.php.

References getUnsentFiles().

238  {
239  return $files = $this->getUnsentFiles();
240  }
getUnsentFiles()
get all files which are not sent find them in directory data/mail/ private
+ Here is the call graph for this function:

◆ initAttachmentMaxUploadSize()

ilFileDataMail::initAttachmentMaxUploadSize ( )
protected
Todo:
mjansen: Unfortunately we cannot reuse the implementation of ilFileInputGUI

Definition at line 558 of file class.ilFileDataMail.php.

Referenced by __construct().

559  {
562  // Copy of ilFileInputGUI: begin
563  // get the value for the maximal uploadable filesize from the php.ini (if available)
564  $umf = ini_get("upload_max_filesize");
565  // get the value for the maximal post data from the php.ini (if available)
566  $pms = ini_get("post_max_size");
567 
568  //convert from short-string representation to "real" bytes
569  $multiplier_a = array("K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024);
570 
571  $umf_parts = preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
572  $pms_parts = preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
573 
574  if(count($umf_parts) == 2)
575  {
576  $umf = $umf_parts[0] * $multiplier_a[$umf_parts[1]];
577  }
578  if(count($pms_parts) == 2)
579  {
580  $pms = $pms_parts[0] * $multiplier_a[$pms_parts[1]];
581  }
582 
583  // use the smaller one as limit
584  $max_filesize = min($umf, $pms);
585 
586  if(!$max_filesize) $max_filesize = max($umf, $pms);
587  // Copy of ilFileInputGUI: end
588 
589  $this->mail_max_upload_file_size = $max_filesize;
590  }
+ Here is the caller graph for this function:

◆ initDirectory()

ilFileDataMail::initDirectory ( )

init directory overwritten method public

Returns
string path

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

References ilFileData\getPath().

63  {
64  if(is_writable($this->getPath()))
65  {
66  if(mkdir($this->getPath().'/'.MAILPATH))
67  {
68  if(chmod($this->getPath().'/'.MAILPATH,0755))
69  {
70  $this->mail_path = $this->getPath().'/'.MAILPATH;
71  return true;
72  }
73  }
74  }
75  return false;
76  }
getPath()
get Path public
+ Here is the call graph for this function:

◆ rotateFiles()

ilFileDataMail::rotateFiles (   $a_path)

rotate files with same name recursive method

Parameters
stringfilename private
Returns
bool

Definition at line 345 of file class.ilFileDataMail.php.

Referenced by storeAsAttachment(), and storeUploadedFile().

346  {
347  if(file_exists($a_path))
348  {
349  $this->rotateFiles($a_path.".old");
350  return rename($a_path,$a_path.'.old');
351  }
352  return true;
353  }
rotateFiles($a_path)
rotate files with same name recursive method
+ Here is the caller graph for this function:

◆ saveFile()

ilFileDataMail::saveFile (   $a_mail_id,
  $a_attachment 
)

save attachment file in a specific mail directory .../mail/<calculated_path>/mail_<mail_id>_<user_id>/...

Parameters
integermail id of mail in sent box
arrayfilenames to save public
Returns
bool

Definition at line 448 of file class.ilFileDataMail.php.

Referenced by saveFiles().

449  {
450  $oStorage = self::getStorage($a_mail_id, $this->user_id);
451  $oStorage->create();
452  $storage_directory = $oStorage->getAbsolutePath();
453 
454  if(@!is_dir($storage_directory))
455  {
456  return false;
457  }
458 
459  return copy($this->mail_path.'/'.$this->user_id.'_'.$a_attachment,
460  $storage_directory.'/'.$a_attachment);
461  }
+ Here is the caller graph for this function:

◆ saveFiles()

ilFileDataMail::saveFiles (   $a_mail_id,
  $a_attachments 
)

save all attachment files in a specific mail directory .../mail/<calculated_path>/mail_<mail_id>_<user_id>/...

Parameters
integermail id of mail in sent box
arrayfilenames to save public
Returns
string error message

Definition at line 405 of file class.ilFileDataMail.php.

References saveFile().

406  {
407  if(!$a_mail_id)
408  {
409  return "INTERNAL HERE ERROR: No valid mail_id given";
410  }
411  if(is_array($a_attachments))
412  {
413  foreach($a_attachments as $attachment)
414  {
415  if(!$this->saveFile($a_mail_id,$attachment))
416  {
417  return $attachment;
418  }
419  }
420  }
421  else
422  {
423  return "ARRAY REQUIRED";
424  }
425  return '';
426  }
saveFile($a_mail_id, $a_attachment)
save attachment file in a specific mail directory .../mail/<calculated_path>/mail_<mail_id>_<user_id>...
+ Here is the call graph for this function:

◆ storeAsAttachment()

ilFileDataMail::storeAsAttachment (   $a_filename,
  $a_content 
)

Store content as attachment.

Parameters
object$a_filename
object$a_content
Returns

Definition at line 282 of file class.ilFileDataMail.php.

References ilUtil\_sanitizeFilemame(), getMailPath(), getUploadLimit(), and rotateFiles().

283  {
284  if(strlen($a_content) >= $this->getUploadLimit())
285  {
286  return 1;
287  }
288 
289  $name = ilUtil::_sanitizeFilemame($a_filename);
290  $this->rotateFiles($this->getMailPath().'/'.$this->user_id.'_'.$name);
291 
292  $abs_path = $this->getMailPath().'/'.$this->user_id.'_'.$name;
293 
294  if(!$fp = @fopen($abs_path,'w+'))
295  {
296  return false;
297  }
298  if(@fwrite($fp,$a_content) === false)
299  {
300  @fclose($fp);
301  return false;
302  }
303  @fclose($fp);
304  return true;
305  }
getMailPath()
get mail path public
static _sanitizeFilemame($a_filename)
rotateFiles($a_path)
rotate files with same name recursive method
+ Here is the call graph for this function:

◆ storeUploadedFile()

ilFileDataMail::storeUploadedFile (   $file)
Parameters
array$file

Definition at line 310 of file class.ilFileDataMail.php.

References $file, ilUtil\_sanitizeFilemame(), getMailPath(), ilUtil\moveUploadedFile(), and rotateFiles().

311  {
312  $file['name'] = ilUtil::_sanitizeFilemame($file['name']);
313 
314  $this->rotateFiles($this->getMailPath() . '/' . $this->user_id . '_' . $file['name']);
315 
317  $file['tmp_name'],
318  $file['name'],
319  $this->getMailPath() . '/' . $this->user_id . '_' . $file['name']
320  );
321  }
print $file
getMailPath()
get mail path public
static _sanitizeFilemame($a_filename)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
rotateFiles($a_path)
rotate files with same name recursive method
+ Here is the call graph for this function:

◆ unlinkFile()

ilFileDataMail::unlinkFile (   $a_filename)

unlink one uploaded file expects a filename e.g 'foo'

Parameters
stringfilename to delete public
Returns
bool

Definition at line 380 of file class.ilFileDataMail.php.

Referenced by unlinkFiles().

381  {
382  if(file_exists($this->mail_path.'/'.basename($this->user_id.'_'.$a_filename)))
383  {
384  return unlink($this->mail_path.'/'.basename($this->user_id.'_'.$a_filename));
385  }
386  }
+ Here is the caller graph for this function:

◆ unlinkFiles()

ilFileDataMail::unlinkFiles (   $a_filenames)

unlink files: expects an array of filenames e.g.

array('foo','bar')

Parameters
arrayfilenames to delete public
Returns
string error message with filename that couldn't be deleted

Definition at line 360 of file class.ilFileDataMail.php.

References $file, and unlinkFile().

361  {
362  if(is_array($a_filenames))
363  {
364  foreach($a_filenames as $file)
365  {
366  if(!$this->unlinkFile($file))
367  {
368  return $file;
369  }
370  }
371  }
372  return '';
373  }
print $file
unlinkFile($a_filename)
unlink one uploaded file expects a filename e.g &#39;foo&#39;
+ Here is the call graph for this function:

Field Documentation

◆ $mail_max_upload_file_size

ilFileDataMail::$mail_max_upload_file_size
protected

Definition at line 36 of file class.ilFileDataMail.php.

Referenced by getUploadLimit().

◆ $mail_path

ilFileDataMail::$mail_path

Definition at line 31 of file class.ilFileDataMail.php.

Referenced by getMailPath().

◆ $user_id

ilFileDataMail::$user_id

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


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