public function rename($hash, $name)
{
if ($this->commandDisabled('rename')) {
return $this->setError(elFinder::ERROR_PERM_DENIED);
}
if (!$this->nameAccepted($name)) {
return $this->setError(elFinder::ERROR_INVALID_NAME, $name);
}
if (!($file = $this->file($hash))) {
return $this->setError(elFinder::ERROR_FILE_NOT_FOUND);
}
if ($name == $file['name']) {
return $file;
}
if (!empty($file['locked'])) {
return $this->setError(elFinder::ERROR_LOCKED, $file['name']);
}
$path = $this->decode($hash);
$dir = $this->_dirname($path);
$stat = $this->stat($this->_joinPath($dir, $name));
if ($stat) {
return $this->setError(elFinder::ERROR_EXISTS, $name);
}
if (!$this->allowCreate($dir, $name)) {
return $this->setError(elFinder::ERROR_PERM_DENIED);
}
$this->rmTmb($file);
// remove old name tmbs, we cannot do this after dir move
if ($path = $this->_move($path, $dir, $name)) {
$this->clearcache();
return $this->stat($path);
}
return false;
}