You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by jf...@apache.org on 2010/10/28 16:54:18 UTC
svn commit: r1028338 - in /incubator/vcl/trunk/web: .ht-inc/images.php
.ht-inc/managementnodes.php .ht-inc/privileges.php .ht-inc/utils.php
js/images.js
Author: jfthomps
Date: Thu Oct 28 14:54:17 2010
New Revision: 1028338
URL: http://svn.apache.org/viewvc?rev=1028338&view=rev
Log:
VCL-401
add manageMapping resource attribute to control resource mapping
utils.php: added getResourcePrivs
managementnodes.php:
-modified these functions to look at manageMapping attribute instead of manageGroup for mapping privileges:
-selectMgmtnodeOption, viewMgmtnodeMapping, submitMgmtnodeMapping
images.php:
-modified these functions to look at manageMapping attribute instead of manageGroup for mapping privileges:
-selectImageOption, viewImageMapping, imageMappingGrid, submitImageMapping, jsonImageMapCompGroups, jsonImageMapImgGroups, AJaddCompGrpToImgGrp, AJremCompGrpFromImgGrp, AJaddImgGrpToCompGrp, and AJremImgGrpFromCompGrp
-converted all references to json-comment-filtered to just json and to use sendJSON function
privileges.php:
-modified viewNodes:
-instead of hardcoding resource types, call getResourcePrivs to get them
-call getResourcePrivRowHTML instead of printResourcePrivRow and then print the returned HTML and JS
-for add resource dialog, loop through resource privs to print checkboxes instead of printing them all directly
-modified selectNode:
-instead of hardcoding resource types, call getResourcePrivs to get them
-due to combining printResourcePrivRow and getResourcePrivRowHTML, needed to add a few str_replace's to prepare html for sending in ajax response
-combined printResourcePrivRow and getResourcePrivRowHTML
-modified getResourcePrivRowHTML:
-added newlines
-added manageMapping to checkboxes that don't get printed if don't have proper rights
-added check to not print available checkbox for schedule and management node groups
-added check to not print manageMapping for schedule groups
-removed preg_replace for single quote; moved replacing them to selectNode
-modified AJsubmitAddResoucePriv to get resource types from getResourcePrivs instead of hard coding them
js/images.js: converted all references to json-comment-filtered to just json
Modified:
incubator/vcl/trunk/web/.ht-inc/images.php
incubator/vcl/trunk/web/.ht-inc/managementnodes.php
incubator/vcl/trunk/web/.ht-inc/privileges.php
incubator/vcl/trunk/web/.ht-inc/utils.php
incubator/vcl/trunk/web/js/images.js
Modified: incubator/vcl/trunk/web/.ht-inc/images.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/images.php?rev=1028338&r1=1028337&r2=1028338&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/images.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/images.php Thu Oct 28 14:54:17 2010
@@ -60,9 +60,11 @@ function selectImageOption() {
$tmp = getUserResources(array("imageAdmin"), array("manageGroup"), 1);
$imgGroupCnt = count($tmp['image']);
- # get a count of computer groups user can manage
- $tmp = getUserResources(array("computerAdmin"), array("manageGroup"), 1);
- $compGroupCnt = count($tmp['computer']);
+ # get a count of image groups and computer groups user can map
+ $tmp = getUserResources(array("imageAdmin"), array("manageMapping"), 1);
+ $imgMapCnt = count($tmp['image']);
+ $tmp = getUserResources(array("computerAdmin"), array("manageMapping"), 1);
+ $compMapCnt = count($tmp['computer']);
print "<H2>Manage Images</H2>\n";
print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
@@ -78,12 +80,12 @@ function selectImageOption() {
$cont = addContinuationsEntry('viewImageGrouping');
print "<INPUT type=radio name=continuation value=\"$cont\">Edit ";
print "Image Grouping<br>\n";
+ }
- if($compGroupCnt) {
- $cont = addContinuationsEntry('viewImageMapping');
- print "<INPUT type=radio name=continuation value=\"$cont\">Edit ";
- print "Image Mapping<br>\n";
- }
+ if($imgMapCnt && $compMapCnt) {
+ $cont = addContinuationsEntry('viewImageMapping');
+ print "<INPUT type=radio name=continuation value=\"$cont\">Edit ";
+ print "Image Mapping<br>\n";
}
if($imgCnt) {
@@ -448,12 +450,12 @@ function imageGroupingGrid() {
function viewImageMapping() {
global $mode;
$tmp = getUserResources(array("imageAdmin"),
- array("manageGroup"), 1);
+ array("manageMapping"), 1);
$imagegroups = $tmp["image"];
uasort($imagegroups, "sortKeepIndex");
$imagecompmapping = getResourceMapping("image", "computer");
$resources = getUserResources(array("computerAdmin"),
- array("manageGroup"), 1);
+ array("manageMapping"), 1);
$compgroups = $resources["computer"];
uasort($compgroups, "sortKeepIndex");
if(! count($imagegroups) || ! count($compgroups)) {
@@ -535,10 +537,7 @@ function viewImageMapping() {
print "button to map it to that group.<br><br>\n";
print "Computer Group:<select name=compgroups id=compgroups>\n";
# build list of groups
- $tmp = getUserResources(array('computerAdmin'), array('manageGroup'), 1);
- $groups = $tmp['computer'];
- uasort($groups, 'sortKeepIndex');
- foreach($groups as $id => $group) {
+ foreach($compgroups as $id => $group) {
print "<option value=$id>$group</option>\n";
}
print "</select>\n";
@@ -612,12 +611,12 @@ function viewImageMapping() {
function imageMappingGrid() {
global $mode;
$tmp = getUserResources(array("imageAdmin"),
- array("manageGroup"), 1);
+ array("manageMapping"), 1);
$imagegroups = $tmp["image"];
uasort($imagegroups, "sortKeepIndex");
$imagecompmapping = getResourceMapping("image", "computer");
$resources2 = getUserResources(array("computerAdmin"),
- array("manageGroup"), 1);
+ array("manageMapping"), 1);
$compgroups = $resources2["computer"];
uasort($compgroups, "sortKeepIndex");
@@ -2312,10 +2311,10 @@ function submitImageMapping() {
# build an array of memberships currently in the db
$tmp = getUserResources(array("imageAdmin"),
- array("manageGroup"), 1);
+ array("manageMapping"), 1);
$imagegroups = $tmp["image"];
$tmp = getUserResources(array("computerAdmin"),
- array("manageGroup"), 1);
+ array("manageMapping"), 1);
$compgroups = $tmp["computer"];
$imageinlist = implode(',', array_keys($imagegroups));
$compinlist = implode(',', array_keys($compgroups));
@@ -2904,8 +2903,7 @@ function jsonImageGroupingImages() {
$groups = getUserResources(array("imageAdmin"), array("manageGroup"), 1);
if(! array_key_exists($groupid, $groups['image'])) {
$arr = array('inimages' => array(), 'outimages' => array(), 'all' => array());
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
@@ -2929,7 +2927,7 @@ function jsonImageGroupingImages() {
}
}
$arr = array('inimages' => $in, 'outimages' => $out, 'all' => $all);
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
}
////////////////////////////////////////////////////////////////////////////////
@@ -2946,8 +2944,7 @@ function jsonImageGroupingGroups() {
$resources = getUserResources(array("imageAdmin"), array("manageGroup"));
if(! array_key_exists($imageid, $resources['image'])) {
$arr = array('ingroups' => array(), 'outgroups' => array(), 'all' => array());
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
$groups = getUserResources(array('imageAdmin'), array('manageGroup'), 1);
@@ -2967,7 +2964,7 @@ function jsonImageGroupingGroups() {
}
}
$arr = array('ingroups' => $in, 'outgroups' => $out, 'all' => $all);
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
}
////////////////////////////////////////////////////////////////////////////////
@@ -2982,14 +2979,13 @@ function jsonImageGroupingGroups() {
////////////////////////////////////////////////////////////////////////////////
function jsonImageMapCompGroups() {
$imagegrpid = processInputVar('imagegrpid', ARG_NUMERIC);
- $resources = getUserResources(array("imageAdmin"), array("manageGroup"), 1);
+ $resources = getUserResources(array("imageAdmin"), array("manageMapping"), 1);
if(! array_key_exists($imagegrpid, $resources['image'])) {
$arr = array('ingroups' => array(), 'outgroups' => array(), 'all' => array());
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
- $compgroups = getUserResources(array('computerAdmin'), array('manageGroup'), 1);
+ $compgroups = getUserResources(array('computerAdmin'), array('manageMapping'), 1);
$mapping = getResourceMapping('image', 'computer');
$in = array();
$out = array();
@@ -3006,7 +3002,7 @@ function jsonImageMapCompGroups() {
}
}
$arr = array('ingroups' => $in, 'outgroups' => $out, 'all' => $all);
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
}
////////////////////////////////////////////////////////////////////////////////
@@ -3021,14 +3017,13 @@ function jsonImageMapCompGroups() {
////////////////////////////////////////////////////////////////////////////////
function jsonImageMapImgGroups() {
$compgrpid = processInputVar('compgrpid', ARG_NUMERIC);
- $resources = getUserResources(array("computerAdmin"), array("manageGroup"), 1);
+ $resources = getUserResources(array("computerAdmin"), array("manageMapping"), 1);
if(! array_key_exists($compgrpid, $resources['computer'])) {
$arr = array('ingroups' => array(), 'outgroups' => array(), 'all' => array());
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
- $imagegroups = getUserResources(array('imageAdmin'), array('manageGroup'), 1);
+ $imagegroups = getUserResources(array('imageAdmin'), array('manageMapping'), 1);
$mapping = getResourceMapping('computer', 'image');
$in = array();
$out = array();
@@ -3045,7 +3040,7 @@ function jsonImageMapImgGroups() {
}
}
$arr = array('ingroups' => $in, 'outgroups' => $out, 'all' => $all);
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
}
////////////////////////////////////////////////////////////////////////////////
@@ -3062,8 +3057,7 @@ function AJaddImageToGroup() {
$groups = getUserResources(array("imageAdmin"), array("manageGroup"), 1);
if(! array_key_exists($groupid, $groups['image'])) {
$arr = array('images' => array(), 'addrem' => 1);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
@@ -3076,8 +3070,7 @@ function AJaddImageToGroup() {
continue;
if(! array_key_exists($id, $resources['image'])) {
$arr = array('images' => array(), 'addrem' => 1);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
$imageids[] = $id;
@@ -3094,8 +3087,7 @@ function AJaddImageToGroup() {
doQuery($query, 287);
$_SESSION['userresources'] = array();
$arr = array('images' => $imageids, 'addrem' => 1);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
}
////////////////////////////////////////////////////////////////////////////////
@@ -3112,8 +3104,7 @@ function AJremImageFromGroup() {
$groups = getUserResources(array("imageAdmin"), array("manageGroup"), 1);
if(! array_key_exists($groupid, $groups['image'])) {
$arr = array('images' => array(), 'addrem' => 0);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
@@ -3126,8 +3117,7 @@ function AJremImageFromGroup() {
continue;
if(! array_key_exists($id, $resources['image'])) {
$arr = array('images' => array(), 'addrem' => 0, 'id' => $id, 'extra' => $resources['image']);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
$imageids[] = $id;
@@ -3142,8 +3132,7 @@ function AJremImageFromGroup() {
}
$_SESSION['userresources'] = array();
$arr = array('images' => $imageids, 'addrem' => 0);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
}
////////////////////////////////////////////////////////////////////////////////
@@ -3160,8 +3149,7 @@ function AJaddGroupToImage() {
$resources = getUserResources(array("imageAdmin"), array("manageGroup"));
if(! array_key_exists($imageid, $resources['image'])) {
$arr = array('groups' => array(), 'addrem' => 1);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
@@ -3174,8 +3162,7 @@ function AJaddGroupToImage() {
continue;
if(! array_key_exists($id, $groups['image'])) {
$arr = array('groups' => array(), 'addrem' => 1);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
$groupids[] = $id;
@@ -3192,8 +3179,7 @@ function AJaddGroupToImage() {
doQuery($query, 101);
$_SESSION['userresources'] = array();
$arr = array('groups' => $groupids, 'addrem' => 1);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
}
////////////////////////////////////////////////////////////////////////////////
@@ -3210,8 +3196,7 @@ function AJremGroupFromImage() {
$resources = getUserResources(array("imageAdmin"), array("manageGroup"));
if(! array_key_exists($imageid, $resources['image'])) {
$arr = array('groups' => array(), 'addrem' => 0);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
@@ -3224,8 +3209,7 @@ function AJremGroupFromImage() {
continue;
if(! array_key_exists($id, $groups['image'])) {
$arr = array('groups' => array(), 'addrem' => 0);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
$groupids[] = $id;
@@ -3240,8 +3224,7 @@ function AJremGroupFromImage() {
}
$_SESSION['userresources'] = array();
$arr = array('groups' => $groupids, 'addrem' => 0);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
}
////////////////////////////////////////////////////////////////////////////////
@@ -3255,15 +3238,14 @@ function AJremGroupFromImage() {
////////////////////////////////////////////////////////////////////////////////
function AJaddCompGrpToImgGrp() {
$imagegrpid = processInputVar('id', ARG_NUMERIC);
- $resources = getUserResources(array("imageAdmin"), array("manageGroup"), 1);
+ $resources = getUserResources(array("imageAdmin"), array("manageMapping"), 1);
if(! array_key_exists($imagegrpid, $resources['image'])) {
$arr = array('groups' => array(), 'addrem' => 1);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
- $compgroups = getUserResources(array("computerAdmin"), array("manageGroup"), 1);
+ $compgroups = getUserResources(array("computerAdmin"), array("manageMapping"), 1);
$tmp = processInputVar('listids', ARG_STRING);
$tmp = explode(',', $tmp);
$compgroupids = array();
@@ -3272,8 +3254,7 @@ function AJaddCompGrpToImgGrp() {
continue;
if(! array_key_exists($id, $compgroups['computer'])) {
$arr = array('groups' => array(), 'addrem' => 1);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
$compgroupids[] = $id;
@@ -3289,8 +3270,7 @@ function AJaddCompGrpToImgGrp() {
doQuery($query, 101);
$_SESSION['userresources'] = array();
$arr = array('groups' => $compgroupids, 'addrem' => 1);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
}
////////////////////////////////////////////////////////////////////////////////
@@ -3304,15 +3284,14 @@ function AJaddCompGrpToImgGrp() {
////////////////////////////////////////////////////////////////////////////////
function AJremCompGrpFromImgGrp() {
$imagegrpid = processInputVar('id', ARG_NUMERIC);
- $resources = getUserResources(array("imageAdmin"), array("manageGroup"), 1);
+ $resources = getUserResources(array("imageAdmin"), array("manageMapping"), 1);
if(! array_key_exists($imagegrpid, $resources['image'])) {
$arr = array('groups' => array(), 'addrem' => 0);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
- $compgroups = getUserResources(array("computerAdmin"), array("manageGroup"), 1);
+ $compgroups = getUserResources(array("computerAdmin"), array("manageMapping"), 1);
$tmp = processInputVar('listids', ARG_STRING);
$tmp = explode(',', $tmp);
$compgroupids = array();
@@ -3321,8 +3300,7 @@ function AJremCompGrpFromImgGrp() {
continue;
if(! array_key_exists($id, $compgroups['computer'])) {
$arr = array('groups' => array(), 'addrem' => 0);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
$compgroupids[] = $id;
@@ -3338,8 +3316,7 @@ function AJremCompGrpFromImgGrp() {
}
$_SESSION['userresources'] = array();
$arr = array('groups' => $compgroupids, 'addrem' => 0);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
}
////////////////////////////////////////////////////////////////////////////////
@@ -3353,15 +3330,14 @@ function AJremCompGrpFromImgGrp() {
////////////////////////////////////////////////////////////////////////////////
function AJaddImgGrpToCompGrp() {
$compgrpid = processInputVar('id', ARG_NUMERIC);
- $resources = getUserResources(array("computerAdmin"), array("manageGroup"), 1);
+ $resources = getUserResources(array("computerAdmin"), array("manageMapping"), 1);
if(! array_key_exists($compgrpid, $resources['computer'])) {
$arr = array('groups' => array(), 'addrem' => 1);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
- $imagegroups = getUserResources(array("imageAdmin"), array("manageGroup"), 1);
+ $imagegroups = getUserResources(array("imageAdmin"), array("manageMapping"), 1);
$tmp = processInputVar('listids', ARG_STRING);
$tmp = explode(',', $tmp);
$imagegroupids = array();
@@ -3370,8 +3346,7 @@ function AJaddImgGrpToCompGrp() {
continue;
if(! array_key_exists($id, $imagegroups['image'])) {
$arr = array('groups' => array(), 'addrem' => 1);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
$imagegroupids[] = $id;
@@ -3387,8 +3362,7 @@ function AJaddImgGrpToCompGrp() {
doQuery($query, 101);
$_SESSION['userresources'] = array();
$arr = array('groups' => $imagegroupids, 'addrem' => 1);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
}
////////////////////////////////////////////////////////////////////////////////
@@ -3402,15 +3376,14 @@ function AJaddImgGrpToCompGrp() {
////////////////////////////////////////////////////////////////////////////////
function AJremImgGrpFromCompGrp() {
$compgrpid = processInputVar('id', ARG_NUMERIC);
- $resources = getUserResources(array("computerAdmin"), array("manageGroup"), 1);
+ $resources = getUserResources(array("computerAdmin"), array("manageMapping"), 1);
if(! array_key_exists($compgrpid, $resources['computer'])) {
$arr = array('groups' => array(), 'addrem' => 0);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
- $imagegroups = getUserResources(array("imageAdmin"), array("manageGroup"), 1);
+ $imagegroups = getUserResources(array("imageAdmin"), array("manageMapping"), 1);
$tmp = processInputVar('listids', ARG_STRING);
$tmp = explode(',', $tmp);
$imagegroupids = array();
@@ -3419,8 +3392,7 @@ function AJremImgGrpFromCompGrp() {
continue;
if(! array_key_exists($id, $imagegroups['image'])) {
$arr = array('groups' => array(), 'addrem' => 0);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
return;
}
$imagegroupids[] = $id;
@@ -3436,8 +3408,7 @@ function AJremImgGrpFromCompGrp() {
}
$_SESSION['userresources'] = array();
$arr = array('groups' => $imagegroupids, 'addrem' => 0);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
}
////////////////////////////////////////////////////////////////////////////////
@@ -3480,8 +3451,7 @@ function AJupdateRevisionComments() {
. "WHERE id = $revisionid";
doQuery($query, 101);
$arr = array('comments' => $comments, 'id' => $revisionid);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
}
////////////////////////////////////////////////////////////////////////////////
@@ -3498,8 +3468,7 @@ function AJdeleteRevisions() {
$ids = explode(',', $checkedids);
foreach($ids as $id) {
if(! is_numeric($id) || ! in_array($id, $revids)) {
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode(array()) . '}*/';
+ sendJSON(array());
return;
}
}
@@ -3510,8 +3479,7 @@ function AJdeleteRevisions() {
doQuery($query, 101);
$html = getRevisionHTML($imageid);
$arr = array('html' => $html);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
+ sendJSON($arr);
}
?>
Modified: incubator/vcl/trunk/web/.ht-inc/managementnodes.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/managementnodes.php?rev=1028338&r1=1028337&r2=1028338&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/managementnodes.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/managementnodes.php Thu Oct 28 14:54:17 2010
@@ -75,9 +75,11 @@ function selectMgmtnodeOption() {
$tmp = getUserResources(array("mgmtNodeAdmin"), array("manageGroup"), 1);
$mnGroupCnt = count($tmp['managementnode']);
- # get a count of computer groups user can manage
- $tmp = getUserResources(array("computerAdmin"), array("manageGroup"), 1);
- $compGroupCnt = count($tmp['computer']);
+ # get a count of mgmt node and computer groups user can manage
+ $tmp = getUserResources(array("mgmtNodeAdmin"), array("manageMapping"), 1);
+ $mnMapCnt = count($tmp['managementnode']);
+ $tmp = getUserResources(array("computerAdmin"), array("manageMapping"), 1);
+ $compMapCnt = count($tmp['computer']);
print "<H2>Manage Management Nodes</H2>\n";
print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
@@ -90,13 +92,13 @@ function selectMgmtnodeOption() {
$cont = addContinuationsEntry('viewMgmtnodeGrouping');
print "<INPUT type=radio name=continuation value=\"$cont\">Edit ";
print "Management Node Grouping<br>\n";
- if($compGroupCnt) {
- $cont = addContinuationsEntry('viewMgmtnodeMapping');
- print "<INPUT type=radio name=continuation value=\"$cont\">Edit ";
- print "Management Node Mapping<br>\n";
- }
}
- if($mnAdminCnt || $mnGroupCnt)
+ if($mnMapCnt && $compMapCnt) {
+ $cont = addContinuationsEntry('viewMgmtnodeMapping');
+ print "<INPUT type=radio name=continuation value=\"$cont\">Edit ";
+ print "Management Node Mapping<br>\n";
+ }
+ if($mnAdminCnt || $mnGroupCnt || ($mnMapCnt && $compMapCnt))
print "<INPUT type=submit value=Submit>\n";
else {
print "You do not have access to manage any management nodes.<br>\n";
@@ -992,12 +994,12 @@ function viewMgmtnodeMapping($mngroups=0
global $mode;
if(! is_array($mngroups)) {
$tmp = getUserResources(array("mgmtNodeAdmin"),
- array("manageGroup"), 1);
+ array("manageMapping"), 1);
$mngroups = $tmp["managementnode"];
}
$mapping = getResourceMapping("managementnode", "computer");
$resources2 = getUserResources(array("computerAdmin"),
- array("manageGroup"), 1);
+ array("manageMapping"), 1);
$compgroups = $resources2["computer"];
uasort($compgroups, "sortKeepIndex");
@@ -1073,10 +1075,10 @@ function submitMgmtnodeMapping() {
# build an array of memberships currently in the db
$tmp = getUserResources(array("mgmtNodeAdmin"),
- array("manageGroup"), 1);
+ array("manageMapping"), 1);
$mngroups = $tmp["managementnode"];
$tmp = getUserResources(array("computerAdmin"),
- array("manageGroup"), 1);
+ array("manageMapping"), 1);
$compgroups = $tmp["computer"];
$mninlist = implode(',', array_keys($mngroups));
$compinlist = implode(',', array_keys($compgroups));
Modified: incubator/vcl/trunk/web/.ht-inc/privileges.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/privileges.php?rev=1028338&r1=1028337&r2=1028338&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/privileges.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/privileges.php Thu Oct 28 14:54:17 2010
@@ -240,7 +240,7 @@ function viewNodes() {
print "</div>\n";
# resources
- $resourcetypes = array("available", "administer", "manageGroup");
+ $resourcetypes = getResourcePrivs();
print "<A name=\"resources\"></a>\n";
print "<div id=resourcesDiv>\n";
print "<H3>Resources</H3>\n";
@@ -253,6 +253,8 @@ function viewNodes() {
print " <TH bgcolor=gray style=\"color: black;\">Block<br>Cascaded<br>Rights</TH>\n";
print " <TH bgcolor=\"#008000\" style=\"color: black;\">Cascade<br>to Child<br>Nodes</TH>\n";
foreach($resourcetypes as $type) {
+ if($type == 'block' || $type == 'cascade')
+ continue;
$img = getImageText("$type");
print " <TH>$img</TH>\n";
}
@@ -263,9 +265,14 @@ function viewNodes() {
$resourcegroups = getResourceGroups();
$resgroupmembers = getResourceGroupMembers();
foreach($resources as $resource) {
- printResourcePrivRow($resource, $i, $privs["resources"], $resourcetypes,
- $resourcegroups, $resgroupmembers,
- $cascadePrivs["resources"], ! $hasResourceGrant);
+ $data = getResourcePrivRowHTML($resource, $i, $privs["resources"],
+ $resourcetypes, $resourcegroups,
+ $resgroupmembers, $cascadePrivs["resources"],
+ ! $hasResourceGrant);
+ print $data['html'];
+ print "<script language=\"Javascript\">\n";
+ print "dojo.addOnLoad(function () {setTimeout(\"{$data['javascript']}\", 500)});\n";
+ print "</script>\n";
$i++;
}
print "</TABLE>\n";
@@ -445,8 +452,9 @@ function viewNodes() {
print " <TD></TD>\n";
print " <TH bgcolor=gray style=\"color: black;\">Block<br>Cascaded<br>Rights</TH>\n";
print " <TH bgcolor=\"#008000\" style=\"color: black;\">Cascade<br>to Child<br>Nodes</TH>\n";
- $resourcetypes = array("available", "administer", "manageGroup");
foreach($resourcetypes as $type) {
+ if($type == 'block' || $type == 'cascade')
+ continue;
$img = getImageText("$type");
print " <TH>$img</TH>\n";
}
@@ -474,12 +482,14 @@ function viewNodes() {
print "name=cascaderesgrp></TD>\n";
# normal rights
- print " <TD align=center id=resgrpcell0:1><INPUT type=checkbox ";
- print "dojoType=dijit.form.CheckBox name=available id=resgrpck0:1></TD>\n";
- print " <TD align=center id=resgrpcell0:2><INPUT type=checkbox ";
- print "dojoType=dijit.form.CheckBox name=administer id=resgrpck0:2></TD>\n";
- print " <TD align=center id=resgrpcell0:3><INPUT type=checkbox ";
- print "dojoType=dijit.form.CheckBox name=manageGroup id=resgrpck0:3></TD>\n";
+ $i = 1;
+ foreach($resourcetypes as $type) {
+ if($type == 'block' || $type == 'cascade')
+ continue;
+ print " <TD align=center id=resgrpcell0:$i><INPUT type=checkbox ";
+ print "dojoType=dijit.form.CheckBox name=$type id=resgrpck0:$i></TD>\n";
+ $i++;
+ }
print " </TR>\n";
print "</TABLE>\n";
print "<div id=addResourceGroupPrivStatus></div>\n";
@@ -796,7 +806,7 @@ function selectNode() {
# resources
$text = "";
- $resourcetypes = array("available", "administer", "manageGroup");
+ $resourcetypes = getResourcePrivs();
$text .= "<H3>Resources</H3>";
$text .= "<FORM id=resourceForm action=\"" . BASEURL . SCRIPT . "#resources\" method=post>";
if(count($privs["resources"]) || count($cascadePrivs["resources"])) {
@@ -807,6 +817,8 @@ function selectNode() {
$text .= " <TH bgcolor=gray style=\"color: black;\">Block<br>Cascaded<br>Rights</TH>";
$text .= " <TH bgcolor=\"#008000\" style=\"color: black;\">Cascade<br>to Child<br>Nodes</TH>";
foreach($resourcetypes as $type) {
+ if($type == 'block' || $type == 'cascade')
+ continue;
$img = getImageText("$type");
$text .= " <TH>$img</TH>";
}
@@ -820,7 +832,10 @@ function selectNode() {
$tmpArr = getResourcePrivRowHTML($resource, $i, $privs["resources"],
$resourcetypes, $resourcegroups, $resgroupmembers,
$cascadePrivs["resources"], ! $hasResourceGrant);
- $text .= $tmpArr['html'];
+ $html = str_replace("\n", '', $tmpArr['html']);
+ $html = str_replace("'", "\'", $html);
+ $html = preg_replace("/>\s*</", "><", $html);
+ $text .= $html;
$js .= $tmpArr['javascript'];
$i++;
}
@@ -1657,122 +1672,6 @@ function jsonGetUserGroupMembers() {
////////////////////////////////////////////////////////////////////////////////
///
-/// \fn printResourcePrivRow($privname, $rownum, $privs, $types,
-/// $resourcegroups, $resgroupmembers, $cascadeprivs,
-/// $disabled)
-///
-/// \param $privname - privilege name
-/// \param $rownum - number of the privilege row on this page
-/// \param $privs - an array of user's privileges
-/// \param $types - an array of privilege types
-/// \param $resourcegroups - array from getResourceGroups()
-/// \param $resgroupmembers - array from getResourceGroupMembers()
-/// \param $cascadeprivs - an array of user's cascaded privileges
-/// \param $disabled - 0 or 1; whether or not the checkboxes should be disabled
-///
-/// \brief prints a table row for this $privname
-///
-////////////////////////////////////////////////////////////////////////////////
-function printResourcePrivRow($privname, $rownum, $privs, $types,
- $resourcegroups, $resgroupmembers, $cascadeprivs,
- $disabled) {
- global $user;
- print " <TR>\n";
- list($type, $name, $id) = explode('/', $privname);
- print " <TH>\n";
- print " <span id=\"resgrp$id\" onmouseover=getGroupMembers(\"$id\",";
- print "\"resgrp$id\",\"rgmcont\"); onmouseout=getGroupMembersCancel";
- print "(\"resgrp$id\");>$name</span>\n";
- print " </TH>\n";
- print " <TH>$type</TH>\n";
-
- if($disabled)
- $disabled = 'disabled=disabled';
- else
- $disabled = '';
-
- # block rights
- if(array_key_exists($privname, $privs) &&
- in_array("block", $privs[$privname])) {
- $checked = "checked";
- $blocked = 1;
- }
- else {
- $checked = "";
- $blocked = 0;
- }
- $count = count($types) + 1;
- $name = "privrow[" . $privname . ":block]";
- print " <TD align=center bgcolor=gray><INPUT type=checkbox ";
- print "dojoType=dijit.form.CheckBox id=ck$rownum:block name=\"$name\" ";
- print "$checked $disabled onClick=\"";
- print "changeCascadedRights(this.checked, $rownum, $count, 1, 3)\"></TD>\n";
-
- #cascade rights
- if(array_key_exists($privname, $privs) &&
- in_array("cascade", $privs[$privname]))
- $checked = "checked";
- else
- $checked = "";
- $name = "privrow[" . $privname . ":cascade]";
- print " <TD align=center bgcolor=\"#008000\" id=cell$rownum:0>";
- print "<INPUT type=checkbox dojoType=dijit.form.CheckBox id=ck$rownum:0 ";
- print "onClick=\"privChange(this.checked, $rownum, 0, 3);\" ";
- print "name=\"$name\" $checked $disabled></TD>\n";
-
- # normal rights
- $j = 1;
- foreach($types as $type) {
- $bgcolor = "";
- $checked = "";
- $value = "";
- $cascaded = 0;
- if(array_key_exists($privname, $cascadeprivs) &&
- in_array($type, $cascadeprivs[$privname])) {
- $bgcolor = "bgcolor=\"#008000\"";
- $checked = "checked";
- $value = "value=cascade";
- $cascaded = 1;
- }
- if(array_key_exists($privname, $privs) &&
- in_array($type, $privs[$privname])) {
- if($cascaded) {
- $value = "value=cascadesingle";
- }
- else {
- $checked = "checked";
- $value = "value=single";
- }
- }
- // if $type is administer or manageGroup, and it is not checked, and the
- # user is not in the resource owner group, don't print the checkbox
- if(($type == "administer" || $type == "manageGroup") &&
- $checked != "checked" &&
- ! array_key_exists($resourcegroups[$id]["ownerid"], $user["groups"])) {
- print "<TD><img src=images/blank.gif></TD>\n";
- }
- else {
- $name = "privrow[" . $privname . ":" . $type . "]";
- print " <TD align=center id=cell$rownum:$j $bgcolor><INPUT ";
- print "type=checkbox dojoType=dijit.form.CheckBox name=\"$name\" ";
- print "id=ck$rownum:$j $checked $value $disabled ";
- print "onClick=\"nodeCheck(this.checked, $rownum, $j, 3);\">";
- #print "onBlur=\"nodeCheck(this.checked, $rownum, $j, 3);\">";
- print "</TD>\n";
- }
- $j++;
- }
- print " </TR>\n";
- $count = count($types) + 1;
- if($blocked) {
- print "<script language=\"Javascript\">\n";
- print "dojo.addOnLoad(function () {setTimeout(\"changeCascadedRights(true, $rownum, $count, 0, 0)\", 500)});\n";
- print "</script>\n";
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-///
/// \fn getResourcePrivRowHTML($privname, $rownum, $privs, $types,
/// $resourcegroups, $resgroupmembers,
/// $cascadeprivs, $disabled)
@@ -1797,15 +1696,14 @@ function getResourcePrivRowHTML($privnam
global $user;
$text = "";
$js = "";
- $text .= " <TR>";
- list($type, $name, $id) = explode('/', $privname);
- $text .= " <TH>";
+ $text .= " <TR>\n";
+ list($grptype, $name, $id) = explode('/', $privname);
+ $text .= " <TH>\n";
$text .= " <span id=\"resgrp$id\" onmouseover=getGroupMembers(\"$id\",";
$text .= "\"resgrp$id\",\"rgmcont\"); onmouseout=getGroupMembersCancel";
- $text .= "(\"resgrp$id\");>$name</span>";
- $text .= " </TH>";
- //$text .= " <TH>$name</TH>";
- $text .= " <TH>$type</TH>";
+ $text .= "(\"resgrp$id\");>$name</span>\n";
+ $text .= " </TH>\n";
+ $text .= " <TH>$grptype</TH>\n";
if($disabled)
$disabled = 'disabled=disabled';
@@ -1827,7 +1725,7 @@ function getResourcePrivRowHTML($privnam
$text .= " <TD align=center bgcolor=gray><INPUT type=checkbox ";
$text .= "dojoType=dijit.form.CheckBox id=ck$rownum:block name=\"$name\" ";
$text .= "$checked $disabled onClick=\"changeCascadedRights";
- $text .= "(this.checked, $rownum, $count, 1, 3)\"></TD>";
+ $text .= "(this.checked, $rownum, $count, 1, 3)\"></TD>\n";
#cascade rights
if(array_key_exists($privname, $privs) &&
@@ -1839,11 +1737,13 @@ function getResourcePrivRowHTML($privnam
$text .= " <TD align=center bgcolor=\"#008000\" id=cell$rownum:0>";
$text .= "<INPUT type=checkbox dojoType=dijit.form.CheckBox id=ck$rownum:0 ";
$text .= "onClick=\"privChange(this.checked, $rownum, 0, 3);\" ";
- $text .= "name=\"$name\" $checked $disabled></TD>";
+ $text .= "name=\"$name\" $checked $disabled></TD>\n";
# normal rights
$j = 1;
foreach($types as $type) {
+ if($type == 'block' || $type == 'cascade')
+ continue;
$bgcolor = "";
$checked = "";
$value = "";
@@ -1865,12 +1765,17 @@ function getResourcePrivRowHTML($privnam
$value = "value=single";
}
}
- // if $type is administer or manageGroup, and it is not checked, and the
- # user is not in the resource owner group, don't print the checkbox
- if(($type == "administer" || $type == "manageGroup") &&
+ // if $type is administer, manageGroup, or manageMapping, and it is not
+ # checked, and the user is not in the resource owner group, don't print
+ # the checkbox
+ if(($type == "administer" || $type == "manageGroup" || $type == "manageMapping") &&
$checked != "checked" &&
! array_key_exists($resourcegroups[$id]["ownerid"], $user["groups"])) {
- $text .= "<TD><img src=images/blank.gif></TD>";
+ $text .= "<TD><img src=images/blank.gif></TD>\n";
+ }
+ elseif(($grptype == 'schedule' && ($type == 'available' || $type == 'manageMapping')) ||
+ ($grptype == 'managementnode' && $type == 'available')) {
+ $text .= "<TD><img src=images/blank.gif></TD>\n";
}
else {
$name = "privrow[" . $privname . ":" . $type . "]";
@@ -1878,17 +1783,15 @@ function getResourcePrivRowHTML($privnam
$text .= "type=checkbox dojoType=dijit.form.CheckBox name=\"$name\" ";
$text .= "id=ck$rownum:$j $checked $value $disabled ";
$text .= "onClick=\"nodeCheck(this.checked, $rownum, $j, 3)\">";
- #$text .= "onBlur=\"nodeCheck(this.checked, $rownum, $j, 3)\">";
- $text .= "</TD>";
+ $text .= "</TD>\n";
}
$j++;
}
- $text .= " </TR>";
+ $text .= " </TR>\n";
$count = count($types) + 1;
if($blocked) {
$js .= "changeCascadedRights(true, $rownum, $count, 0, 0);";
}
- $text = preg_replace("/'/", ''', $text);
return array('html' => $text,
'javascript' => $js);
}
@@ -2542,7 +2445,7 @@ function AJsubmitAddResourcePriv() {
}
$perms = explode(':', processInputVar('perms', ARG_STRING));
- $privtypes = array("block", "cascade", "available", "administer", "manageGroup");
+ $privtypes = getResourcePrivs();
$newgroupprivs = array();
foreach($privtypes as $type) {
if(in_array($type, $perms))
Modified: incubator/vcl/trunk/web/.ht-inc/utils.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/utils.php?rev=1028338&r1=1028337&r2=1028338&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/utils.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/utils.php Thu Oct 28 14:54:17 2010
@@ -7417,6 +7417,25 @@ function getResourceTypeID($name) {
////////////////////////////////////////////////////////////////////////////////
///
+/// \fn getResourcePrivs()
+///
+/// \return an array of resource privileges
+///
+/// \brief gets the availabe resource privileges as defined in the resourcepriv
+/// table
+///
+////////////////////////////////////////////////////////////////////////////////
+function getResourcePrivs() {
+ $query = "show columns from resourcepriv where field = 'type'";
+ $qh = doQuery($query, 101);
+ $row = mysql_fetch_assoc($qh);
+ preg_match("/^enum\(([a-zA-Z0-9,']+)\)$/", $row['Type'], $matches);
+ $tmp = str_replace("'", '', $matches[1]);
+ return explode(',', $tmp);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
/// \fn getNodeInfo($nodeid)
///
/// \param $nodeid - an id from the privnode table
Modified: incubator/vcl/trunk/web/js/images.js
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/js/images.js?rev=1028338&r1=1028337&r2=1028338&view=diff
==============================================================================
--- incubator/vcl/trunk/web/js/images.js (original)
+++ incubator/vcl/trunk/web/js/images.js Thu Oct 28 14:54:17 2010
@@ -37,7 +37,7 @@ function addRemItem(cont, objid1, objid2
dojo.xhrPost({
url: 'index.php',
load: cb,
- handleAs: "json-comment-filtered",
+ handleAs: "json",
error: errorHandler,
content: {continuation: cont,
listids: listids,
@@ -289,7 +289,7 @@ function getImagesButton() {
dojo.xhrPost({
url: 'index.php',
- handleAs: "json-comment-filtered",
+ handleAs: "json",
load: imagesCallback,
error: errorHandler,
content: {continuation: obj.value,
@@ -332,7 +332,7 @@ function getGroupsButton() {
dojo.xhrPost({
url: 'index.php',
- handleAs: "json-comment-filtered",
+ handleAs: "json",
load: groupsCallback,
error: errorHandler,
content: {continuation: obj.value,
@@ -375,7 +375,7 @@ function getMapCompGroupsButton() {
dojo.xhrPost({
url: 'index.php',
- handleAs: "json-comment-filtered",
+ handleAs: "json",
load: mapCompGroupsCB,
error: errorHandler,
content: {continuation: obj.value,
@@ -418,7 +418,7 @@ function getMapImgGroupsButton() {
dojo.xhrPost({
url: 'index.php',
- handleAs: "json-comment-filtered",
+ handleAs: "json",
load: mapImgGroupsCB,
error: errorHandler,
content: {continuation: obj.value,
@@ -460,7 +460,7 @@ function updateRevisionComments(id, cont
var comments = dijit.byId(id).value;
dojo.xhrPost({
url: 'index.php',
- handleAs: "json-comment-filtered",
+ handleAs: "json",
load: updateRevisionCommentsCB,
error: errorHandler,
content: {continuation: cont,
@@ -495,7 +495,7 @@ function deleteRevisions(cont, idlist) {
checkedids = checkedids.join(',');
dojo.xhrPost({
url: 'index.php',
- handleAs: "json-comment-filtered",
+ handleAs: "json",
load: deleteRevisionsCB,
error: errorHandler,
content: {continuation: cont,