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

References ilUtil\delDir().

Referenced by deassignAttachmentFromDirectory().

508  {
509  ilUtil::delDir($this->mail_path . "/" . $a_rel_path);
510 
511  return true;
512  }
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 559 of file class.ilFileDataMail.php.

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

Referenced by ilObjMailAccess\_lookupDiskUsageOfUser().

560  {
561  // XXX - This method is extremely slow. We should
562  // use a cache to speed it up, for example, we should
563  // store the disk space used in table mail_attachment.
564  global $DIC;
565 
566  $mail_data_dir = ilUtil::getDataDir('filesystem') . DIRECTORY_SEPARATOR . "mail";
567 
568  $q = "SELECT path " .
569  "FROM mail_attachment ma " .
570  "JOIN mail m ON ma.mail_id=m.mail_id " .
571  "WHERE m.user_id = " . $DIC->database()->quote($user_id);
572  $result_set = $DIC->database()->query($q);
573  $size = 0;
574  $count = 0;
575  while ($row = $result_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
576  $attachment_path = $mail_data_dir . DIRECTORY_SEPARATOR . $row['path'];
577  $attachment_size = ilUtil::dirsize($attachment_path);
578  if ($attachment_size != -1) {
579  $size += $attachment_size;
580  }
581  $count++;
582  }
583  return array('count'=>$count, 'size'=>$size);
584  }
$size
Definition: RandomTest.php:84
global $DIC
Definition: saml.php:7
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)
+ 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 193 of file class.ilFileDataMail.php.

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

194  {
195  if (is_array($a_attachments)) {
196  foreach ($a_attachments as $file) {
197  $path = $this->getAttachmentPath($file, $a_mail_id);
198  if (!copy($path, $this->getMailPath() . '/' . $this->user_id . '_' . $file)) {
199  return "ERROR: $this->getMailPath().'/'.$this->user_id.'_'.$file cannot be created";
200  }
201  }
202  } else {
203  return "ARRAY REQUIRED";
204  }
205  return '';
206  }
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 451 of file class.ilFileDataMail.php.

References $ilDB, $res, and array.

452  {
453  global $ilDB;
454 
455  /* $query = "INSERT INTO mail_attachment ".
456  "SET mail_id = ".$ilDB->quote($a_mail_id).", ".
457  "path = ".$ilDB->quote($this->user_id."_".$a_sent_mail_id)." ";
458  $res = $this->ilias->db->query($query);
459  */
460 
461  $oStorage = self::getStorage($a_sent_mail_id, $this->user_id);
462  $res = $ilDB->manipulateF(
463  '
464  INSERT INTO mail_attachment
465  ( mail_id, path) VALUES (%s, %s)',
466  array('integer', 'text'),
467  array($a_mail_id, $oStorage->getRelativePathExMailDirectory())
468  );
469  }
foreach($_POST as $key=> $value) $res
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 432 of file class.ilFileDataMail.php.

References $file.

433  {
434  if ($a_files) {
435  foreach ($a_files as $file) {
436  if (!file_exists($this->mail_path . '/' . $this->user_id . '_' . $file)) {
437  return false;
438  }
439  }
440  return true;
441  }
442  return true;
443  }
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 214 of file class.ilFileDataMail.php.

Referenced by __construct().

215  {
216  if (is_writable($this->mail_path) && is_readable($this->mail_path)) {
217  return true;
218  } else {
219  $this->ilias->raiseError("Mail directory is not readable/writable by webserver: " . $this->mail_path, $this->ilias->error_obj->FATAL);
220  }
221  }
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 312 of file class.ilFileDataMail.php.

References getMailPath().

313  {
314  @copy($a_abs_path, $this->getMailPath() . "/" . $this->user_id . "_" . $a_new_name);
315 
316  return true;
317  }
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 476 of file class.ilFileDataMail.php.

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

477  {
478  global $ilDB;
479  // IF IT'S THE LAST MAIL CONTAINING THESE ATTACHMENTS => DELETE ATTACHMENTS
480  $res = $ilDB->query("SELECT path FROM mail_attachment
481  WHERE mail_id = " . $ilDB->quote($a_mail_id, 'integer'));
482 
483  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
484  $path = $row->path;
485  }
486  if ($path) {
487  $res = $ilDB->query("SELECT COUNT(mail_id) count_mail_id FROM mail_attachment
488  WHERE path = " . $ilDB->quote($path, 'text')) ;
489 
490  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
491  $cnt_mail_id = $row->count_mail_id;
492  }
493  if ($cnt_mail_id == 1) {
495  }
496  }
497 
498  $res = $ilDB->manipulateF(
499  "DELETE FROM mail_attachment
500  WHERE mail_id = %s",
501  array('integer'),
502  array($a_mail_id)
503  );
504  return true;
505  }
foreach($_POST as $key=> $value) $res
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 110 of file class.ilFileDataMail.php.

