subroutine w3Admin.w3Apps.update(appName)
**************************************************************************
* 09 FEB 01 DJZ Initial draft.
* w3Admin.w3Apps.update
* editEntry
* genUpdateForm
* getValues
* updateItem
* newEntry
* genUpdateForm
* getValues
* updateItem
**************************************************************************
$options EXT
include wbp w3include
include bp w3Admin.Include
equ WAITTIME to 300
if appName # '' then ; * appName specified?
gosub editEntry ; * yup, edit and existing item
end else
gosub newEntry ; * nope, this is a new item
end
return
**************************************************************************
editEntry:
**************************************************************************
editMode = 1
gosub genUpdateForm
gosub getValues
if rsubmit # 'Cancel' then
ischanged = 0
usersInCnt = dcount(rusersIn, @vm) ;* note if user clicked on any names in users or groups
usersOutCnt = dcount(rusersOut, @vm)
groupsInCnt = dcount(rgroupsIn, @vm)
groupsOutCnt = dcount(rgroupsOut, @vm)
if trim(description) # trim(rdescription) then ischanged = 1
if usersInCnt > 0 OR usersOutCnt > 0 OR groupsInCnt > 0 OR groupsOutCnt > 0 then ischanged = 1
if raccount # account then ischanged = 1
if rpassword # password then ischanged = 1
if rssl # ssl then ischanged = 1
if rprofile # profile then ischanged = 1
if ranon # anon then ischanged = 1
if rdebugmode # debugmode then ischanged = 1
if rtimeout # timeout then ischanged = 1
if rprogram # program then ischanged = 1
if rcategory # category then ischanged = 1
if ischanged then ;* The user made a change, gotta update the item
call w3admin.w3apps.delete(rappName)
rusers = users
rgroups= groups
convert @vm to @am in rusersIn ;* prepare to use "locate" command
convert @vm to @am in rusersOut
convert @vm to @am in rgroupsIn
convert @vm to @am in rgroupsOut
for i = 1 to usersInCnt
locate(rusersIn<i>, rusers;loc) then
rusers = delete(rusers, loc)
end
next i
for j = 1 to usersOutCnt
rusers<-1> = rusersOut<j>
next j
for i = 1 to groupsInCnt
locate(rgroupsIn<i>, rgroups;loc) then
rgroups = delete(rgroups, loc)
end
next i
for j = 1 to groupsOutCnt
rgroups<-1> = rgroupsOut<j>
next j
convert @am to @vm in rusers
convert @am to @vm in rgroups
gosub updateItem
end
end
return
**************************************************************************
newEntry:
**************************************************************************
editMode = 0
gosub genUpdateForm
gosub getValues
if rsubmit # 'Cancel' then
rusers = rusersOut
rgroups = rgroupsOut
gosub updateItem
end
return
**************************************************************************
getValues:
* if the user didn't select "Cancel" then retrieve the values
* from the form
**************************************************************************
if rsubmit # 'Cancel' then ;* if it wasn't cancel, then process the values
call w3GetVal(rappName, 'appName')
call w3GetVal(rdescription, 'desc')
rdescription = swap(rdescription, char(13):char(10), ' ')
call w3GetVal(rusersIn, ']usersIn')
call w3GetVal(rusersOut, ']usersOut')
call w3GetVal(raccount, 'acct')
call w3GetVal(rpassword, 'passwd')
call w3GetVal(rssl, 'SSL')
roptions = ''
if rssl # '' then
rssl = 'S'
roptions := 'S'
end
call w3GetVal(rprofile, 'profile')
if rprofile # '' then
rprofile = 'Y'
end
call w3GetVal(ranon, 'anon')
if ranon # '' then
ranon = 'Y'
end
call w3GetVal(rdebugmode, 'dbmode')
if rdebugmode # '' then
rdebugmode = 'D'
roptions := 'D'
end
call w3GetVal(rgroupsIn, ']groupsIn')
call w3GetVal(rgroupsOut, ']groupsOut')
call w3GetVal(rtimeout, 'timeout')
call w3GetVal(rprogram, 'program')
call w3GetVal(rcategory, 'category')
end
return
**************************************************************************
genUpdateForm:
* build the form and wait for the user to fill it out
* if editmode = 1, then initialize the form with data from the
* specified item (appName)
**************************************************************************
call w3HtmlInit('w3admin2', '')
subs = ''
subs<-1> = '##TITLE##':@vm:'FlashCONNECT Applications Maintenance'
subs<-1> = '#HEADLINE#':@vm:'FlashCONNECT Applications Maintenance'
call w3HtmlHeader('', subs)
w3AppsItem = ''
if editMode then
call w3Admin.w3Apps.Get(appName, w3AppsItem); * assume read ok and
anon = oconv(w3AppsItem<1>, 'mcu')
users= w3AppsItem<2>
convert @vm to @am in users
groups = w3AppsItem<3>
description = w3AppsItem<4>
account = w3AppsItem<5>
password = w3AppsItem<6>
profile = oconv(w3AppsItem<7>, 'mcu')
options = oconv(w3AppsItem<8>, 'mcu')
program = w3AppsItem<9>
timeout = w3AppsItem<10>
category = w3AppsItem<11>
end else
anon = ''
users = ''
groups = ''
description = ''
account = ''
password = ''
options = ''
profile = ''
program = ''
timeout = ''
category = ''
end
if index(options, 'S', 1) then
ssl = 'S'
sslchecked = ' checked'
end else
ssl = ''
sslchecked = ''
end
if index(options, 'D', 1) then
debugmode = 'D'
debugmodechecked = ' checked'
end else
debugmode = ''
debugmodechecked = ''
end
if anon = 'Y' then
anonchecked = ' checked'
end else
anonchecked = ''
end
if profile = 'Y' then
profilechecked = ' checked'
end else
profilechecked = ''
end
call w3HtmlFormBeg('', '')
call w3HtmlInsertSection('w3Admin.w3Apps.template', '', 'section1')
if editMode then
sub = '##APPNAME##':@vm:appName
call w3HtmlInsertSection('w3Admin.w3Apps.template', sub, 'section2')
end else
call w3HtmlInsertSection('w3Admin.w3Apps.template', '', 'section3')
end
sub = '##DESCRIPTION##':@vm:trim(description)
call w3HtmlInsertSection('w3Admin.w3Apps.template', sub, 'section4')
call w3printn("Members<BR>")
call w3HtmlSelect('usersIn', users, users, '', '', 'multiple size="1"', '')
outlist = ''
call w3admin.w3users.getIds(outlist); * return list of all users' id in file w3users
cnt = dcount(users, @am)
inList = ''
for i = 1 to cnt
locate(users<i>, outlist;loc) then
inList<-1> = outlist<loc>
outlist = delete(outlist, loc)
end
next i
call w3printn("<BR>Non-Members<BR>")
call w3HtmlSelect('usersOut', outlist, outlist, '', '', 'multiple size="1"', '')
sub = '##PROGRAM##':@vm:program
sub<-1> = '##ACCOUNT##':@vm:account
sub<-1> = '##PASSWORD##':@vm:password
sub<-1> = '##SSLCHECKED##':@vm:sslchecked
sub<-1> = '##PROFILECHECKED##':@vm:profilechecked
sub<-1> = '##ANONCHECKED##':@vm:anonchecked
sub<-1> = '##DBMODECHECKED##':@vm:debugmodechecked
call w3HtmlInsertSection('w3Admin.w3Apps.template', sub, 'section5')
** handle groups
groupid = ''
groupdesc = ''
dummy1 = ''
dummy2 = ''
open 'w3groups' to f.w3groups else exit
call w3Admin.w3Groups.GetInfo(groupid, groupdesc, dummy1, dummy2)
convert @vm to @am in groups
cnt = dcount(groups, @am)
outGroupId = groupid
outGroupdesc = groupdesc
inGroupId = ''
inGroupDesc = ''
for i = 1 to cnt
locate(groups<i>, outGroupId; loc) then
inGroupId<-1> = outGroupId<loc>
inGroupDesc<-1> = outGroupDesc<loc>
outGroupId = delete(outGroupId, loc)
outGroupDesc = delete(outGroupDesc, loc)
end
next i
call w3printn("Members<BR>")
call w3HtmlSelect('groupsIn', inGroupId, inGroupDesc, '', '', 'multiple size="1"', '')
call w3printn("<BR>Non-Members<BR>")
call w3HtmlSelect('groupsOut', outGroupId, outGroupDesc, '', '', 'multiple size="1"', '')
sub = '##TIMEOUT##':@vm:timeout
sub<-1> = '##CATEGORY##':@vm:category
call w3HtmlInsertSection('w3Admin.w3Apps.template', sub, 'section6')
if editMode then
txt = 'Update'
end else
txt = 'Add'
end
sub = '##BUTTONTEXT##':@vm:txt
call w3HtmlInsertSection('w3Admin.w3Apps.template', sub, 'section7')
call w3HtmlFormEnd
call w3HtmlFooter('', '')
call w3Input(err, WAITTIME, '')
if err # w3_OK then
rsubmit = 'Cancel'
end else
call w3GetVal(rsubmit, 'B1')
end
return
******************************************************************
updateItem:
******************************************************************
item = ''
item<1> = ranon
item<2> = rusers
item<3> = rgroups
item<4> = trim(rdescription)
item<5> = raccount
item<6> = rpassword
item<7> = rprofile
item<8> = roptions
item<9> = rprogram
item<10>= rtimeout
item<11>= rcategory
call w3admin.w3apps.save(rappName, item)
return