ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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...
 
 getAbsoluteAttachmentPoolPathPrefix ()
 
 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...
 
 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 ($fileName)
 get absolute path of filename More...
 
 saveFiles ($a_mail_id, array $a_attachments)
 Saves 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)
 
- 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

static getStorage ($a_mail_id, $a_usr_id)
 
static _lookupDiskUsageOfUser ($user_id)
 Returns the number of bytes used on the harddisk for mail attachments, by the user with the specified user id. More...
 

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 18 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 46 of file class.ilFileDataMail.php.

References checkReadWrite(), and initAttachmentMaxUploadSize().

47  {
48  define('MAILPATH','mail');
49  parent::__construct();
50  $this->mail_path = parent::getPath()."/".MAILPATH;
51  $this->checkReadWrite();
52  $this->user_id = $a_user_id;
53 
55  }
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 544 of file class.ilFileDataMail.php.

References ilUtil\delDir().

Referenced by deassignAttachmentFromDirectory().

545  {
546  ilUtil::delDir($this->mail_path."/".$a_rel_path);
547 
548  return true;
549  }
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()

static ilFileDataMail::_lookupDiskUsageOfUser (   $user_id)
static

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 596 of file class.ilFileDataMail.php.

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

Referenced by ilObjMailAccess\_lookupDiskUsageOfUser().

