w3Admin.w3Apps.create

subroutine w3Admin.w3Apps.create

**************************************************************************

* 09 FEB 01  DJZ  Initial draft.

**************************************************************************

include wbp w3include

equ WAITTIME to 300

* define variables for each attribute in the w3Apps item

equ anon        to w3AppsItem<1>

equ users       to w3AppsItem<2>

equ description to w3AppsItem<4>

equ groups      to w3AppsItem<3>

equ account     to w3AppsItem<5>                          

equ password    to w3AppsItem<6>

equ profile     to w3AppsItem<7>

equ options     to w3AppsItem<8>

equ program     to w3AppsItem<9>

equ timeout     to w3AppsItem<10>

status = ''

call w3Admin.Housekeeping(status)

*  Handle housekeeping errorsif status # '' then   

   call w3HtmlInit(w3Admin.background, '')   

   subs     = ''   subs<-1> = '##TITLE##':@vm:'wAdmin Fatal Error'

   subs<-1> = '##HEADLINE##':@VM:'w3Admin Initialization Error'   

   call w3HtmlHeader('', subs)   

   call w3HtmlInsertSection('w3Config', '', 'head')   

*  Insert messages   

   msgs = dcount(status, @am)   

   call w3HtmlInsertSection('w3Config', '', 'Messages.start')   

   for i = 1 to msgs                        

       text = trim(status<i>)      

       if text # '' then         

          subs = '#text#':@vm:status<i>         

          call w3HtmlInsertSection('w3Config', subs, 'Messages.text')

       end   

   next i   

   call w3HtmlInsertSection('w3Config', '', 'Messages.end')   

   call w3HtmlFooter('','')   

   return

end

loop

   gosub genNamesForm

   begin case

      case cmd = 'Edit';   gosub editEntry

      case cmd = 'Delete'; gosub deleteEntry

      case cmd = 'New';    gosub newEntry

   end case

until cmd = 'Quit' do

repeat

   

return

**************************************************************************

genNamesForm:

**************************************************************************

call w3HtmlInit('w3Admin', '')

subs     = ''

subs<-1> = '##TITLE##':@vm:'w3Apps Editor'

subs<-1> = '#HEADLINE#':@vm:'w3Apps Editor'

call w3HtmlHeader('', subs)

call w3HtmlFormBeg('', "")

list.id = ""

call w3Admin.w3Apps.GetNames(list.id)

call w3HtmlSelect("appName", list.id, list.id, '', 'size="1"', '')

call w3HtmlSubmit('B1', 'Edit', '')

call w3HtmlSubmit('B1', 'Delete', '')

call w3HtmlSubmit('B1', 'New', '')

call w3HtmlSubmit('B1', 'Quit', '')

call w3Printn('<input type="reset" value="Reset" name="B2">')

call w3HtmlFormEnd

call w3HtmlFooter( '', '')

call w3Input(err, WAITTIME, '')

if err # w3_OK then

   cmd = 'Quit'

end else

   call w3GetVal(cmd, 'B1')

   call w3GetVal(appName, 'appName')

end

return

**************************************************************************

editEntry:

**************************************************************************

editMode = 1

gosub genUpdateForm

gosub getValues

return

**************************************************************************

newEntry:

**************************************************************************

editMode = ''

gosub genUpdateForm

gosub getValues

return

**************************************************************************

getValues:

**************************************************************************

call w3GetVal(appName, 'appName')

call w3GetVal(description, 'desc')

call w3GetVal(usersIn, 'usersIn')

call w3GetVal(usersOut, 'usersOut')

call w3GetVal(account, 'acct')

call w3GetVal(password, 'passwd')

call w3GetVal(ssl, 'SSL')

call w3GetVal(profile, 'profile')

call w3GetVal(anon, 'anon')

call w3GetVal(debugmode, 'dbmode')

call w3GetVal(groupsIn, 'groupsIn')

call w3GetVal(groupsOut, 'groupsOut')

call w3GetVal(timeout, 'timeout')

return

**************************************************************************

deleteEntry:

**************************************************************************

execute 'delete from appnames where id=':appName

return

**************************************************************************

genUpdateForm:

**************************************************************************

w3AppsItem = ""

