Example #1
0
 public static function getContents($attachment)
 {
     if (!is_array($attachment)) {
         if ($res = CMailAttachment::getByID($attachment)) {
             $attachment = $res->fetch();
         }
     }
     if (!is_array($attachment) || !isset($attachment['FILE_DATA']) && empty($attachment['FILE_ID'])) {
         return false;
     }
     if ($attachment['FILE_ID'] > 0) {
         if ($file = CFile::makeFileArray($attachment['FILE_ID'])) {
             return file_get_contents($file['tmp_name']);
         }
     } else {
         return $attachment['FILE_DATA'];
     }
 }