2007-07-19 12:40:05 +02:00
|
|
|
SiteTreeHandlers.parentChanged_url = 'admin/security/ajaxupdateparent';
|
|
|
|
SiteTreeHandlers.orderChanged_url = 'admin/security/ajaxupdatesort';
|
|
|
|
SiteTreeHandlers.loadPage_url = 'admin/security/getitem';
|
2007-09-04 06:12:30 +02:00
|
|
|
SiteTreeHandlers.controller_url = 'admin/security';
|
2007-07-19 12:40:05 +02:00
|
|
|
|
|
|
|
_HANDLER_FORMS['deletegroup'] = 'deletegroup_options';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add page action
|
|
|
|
* @todo Remove duplication between this and the CMSMain Add page action
|
|
|
|
*/
|
|
|
|
addgroup = {
|
|
|
|
button_onclick : function() {
|
|
|
|
addgroup.form_submit();
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
form_submit : function() {
|
|
|
|
var st = $('sitetree');
|
|
|
|
$('addgroup_options').elements.ParentID.value = st.firstSelected() ? st.getIdxOf(st.firstSelected()) : 0;
|
|
|
|
Ajax.SubmitForm('addgroup_options', null, {
|
|
|
|
onSuccess : Ajax.Evaluator,
|
|
|
|
onFailure : function(response) {
|
|
|
|
errorMessage('Error adding page', response);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete page action
|
|
|
|
*/
|
|
|
|
deletegroup = {
|
|
|
|
button_onclick : function() {
|
|
|
|
/*if( $('deletegroup_options').style.display == 'none' )
|
|
|
|
$('deletegroup_options').style.display = 'block';
|
|
|
|
else
|
|
|
|
$('deletegroup_options').style.display = 'none';*/
|
|
|
|
|
|
|
|
if(treeactions.toggleSelection(this)) {
|
|
|
|
$('deletegroup_options').style.display = 'block';
|
|
|
|
|
|
|
|
deletegroup.o1 = $('sitetree').observeMethod('SelectionChanged', deletegroup.treeSelectionChanged);
|
|
|
|
deletegroup.o2 = $('deletegroup_options').observeMethod('Close', deletegroup.popupClosed);
|
|
|
|
addClass($('sitetree'),'multiselect');
|
|
|
|
|
|
|
|
deletegroup.selectedNodes = { };
|
|
|
|
|
|
|
|
var sel = $('sitetree').firstSelected();
|
|
|
|
if(sel && sel.className.indexOf('nodelete') == -1) {
|
|
|
|
var selIdx = $('sitetree').getIdxOf(sel);
|
|
|
|
deletegroup.selectedNodes[selIdx] = true;
|
|
|
|
sel.removeNodeClass('current');
|
|
|
|
sel.addNodeClass('selected');
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
$('deletegroup_options').style.display = 'none';
|
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
treeSelectionChanged : function(selectedNode) {
|
|
|
|
var idx = $('sitetree').getIdxOf(selectedNode);
|
|
|
|
|
|
|
|
if(selectedNode.className.indexOf('nodelete') == -1) {
|
|
|
|
if(selectedNode.selected) {
|
|
|
|
selectedNode.removeNodeClass('selected');
|
|
|
|
selectedNode.selected = false;
|
|
|
|
deletegroup.selectedNodes[idx] = false;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
selectedNode.addNodeClass('selected');
|
|
|
|
selectedNode.selected = true;
|
|
|
|
deletegroup.selectedNodes[idx] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
popupClosed : function() {
|
|
|
|
removeClass($('sitetree'),'multiselect');
|
|
|
|
$('sitetree').stopObserving(deletegroup.o1);
|
|
|
|
$('deletegroup_options').stopObserving(deletegroup.o2);
|
|
|
|
|
|
|
|
for(var idx in deletegroup.selectedNodes) {
|
|
|
|
if(deletegroup.selectedNodes[idx]) {
|
|
|
|
node = $('sitetree').getTreeNodeByIdx(idx);
|
|
|
|
if(node) {
|
|
|
|
node.removeNodeClass('selected');
|
|
|
|
node.selected = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
form_submit : function() {
|
|
|
|
var csvIDs = "";
|
|
|
|
for(var idx in deletegroup.selectedNodes) {
|
|
|
|
if(deletegroup.selectedNodes[idx]) csvIDs += (csvIDs ? "," : "") + idx;
|
|
|
|
}
|
|
|
|
if(csvIDs) {
|
2007-10-26 05:11:37 +02:00
|
|
|
if(confirm("Do you really want to delete these groups?")) {
|
2007-09-16 04:19:43 +02:00
|
|
|
$('deletegroup_options').elements.csvIDs.value = csvIDs;
|
|
|
|
|
|
|
|
Ajax.SubmitForm('deletegroup_options', null, {
|
|
|
|
onSuccess : function(response) {
|
|
|
|
Ajax.Evaluator(response);
|
|
|
|
|
|
|
|
var sel;
|
|
|
|
if((sel = $('sitetree').firstSelected()) && sel.parentNode) sel.addNodeClass('current');
|
|
|
|
else $('Form_EditForm').innerHTML = "";
|
|
|
|
|
|
|
|
treeactions.closeSelection($('deletegroup'));
|
|
|
|
},
|
|
|
|
onFailure : function(response) {
|
|
|
|
errorMessage('Error deleting pages', response);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('deletegroup').getElementsByTagName('button')[0].onclick();
|
|
|
|
}
|
2007-07-19 12:40:05 +02:00
|
|
|
} else {
|
2007-10-26 05:11:37 +02:00
|
|
|
alert("Please select at least one group.");
|
2007-07-19 12:40:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialisation function to set everything up
|
|
|
|
*/
|
|
|
|
Behaviour.addLoader(function () {
|
|
|
|
// Set up add page
|
|
|
|
Observable.applyTo($('addgroup_options'));
|
|
|
|
$('addgroup').onclick = addgroup.button_onclick;
|
2007-09-15 02:54:13 +02:00
|
|
|
$('addgroup').getElementsByTagName('button')[0].onclick = function() {return false;};
|
2007-07-19 12:40:05 +02:00
|
|
|
$('addgroup_options').onsubmit = addgroup.form_submit;
|
|
|
|
|
|
|
|
// Set up delete page
|
|
|
|
Observable.applyTo($('deletegroup_options'));
|
|
|
|
$('deletegroup').onclick = deletegroup.button_onclick;
|
2007-09-15 02:54:13 +02:00
|
|
|
$('deletegroup').getElementsByTagName('button')[0].onclick = function() {return false;};
|
2007-07-19 12:40:05 +02:00
|
|
|
$('deletegroup_options').onsubmit = deletegroup.form_submit;
|
|
|
|
});
|