2011-01-07 11:42:38 +01:00
{
"name" : "chmod" ,
"info" : {
"syntax" : "chmod <perms> <file|directory>" ,
2011-01-07 22:54:07 +01:00
"brief" : "Change the access permissions to a file or directory for one or more users or groups, example: \"chmod user1,user2,@group1,@group2+r /path\", \"chmod @all+rw /path\""
2011-01-07 11:42:38 +01:00
} ,
"action" : function ( arg )
{
var out = '' ;
if ( ! arg . match ( /^\s*([^+|-]*)(\+|\-)((r|w)+)\s+(.+)\s*$/ ) )
{
return "Usage: " + this . info . syntax + "<br/>\n" ;
}
shell . auto _prompt _refresh = false ;
var userlist = RegExp . $1 ;
var resource = RegExp . $5 ;
var perm _string = RegExp . $3 ;
var perms = 0 ;
// Unset R/W perms: 011. Unset R perms: 010. Unset W perms: 001
// Set R/W perms: 111. Set R perms: 110. Set W perms: 101
perms |= ( ( RegExp . $2 == '+' ) ? 4 : 0 ) ;
perms |= ( ( perm _string . match ( 'r' ) ) ? 2 : 0 ) ;
perms |= ( ( perm _string . match ( 'w' ) ) ? 1 : 0 ) ;
resource = shell . expandPath ( resource ) ;
2022-10-17 01:12:44 +02:00
var users _php = './modules/users/users.php' ;
2011-01-07 11:42:38 +01:00
params = 'action=chmod&resource=' + escape ( resource ) + '&perms=' + escape ( perms . toString ( ) ) ;
if ( userlist )
{
params += '&userlist=' + escape ( userlist ) ;
}
var http = new XMLHttpRequest ( ) ;
http . open ( "POST" , users _php , true ) ;
http . setRequestHeader ( "Content-type" , "application/x-www-form-urlencoded" ) ;
http . onreadystatechange = function ( )
{
if ( http . readyState == 4 && http . status == 200 )
{
2011-01-11 12:18:45 +01:00
shell . cmdOut . innerHTML = http . responseText ;
2011-01-07 11:42:38 +01:00
shell . auto _prompt _refresh = true ;
shell . refreshPrompt ( false , false ) ;
}
}
http . send ( params ) ;
shell . cmdOut . innerHTML = '' ;
return out ;
}
}