/**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // check permission
     WCF::getUser()->checkPermission('admin.attachment.canDeleteAttachment');
     // delete warning
     $this->attachment->delete();
     $this->executed();
     // forward to list page
     if (!empty($this->url)) {
         HeaderUtil::redirect($this->url . '&deletedAttachmentID=' . $this->attachmentID . SID_ARG_2ND_NOT_ENCODED);
     } else {
         HeaderUtil::redirect('index.php?page=AdminAttachmentListPage&deletedAttachmentID=' . $this->attachmentID . '&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED);
     }
     exit;
 }
 /**
  * Creates a new attachments.
  *
  * @param	string		$file
  * @param	array		$attachmentData
  * @return	AttachmentEditor
  */
 public static function create($file, $attachmentData)
 {
     $attachmentData['isBinary'] = 1;
     if (!$attachmentData['isImage']) {
         $attachmentData['isBinary'] = (int) FileUtil::isBinary($file);
     }
     // insert attachment
     $attachmentID = self::insert($attachmentData);
     $attachmentData['attachmentID'] = $attachmentID;
     $attachment = new AttachmentEditor(null, $attachmentData);
     // copy tmp file to /attachments folders
     try {
         $path = WCF_DIR . 'attachments/attachment-' . $attachmentID;
         if (!@move_uploaded_file($file, $path)) {
             throw new SystemException();
         }
         @chmod($path, 0777);
     } catch (SystemException $e) {
         // could not copy uploaded file, rollback insert statement
         $attachment->delete();
         return null;
     }
     return $attachment;
 }
 /**
  * @see AbstractLostAndFounDatabaseItem::delete	 
  */
 public function delete()
 {
     $editor = new AttachmentEditor($this->objectID);
     $editor->delete();
 }