home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / editroleri.tcl < prev    next >
Text File  |  1996-05-29  |  4KB  |  143 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cadre Technologies Inc.    1996
  4. #
  5. #      File:           @(#)editroleri.tcl    1.13
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)editroleri.tcl    1.13   26 Mar 1996 Copyright 1996 Cadre Technologies Inc.
  10.  
  11. # Start user added include file section
  12. # End user added include file section
  13.  
  14. require "rolerights.tcl"
  15.  
  16. Class EditRoleRightsDlg : {RoleRightsDlg} {
  17.     constructor
  18.     method destructor
  19.     method ok
  20.     method popUp
  21.     attribute errorStack
  22. }
  23.  
  24. constructor EditRoleRightsDlg {class this name} {
  25.     set this [RoleRightsDlg::constructor $class $this $name]
  26.     # Start constructor user section
  27.  
  28.     set errorStack ""
  29.     set nonEditableList ""
  30.     $this editable 1
  31.     [$this selectedSet] foreach obj {
  32.         if [catch {$obj Controlled::edit} msg] {
  33.         lappend nonEditableList $obj
  34.         if {"$errorStack" != ""} {
  35.             append errorStack "\n"
  36.         }
  37.         append errorStack $msg
  38.         }
  39.     }
  40.     $this errorStack $errorStack
  41.     foreach nonEditable $nonEditableList {
  42.         $this removeSelected $nonEditable
  43.     }
  44.  
  45.     # End constructor user section
  46.     return $this
  47. }
  48.  
  49. method EditRoleRightsDlg::destructor {this} {
  50.     # Start destructor user section
  51.  
  52.     [$this selectedSet] foreach obj {
  53.         $obj Controlled::quit
  54.     }
  55.  
  56.     # End destructor user section
  57.     $this RoleRightsDlg::destructor
  58. }
  59.  
  60. method EditRoleRightsDlg::ok {this} {
  61.     set script ""
  62.     foreach type [$this.top.row.leftCol.ruleType.row.type entrySet] {
  63.     global $this$type
  64.     if {! [info exists $this$type]} continue
  65.  
  66.     set role ""
  67.     set index ""
  68.     set ${this}${type}(last,,) 0
  69.     foreach triple [lsort [array names $this$type]] {
  70.         set first [string first "," $triple]
  71.         set last [string last "," $triple]
  72.         set newIndex [string range $triple 0 [expr $first -1]]
  73.         set newRole [string range $triple [expr $first +1] [expr $last -1]]
  74.         set action [string range $triple [expr $last +1] end]
  75.         set access [set ${this}${type}($triple)]
  76.         unset ${this}${type}($triple)
  77.  
  78.         if {"$index" != "$newIndex" || "$role" != "$newRole"} {
  79.         if {"$index" != ""} {
  80.             set obj [[$this selectedSet] index $index]
  81.             if {"$script" != ""} {
  82.             append script " ;"
  83.             }
  84.             case "$type" in {
  85.             childRight {
  86.                 append script " $obj modifyNewChildRights \
  87.                 $role $allowedMap $prohibitedMap $undefinedMap"
  88.             }
  89.             default {
  90.                 append script " $obj modifyPermission \
  91.                 $role $allowedMap $prohibitedMap $undefinedMap"
  92.             }
  93.             }
  94.         }
  95.         set allowedMap 0
  96.         set prohibitedMap 0
  97.         set undefinedMap 0
  98.         }
  99.  
  100.         if {"$newIndex" == "last"} break
  101.  
  102.         set index $newIndex
  103.         set role $newRole
  104.         set actionMap [BrowserProcs::string2Action $action]
  105.         case "$access" in {
  106.         Allowed {
  107.             set allowedMap [expr $allowedMap | $actionMap]
  108.         }
  109.         Prohibited {
  110.             set prohibitedMap [expr $prohibitedMap | $actionMap]
  111.         }
  112.         Undefined {
  113.             set undefinedMap [expr $undefinedMap | $actionMap]
  114.         }
  115.         }
  116.     }
  117.     }
  118.  
  119.     if {"$script" != ""} {
  120.     $wmttoolObj startCommand tcl "$script" "wmtkmessage {}" \
  121.         "Saving role rights" {0 0} 1
  122.     }
  123.  
  124.     $this AccessControlDlg::ok
  125. }
  126.  
  127. method EditRoleRightsDlg::popUp {this} {
  128.     $this createObjectsIf
  129.     $this createRolesIf
  130.     $this createActionsIf
  131.     $this createRoleRightTypeIf
  132.     $this createApplyIf
  133.     $this selectedObjectSetChanged
  134.     $this TemplateDialog::popUp
  135.     if {"[$this errorStack]" != ""} {
  136.     wmtkwarning [$this errorStack]
  137.     $this errorStack ""
  138.     }
  139. }
  140.  
  141. # Do not delete this line -- regeneration end marker
  142.  
  143.