Delete resource link share key object.

@param ResourceLinkShareKey $shareKey Resource link share key object

@return boolean True if the resource link share key object was successfully deleted
171789
public function deleteResourceLinkShareKey($shareKey)
    {

        $id = $shareKey->getId();
        $sql = "DELETE FROM {$this->dbTableNamePrefix}" . DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . ' WHERE share_key_id = :id';
        $query = $this->db->prepare($sql);
        $query->bindValue('id', $id, PDO::PARAM_STR);
        $ok = $query->execute();

        if ($ok) {
            $shareKey->initialize();
        }

        return $ok;

    }
503979
public function delete($key) {
        $filename = $this->getFileName($key);
        if (file_exists($filename)) {
            return unlink($filename);
        }else{
            return false;
        }
    }
90286
public static ssl_key delete(nitro_service client, ssl_key resource) throws Exception
	{
		resource.validate("delete");
		return ((ssl_key[]) resource.delete_resource(client))[0];
	}
907039
public function loadResourceLinkShareKey($sharekey) {
        global $DB;

        // Clear expired share keys.
        $now = time();
        $where = "expires <= :expires";

        $DB->delete_records_select($this->sharekeytable, $where, ['expires' => $now]);

        // Load share key.
        $fields = 'resourcelinkid, autoapprove, expires';
        if ($sharekeyrecord = $DB->get_record($this->sharekeytable, ['sharekey' => $sharekey->getId()], $fields)) {
            if ($sharekeyrecord->resourcelinkid == $sharekey->resourceLinkId) {
                $sharekey->autoApprove = $sharekeyrecord->autoapprove == 1;
                $sharekey->expires = $sharekeyrecord->expires;
                return true;
            }
        }

        return false;
    }
1093262
public function drop($key) {
        $fileName = $this->getFilePath($key);

        if (is_file($fileName)) {
            if (unlink($fileName)) {
                clearstatcache();

                $this->getReferencePool()->drop($key);
                return true;
            }
            throw new RuntimeException('Cannot delete file: '.$fileName);
        }

        return false;
    }
198743
public function deleteResource(PersistentResource $resource)
    {
        $this->s3Client->deleteObject(array(
            'Bucket' => $this->bucketName,
            'Key' => $this->keyPrefix . $resource->getSha1()
        ));
        return true;
    }
928988
public function delete($remote_path, $recursive = false)
    {
        if (null === $this->_sftp_resource) {
            throw new TransportException(sprintf('None SSH connection available.'));
        }

        if (true === $recursive) {
            // @todo
            throw new TransportException(sprintf('REcursive option not implemented yet.'));
        }

        $remote_path = $this->_getAbsoluteRemotePath($remote_path);
        if (false === @ssh2_sftp_stat($this->_sftp_resource, $remote_path)) {
            return $this->_trigger_error(sprintf('Remote file to delete does not exist: %s.', $remote_path));
        }

        if (false === ssh2_sftp_unlink($this->_sftp_resource, $remote_path)) {
            return ssh2_sftp_rmdir($this->_sftp_resource, $remote_path);
        }

        return true;
    }
118404
public function deleteByKey(string $key): bool
    {
        if (!$this->users_id) {
            throw new Exception('No users is set to save config');
        }

        if ($config = $this->findFirst(['conditions' => 'users_id = ?0 and name = ?1', 'bind' => [$this->users_id, $key]])) {
            return $config->delete();
        }

        return false;
    }
722425
public function delete(string $key): bool
    {
        Redis::delete(self::PREFIX . $key);
        return parent::delete($key);
    }
702111
public function saveResourceLinkShareKey($shareKey)
    {

        if ($shareKey->autoApprove) {
            $approve = 1;
        } else {
            $approve = 0;
        }
        $expires = date("{$this->dateFormat} {$this->timeFormat}", $shareKey->expires);
        $sql = sprintf("INSERT INTO {$this->dbTableNamePrefix}" . DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . ' ' .
                       '(share_key_id, resource_link_pk, auto_approve, expires) ' .
                       "VALUES (%s, %d, {$approve}, '{$expires}')",
                       DataConnector::quoted($shareKey->getId()), $shareKey->resourceLinkId);
        $ok = mysql_query($sql);

        return $ok;

    }
335277
public function removeDir($key, $recursive = false)
    {
        $query = ['dir' => 'true'];

        if ($recursive === true) {
            $query['recursive'] = 'true';
        }

        return $this->httpDelete($this->server . $this->getKeyPath($key), $query);
    }
766842
public function delete($key)
    {
        $role   =   $this->findByKey($key);
        if (! isset($role)) {
            return true;
        }

        return $role->delete();
    }
288929
public function decryptStringRequestWithSharedKey(
        RequestInterface $request,
        SharedEncryptionKey $key
    ): string {
        return Simple::decrypt(
            (string) $request->getBody(),
            $key
        );
    }
391807
public function loadResourceLinkShareKey($shareKey)
    {

        $ok = false;

// Clear expired share keys
        $now = date("{$this->dateFormat} {$this->timeFormat}", time());
        $sql = "DELETE FROM {$this->dbTableNamePrefix}" . DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . " WHERE expires <= '{$now}'";
        mysql_query($sql);

// Load share key
        $id = mysql_real_escape_string($shareKey->getId());
        $sql = 'SELECT resource_link_pk, auto_approve, expires ' .
               "FROM {$this->dbTableNamePrefix}" . DataConnector::RESOURCE_LINK_SHARE_KEY_TABLE_NAME . ' ' .
               "WHERE share_key_id = '{$id}'";
        $rsShareKey = mysql_query($sql);
        if ($rsShareKey) {
            $row = mysql_fetch_object($rsShareKey);
            if ($row && (intval($row->resource_link_pk) === $shareKey->resourceLinkId)) {
                $shareKey->autoApprove = (intval($row->auto_approve) === 1);
                $shareKey->expires = strtotime($row->expires);
                $ok = true;
            }
        }

        return $ok;

    }
