w3admin.w3apps

subroutine w3Admin.w3Apps

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

* w3Admin.w3Apps: Maintain the w3Apps file

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

* [00] 15Jan01  jdr Initial creation

include wbp w3Include

*  Determine what to do

*

*    submitting field = newname & it isn't empty,

*    create a new app, bring it up and show it

*

*    submitting field = apps, bring it up and show it

*

*    submitting field = submit, save the changes and

*    bring it up and show it

*

*    submitting field = delete, delete the item and

*    bring it up and show it

*

status = ""

call w3Admin.Housekeeping(status)

submitName = ""

submitEvent = ""

call w3GetVal(submitName,  "w3TriggerObject")

call w3GetVal(submitEvent, "w3TriggerEvent")

itemw3Apps  = ""

itemName    = ""

                        

CRT "w3Admin.w3Apps"

CRT "Object: ":submitName

CRT "Event: ":submitEvent

begin case

      case submitName = "newName" and submitEvent = "evAfter"

           CRT "New"

           call w3GetVal(itemName, "newName")

           call w3Admin.w3Apps.Get(itemName, itemw3Apps)

      case submitName = "apps" and submitEvent = "evClick"

           CRT "Edit"

           call w3GetVal(itemName, "apps.Name")

           call w3Admin.w3Apps.Get(itemName, itemw3Apps)

      case submitName = "delete" and submitEvent = "evClick"

           CRT "Delete"

           call w3GetVal(itemName, "apps.Name")

           call w3Admin.w3Apps.Delete(itemName)

      case submitName = "reset" and submitEvent = "evClick"

           CRT "Reset"

           null

      case submitName = "Submit" and submitEvent = "evClick"

           CRT "Save"

           gosub loadForm        ;* read screen & convert to w3App item

           call w3Admin.w3Apps.Save(itemName, itemw3Apps)

       case 1        

           CRT "Default"

           null

end case

gosub DisplayCurrentItem

return

loadForm:            * reads the current mvDesigner form and

*                      converts it into a w3Apps item

*                    Input: mvDesigner Form Data

*                    Output: itemw3apps, itemName

   itemName   = ""

   itemw3Apps = ""

   call w3GetVal(itemName, "apps.Name")

   * establish local variables for all features

   * then convert from screen to local representation

   

    anonymous   = 0

    userList    = ""

    groupList   = ""

    ssl         = 0

    debugging   = 0

    profiling   = 0

    timeout     = 0

    program     = ""

    account     = ""

    password    = ""

    description = ""

    

    call w3GetVal(ssl, "ssl")

    call w3GetVal(anonymous, "anonymous")

    call w3GetVal(timeout, "timeout")

    call w3GetVal(debugging, "debugging")

    call w3GetVal(program, "program")

    call w3GetVal(password, "password")

    call w3GetVal(description, "description")

    call w3getVal(userList, "]users.Id")

    call w3GetVal(groupList, "]groups.Id")

    call w3getVal(profiling, "profiling")

    call w3GetVal(account, "account.Name")

    

    if anonymous = 1 then itemw3Apps<1> = "y"

    itemw3Apps<2> = userList

    itemw3Apps<3> = groupList

    itemw3Apps<4> = description

    itemw3Apps<5> = account

    itemw3Apps<6> = password

    if profiling = 1 then itemw3Apps<7> = "y"

    if ssl = 1       then itemw3Apps<8> := "s"

    if debugging = 1 then itemw3Apps<8> := "d"

    itemw3Apps<9> = program

    if timeout > -1 and timeout < 86401 and num(timeout) then

       itemw3Apps<10> = timeout

    end

return

DisplayCurrentItem:  * Displays the currently selected (if any)

*                      itemw3Apps

*                    Input: itemName, itemw3Apps

*                    Output: editw3Apps form