Referenced by getAbsolutePath().

111  {
112  return $this->mail_path . '/' . $this->user_id . '_';
113  }
+ 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 371 of file class.ilFileDataMail.php.

References getAbsoluteAttachmentPoolPathPrefix().

372  {
373  return $this->getAbsoluteAttachmentPoolPathPrefix() . $fileName;
374  }
+ 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 161 of file class.ilFileDataMail.php.

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

Referenced by adoptAttachments().

162  {
163  global $ilDB;
164 
165  /* $query = "SELECT path FROM mail_attachment ".
166  "WHERE mail_id = ".$ilDB->quote($a_mail_id)."";
167 
168  $row = $this->ilias->db->getRow($query,ilDBConstants::FETCHMODE_OBJECT);
169  $path = $this->getMailPath().'/'.$row->path.'/'.$a_filename;
170  */
171  $query = $ilDB->query("SELECT path FROM mail_attachment " .
172  "WHERE mail_id = " . $ilDB->quote($a_mail_id, 'integer') . "");
173 
174  while ($row = $ilDB->fetchObject($query)) {
175  $path = $this->getMailPath() . '/' . $row->path . '/' . $a_filename;
176  }
177 
178  if (file_exists($path)) {
179  if (is_readable($path)) {
180  return $path;
181  }
182  return '';
183  }
184  return '';
185  }
getMailPath()
get mail path public
$query
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 122 of file class.ilFileDataMail.php.

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

123  {
124  global $ilDB;
125 
126  /* $query = "SELECT path FROM mail_attachment ".
127  "WHERE mail_id = ".$ilDB->quote($a_mail_id)."";
128 
129  $row = $this->ilias->db->getRow($query,ilDBConstants::FETCHMODE_OBJECT);
130  $path = $this->getMailPath().'/'.$row->path;
131  */
132  $query = $ilDB->query("SELECT path FROM mail_attachment
133  WHERE mail_id = " . $ilDB->quote($a_mail_id, 'integer') . "");
134 
135  $rel_path = "";
136  while ($row = $ilDB->fetchObject($query)) {
137  $rel_path = $row->path;
138  $path = $this->getMailPath() . '/' . $row->path;
139  }
140 
142  foreach ((array) $files as $file) {
143  if ($file['type'] == 'file' && md5($file['entry']) == $a_filename) {
144  return array(
145  'path' => $this->getMailPath() . '/' . $rel_path . '/' . $file['entry'],
146  'filename' => $file['entry']
147  );
148  }
149  }
150  return '';
151  }
$files
Definition: add-vimline.php:18
getMailPath()
get mail path public
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
$query
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 87 of file class.ilFileDataMail.php.

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

References $mail_path.

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

103  {
104  return $this->mail_path;
105  }
+ Here is the caller graph for this function:

◆ getStorage()

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

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

References array.

393  {
394  static $fsstorage_cache = array();
395 
396  if (!is_object($fsstorage_cache[$a_mail_id][$a_usr_id])) {
397  include_once 'Services/Mail/classes/class.ilFSStorageMail.php';
398  $fsstorage_cache[$a_mail_id][$a_usr_id] = new ilFSStorageMail($a_mail_id, $a_usr_id);
399  }
400 
401  return $fsstorage_cache[$a_mail_id][$a_usr_id];
402  }
Create styles array
The data for the language used.

◆ getUploadLimit()

ilFileDataMail::getUploadLimit ( )
Returns
int

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

References $mail_max_upload_file_size.

Referenced by storeAsAttachment().

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

◆ getUserFilesData()

ilFileDataMail::getUserFilesData ( )

get all attachments of a specific user public

Returns
array

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

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

228  {
229  return $this->getUnsentFiles();
230  }

◆ initAttachmentMaxUploadSize()

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

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

References array.

Referenced by __construct().

518  {
521  // Copy of ilFileInputGUI: begin
522  // get the value for the maximal uploadable filesize from the php.ini (if available)
523  $umf = ini_get("upload_max_filesize");
524  // get the value for the maximal post data from the php.ini (if available)
525  $pms = ini_get("post_max_size");
526 
527  //convert from short-string representation to "real" bytes
528  $multiplier_a = array("K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024);
529 
530  $umf_parts = preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
531  $pms_parts = preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
532 
533  if (count($umf_parts) == 2) {
534  $umf = $umf_parts[0] * $multiplier_a[$umf_parts[1]];
535  }
536  if (count($pms_parts) == 2) {
537  $pms = $pms_parts[0] * $multiplier_a[$pms_parts[1]];
538  }
539 
540  // use the smaller one as limit
541  $max_filesize = min($umf, $pms);
542 
543  if (!$max_filesize) {
544  $max_filesize = max($umf, $pms);
545  }
546  // Copy of ilFileInputGUI: end
547 
548  $this->mail_max_upload_file_size = $max_filesize;
549  }
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  if (mkdir($this->getPath() . '/' . MAILPATH)) {
67  if (chmod($this->getPath() . '/' . MAILPATH, 0755)) {
68  $this->mail_path = $this->getPath() . '/' . MAILPATH;
69  return true;
70  }
71  }
72  }
73  return false;
74  }
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 328 of file class.ilFileDataMail.php.

