home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
borland
/
ib
/
setups
/
intrabld
/
data.z
/
SMRADMIN.JFM
< prev
next >
Wrap
Text File
|
1996-12-11
|
16KB
|
510 lines
/****************************************************************************\
* *
* SmRAdmin.jfm -- Security Resource Administration Form *
* *
* This form is part of the security administration prebuilt business *
* solution. This is the resource adminstration form. It allows you to define *
* new groups and update existing resources. This form is called from the *
* SmAdmin form. *
* *
* Dependencies: secur21.gif *
* *
* Updated 11/13/96 by IntraBuilder Samples Group *
* $Revision: 1.10 $ *
* *
* Copyright (c) 1996, Borland International, Inc. All rights reserved. *
* *
\****************************************************************************/
#include "security.h"
// {End Header} Do not remove this comment//
// Generated on 11/13/96
//
var f = new smradminForm();
f.open();
class smradminForm extends SecurityForm from "SMADMIN.JCF" {
_sys.scripts.load(_sys.env.home() + "APPS\\SHARED\\CONTROLS.CC")
with (this) {
onServerLoad = class::Form_onServerLoad;
color = "fff7c4";
height = 14.6667;
left = 0;
top = 0;
width = 74;
title = "Resource Administration";
}
with (this.rule1 = new Rule(this)){
top = 4;
size = 2;
right = 74;
pageno = 0;
}
with (this.rule2 = new Rule(this)){
top = 17;
size = 2;
right = 74;
pageno = 0;
}
with (this.actionHTML = new HTML(this)){
height = 1;
left = 12;
top = 2;
width = 28;
color = "400040";
text = "Update Existing Resource";
}
with (this.saveButton = new Button(this)){
onServerClick = class::saveButton_onServerClick;
left = 40;
top = 2;
width = 14;
text = "Save";
}
with (this.exitButton = new Button(this)){
onServerClick = class::exitButton_onServerClick;
left = 56;
top = 2;
width = 14;
text = " Exit ";
}
with (this.resourceHTML = new HTML(this)){
height = 1;
top = 4.5;
width = 18;
color = "400040";
alignVertical = 1;
text = "Resource name";
}
with (this.resourcenameHTML = new HTML(this)){
height = 1;
left = 18;
top = 4.5;
width = 18;
color = "black";
alignVertical = 1;
text = "resourcename";
}
with (this.resourcenameText = new Text(this)){
visible = false;
left = 18;
top = 4.5;
width = 18;
value = "resourcename";
}
with (this.descriptionHTML = new HTML(this)){
height = 1;
top = 5.5;
width = 18;
color = "400040";
alignVertical = 1;
text = "Description";
}
with (this.descriptionText = new Text(this)){
left = 18;
top = 5.5;
width = 40;
value = "description";
}
with (this.inUserHTML = new HTML(this)){
height = 1;
top = 12;
width = 24;
color = "400040";
text = "Users with access";
}
with (this.outUserHTML = new HTML(this)){
height = 1;
left = 48;
top = 12;
width = 24;
color = "400040";
text = "Users without access";
}
with (this.inUserSelect = new ListBox(this)){
height = 3.5;
top = 13;
width = 24;
}
with (this.addUserButton = new Button(this)){
onServerClick = class::addUserButton_onServerClick;
left = 26;
top = 13;
width = 20;
text = "Add User";
}
with (this.removeUserButton = new Button(this)){
onServerClick = class::removeUserButton_onServerClick;
left = 26;
top = 14.5;
width = 20;
text = "Remove User";
}
with (this.outUserSelect = new ListBox(this)){
height = 3.5;
left = 48;
top = 13;
width = 24;
}
with (this.inGroupHTML = new HTML(this)){
height = 1;
top = 7;
width = 24;
color = "400040";
text = "Groups with access";
}
with (this.outGroupHTML = new HTML(this)){
height = 1;
left = 48;
top = 7;
width = 24;
color = "400040";
text = "Groups without access";
}
with (this.inGroupSelect = new ListBox(this)){
height = 3.5;
top = 8;
width = 24;
}
with (this.addGroupButton = new Button(this)){
onServerClick = class::addGroupButton_onServerClick;
left = 26;
top = 8;
width = 20;
text = "Add Group";
}
with (this.removeGroupButton = new Button(this)){
onServerClick = class::removeGroupButton_onServerClick;
left = 26;
top = 9.5;
width = 20;
text = "Remove Group";
}
with (this.outGroupSelect = new ListBox(this)){
height = 3.5;
left = 48;
top = 8;
width = 24;
}
with (this.errorHTML = new HTML(this)){
height = 5;
top = 5;
width = 74;
color = "black";
text = "Error loading group administration form. Notify system administrator.";
pageno = 2;
}
with (this.backButton = new Button(this)){
onServerClick = {;this.form.pageno = 1};
top = 10;
width = 20;
text = "Back";
pageno = 2;
}
with (this.GeneratedHTML1 = new GeneratedHTML(this)){
height = 1;
top = 17.5;
width = 74;
pageno = 0;
}
function Form_onServerLoad()
{
try {
//
// make sure that all the custom properties are set
//
var x = this.copyEntity?1:0;
var x = this.entity.name;
var x = this.security._admin;
var x = this.callingForm.title;
//
// set the action text
//
this.createNew = true;
if (this.entity.name == null)
this.actionHTML.text = "Create New Resource";
else if (this.copyEntity)
this.actionHTML.text = ("Copy " + this.entity.name + " To New Resource");
else {
this.createNew = false;
this.actionHTML.text = "Update Existing Resource";
}
//
// set the control values on this form
//
if (this.createNew) {
this.resourcenameText.value = new StringEx().replicate(" ",20);
this.resourcenameText.visible = true;
this.resourcenameHTML.visible = false;
}
else {
this.resourcenameHTML.text = this.entity.name;
this.resourcenameHTML.visible = true;
this.resourcenameText.visible = false;
}
this.descriptionText.value = (this.entity.description == null) ?
new StringEx().replicate(" ",80) :
this.entity.description;
// create arrays for the select controls
this.inUser = new Array();
this.outUser = new Array();
this.inGroup = new Array();
this.outGroup = new Array();
// save original groups/users for use in save
this.inUserStart = new Array();
this.inGroupStart = new Array();
var entity = "";
// build user lists
if (this.createNew)
var inUser = new AssocArray();
else
var inUser = this.security.getAllUsers(this.entity.name, SM_ENTITY_RESOURCE);
var outUser = this.security.getAllUsers();
// add all in users to list
for (var i = 0; i<inUser.count(); i++) {
entity = (i==0) ? inUser.firstKey : inUser.nextKey(entity);
this.inUser.add(entity);
this.inUserStart.add(entity);
}
this.inUser.sort();
this.inUserSelect.options = 'array this.inUser';
// add users to out list if they are not in in list
for (i = 0; i<outUser.count(); i++) {
entity = (i==0) ? outUser.firstKey : outUser.nextKey(entity);
if (!inUser.isKey(entity))
this.outUser.add(entity);
}
this.outUser.sort();
this.outUserSelect.options = 'array this.outUser';
// build group lists
if (this.entity.name == null)
var inGroup = new AssocArray();
else
var inGroup = this.security.getAllGroups(this.entity.name, SM_ENTITY_RESOURCE);
var outGroup = this.security.getAllGroups();
// add all in group to list
for (var i = 0; i<inGroup.count(); i++) {
entity = (i==0) ? inGroup.firstKey : inGroup.nextKey(entity);
this.inGroup.add(entity);
this.inGroupStart.add(entity);
}
this.inGroup.sort();
this.inGroupSelect.options = 'array this.inGroup';
// add groups to out list if they are not in in list
for (i = 0; i<outGroup.count(); i++) {
entity = (i==0) ? outGroup.firstKey : outGroup.nextKey(entity);
if (!inGroup.isKey(entity))
this.outGroup.add(entity);
}
this.outGroup.sort();
this.outGroupSelect.options = 'array this.outGroup';
}
catch (Exception e) {
form.errorHTML.text = "Error loading resource: " + e.message + " (" + e.code + ")";
this.pageno = 2;
}
}
function saveButton_onServerClick()
{
var form = this.form;
try {
// have an exception ready
var error = new Exception();
error.message = "";
error.code = 0;
//
// set the properties of the entity object
//
// resource name
if (form.createNew) {
var name = new StringEx(form.resourcenameText.value);
name.string = name.leftTrim();
name.string = name.rightTrim();
if (name.length == 0) {
error.message = "Resource name may not be blank";
throw error;
}
else
form.entity.name = name;
}
// description
form.entity.description = form.descriptionText.value;
//
// call create/update with entity object
//
if (form.createNew)
form.security.createResource(form.entity);
else
form.security.updateResource(form.entity);
//
// assign user privileges
//
for (var i = 0; i<form.inUser.length; i++) {
if ((form.createNew) || (form.inUserStart.scan(form.inUser[i]) < 0))
form.security.assignResourceUser(form.entity.name,form.inUser[i]);
}
//
// assign group privileges
//
for (var i = 0; i<form.inGroup.length; i++) {
if ((form.createNew) || (form.inGroupStart.scan(form.inGroup[i]) < 0))
form.security.assignResourceGroup(form.entity.name,form.inGroup[i]);
}
//
// remove user privileges for existing resources only
//
if (!form.createNew) {
for (var i = 0; i<form.inUserStart.length; i++) {
if (form.inUser.scan(form.inUserStart[i]) < 0)
form.security.unassignResourceUser(form.entity.name,form.inUserStart[i]);
}
}
//
// remove group privileges for existing resources only
//
if (!form.createNew) {
for (var i = 0; i<form.inGroupStart.length; i++) {
if (form.inGroup.scan(form.inGroupStart[i]) < 0)
form.security.unassignResourceGroup(form.entity.name,form.inGroupStart[i]);
}
}
//
// Successful change, no longer in createNew mode
//
if (form.createNew) {
form.createNew = false;
form.actionHTML.text = "Update Existing Resource";
form.resourcenameHTML.text = form.entity.name;
form.resourcenameHTML.visible = true;
form.resourcenameText.visible = false;
}
//
// current inXxxxx arrays become the inXxxxxStart arrays
//
form.inUserStart = new Array();
form.inGroupStart = new Array();
for (var i = 0; i<form.inUser.length; i++)
form.inUserStart.add(form.inUser[i]);
for (var i = 0; i<form.inGroup.length; i++)
form.inGroupStart.add(form.inGroup[i]);
}
catch (Exception e) {
form.errorHTML.text = "Error saving resource: " + e.message + " (" + e.code + ")";
form.pageno = 2;
}
}
function exitButton_onServerClick()
{
try {
this.form.callingForm.open();
this.form.close();
this.form.release();
}
catch (Exception e) {
this.form.errorHTML.text = "Unable to return to calling form.";
this.form.pageno = 2;
}
}
function addUserButton_onServerClick()
{
if ((this.form.outUserSelect.value.length > 0) && (this.form.outUser.scan(this.form.outUserSelect.value) >= 0)) {
this.form.inUser.add(this.form.outUserSelect.value);
this.form.inUser.sort();
this.form.inUserSelect.options = "array this.form.inUser";
this.form.outUser.delete(this.form.outUser.scan(this.form.outUserSelect.value));
this.form.outUser.length -= 1;
this.form.outUserSelect.options = "array this.form.outUser";
}
}
function removeUserButton_onServerClick()
{
if ((this.form.inUserSelect.value.length > 0) && (this.form.inUser.scan(this.form.inUserSelect.value) >= 0)) {
this.form.outUser.add(this.form.inUserSelect.value);
this.form.outUser.sort();
this.form.outUserSelect.options = "array this.form.outUser";
this.form.inUser.delete(this.form.inUser.scan(this.form.inUserSelect.value));
this.form.inUser.length -= 1;
this.form.inUserSelect.options = "array this.form.inUser";
}
}
function addGroupButton_onServerClick()
{
if ((this.form.outGroupSelect.value.length > 0) && (this.form.outGroup.scan(this.form.outGroupSelect.value) >= 0)) {
this.form.inGroup.add(this.form.outGroupSelect.value);
this.form.inGroup.sort();
this.form.inGroupSelect.options = "array this.form.inGroup";
this.form.outGroup.delete(this.form.outGroup.scan(this.form.outGroupSelect.value));
this.form.outGroup.length -= 1;
this.form.outGroupSelect.options = "array this.form.outGroup";
}
}
function removeGroupButton_onServerClick()
{
if ((this.form.inGroupSelect.value.length > 0) && (this.form.inGroup.scan(this.form.inGroupSelect.value) >= 0)) {
this.form.outGroup.add(this.form.inGroupSelect.value);
this.form.outGroup.sort();
this.form.outGroupSelect.options = "array this.form.outGroup";
this.form.inGroup.delete(this.form.inGroup.scan(this.form.inGroupSelect.value));
this.form.inGroup.length -= 1;
this.form.inGroupSelect.options = "array this.form.inGroup";
}
}
}