Пример #1
0
 /**
  * @static
  * @param int $templateSID
  * @return array|bool|int
  */
 public static function deleteEmailTemplateBySID($templateSID)
 {
     $emailTemplate = SJB_EmailTemplateEditor::getEmailTemplateBySID($templateSID);
     if (!empty($emailTemplate)) {
         $userDefined = $emailTemplate->getPropertyValue('user_defined');
         if ($userDefined) {
             // delete atachment
             $fileProp = $emailTemplate->getProperty('file');
             if ($fileProp) {
                 SJB_UploadFileManager::deleteUploadedFileByID($fileProp->value);
             }
             return SJB_ObjectDBManager::deleteObjectInfoFromDB('email_templates', $templateSID);
         }
     }
     return false;
 }
Пример #2
0
 /**
  * @static
  * @param $fileName
  * @param int $etSID - email template SID
  * @return bool
  */
 public static function openEmailTemplateFile($fileName, $etSID)
 {
     $emailTpl = SJB_EmailTemplateEditor::getEmailTemplateBySID($etSID);
     $file_info = SJB_UploadFileManager::getEmailTemplateFileMimeTypeByFilename($emailTpl->getPropertyValue('file'));
     if ($file_info) {
         $file_link = SJB_UploadFileManager::getUploadedFileLink($file_info['id'], false, true);
         for ($i = 0; $i < ob_get_level(); $i++) {
             ob_end_clean();
         }
         header('Content-Length:' . filesize($file_link));
         header('Content-Disposition: attachment; filename="' . $fileName . '"');
         header('Content-type: ' . $file_info['mime_type']);
         readfile($file_link);
         exit;
     }
     return false;
 }