コード例 #1
0
                    $oAttachment->Set('item_class', $sObjClass);
                    $oAttachment->SetDefaultOrgId();
                    $oAttachment->Set('contents', $oDoc);
                    $iAttId = $oAttachment->DBInsert();
                    $aResult['msg'] = $oDoc->GetFileName();
                    $aResult['icon'] = utils::GetAbsoluteUrlAppRoot() . AttachmentPlugIn::GetFileIcon($oDoc->GetFileName());
                    $aResult['att_id'] = $iAttId;
                    $aResult['preview'] = $oDoc->IsPreviewAvailable() ? 'true' : 'false';
                } catch (FileUploadException $e) {
                    $aResult['error'] = $e->GetMessage();
                }
            }
            $oPage->add(json_encode($aResult));
            break;
        case 'remove':
            $iAttachmentId = utils::ReadParam('att_id', '');
            $oSearch = DBObjectSearch::FromOQL("SELECT Attachment WHERE id = :id");
            $oSet = new DBObjectSet($oSearch, array(), array('id' => $iAttachmentId));
            while ($oAttachment = $oSet->Fetch()) {
                $oAttachment->DBDelete();
            }
            break;
        default:
            $oPage->p("Missing argument 'operation'");
    }
    $oPage->output();
} catch (Exception $e) {
    // note: transform to cope with XSS attacks
    echo htmlentities($e->GetMessage(), ENT_QUOTES, 'utf-8');
    IssueLog::Error($e->getMessage());
}
コード例 #2
0
 /**
  * Helper to download the file directly from the browser	
  */
 public function DownloadBackup($sFile)
 {
     $oP = new ajax_page('backup');
     $oP->SetContentType("multipart/x-zip");
     $oP->SetContentDisposition('inline', basename($sFile));
     $oP->add(file_get_contents($sFile));
     $oP->output();
 }