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.
518349
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();         
   }
399382
def remove_draft_child(self):
        """"""
        if self.draft_child:
            with db.session.begin_nested():
                super(PIDNodeVersioning, self).remove_child(self.draft_child,
                                                            reorder=True)
947702
public function deleteEntry($dn)
    {
        if (! (@ldap_delete($this->connection, $dn))) {
            $code = @ldap_errno($this->connection);
            throw new PersistenceException(
                sprintf(
                    'Could not delete entry %s: Ldap Error Code=%s - %s',
                    $dn,
                    $code,
                    ldap_err2str($code)
                )
            );
        }
    }
905663
function del($key)
    {
        parent::del($key);


        $realm = $this->getRealm();

        try {

            $sql = "DELETE FROM `KVStore` WHERE `realm` = '$realm' and `key` = '$key';";
            $this->pdo->exec($sql);

        } catch (\Exception $e) {
            throw new exWriteError($e->getMessage(), $e->getCode(), $e);
        }
    }
835070
public void deleteSSHKey(Integer targetUserId, Integer targetKeyId) throws IOException {
        String tailUrl = GitlabUser.USERS_URL + "/" + targetUserId + GitlabSSHKey.KEYS_URL + "/" + targetKeyId;
        retrieve().method(DELETE).to(tailUrl, Void.class);
    }
541895
public function SignOut($TransientKey = "") {
      $this->CheckOverride('SignOut', $this->Target(), $TransientKey);
      
      if (Gdn::Session()->ValidateTransientKey($TransientKey) || $this->Form->IsPostBack()) {
         $User = Gdn::Session()->User;
         
         $this->EventArguments['SignoutUser'] = $User;
         $this->FireEvent("BeforeSignOut");
         
         // Sign the user right out.
         Gdn::Session()->End();
         $this->SetData('SignedOut', TRUE);
         
         $this->EventArguments['SignoutUser'] = $User;
         $this->FireEvent("SignOut");
         
         $this->_SetRedirect();
      } elseif (!Gdn::Session()->IsValid())
         $this->_SetRedirect();
      
      $this->SetData('Target', $this->Target());
      $this->Leaving = FALSE;
      $this->Render();
   }
1141916
public function delete($key)
    {
		if (! $key || ! is_string($key)) {
			throw new InvalidArgumentException('Invalid cache key');
		}

		$transientKey = $this->generateTransientKey($key);
		delete_transient($transientKey);
	}
434857
public function SendInvite($InvitationID = '', $TransientKey = '') {
      $this->Permission('Garden.SignIn.Allow');
      $InvitationModel = new InvitationModel();
      $Session = Gdn::Session();
      if ($Session->ValidateTransientKey($TransientKey)) {
         try {
            $Email = new Gdn_Email();
            $InvitationModel->Send($InvitationID, $Email);
         } catch (Exception $ex) {
            $this->Form->AddError(strip_tags($ex->getMessage()));
         }
         if ($this->Form->ErrorCount() == 0)
            $this->InformMessage(T('The invitation was sent successfully.'));

      }
      
      $this->View = 'Invitations';
      $this->Invitations();
   }
782967
public function Delete($ActivityID = '', $TransientKey = '') {
      $Session = Gdn::Session();
      if (!$Session->ValidateTransientKey($TransientKey))
         throw PermissionException();
      
      if (!is_numeric($ActivityID))
         throw Gdn_UserException('Invalid activity ID');
      
      
      $HasPermission = $Session->CheckPermission('Garden.Activity.Delete');
      if (!$HasPermission) {
         $Activity = $this->ActivityModel->GetID($ActivityID);
         if (!$Activity)
            throw NotFoundException('Activity');
         $HasPermission = $Activity['InsertUserID'] == $Session->UserID;
      }
      if (!$HasPermission)
         throw PermissionException();

      $this->ActivityModel->Delete($ActivityID);
      
      if ($this->_DeliveryType === DELIVERY_TYPE_ALL)
         Redirect(GetIncomingValue('Target', $this->SelfUrl));
      
      // Still here? Getting a 404.
      $this->ControllerName = 'Home';
      $this->View = 'FileNotFound';
      $this->Render();
   }
1200317
public function deleteAction($key, $type)
    {
        $this->storageRepository->remove($type, $key);
        $this->generateAction();
        $this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.content.deletedcontentelement',
            'mask'));
        $this->redirect('list');
    }
389035
public static void deleteQueue(DbConn cnx, int id)
    {
        int countRunning = cnx.runSelectSingle("ji_select_count_by_queue", Integer.class, id);
        if (countRunning > 0)
        {
            cnx.setRollbackOnly();
            throw new JqmAdminApiUserException(
                    "cannot delete a queue with running instances. Disable it, wait for the end of all running instances, then retry.");
        }

        cnx.runUpdate("dp_delete_for_queue", id);
        QueryResult qr = cnx.runUpdate("q_delete_by_id", id);
        if (qr.nbUpdated != 1)
        {
            cnx.setRollbackOnly();
            throw new JqmAdminApiUserException("no item with ID " + id);
        }
    }
931245
private function revertPostProcess(AbstractClassContent $content, Revision $draft)
    {
        $data = $draft->jsonSerialize();

        if (
            0 === count($data['parameters'])
            && (
                0 === count($data['elements'])
                || (
                    $content instanceof ContentSet
                    && $data['elements']['current'] === $data['elements']['draft']
                )
            )
        ) {
            if ($content instanceof ContentSet) {
                $draft->clear();
            }

            if (AbstractClassContent::STATE_NEW === $content->getState()) {
                $classname = AbstractClassContent::getClassnameByContentType($content->getContentType());
                $this->entityManager->getRepository($classname)->deleteContent($content);
            } else {
                $this->entityManager->remove($draft);
            }
        }

        return $this;
    }
896886
@Transactional
  @DeleteMapping("/{entityTypeId}/{id}")
  @ResponseStatus(NO_CONTENT)
  public void deleteDelete(
      @PathVariable("entityTypeId") String entityTypeId, @PathVariable("id") String untypedId) {
    delete(entityTypeId, untypedId);
  }
424673
private void removeSessionTicket(final String id) {
        val ticketId = TransientSessionTicketFactory.normalizeTicketId(id);
        this.ticketRegistry.deleteTicket(ticketId);
    }
450382
public static MozuUrl deleteOrderDraftUrl(String orderId, String version)
	{
		UrlFormatter formatter = new UrlFormatter("/api/commerce/orders/{orderId}/draft?version={version}");
		formatter.formatUrl("orderId", orderId);
		formatter.formatUrl("version", version);
		return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
	}
163025
public function RemoveLogo($TransientKey = '') {
      $Session = Gdn::Session();
      if ($Session->ValidateTransientKey($TransientKey) && $Session->CheckPermission('Garden.Settings.Manage')) {
         $Logo = C('Garden.Logo', '');
         RemoveFromConfig('Garden.Logo');
         @unlink(PATH_ROOT . DS . $Logo);
      }

      Redirect('/settings/banner');
   }
362593
public function deleteByEntryId($entryId)
    {
        $entryId = (int) $entryId;
        if ($entryId >= 2) {
            $entry = $this->getByEntryId($entryId);
            if ($entry instanceof AcumulusEntry) {
                return $this->delete($entry);
            }
        }
        return true;
    }