/**
  * Returns the list of fields that can be exported
  *
  * @param bool $prefix
  *
  * @return array
  */
 static function &export($prefix = false)
 {
     if (!self::$_export) {
         self::$_export = array();
         $fields = self::fields();
         foreach ($fields as $name => $field) {
             if (CRM_Utils_Array::value('export', $field)) {
                 if ($prefix) {
                     self::$_export['simplemailinlineattachment'] =& $fields[$name];
                 } else {
                     self::$_export[$name] =& $fields[$name];
                 }
             }
         }
     }
     return self::$_export;
 }
 /**
  * Deletes all the attachments in the table that match the simple mail ID provided
  */
 public static function removeAll($simpleMailId)
 {
     if (!CRM_Core_Permission::check(SM_PERMISSION_DELETE)) {
         throw new CRM_Extension_Exception('Sorry! You do not have permission to delete attachments', 500);
     }
     // not the most efficient way but then I doubt we'll be deleting 100's of attachments
     // so this feels the most consistent way to do deletions
     $attachment = new CRM_Simplemail_DAO_SimpleMailInlineAttachment();
     $attachment->simplemail_id = $simpleMailId;
     $total = $attachment->find();
     while ($attachment->fetch()) {
         $filename = CRM_Simplemail_BAO_SimpleMailHelper::getUploadDirPath(static::DIRECTORY);
         $filename .= basename($attachment->url);
         $unlinkResult = unlink($filename);
         $attachment->delete();
     }
     return true;
 }