*

    err  = w3_OK

    call w3mvDInit("", "")

    * A1 = Anonymous

    * A2 = Users

    * A3 = Groups

    * A4 = Description

    * A5 = Account

    * A6 = Account Password

    * A7 = Profiling

    * A8 = Options

    * A9 = Program

    * A10= Profile Time out

                   

    * create local variable for fields which need transformation

                                             

    anonymous   = 0

    userList    = "" ; userProp = ""    ; userId = ""

    groupList   = "" ; groupProp = ""   ; groupId = ""

    accountList = "" ; accountProp = ""

    ssl         = 0

    debugging   = 0

    profiling   = 0

    account     = ""

   

    if itemw3Apps<1> = "y"          then anonymous = 1

    if index(itemw3Apps<8>, "s", 1) then ssl = 1

    if index(itemw3Apps<8>, "d", 1) then debugging = 1

    if itemw3Apps<7> = "y"          then profiling = 1

    account = itemw3Apps<5>

    * set easy data

    call w3mvDInsert("ssl", ssl, "")

    call w3mvDInsert("debugging", debugging, "")

    call w3mvDInsert("description", itemw3Apps<4>, "")

    call w3mvDInsert("timeout", itemw3Apps<10>, "")

    call w3mvDInsert("password", itemw3Apps<6>, "")

    call w3mvDInsert("anonymous", anonymous, "")

    call w3mvDInsert("profiling", profiling, "")

    call w3mvDInsert("program", itemw3Apps<9>, "")

    * Generate the list of applications, adding and or highlighting

    * the application (if any) being displayed

    

    appsList = ""

    appsProp = ""

    call w3Admin.w3Apps.GetNames(appsList)   ;* all application names

    convert @am to @vm in appsList

    locate(itemName, appsList, 1; loc) then

       appsProp<1, loc> = p_UCV_Focus

    end else

       appsProp<1, 1>   = p_UCV_Focus

       appsList         = insert(appsList, 1, 1; itemName)

    end

    call w3mvDInsert("apps.Name", appsList, appsProp)

    * Set Account

    call w3Admin.getAccounts(accountList)

    

    * All selecting no account by adding a blank

    accountList<0> = ""

    convert @am to @vm in accountList

    

    locate(account, accountList, 1; loc) then

       accountProp<1, loc> = p_UCV_Focus

    end

    call w3mvDInsert("account.Name", accountList, accountProp)

    * Set Groups

    groupsAll = ""

    call w3Admin.w3Groups.GetIdName(groupsAll)

   

    cntGroups   = dcount(groupsAll<1>, @vm)

    Groups      = itemw3Apps<3>

 

    for i = 1 to cntGroups

        groupList<i> = groupsAll<2, i>                   

        groupId<i>   = groupsAll<1, i>

        locate(groupsAll<1, i>, Groups, 1; loc) then

              if groupProp = "" then groupProp<i> = p_UCV_Focus

              groupProp<i> += p_UCV_Selected

        end

    next i

    * add a blank entry for selection of none

    groupList<0>  = ""

    groupId<0>    = ""

    groupProp<0>  = ""    

    

    convert @am to @vm in groupId

    convert @am to @vm in groupList

    convert @am to @vm in groupProp

    call w3mvDInsert("groups.Name", groupList, groupProp)

    call w3mvDInsert("groups.Id",   groupId,   groupProp)

    * Set Users

    usersAll = ""

    status   = ""

    call w3Admin.w3users.GetIdName(usersAll, status)

   

    cntusers   = dcount(usersAll<1>, @vm)

    Users      = itemw3Apps<2>

 

    for i = 1 to cntusers

        userList<i> = usersAll<2, i>                   

        userId<i>   = usersAll<1, i>

        locate(usersAll<1, i>, users, 1 ; loc) then

              if userProp = "" then userProp<i> = p_UCV_Focus

              userProp<i> += p_UCV_Selected

        end

    next i

    

    * add a blank entry for selection of none

    userList<0>  = ""

    userId<0>    = ""

    userProp<0>  = ""    

     

    convert @am to @vm in userId

    convert @am to @vm in userList

    convert @am to @vm in userProp

    call w3mvDInsert("users.Name", userList, userProp)

    call w3mvDInsert("users.Id",   userId,   userProp)

    call w3mvDInput(err, 0 , "")

return