Figure out if a node can be sent to trash or if it should be directly deleted as objects
containing ezuser attributes can not be sent to trash.

@return bool true if it can go to trash, false if it should be deleted
428329
public function isNodeTrashAllowed()
    {
        $userClassIDArray = eZUser::contentClassIDs();

        $class = $this->attribute( 'object' )->attribute( 'content_class' );

        // If current object has ezuser attributes, it can't be sent to trash
        if ( in_array( $class->attribute( 'id' ), $userClassIDArray ) )
        {
            return false;
        }

        // Checking for children using classes with ezuser attribute. Using == because subTreecount returns strings
        return $this->subTreeCount(
                    array(
                        'Limitation' => array(),
                        'SortBy' => array( 'path' , false ),
                        'IgnoreVisibility' => true,
                        'ClassFilterType' => 'include',
                        'ClassFilterArray' => $userClassIDArray,
                        'AsObject' => false
                    )
                ) == 0 ;
    }
430612
public function isTethered(): bool
    {
        $parent = $this->getParent();
        if ($parent === null) {
            return false;
        }
        if (array_key_exists($this->getName(), $parent->getNodeType()->getAutoCreatedChildNodes())) {
            return true;
        }

        return false;
    }
784652
public function isDeletable(): bool {
		
		$app = Application::getInstance();
		
		if ($this->id == $app->currentUser->id) {
			return FALSE;
		}
		
		return parent::isDeletable();
		
	}
214453
public function delete()
    {
        // we will NOT let you delete the admin user
        if ($this->getUserID() == USER_SUPER_ID) {
            return false;
        }

        // Dispatch an on_user_delete event, that every subscriber can cancel.
        $ue = new DeleteUserEvent($this);
        $ue = $this->getDirector()->dispatch('on_user_delete', $ue);
        if (!$ue->proceed()) {
            return false;
        }

        // Dispatch an on_user_deleted event: subscribers can't cancel this event.
        // This event could be at the end of this method, but let's keep it here so that subscribers
        // can get all the details of the user being deleted.
        $this->getDirector()->dispatch('on_user_deleted', new UserInfoEvent($this));

        $attributes = $this->attributeCategory->getAttributeValues($this->getEntityObject());
        foreach ($attributes as $attribute) {
            $this->attributeCategory->deleteValue($attribute);
        }

        $this->connection->executeQuery('DELETE FROM OauthUserMap WHERE user_id = ?', [(int) $this->getUserID()]);
        $this->connection->executeQuery('DELETE FROM Logs WHERE uID = ?', [(int) $this->getUserID()]);
        $this->connection->executeQuery('DELETE FROM UserSearchIndexAttributes WHERE uID = ?', [(int) $this->getUserID()]);
        $this->connection->executeQuery('DELETE FROM UserGroups WHERE uID = ?', [(int) $this->getUserID()]);
        $this->connection->executeQuery('DELETE FROM UserValidationHashes WHERE uID = ?', [(int) $this->getUserID()]);
        $this->connection->executeQuery('DELETE FROM Piles WHERE uID = ?', [(int) $this->getUserID()]);
        $this->connection->executeQuery('DELETE FROM ConfigStore WHERE uID = ?', [(int) $this->getUserID()]);
        $this->connection->executeQuery('DELETE FROM ConversationSubscriptions WHERE uID = ?', [(int) $this->getUserID()]);
        $this->connection->executeQuery('DELETE FROM PermissionAccessEntityUsers WHERE uID = ?', [(int) $this->getUserID()]);
        $this->connection->executeQuery('DELETE FROM authTypeConcreteCookieMap WHERE uID = ?', [(int) $this->getUserID()]);

        // Conversation messages and ratings should be detached from the user
        $this->connection->executeQuery('UPDATE ConversationMessages SET uID = 0, cnvMessageAuthorName = NULL, cnvMessageAuthorEmail = NULL, cnvMessageAuthorWebsite = NULL, cnvMessageSubmitIP = NULL, cnvMessageSubmitUserAgent = NULL WHERE uID = ?', [(int) $this->getUserID()]);
        $this->connection->executeQuery('UPDATE ConversationMessageRatings SET cnvMessageRatingIP = NULL, uID = 0 WHERE uID = ?', [(int) $this->getUserID()]);

        // Public file sets should be detached from the user
        $this->connection->executeQuery('UPDATE FileSets SET uID = 0 WHERE uID = ? AND fsType = ?', [
            (int) $this->getUserID(),
            \Concrete\Core\File\Set\Set::TYPE_PUBLIC,
        ]);

        // Delete private file sets from this user
        foreach (\Concrete\Core\File\Set\Set::getOwnedSets($this) as $set) {
            $set->delete();
        }



        $this->connection->executeQuery('UPDATE Blocks set uID = ? WHERE uID = ?', [(int) USER_SUPER_ID, (int) $this->getUserID()]);
        $this->connection->executeQuery('UPDATE Pages set uID = ? WHERE uID = ?', [(int) USER_SUPER_ID, (int) $this->getUserID()]);
        $this->connection->executeQuery('UPDATE DownloadStatistics set uID = 0 WHERE uID = ?', [(int) $this->getUserID()]);

        // We need to clear out the doctrine proxies for userSignups or we will get a Doctrine Error
        /** @var \Concrete\Core\Entity\User\UserSignup[] $userSignups */
        $userSignups = $this->entityManager->getRepository(\Concrete\Core\Entity\User\UserSignup::class)->findBy(['createdBy'=>(int) $this->getUserID()]);
        $superAdminEntity = $this->entityManager->getRepository(UserEntity::class)->find((int) USER_SUPER_ID);

        foreach ($userSignups as $userSignup) {
            // If there is no SuperAdmin Just remove the relatedUserSignups
            if (is_object($superAdminEntity)) {
                $userSignup->setCreatedBy($superAdminEntity);
                $this->entityManager->persist($userSignup);
            } else {
                $this->entityManager->remove($userSignup);
            }

        }

        $this->entityManager->remove($this->entity);
        $this->entityManager->flush();

        return true;
    }
107063
public function cleanTrash()
	{
		$response = $this->send(new Request($this->uri->withPath($this->uri->getPath().'trash/resources'), 'DELETE'));

		if ($response->getStatusCode() == 204)
		{
			$response = json_decode($response->getBody(), true);

			if ( ! empty($response['operation']))
			{
				return $response['operation'];
			}

			return true;
		}

		return false;
	}
310180
public function deletedBecauseEmpty()
    {
        if ($file = $this->getAttributeValue('file')) {
            return false;
        }

        if ($this->exists) {
            $this->delete();
        }

        return true;
    }
1090018
public function canSave()
    {
        if($this->getRequest()->getFormat() == 'html')
        {
            if($this->getModel()->getState()->isUnique())
            {
                if($this->canEdit() && !$this->isLocked()) {
                    return true;
                }
            }
            else
            {
                if($this->canAdd()) {
                    return true;
                }
            }
        }

        return false;
    }
1013305
protected function performDeleteOnModel()
    {
        $results = $this->makeRequest($this->getEndpoint(), 'destroy', [
            $this->getKey()
        ]);

        // Creation failed
        if (!$results) {
            return false;
        }

        return true;
    }
1203311
public function MoveToRoot()
	{
		if ( is_null( $this->domNode ) ) return false;

		// Already at the root?
		if ( $this->domNode->nodeType == XML_DOCUMENT_NODE ) return true;

		$this->domNode = $this->domNode->ownerDocument;
		return true;
	}
678781
public function delete()
	{
		if ( ! $this->is_loaded() ) return false;

		$error = wp_delete_post( $this->attributes['ID'], $this->forceDelete );

		return $error !== false;
	}
511932
public function destroy()
	{
		// If it has an associated asset entry, try deleting that first
		if ($this->hasAttribute('asset_id'))
		{
			if (!Asset::destroy($this))
			{
				return false;
			}
		}

		\Event::trigger('system.onContentDestroy', array($this->getTableName(), $this));
		return $this->query->remove(
			$this->getTableName(),
			$this->getPrimaryKey(),
			$this->getPkValue()
		);
	}
492198
public function check(): bool
    {
        $path = \app()->storagePath();

        $this->description = Str::replace($this->description, \compact('path'));

        return $this->checkPathIsWritable($path);
    }
272385
public function delete()
    {
        $this->exitIfModelNotSet();

        $params = [
            'id'    => $this->model->getKey(),
            'type'  => $this->model->getDocumentType(),
            'index' => $this->model->getDocumentIndex(),
        ];

        // check if the document exists before deleting
        if ($this->connection->existsStatement($params)) {
            return $this->connection->deleteStatement($params);
        }

        return true;
    }
476342
public function purgeAttributes()
    {
        // Get the attribute keys
        $keys = array_keys($this->getAttributes());

        // Filter out keys that should purged
        $attributes = array_filter($keys, function ($key) {
            // Remove attributes that should be purged
            if (in_array($key, $this->getPurgeable())) {
                return false;
            }

            // Remove attributes ending with _confirmation
            if (Str::endsWith($key, '_confirmation')) {
                return false;
            }

            // Remove attributes starting with _ prefix
            if (Str::startsWith($key, '_')) {
                return false;
            }

            return true;
        });

        // Keep only the attributes that were not purged
        $this->attributes = array_intersect_key($this->getAttributes(), array_flip($attributes));
    }
938728
public function canApply()
    {
        $subject = $this->getSubject();
        $nodeType = $this->getNodeType();

        return $subject->isNodeTypeAllowedAsChildNode($nodeType);
    }
1002224
public static function isTrash()
    {
        $nodes = explode('/', request()->path());
        $last_node = current(array_values(array_slice($nodes, -1)));
        return ($last_node === 'trash');
    }
33618
public function destroy()
	{
		$data = $this->toArray();

		// Trigger the onUserBeforeDelete event
		Event::trigger('user.onUserBeforeDelete', array($data));

		// Remove associated data
		if ($this->reputation->get('id'))
		{
			if (!$this->reputation->destroy())
			{
				$this->addError($this->reputation->getError());
				return false;
			}
		}

		foreach ($this->tokens()->rows() as $token)
		{
			if (!$token->destroy())
			{
				$this->addError($token->getError());
				return false;
			}
		}

		Map::destroyByUser($this->get('id'));

		// Attempt to delete the record
		$result = parent::destroy();

		if ($result)
		{
			// Trigger the onUserAfterDelete event
			Event::trigger('user.onUserAfterDelete', array($data, true, $this->getError()));
		}

		return $result;
	}