home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
borland
/
ib
/
setups
/
intrabld
/
data.z
/
SMGADMIN.JFM
< prev
next >
Wrap
Text File
|
1996-12-11
|
16KB
|
510 lines
/****************************************************************************\
* *
* SmGAdmin.jfm -- Security Group Administration Form *
* *
* This form is part of the security administration prebuilt business *
* solution. This is the group adminstration form. It allows you to define *
* new groups and update existing groups. This form is called from the *
* SmAdmin form. *
* *
* Dependencies: secur21.gif *
* *
* Updated 11/13/96 by IntraBuilder Samples Group *
* $Revision: 1.11 $ *
* *
* 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 smgadminForm();
f.open();
class smgadminForm 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;
left = 0;
top = 0;
width = 74;
title = "Group Administration";
}
with (this.rule1 = new Rule(this)){
top = 17;
size = 2;
right = 74;
pageno = 0;
}
with (this.rule2 = new Rule(this)){
top = 4;
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 Group";
}
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.groupHTML = new HTML(this)){
height = 1;
top = 4.5;
width = 14;
color = "400040";
alignVertical = 1;
text = "Group name";
}
with (this.groupnameHTML = new HTML(this)){
height = 1;
left = 14;
top = 4.5;
width = 14;
color = "black";
alignVertical = 1;
text = "groupname";
}
with (this.groupnameText = new Text(this)){
visible = false;
left = 14;
top = 4.5;
width = 14;
value = "groupname";
}
with (this.descriptionHTML = new HTML(this)){
height = 1;
top = 5.5;
width = 14;
color = "400040";
alignVertical = 1;
text = "Description";
}
with (this.descriptionText = new Text(this)){
left = 14;
top = 5.5;
width = 36;
value = "description";
}
with (this.inUserHTML = new HTML(this)){
height = 1;
top = 7;
width = 24;
color = "400040";
text = "Member Users";
}
with (this.outUserHTML = new HTML(this)){
height = 1;
left = 48;
top = 7;
width = 24;
color = "400040";
text = "Non-Member Users";
}
with (this.inUserSelect = new ListBox(this)){
height = 3.5;
top = 8;
width = 24;
}
with (this.addUserButton = new Button(this)){
onServerClick = class::addUserButton_onServerClick;
left = 26;
top = 8;
width = 20;
text = "Add User";
}
with (this.removeUserButton = new Button(this)){
onServerClick = class::removeUserButton_onServerClick;
left = 26;
top = 9.5;
width = 20;
text = "Remove User";
}
with (this.outUserSelect = new ListBox(this)){
height = 3.5;
left = 48;
top = 8;
width = 24;
}
with (this.inResourceHTML = new HTML(this)){
height = 1;
top = 12;
width = 24;
color = "400040";
text = "May access resource";
}
with (this.outResourceHTML = new HTML(this)){
height = 1;
left = 48;
top = 12;
width = 24;
color = "400040";
text = "May not access resource";
}
with (this.inResourceSelect = new ListBox(this)){
height = 3.5;
top = 13;
width = 24;
}
with (this.addResourceButton = new Button(this)){
onServerClick = class::addResourceButton_onServerClick;
left = 26;
top = 13;
width = 20;
text = "Add Res.";
}
with (this.removeResourceButton = new Button(this)){
onServerClick = class::removeResourceButton_onServerCli;
left = 26;
top = 14.5;
width = 20;
text = "Remove Res.";
}
with (this.outResourceSelect = new ListBox(this)){
height = 3.5;
left = 48;
top = 13;
width = 24;
}
with (this.errorHTML = new HTML(this)){
height = 4;
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 = 9;
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 Group";
else if (this.copyEntity)
this.actionHTML.text = ("Copy " + this.entity.name + " To New Group");
else {
this.createNew = false;
this.actionHTML.text = "Update Existing Group";
}
//
// set the control values on this form
//
if (this.createNew) {
this.groupnameText.value = new StringEx().replicate(" ",20);
this.groupnameText.visible = true;
this.groupnameHTML.visible = false;
}
else {
this.groupnameHTML.text = this.entity.name;
this.groupnameHTML.visible = true;
this.groupnameText.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.inResource = new Array();
this.outResource = new Array();
// save original groups/resources for use in save
this.inUserStart = new Array();
this.inResourceStart = 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_GROUP);
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 resource lists
if (this.entity.name == null)
var inResource = new AssocArray();
else
var inResource = this.security.getAllResources(this.entity.name, SM_ENTITY_GROUP);
var outResource = this.security.getAllResources();
// add all in resources to list
for (var i = 0; i<inResource.count(); i++) {
entity = (i==0) ? inResource.firstKey : inResource.nextKey(entity);
this.inResource.add(entity);
this.inResourceStart.add(entity);
}
this.inResource.sort();
this.inResourceSelect.options = 'array this.inResource';
// add resources to out list if they are not in in list
for (i = 0; i<outResource.count(); i++) {
entity = (i==0) ? outResource.firstKey : outResource.nextKey(entity);
if (!inResource.isKey(entity))
this.outResource.add(entity);
}
this.outResource.sort();
this.outResourceSelect.options = 'array this.outResource';
}
catch (Exception e) {
this.errorHTML.text = "Error loading group: " + 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
//
// group name
if (form.createNew) {
var name = new StringEx(form.groupnameText.value);
name.string = name.leftTrim();
name.string = name.rightTrim();
if (name.length == 0) {
error.message = "Group 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.createGroup(form.entity);
else
form.security.updateGroup(form.entity);
//
// assign user membership
//
for (var i = 0; i<form.inUser.length; i++) {
if ((form.createNew) || (form.inUserStart.scan(form.inUser[i]) < 0))
form.security.assignGroupUser(form.entity.name,form.inUser[i]);
}
//
// assign resource privileges
//
for (var i = 0; i<form.inResource.length; i++) {
if ((form.createNew) || (form.inResourceStart.scan(form.inResource[i]) < 0))
form.security.assignResourceGroup(form.inResource[i],form.entity.name);
}
//
// remove user memberships for existing groups only
//
if (!form.createNew) {
for (var i = 0; i<form.inUserStart.length; i++) {
if (form.inUser.scan(form.inUserStart[i]) < 0)
form.security.unassignGroupUser(form.entity.name,form.inUserStart[i]);
}
}
//
// remove resource privileges for existing groups only
//
if (!form.createNew) {
for (var i = 0; i<form.inResourceStart.length; i++) {
if (form.inResource.scan(form.inResourceStart[i]) < 0)
form.security.unassignResourceGroup(form.inResourceStart[i],form.entity.name);
}
}
//
// Successful change, no longer in createNew mode
//
if (form.createNew) {
form.createNew = false;
form.actionHTML.text = "Update Existing Group";
form.groupnameHTML.text = form.entity.name;
form.groupnameHTML.visible = true;
form.groupnameText.visible = false;
}
//
// current inXxxxx arrays become the inXxxxxStart arrays
//
form.inUserStart = new Array();
form.inResourceStart = new Array();
for (var i = 0; i<form.inUser.length; i++)
form.inUserStart.add(form.inUser[i]);
for (var i = 0; i<form.inResource.length; i++)
form.inResourceStart.add(form.inResource[i]);
}
catch (Exception e) {
form.errorHTML.text = "Error saving group: " + 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 addResourceButton_onServerClick()
{
if ((this.form.outResourceSelect.value.length > 0) && (this.form.outResource.scan(this.form.outResourceSelect.value) >= 0)) {
this.form.inResource.add(this.form.outResourceSelect.value);
this.form.inResource.sort();
this.form.inResourceSelect.options = "array this.form.inResource";
this.form.outResource.delete(this.form.outResource.scan(this.form.outResourceSelect.value));
this.form.outResource.length -= 1;
this.form.outResourceSelect.options = "array this.form.outResource";
}
}
function removeResourceButton_onServerClick()
{
if ((this.form.inResourceSelect.value.length > 0) && (this.form.inResource.scan(this.form.inResourceSelect.value) >= 0)) {
this.form.outResource.add(this.form.inResourceSelect.value);
this.form.outResource.sort();
this.form.outResourceSelect.options = "array this.form.outResource";
this.form.inResource.delete(this.form.inResource.scan(this.form.inResourceSelect.value));
this.form.inResource.length -= 1;
this.form.inResourceSelect.options = "array this.form.inResource";
}
}
}