597  {
598  // XXX - This method is extremely slow. We should
599  // use a cache to speed it up, for example, we should
600  // store the disk space used in table mail_attachment.
601  global $ilDB, $lng;
602 
603  $mail_data_dir = ilUtil::getDataDir('filesystem').DIRECTORY_SEPARATOR."mail";
604 
605  $q = "SELECT path ".
606  "FROM mail_attachment ma ".
607  "JOIN mail m ON ma.mail_id=m.mail_id ".
608  "WHERE m.user_id = ".$ilDB->quote($user_id);
609  $result_set = $ilDB->query($q);
610  $size = 0;
611  $count = 0;
612  while($row = $result_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
613  {
614  $attachment_path = $mail_data_dir.DIRECTORY_SEPARATOR.$row['path'];
615  $attachment_size = ilUtil::dirsize($attachment_path);
616  if ($attachment_size != -1)
617  {
618  $size += $attachment_size;
619  }
620  $count++;
621  }
622  return array('count'=>$count, 'size'=>$size);
623  }
$size
Definition: RandomTest.php:79
Create styles array
The data for the language used.
static dirsize($directory)
get size of a directory or a file.
static getDataDir()
get data directory (outside webspace)
global $lng
Definition: privfeed.php:17
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 204 of file class.ilFileDataMail.php.

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

205  {
206  if(is_array($a_attachments))
207  {
208  foreach($a_attachments as $file)
209  {
210  $path = $this->getAttachmentPath($file,$a_mail_id);
211  if(!copy($path,$this->getMailPath().'/'.$this->user_id.'_'.$file))
212  {
213  return "ERROR: $this->getMailPath().'/'.$this->user_id.'_'.$file cannot be created";
214  }
215  }
216  }
217  else
218  {
219  return "ARRAY REQUIRED";
220  }
221  return '';
222  }
getAttachmentPath($a_filename, $a_mail_id)
get the path of a specific attachment
getMailPath()
get mail path public
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ 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 486 of file class.ilFileDataMail.php.

References $ilDB, $res, and array.

487  {
488  global $ilDB;
489 
490 /* $query = "INSERT INTO mail_attachment ".
491  "SET mail_id = ".$ilDB->quote($a_mail_id).", ".
492  "path = ".$ilDB->quote($this->user_id."_".$a_sent_mail_id)." ";
493  $res = $this->ilias->db->query($query);
494 */
495 
496  $oStorage = self::getStorage($a_sent_mail_id, $this->user_id);
497  $res = $ilDB->manipulateF('
498  INSERT INTO mail_attachment
499  ( mail_id, path) VALUES (%s, %s)',
500  array('integer', 'text'),
501  array($a_mail_id, $oStorage->getRelativePathExMailDirectory())
502  );
503 
504  }
Create styles array
The data for the language used.
global $ilDB

◆ checkFilesExist()

ilFileDataMail::checkFilesExist (   $a_files)

check if files exist

Parameters
arrayfilenames to check public
Returns
bool

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

References $file.

465  {
466  if($a_files)
467  {
468  foreach($a_files as $file)
469  {
470  if(!file_exists($this->mail_path.'/'.$this->user_id.'_'.$file))
471  {
472  return false;
473  }
474  }
475  return true;
476  }
477  return true;
478  }
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file

◆ checkReadWrite()

ilFileDataMail::checkReadWrite ( )

check if directory is writable overwritten method from base class private

Returns
bool

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

Referenced by __construct().

231  {
232  if(is_writable($this->mail_path) && is_readable($this->mail_path))
233  {
234  return true;
235  }
236  else
237  {
238  $this->ilias->raiseError("Mail directory is not readable/writable by webserver: ".$this->mail_path,$this->ilias->error_obj->FATAL);
239  }
240  }
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 337 of file class.ilFileDataMail.php.

References getMailPath().

338  {
339  @copy($a_abs_path,$this->getMailPath()."/".$this->user_id."_".$a_new_name);
340 
341  return true;
342  }
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 511 of file class.ilFileDataMail.php.

References $ilDB, ilFile\$path, $res, $row, __deleteAttachmentDirectory(), array, and ilDBConstants\FETCHMODE_OBJECT.

512  {
513  global $ilDB;
514  // IF IT'S THE LAST MAIL CONTAINING THESE ATTACHMENTS => DELETE ATTACHMENTS
515  $res = $ilDB->query("SELECT path FROM mail_attachment
516  WHERE mail_id = ".$ilDB->quote($a_mail_id,'integer'));
517 
518  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
519  {
520  $path = $row->path;
521  }
522  if($path)
523  {
524  $res = $ilDB->query("SELECT COUNT(mail_id) count_mail_id FROM mail_attachment
525  WHERE path = ".$ilDB->quote($path,'text')) ;
526 
527  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
528  {
529  $cnt_mail_id = $row->count_mail_id;
530  }
531  if($cnt_mail_id == 1)
532  {
534  }
535  }
536 
537  $res = $ilDB->manipulateF("DELETE FROM mail_attachment
538  WHERE mail_id = %s",
539  array('integer'),
540  array($a_mail_id));
541  return true;
542  }
Create styles array
The data for the language used.
global $ilDB
__deleteAttachmentDirectory($a_rel_path)
+ Here is the call graph for this function:

◆ getAbsoluteAttachmentPoolPathPrefix()

ilFileDataMail::getAbsoluteAttachmentPoolPathPrefix ( )
Returns
string

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

Referenced by getAbsolutePath().

115  {
116  return $this->mail_path . '/' . $this->user_id . '_';
117  }
+ Here is the caller graph for this function:

◆ getAbsolutePath()

ilFileDataMail::getAbsolutePath (   $fileName)

get absolute path of filename

Parameters
stringrelative path public
Returns
string absolute path

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

References getAbsoluteAttachmentPoolPathPrefix().

402  {
403  return $this->getAbsoluteAttachmentPoolPathPrefix() . $fileName;
404  }
+ Here is the call graph for this function:

◆ 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 169 of file class.ilFileDataMail.php.

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

Referenced by adoptAttachments().

170  {
171  global $ilDB;
172 
173 /* $query = "SELECT path FROM mail_attachment ".
174  "WHERE mail_id = ".$ilDB->quote($a_mail_id)."";
175 
176  $row = $this->ilias->db->getRow($query,ilDBConstants::FETCHMODE_OBJECT);
177  $path = $this->getMailPath().'/'.$row->path.'/'.$a_filename;
178 */
179  $query = $ilDB->query("SELECT path FROM mail_attachment ".
180  "WHERE mail_id = ".$ilDB->quote($a_mail_id, 'integer')."");
181 
182  while($row = $ilDB->fetchObject($query))
183  {
184  $path = $this->getMailPath().'/'.$row->path.'/'.$a_filename;
185  }
186 
187  if(file_exists($path))
188  {
189  if(is_readable($path))
190  {
191  return $path;
192  }
193  return '';
194  }
195  return '';
196  }
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 126 of file class.ilFileDataMail.php.

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

127  {
128  global $ilDB;
129 
130 /* $query = "SELECT path FROM mail_attachment ".
131  "WHERE mail_id = ".$ilDB->quote($a_mail_id)."";
132 
133  $row = $this->ilias->db->getRow($query,ilDBConstants::FETCHMODE_OBJECT);
134  $path = $this->getMailPath().'/'.$row->path;
135 */
136  $query = $ilDB->query("SELECT path FROM mail_attachment
137  WHERE mail_id = ".$ilDB->quote($a_mail_id,'integer')."");
138 
139  $rel_path = "";
140  while($row = $ilDB->fetchObject($query))
141  {
142  $rel_path = $row->path;
143  $path = $this->getMailPath().'/'.$row->path;
144 
145  }
146 
148  foreach((array)$files as $file)
149  {
150  if($file['type'] == 'file' && md5($file['entry']) == $a_filename)
151  {
152  return array(
153  'path' => $this->getMailPath().'/'.$rel_path.'/'.$file['entry'],
154  'filename' => $file['entry']
155  );
156  }
157  }
158  return '';
159  }
$files
Definition: add-vimline.php:18
getMailPath()
get mail path public
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
Create styles array
The data for the language used.
global $ilDB
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the call graph for this function:

◆ getAttachmentsTotalSizeLimit()

ilFileDataMail::getAttachmentsTotalSizeLimit ( )
Returns
float|null

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

91  {
92  $max_size = $this->ilias->getSetting('mail_maxsize_attach', '');
93  if(!strlen($max_size))
94  {
95  return null;
96  }
97 
98  return (float)$this->ilias->getSetting('mail_maxsize_attach', 0) * 1024;
99  }
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 106 of file class.ilFileDataMail.php.

References $mail_path.

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

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

◆ getStorage()

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

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

References array.

425  {
426  static $fsstorage_cache = array();
427 
428  if(!is_object($fsstorage_cache[$a_mail_id][$a_usr_id]))
429  {
430  include_once 'Services/Mail/classes/class.ilFSStorageMail.php';
431  $fsstorage_cache[$a_mail_id][$a_usr_id] = new ilFSStorageMail($a_mail_id, $a_usr_id);
432  }
433 
434  return $fsstorage_cache[$a_mail_id][$a_usr_id];
435  }
Create styles array
The data for the language used.

◆ getUploadLimit()

ilFileDataMail::getUploadLimit ( )
Returns
int

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

References $mail_max_upload_file_size.

Referenced by storeAsAttachment().

83  {
85  }
+ Here is the caller graph for this function:

◆ getUserFilesData()

ilFileDataMail::getUserFilesData ( )

get all attachments of a specific user public

Returns
array

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

References $file, $files, $rest, and array.

247  {
248  return $this->getUnsentFiles();
249  }

◆ initAttachmentMaxUploadSize()

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

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

References array.

Referenced by __construct().

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

◆ initDirectory()

ilFileDataMail::initDirectory ( )

init directory overwritten method public

Returns
string path

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

References ilFileData\getPath().

64  {
65  if(is_writable($this->getPath()))
66  {
67  if(mkdir($this->getPath().'/'.MAILPATH))
68  {
69  if(chmod($this->getPath().'/'.MAILPATH,0755))
70  {
71  $this->mail_path = $this->getPath().'/'.MAILPATH;
72  return true;
73  }
74  }
75  }
76  return false;
77  }
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 353 of file class.ilFileDataMail.php.

Referenced by storeAsAttachment(), and storeUploadedFile().

354  {
355  if(file_exists($a_path))
356  {
357  $this->rotateFiles($a_path.".old");
358  return \ilFileUtils::rename($a_path, $a_path . '.old');
359  }
360  return true;
361  }
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 444 of file class.ilFileDataMail.php.

Referenced by saveFiles().

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

◆ saveFiles()

ilFileDataMail::saveFiles (   $a_mail_id,
array  $a_attachments 
)

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

Parameters
integer$a_mail_idid of mail in sent box
array$a_attachmentsto save

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

References saveFile().

412  {
413  if(!is_numeric($a_mail_id) || $a_mail_id < 1)
414  {
415  throw new InvalidArgumentException('The passed mail_id must be a valid integer!');
416  }
417 
418  foreach($a_attachments as $attachment)
419  {
420  $this->saveFile($a_mail_id, $attachment);
421  }
422  }
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 290 of file class.ilFileDataMail.php.

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

291  {
292  if(strlen($a_content) >= $this->getUploadLimit())
293  {
294  return 1;
295  }
296 
297  $name = ilUtil::_sanitizeFilemame($a_filename);
298  $this->rotateFiles($this->getMailPath().'/'.$this->user_id.'_'.$name);
299 
300  $abs_path = $this->getMailPath().'/'.$this->user_id.'_'.$name;
301 
302  if(!$fp = @fopen($abs_path,'w+'))
303  {
304  return false;
305  }
306  if(@fwrite($fp,$a_content) === false)
307  {
308  @fclose($fp);
309  return false;
310  }
311  @fclose($fp);
312  return true;
313  }
getMailPath()
get mail path public
static _sanitizeFilemame($a_filename)
$a_content
Definition: workflow.php:94
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 318 of file class.ilFileDataMail.php.

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

319  {
320  $file['name'] = ilUtil::_sanitizeFilemame($file['name']);
321 
322  $this->rotateFiles($this->getMailPath() . '/' . $this->user_id . '_' . $file['name']);
323 
325  $file['tmp_name'],
326  $file['name'],
327  $this->getMailPath() . '/' . $this->user_id . '_' . $file['name']
328  );
329  }
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
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $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 388 of file class.ilFileDataMail.php.

Referenced by unlinkFiles().

389  {
390  if(file_exists($this->mail_path.'/'.basename($this->user_id.'_'.$a_filename)))
391  {
392  return unlink($this->mail_path.'/'.basename($this->user_id.'_'.$a_filename));
393  }
394  }
+ 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 368 of file class.ilFileDataMail.php.

References $file, and unlinkFile().

369  {
370  if(is_array($a_filenames))
371  {
372  foreach($a_filenames as $file)
373  {
374  if(!$this->unlinkFile($file))
375  {
376  return $file;
377  }
378  }
379  }
380  return '';
381  }
unlinkFile($a_filename)
unlink one uploaded file expects a filename e.g &#39;foo&#39;
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ 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 37 of file class.ilFileDataMail.php.

Referenced by getUploadLimit().

◆ $mail_path

ilFileDataMail::$mail_path

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

Referenced by getMailPath().

◆ $user_id

ilFileDataMail::$user_id

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


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