### BEGIN COPYRIGHT BLURB # # TAO - Tcl Architecture of Objects # Copyright (C) 2007 Sean Woods # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # ### END COPYRIGHT BLURB ### # # Polymorphic ODIE Node Implementaion # # Both classes depend on each other so much # that splitting them up would create circular # references ### ::tao::class tdif.element { inherit tdif.node static node_id static fieldList ### # Load the contents of the record # from our container on startup ### constructor { thanatos alloc $this } destructor { ### # Give up our toys ### thanatos free $this } ### # Permanently delete a record from the system ### method trashRecord {} { # Unlink us from TDIF tdif NodeUnlink $globalName # Delete us from the container $containerObj nodeDelete $node_id carosel } ### # Mark that this object should be deleted # on the next pass of the garbage collector # # CAROSEL... RENEW RENEW ### method carosel {} { thanatos kiss $this } ### # Write the contentes of this node to the container's table # # This will automatically put the object on the carosel to # be "renewed" on the next pass of the garbage collector ### method renew {} { $containerObj nodeSet $node_id [dict get [set $statevar] state] carosel } method NodeId {} { return $node_id } method Get {{field {}}} { set dat [dict get [set $objstate] state] if { $field == {} } { return $dat } else { if [dict exists $dat $field] { return [dict get $dat $field] } } } method Set {data} { set dat [dict get [set $objstate] state] set newState [dict merge $dat $data] $containerObj nodeSet $node_id $newState dict set $objstate state $newState carosel } method Input {valuelist {complete 0}} { set info [$containerObj ValueListFormat column $valuelist $table] set errors {} set newvaluelist {} foreach {var val} $info { if { $var == {} || $var == 0 } { continue } if [catch { [/column $var] Input $val } newval] { lappend errors $var $newval } else { if { $newval != [set $val] } { ### # Only bother entering data that has actually changed ### lappend newvaluelist $var $newval } } } if { $errors != {} } { error $errors } return $newvaluelist } } ::tao::class tdif.element.linked { inherit tdif.element chain links {} { } } ### # Access Control List manager ### ::tao::class tdif.node.acl { ### # ACL ### method aclNode {} { return [::acl::nodeAcl $globalName] } ### # For "Group" types, expand out to a list of all the # object included in the list # By default simply return the name of this object ### public method aclExpand {} { return [cget globalName -err] } public method wheelMode {} { return [acl aclWheelMode] } ### # The default simply asks the tree # Returns a list of the following rights: # # subscribe - Present this node in menus for the user # view - View the node # modify - Modify the node # state - Change state # delete - Delete this node # create - Create new sub-nodes # admin - Access extended properies (like manually change state) # *** Admin implies all other flags *** ### public method Rights {userid {test {}}} { set rights [::acl::aclRights [::acl::nodeAcl $globalName] $userid] foreach right [customRights $userid] { ladd rights $right } if [lcontains $rights admin] { if { $test == {} } { return admin } else { return true } } if { $test == {} } { return $rights } return [lcontains $rights $test] } chain customRights userid { } }