Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable alias rename #3693

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions js/commands/rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@ elFinder.prototype.commands.rename = function() {
"use strict";

// set alwaysEnabled to allow root rename on client size
this.alwaysEnabled = true;
if (this.fm.options.enableRootRename !== false) {
this.alwaysEnabled = true;
}

this.syncTitleOnChange = true;

var self = this,
fm = self.fm,
enableRootRename = fm.options.enableRootRename !== false,
request = function(dfrd, targtes, file, name) {
var sel = targtes? [file.hash].concat(targtes) : [file.hash],
cnt = sel.length,
data = {}, rootNames;

fm.lockfiles({files : sel});

if (fm.isRoot(file) && !file.netkey) {
if (fm.isRoot(file) && !file.netkey && enableRootRename) {
if (!(rootNames = fm.storage('rootNames'))) {
rootNames = {};
}
Expand Down Expand Up @@ -268,7 +271,7 @@ elFinder.prototype.commands.rename = function() {
isRoot = fm.isRoot(sel[0]);
}

state = (cnt === 1 && ((fm.cookieEnabled && isRoot) || !sel[0].locked) || (fm.api > 2.1030 && cnt === $.grep(sel, function(f) {
state = (cnt === 1 && ((enableRootRename && fm.cookieEnabled && isRoot) || !sel[0].locked) || (fm.api > 2.1030 && cnt === $.grep(sel, function(f) {
if (!brk && !f.locked && f.phash === phash && !fm.isRoot(f) && (mime === f.mime || ext === fm.splitFileExtention(f.name)[1].toLowerCase())) {
return true;
} else {
Expand Down Expand Up @@ -539,7 +542,7 @@ elFinder.prototype.commands.rename = function() {
return dfrd.reject('errCmdParams', this.title);
}

if (file.locked && !fm.isRoot(file)) {
if (file.locked && (!fm.isRoot(file) || !enableRootRename)) {
return dfrd.reject(['errLocked', file.name]);
}

Expand Down
2 changes: 1 addition & 1 deletion js/elFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -8112,7 +8112,7 @@ elFinder.prototype = {
}
}

if (isRoot) {
if (isRoot && self.options.enableRootRename !== false) {
if (rootNames = self.storage('rootNames')) {
if (rootNames[file.hash]) {
file._name = file.name;
Expand Down
7 changes: 6 additions & 1 deletion js/elFinder.options.js
Original file line number Diff line number Diff line change
Expand Up @@ -1363,5 +1363,10 @@ elFinder.prototype._options = {
*
* @type Boolean|Object (toast options)
*/
toastBackendWarn : true
toastBackendWarn : true,

/**
* Whether renaming root folders is enabled. If true, the alias for the root folder is stored as a preference for the user.
*/
enableRootRename : true,
};
Loading