ssl        = 0

debugmode  = 0

if editMode then

   call w3Admin.w3Apps.Get(appName, w3AppsItem)   ;* assume read ok and

   debugmode = index(options, "D", 1)             ;* not a new item

   ssl       = index(options, "S", 1)

end

call w3HtmlInit('w3Apps', '')

call w3HtmlHeader('', '')

call w3HtmlFormBeg('', '')

call w3Printn('<table BORDER><tr>')

call w3Printn('<td bgcolor="#C0C0C0">Application</td>')

call w3Printn('<td bgcolor="#C0C0C0" colspan="2">Description</td>')

call w3Printn('<td bgcolor="#C0C0C0">Users</td>')

call w3Printn('<td bgcolor="#C0C0C0">Program</td>')

call w3Printn('</tr><tr><td>')

if editMode then

   call w3Printn(appName)

   call w3Hidden('appName', appName, '')

else

   call w3Printn('<input type="text" name="appName" size="10">')

end

call w3Printn('</td><td colspan="2"><textarea name="desc" rows="2" cols="40">')

if editMode then

   call w3Printn(description)

end

call w3Printn('</textarea></td>')

call w3Printn('<td>')

 

call w3HtmlSelect('usersIn', users, users, '', 'multiple size="4"', '')

if editMode then

   list.id = execute 'sselect user-File where user not in' capturing x returning y

else

   list.id = execute 'sselect user-File' capturing x returning y

end

call w3HtmlSelect('usersOut', list.id, list.id, '', 'multiple size="4"', '')

call w3Printn('</td></tr><tr>')

call w3Printn('<td bgcolor="#C0C0C0">Account</td>')

call w3Printn('<td bgcolor="#C0C0C0">Password</td>')

call w3Printn('<td bgcolor="#C0C0C0">Options</td>')

call w3Printn('<td bgcolor="#C0C0C0">Groups</td>')

call w3Printn('<td bgcolor="#C0C0C0">Timeout</td></tr>')

call w3Printn('<tr><td><input type="text" name="acct" size="8"')

if editMode then

   call w3Printn('value="':account:'"')

end

call w3Printn('></td>')

call w3Printn('<td><input type="text" name="passwd" size="8"')

if editMode then

   call w3Printn('value="':password:'"')

end

call w3Printn('></td><td>')

call w3Printn('<table width="100%"><tr><td>')

call w3Printn('<input type="checkbox" name="SSL"')

if ssl then

   call w3Printn(' checked')

end

call w3Printn('>Use SSL<br>')

call w3Printn('<input type="checkbox" name="profile"')

if profile then

   call w3Printn(' checked')

end

call w3Printn('>Profile<br></td><td>')

call w3Printn('<input type="checkbox" name="anon"')

if anon then

   call w3Printn(' checked')

end

call w3Printn('>Anonymous<br>')

call w3Printn('<input type="checkbox" name="dbmode"')

if debugmode then

   call w3Printn(' checked')

end

call w3Printn('>Debug Mode</td><tr>')

call w3Printn('</table></td><td>')

if editMode then

   list.id = execute 'sselect group-File where group in' capturing x returning y

else

   list.id = ''   

end

call w3HtmlSelect('groupsIn', list.id, list.id, '', 'multiple size="4"', '')

if editMode then

   list.id = execute 'sselect group-File where group not in' capturing x returning y

else

   list.id = execute 'sselect group-File' capturing x returning y

end

call w3HtmlSelect('groupsOut', list.id, list.id, '', 'multiple size="4"', '')

call w3Printn('</td><td><input type="text" name="timeout" size="3"')

if editMode then

  call w3Printn(' value="':timeout:'"')

end

call w3Printn('></td></tr></table>')

if editMode then

   txt = 'Update'

else

   txt = 'Add'

End      

call w3HtmlSubmit('B1', txt, '')

call w3HtmlSubmit('B1', 'Cancel', '')

call w3Printn('<input type="reset" value="Reset" name="B2">')

call w3HtmlFormEnd

call w3HtmlFooter('', '')

call w3Input(err, WAITTIME, '')

if err # w3_OK then

   cmd = 'Quit'

end else

   call w3GetVal(cmd, 'B1')

end

return