protected function SetupAttachment() { // Lookup Object PK information from Query String (if applicable) // Set mode to Edit or New depending on what's found $intAttachmentId = QApplication::QueryString('intAttachmentId'); if ($intAttachmentId) { $this->objAttachment = Attachment::Load($intAttachmentId); if (!$this->objAttachment) { throw new Exception('Could not find a Attachment object with PK arguments: ' . $intAttachmentId); } $this->strTitleVerb = QApplication::Translate('Edit'); $this->blnEditMode = true; } else { $this->objAttachment = new Attachment(); $this->strTitleVerb = QApplication::Translate('Create'); $this->blnEditMode = false; } }
public function lblDelete_Click($strFormId, $strControlId, $strParameter) { $objAttachment = Attachment::Load($strParameter); if (AWS_S3) { require __DOCROOT__ . __PHP_ASSETS__ . '/s3.class.php'; $objS3 = new S3(); $objS3->deleteObject('attachments/' . $objAttachment->TmpFilename, AWS_BUCKET); } else { if (file_exists($objAttachment->Path)) { unlink($objAttachment->Path); } } $objAttachment->Delete(); if ($this->objParentControl) { $this->objParentControl->pnlAttachments_Create(); } else { $this->objForm->pnlAttachments_Create(); } }
public function lblDelete_Click($strFormId, $strControlId, $strParameter) { $objAttachment = Attachment::Load($strParameter); if (AWS_S3) { require __DOCROOT__ . __PHP_ASSETS__ . '/S3.php'; $objS3 = new S3(AWS_ACCESS_KEY, AWS_SECRET_KEY); $strS3Path = AWS_PATH != '' ? ltrim(AWS_PATH, '/') . '/' : ''; $objS3->deleteObject(AWS_BUCKET, $strS3Path . 'attachments/' . $objAttachment->TmpFilename); } else { if (file_exists($objAttachment->Path)) { unlink($objAttachment->Path); } } $objAttachment->Delete(); if ($this->objParentControl) { $this->objParentControl->pnlAttachments_Create(); } else { $this->objForm->pnlAttachments_Create(); } }
public static function ExportToCSV($arrHiddenFields = array()) { $strReturn = ''; $arrEntries = FBContestApplication::GetContestEntries(); $objEntry = $arrEntries[0]; $arrFields = $objEntry->GetContestFormAnswerAsIdArray(); foreach ($arrFields as $intFieldIndex => $objField) { if (!array_search($objField->name, $arrHiddenFields)) { $strReturn .= $objField->name . ','; } } $strReturn = substr($strReturn, 0, strlen($strReturn) - 1); $strReturn .= "\n"; foreach ($arrEntries as $intIndex => $objEntry) { if ($intIndex != 0) { $arrFields = $objEntry->GetContestFormAnswerAsIdArray(); } foreach ($arrFields as $intFieldIndex => $objField) { if (!array_search($objField->name, $arrHiddenFields)) { switch ($objField->idContestFormFieldType) { case MFBContestFormFieldType::Select: case MFBContestFormFieldType::Text: case MFBContestFormFieldType::LongText: $strReturn .= $objField->value . ','; break; case MFBContestFormFieldType::Upload: $objAttachment = Attachment::Load($objField->value); if (!is_null($objAttachment)) { $strReturn .= AWS_BUCKET_URL . DS . AWS_BUCKET_NAME . DS . $objAttachment->value . ','; } break; } } } $strReturn = substr($strReturn, 0, strlen($strReturn) - 1); $strReturn .= "\n"; } return $strReturn; }
/** * Static Helper Method to Create using PK arguments * You must pass in the PK arguments on an object to load, or leave it blank to create a new one. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to * edit, or if we are also allowed to create a new one, etc. * * @param mixed $objParentObject QForm or QPanel which will be using this AttachmentMetaControl * @param integer $intAttachmentId primary key value * @param QMetaControlCreateType $intCreateType rules governing Attachment object creation - defaults to CreateOrEdit * @return AttachmentMetaControl */ public static function Create($objParentObject, $intAttachmentId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intAttachmentId)) { $objAttachment = Attachment::Load($intAttachmentId); // Attachment was found -- return it! if ($objAttachment) { return new AttachmentMetaControl($objParentObject, $objAttachment); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a Attachment object with PK arguments: ' . $intAttachmentId); } } // If EditOnly is specified, throw an exception } else { if ($intCreateType == QMetaControlCreateType::EditOnly) { throw new QCallerException('No PK arguments specified'); } } // If we are here, then we need to create a new record return new AttachmentMetaControl($objParentObject, new Attachment()); }
* Tracmor is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Tracmor is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Tracmor; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once '../prepend.inc.php'; $objAttachment = Attachment::Load($_GET['attachment_id']); // Check that the filenames exist if ($objAttachment->TmpFilename == $_GET['tmp_filename']) { header("Pragma: hack"); // IE chokes on "no cache", so set to something, anything, else. header("Content-Type: " . $objAttachment->FileType); header("Content-Length:" . $objAttachment->Size); header("Content-Disposition: attachment; filename=" . $objAttachment->Filename); header("Content-Transfer-Encoding: binary"); ob_clean(); ob_end_flush(); readfile($objAttachment->Path); exit; } else { echo "HACKING ATTEMPT"; exit;
/** * Reload this Attachment from the database. * @return void */ public function Reload() { // Make sure we are actually Restored from the database if (!$this->__blnRestored) { throw new QCallerException('Cannot call Reload() on a new, unsaved Attachment object.'); } // Reload the Object $objReloaded = Attachment::Load($this->intAttachmentId); // Update $this's local variables to match $this->EntityQtypeId = $objReloaded->EntityQtypeId; $this->intEntityId = $objReloaded->intEntityId; $this->strFilename = $objReloaded->strFilename; $this->strTmpFilename = $objReloaded->strTmpFilename; $this->strFileType = $objReloaded->strFileType; $this->strPath = $objReloaded->strPath; $this->intSize = $objReloaded->intSize; $this->CreatedBy = $objReloaded->CreatedBy; $this->dttCreationDate = $objReloaded->dttCreationDate; }
public function btnEdit_Click($strFormId, $strControlId, $strParameter) { $strParameterArray = explode(',', $strParameter); $objAttachment = Attachment::Load($strParameterArray[0]); $objEditPanel = new AttachmentEditPanel($this, $this->strCloseEditPanelMethod, $objAttachment); $strMethodName = $this->strSetEditPanelMethod; $this->objForm->{$strMethodName}($objEditPanel); }