835707
public function getSharesResourceLink($resourceLink)
    {

        $id = $resourceLink->getRecordId();

        $shares = array();

        $sql = 'SELECT consumer_pk, resource_link_pk, share_approved ' .
               "FROM {$this->dbTableNamePrefix}" . DataConnector::RESOURCE_LINK_TABLE_NAME . ' ' .
               'WHERE (primary_resource_link_pk = :id) ' .
               'ORDER BY consumer_pk';
        $query = $this->db->prepare($sql);
        $query->bindValue('id', $id, PDO::PARAM_INT);
        if ($query->execute()) {
            while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
                $row = array_change_key_case($row);
                $share = new ToolProvider\ResourceLinkShare();
                $share->resourceLinkId = intval($row['resource_link_pk']);
                $share->approved = (intval($row['share_approved']) === 1);
                $shares[] = $share;
            }
        }

        return $shares;

    }
679877
public function delete(ResourceNode $resourceNode, $force = false, $softDelete = false)
    {
        $this->log('Removing '.$resourceNode->getName().'['.$resourceNode->getResourceType()->getName().':id:'.$resourceNode->getId().']');

        if (null === $resourceNode->getParent() && !$force) {
            throw new \LogicException('Root directory cannot be removed');
        }

        $workspace = $resourceNode->getWorkspace();
        $nodes = $this->getDescendants($resourceNode);
        $nodes[] = $resourceNode;
        $this->om->startFlushSuite();
        $this->log('Looping through '.count($nodes).' children...');

        foreach ($nodes as $node) {
            $eventSoftDelete = false;
            $this->log('Removing '.$node->getName().'['.$node->getResourceType()->getName().':id:'.$node->getId().']');
            $resource = $this->getResourceFromNode($node);
            /*
             * resChild can be null if a shortcut was removed
             *
             * activities must be ignored atm
             */

            $ignore = ['activity'];

            if (null !== $resource) {
                if (!$softDelete && !in_array($node->getResourceType()->getName(), $ignore)) {
                    $event = $this->dispatcher->dispatch(
                        "delete_{$node->getResourceType()->getName()}",
                        'Resource\DeleteResource',
                        [$resource, $softDelete]
                    );
                    $eventSoftDelete = $event->isSoftDelete();

                    foreach ($event->getFiles() as $file) {
                        if ($softDelete) {
                            $parts = explode(
                                $this->filesDirectory.DIRECTORY_SEPARATOR,
                                $file
                            );

                            if (2 === count($parts)) {
                                $deleteDir = $this->filesDirectory.
                                    DIRECTORY_SEPARATOR.
                                    'DELETED_FILES';
                                $dest = $deleteDir.
                                    DIRECTORY_SEPARATOR.
                                    $parts[1];
                                $additionalDirs = explode(DIRECTORY_SEPARATOR, $parts[1]);

                                for ($i = 0; $i < count($additionalDirs) - 1; ++$i) {
                                    $deleteDir .= DIRECTORY_SEPARATOR.$additionalDirs[$i];
                                }

                                if (!is_dir($deleteDir)) {
                                    mkdir($deleteDir, 0777, true);
                                }
                                rename($file, $dest);
                            }
                        } else {
                            unlink($file);
                        }

                        //It won't work if a resource has no workspace for a reason or an other. This could be a source of bug.
                        $dir = $this->filesDirectory.
                            DIRECTORY_SEPARATOR.
                            'WORKSPACE_'.
                            $workspace->getId();

                        if (is_dir($dir) && $this->isDirectoryEmpty($dir)) {
                            rmdir($dir);
                        }
                    }
                } elseif ($softDelete && !in_array($node->getResourceType()->getName(), $ignore)) {
                    $this->dispatcher->dispatch(
                        "resource.{$node->getResourceType()->getName()}.soft_delete",
                        'Resource\SoftDeleteResource',
                        [$resource]
                    );
                }

                if ($softDelete || $eventSoftDelete) {
                    $node->setActive(false);
                    // Rename node to allow future nodes have the same name
                    $node->setName($node->getName().uniqid('_'));
                    $this->om->persist($node);
                } else {
                    //what is it ?
                    $this->dispatcher->dispatch(
                        'claroline_resources_delete',
                        'GenericData',
                        [[$node]]
                    );

                    /*
                     * If the child isn't removed here aswell, doctrine will fail to remove $resChild
                     * because it still has $resChild in its UnitOfWork or something (I have no idea
                     * how doctrine works tbh). So if you remove this line the suppression will
                     * not work for directory containing children.
                     */
                    $this->om->remove($resource);
                    $this->om->remove($node);
                }

                $this->dispatcher->dispatch(
                    'log',
                    'Log\LogResourceDelete',
                    [$node]
                );
            } else {
                if ($softDelete || $eventSoftDelete) {
                    $node->setActive(false);
                    // Rename node to allow future nodes have the same name
                    $node->setName($node->getName().uniqid('_'));
                    $this->om->persist($node);
                } else {
                    //what is it ?
                    $this->dispatcher->dispatch(
                        'claroline_resources_delete',
                        'GenericData',
                        [[$node]]
                    );

                    $this->om->remove($node);
                }

                $this->dispatcher->dispatch(
                    'log',
                    'Log\LogResourceDelete',
                    [$node]
                );
            }
        }

        $this->om->endFlushSuite();
    }
1041303
public function delete($key)
    {
        if (empty($this->memcache)) {
            return false;
        }

        $key = $this->processKey($key);

        return $this->memcache->delete($key);
    }