w3admin.w3user.process

subroutine w3Admin.w3User.process

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

* w3Admin.w3User.process: Process a submitted w3Admin.w3Create

*                         web page. Redisplay page when done.

*                         Show any errors

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

* [00] 06feb01

* [01] 30Mar01 jr Act 25103, if user has a password make sure it has

*                            changed before reencrypting it and saving it

include wbp w3Include

include bp w3Admin.Include

CRT "w3Admin.w3User.process"

ids = ""

call w3getVal(ids, "ID")

convert "~" to @am in ids

messages = ""

ok       = w3_OK

skipEntries = ""             ;* If deleting an entry has an error, then

*                               don't show it on a error refresh.  This

*                               is the means used to remove unwanted,

*                               invalid entries.

rows = dcount(ids, @am)

for i = 1 to rows

    id        = ""

    name      = ""

    password  = ""

    delgroup  = ""

    addgroup  = ""

    delete    = ""

    change    = ""

    status    = ""

    call w3getVal(id, "ID":i)

    call w3getVal(name,"name":i)

    call w3getVal(password, "password":i)

    call w3getVal(delgroup,"]MEMBER":i)           ;*groups asked to remove

    call w3getVal(addgroup,"]NONMEMBER":i)        ;*groups asked to add

    dcnt = dcount(delgroup,@vm)

    acnt = dcount(addgroup,@vm)

    call w3getVal(change, "Change":i)

    if change = "Delete" then

         call w3User.process("Delete",id, name, "", "", status)

         if status # "" then

             skipEntries<-1> = i

         end

    end else

         status = w3_OK

         rid = ""

         rname = ""

         rgroup = ""                             ;*current group in record

         rpassword = ""

         call w3User.process("Read", id, rname, rgroup, rpassword, status)

         ischanged = 0

         if name # rname then ischanged = 1

         if dcnt > 0 then ischanged = 1

         if acnt > 0 then ischanged = 1

         

         if password # rpassword then

            ischanged = 1

            if password # "" then                          ;* [01]

               password = oconv(password,"u3060")          ;* [01]

            end                                            ;* [01]

         end

         ** has changed in entry field(s), time to update them.

         if ischanged then

             convert @vm to @am in rgroup

             convert @vm to @am in delgroup

             convert @vm to @am in addgroup

             for j = 1 to dcnt

                 locate(delgroup<j>, rgroup; loc) then

                    rgroup = delete(rgroup,loc)

                 end

             next j

             

             for k = 1 to acnt

                 rgroup<-1> = addgroup<k>

             next k

             status = ""

             convert @am to @vm in rgroup

             call w3User.process("Update", id, name, rgroup, password, status)

              if status # "" then

                  ok = w3_Error

                  messages<-1> = "Line ":i:@am:status

              end

          end

     end

 next i

 

 

 * check for add

 rows += 1

 i = rows

 id = ""

 name = ""

 password = ""

 ingroup = ""

 

 call w3getVal(id, "userid":i)

 call w3getVal(name, "name":i)

 call w3getVal(password, "password":i)

 call w3getVal(ingroup, "]ADDGROUP");

 

 if id # "" then

     call w3User.process("Update", id, name, ingroup, password, status)

     if status # "" then

        ok = w3_Error

        messages<-1> = "Line ":i:@am:status

     end

 end

 

 if ok = w3_OK then

     call w3Admin.w3User.create

 end else

     users = ""

     status = ""

     call w3Admin.w3users.getIdName(users, status)

     call w3Admin.w3User.form( users, messages)

 end

 

 return