Referenced by storeAsAttachment(), and storeUploadedFile().

329  {
330  if (file_exists($a_path)) {
331  $this->rotateFiles($a_path . ".old");
332  return \ilFileUtils::rename($a_path, $a_path . '.old');
333  }
334  return true;
335  }
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 411 of file class.ilFileDataMail.php.

Referenced by saveFiles().

412  {
413  $oStorage = self::getStorage($a_mail_id, $this->user_id);
414  $oStorage->create();
415  $storage_directory = $oStorage->getAbsolutePath();
416 
417  if (@!is_dir($storage_directory)) {
418  return false;
419  }
420 
421  return copy(
422  $this->mail_path . '/' . $this->user_id . '_' . $a_attachment,
423  $storage_directory . '/' . $a_attachment
424  );
425  }
+ 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 381 of file class.ilFileDataMail.php.

References saveFile().

382  {
383  if (!is_numeric($a_mail_id) || $a_mail_id < 1) {
384  throw new InvalidArgumentException('The passed mail_id must be a valid integer!');
385  }
386 
387  foreach ($a_attachments as $attachment) {
388  $this->saveFile($a_mail_id, $attachment);
389  }
390  }
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 268 of file class.ilFileDataMail.php.

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

269  {
270  if (strlen($a_content) >= $this->getUploadLimit()) {
271  return 1;
272  }
273 
274  $name = ilUtil::_sanitizeFilemame($a_filename);
275  $this->rotateFiles($this->getMailPath() . '/' . $this->user_id . '_' . $name);
276 
277  $abs_path = $this->getMailPath() . '/' . $this->user_id . '_' . $name;
278 
279  if (!$fp = @fopen($abs_path, 'w+')) {
280  return false;
281  }
282  if (@fwrite($fp, $a_content) === false) {
283  @fclose($fp);
284  return false;
285  }
286  @fclose($fp);
287  return true;
288  }
getMailPath()
get mail path public
static _sanitizeFilemame($a_filename)
if($format !==null) $name
Definition: metadata.php:146
$a_content
Definition: workflow.php:93
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 293 of file class.ilFileDataMail.php.

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

294  {
295  $file['name'] = ilUtil::_sanitizeFilemame($file['name']);
296 
297  $this->rotateFiles($this->getMailPath() . '/' . $this->user_id . '_' . $file['name']);
298 
299  ilUtil::moveUploadedFile(
300  $file['tmp_name'],
301  $file['name'],
302  $this->getMailPath() . '/' . $this->user_id . '_' . $file['name']
303  );
304  }
getMailPath()
get mail path public
static _sanitizeFilemame($a_filename)
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 359 of file class.ilFileDataMail.php.

Referenced by unlinkFiles().

360  {
361  if (file_exists($this->mail_path . '/' . basename($this->user_id . '_' . $a_filename))) {
362  return unlink($this->mail_path . '/' . basename($this->user_id . '_' . $a_filename));
363  }
364  }
+ 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 342 of file class.ilFileDataMail.php.

References $file, and unlinkFile().

343  {
344  if (is_array($a_filenames)) {
345  foreach ($a_filenames as $file) {
346  if (!$this->unlinkFile($file)) {
347  return $file;
348  }
349  }
350  }
351  return '';
352  }
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.

Referenced by _lookupDiskUsageOfUser().


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