mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-04-20 20:13:40 +03:00
Allow copying of permissions when cloning a zone.
This commit is contained in:
parent
19a8e2c223
commit
e1df632852
3 changed files with 28 additions and 0 deletions
|
@ -90,6 +90,22 @@ function set_permissions($userid,$groupid,$zone,$permissions) {
|
|||
}
|
||||
}
|
||||
|
||||
// Interface function - Copy permissions from one zone to another - used for cloning, so assumes no existing permissions on the domain
|
||||
|
||||
function copy_permissions($srczone,$dstzone) {
|
||||
$db = get_db();
|
||||
|
||||
$q = $db->prepare('SELECT p.user,p."group",p.permissions FROM permissions p, zones z WHERE p.zone=z.id AND z.zone=?');
|
||||
$q->bindValue(1, $srczone, SQLITE3_TEXT);
|
||||
$result = $q->execute();
|
||||
|
||||
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
|
||||
set_permissions($row['user'],$row['group'],$dstzone,$row['permissions']);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Interface function - Update permissions for a zone
|
||||
function update_permissions($id,$permissions) {
|
||||
global $permissionmap;
|
||||
|
|
|
@ -1055,6 +1055,13 @@ $(document).ready(function () {
|
|||
title: 'Domain',
|
||||
inputClass: 'destname'
|
||||
},
|
||||
copypermissions: {
|
||||
title: 'Copy Permissions',
|
||||
type: 'checkbox',
|
||||
values: {'0': 'No', '1': 'Yes'},
|
||||
defaultValue: 1,
|
||||
inputClass: 'copypermissions'
|
||||
},
|
||||
account: {
|
||||
title: 'Owner',
|
||||
options: function(data) {
|
||||
|
|
|
@ -522,6 +522,7 @@ case "export":
|
|||
case "clone":
|
||||
$name = $_POST['destname'];
|
||||
$src = $_POST['sourcename'];
|
||||
$copypermissions = $_POST['copypermissions'];
|
||||
|
||||
if (!is_adminuser() and $allowzoneadd !== true) {
|
||||
jtable_respond(null, 'error', "You are not allowed to add zones");
|
||||
|
@ -566,6 +567,10 @@ case "clone":
|
|||
|
||||
$zone = $api->savezone($srczone->export());
|
||||
|
||||
if($copypermissions==1) {
|
||||
copy_permissions($src,$name);
|
||||
}
|
||||
|
||||
writelog("Cloned zone $src into $name");
|
||||
jtable_respond($zone, 'single');
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue