Example #1
0
 public function Delete($DraftID = '', $TransientKey = '')
 {
     $Form = new Form();
     $Session = Gdn::Session();
     if (is_numeric($DraftID) && $DraftID > 0 && $Session->UserID > 0 && $Session->ValidateTransientKey($TransientKey)) {
         $Draft = $this->DraftModel->GetID($DraftID);
         if ($Draft && !$this->DraftModel->Delete($DraftID)) {
             $Form->AddError('Failed to delete discussion');
         }
     } else {
         $Form->AddError('ErrPermission');
     }
     // Redirect
     if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
         $Target = GetIncomingValue('Target', '/vanilla/drafts');
         Redirect($Target);
     }
     if ($Form->ErrorCount() > 0) {
         $this->SetJson('ErrorMessage', $Form->Errors());
     }
     $this->Render();
 }