applications/vanilla/controllers/class.draftscontroller.php
public function Delete($DraftID = '', $TransientKey = '') {
      $Form = Gdn::Factory('Form');
      $Session = Gdn::Session();
      if (
         is_numeric($DraftID)
         && $DraftID > 0
         && $Session->UserID > 0
         && $Session->ValidateTransientKey($TransientKey)
      ) {
         // Delete the draft
         $Draft = $this->DraftModel->GetID($DraftID);
         if ($Draft && !$this->DraftModel->Delete($DraftID))
            $Form->AddError('Failed to delete discussion');
      } else {
         // Log an error
         $Form->AddError('ErrPermission');
      }
      
      // Redirect
      if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
         $Target = GetIncomingValue('Target', '/vanilla/drafts');
         Redirect($Target);
      }
      
      // Return any errors  
      if ($Form->ErrorCount() > 0)
         $this->SetJson('ErrorMessage', $Form->Errors());
      
      // Render default view
      $this->Render();         
   }
public function Delete($DraftID = '', $TransientKey = '') {
      $Form = Gdn::Factory('Form');
      $Session = Gdn::Session();
      if (
         is_numeric($DraftID)
         && $DraftID > 0
         && $Session->UserID > 0
         && $Session->ValidateTransientKey($TransientKey)
      ) {
         // Delete the draft
         $Draft = $this->DraftModel->GetID($DraftID);
         if ($Draft && !$this->DraftModel->Delete($DraftID))
            $Form->AddError('Failed to delete discussion');
      } else {
         // Log an error
         $Form->AddError('ErrPermission');
      }
      
      // Redirect
      if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
         $Target = GetIncomingValue('Target', '/vanilla/drafts');
         Redirect($Target);
      }
      
      // Return any errors  
      if ($Form->ErrorCount() > 0)
         $this->SetJson('ErrorMessage', $Form->Errors());
      
      // Render default view
      $this->Render();         
   }
public function Delete ( $ DraftID = '' , $ TransientKey = '' ) { $ Form = Gdn :: Factory ( 'Form' ) ; $ Session = Gdn :: Session ( ) ; if ( is_numeric ( $ DraftID ) && $ DraftID > 0 && $ Session -> UserID > 0 && $ Session -> ValidateTransientKey ( $ TransientKey ) ) { // Delete the draft $ Draft = $ this -> DraftModel -> GetID ( $ DraftID ) ; if ( $ Draft && ! $ this -> DraftModel -> Delete ( $ DraftID ) ) $ Form -> AddError ( 'Failed to delete discussion' ) ; } else { // Log an error $ Form -> AddError ( 'ErrPermission' ) ; } // Redirect if ( $ this -> _DeliveryType === DELIVERY_TYPE_ALL ) { $ Target = GetIncomingValue ( 'Target' , '/vanilla/drafts' ) ; Redirect ( $ Target ) ; } // Return any errors   if ( $ Form -> ErrorCount ( ) > 0 ) $ this -> SetJson ( 'ErrorMessage' , $ Form -> Errors ( ) ) ; // Render default view $ this -> Render ( ) ; }
Delete a single draft.

Redirects user back to Index unless DeliveryType is set.

@since 2.0.0
@access public

@param int $DraftID Unique ID of draft to be deleted.
@param string $TransientKey Single-use hash to prove intent.
Delete a single draft .