donb
committed
on 13 Aug 09
Added preliminary versions of view support. Documented some of the Tcl API.
openacs-4/.../workflow/tcl/action-procs.tcl (+5 -2)
202 202         always_enabled_p
203 203         assigned_role
204 204         timeout_seconds
205 205     } {
206 206         if { [info exists row($attr)] } {
207 207             set varname attr_$attr
208 208             # Convert the Tcl value to something we can use in the query
209 209             switch $attr {
210 210                 short_name {
211 211                     if { ![exists_and_not_null row(pretty_name)] } {
212 212                         if { [empty_string_p $row(short_name)] } {
213 213                             error "You cannot edit with an empty short_name without also setting pretty_name"
214 214                         } else {
215 215                             set row(pretty_name) {}
216 216                         }
217 217                     }
218 218                        
219 219                     set $varname [workflow::action::generate_short_name \
220 220                                       -workflow_id $workflow_id \
221 221                                       -pretty_name $row(pretty_name) \
222                                         -short_name $row(short_name)]
  222                                       -short_name $row(short_name) \
  223                                       -action_id $action_id]
223 224                 }
224 225                 always_enabled_p {
225 226                     set $varname [db_boolean [template::util::is_true $row($attr)]]
226 227                 }
227 228                 assigned_role {
228 229                     if { [empty_string_p $row($attr)] } {
229 230                         set $varname [db_null]
230 231                     } else {
231 232                         # Get role_id by short_name
232 233                         set $varname [workflow::role::get_id \
233 234                                           -workflow_id $workflow_id \
234 235                                           -short_name $row($attr)]
235 236                     }
236 237                 }
237 238                 default {
238 239                     set $varname $row($attr)
239 240                 }
240 241             }
241 242             # Add the column to the SET clause
242 243             switch $attr {
 
942 943     Generate the spec for an individual action definition.
943 944
944 945     @param action_id The id of the action to generate spec for.
945 946     @return spec The actions spec
946 947
947 948     @author Lars Pind (lars@collaboraid.biz)
948 949 } {
949 950     get -action_id $action_id -array row
950 951
951 952     # Get rid of elements that shouldn't go into the spec
952 953     array unset row short_name
953 954     array unset row action_id
954 955     array unset row workflow_id
955 956     array unset row sort_order
956 957     array unset row assigned_role_id
957 958     array unset row new_state_id
958 959     array unset row callbacks_array
959 960     array unset row callback_ids
960 961     array unset row allowed_roles_array
961 962     array unset row allowed_role_ids
  963     array unset row enabled_state_ids
  964     array unset row assigned_state_ids
962 965
963 966     # Get rid of a few defaults
964 967     array set defaults { initial_action_p f always_enabled_p f }
965 968
966 969     foreach name [array names defaults] {
967 970         if { [string equal $row($name) $defaults($name)] } {
968 971             array unset row $name
969 972         }
970 973     }
971 974  
972 975     # Get rid of empty strings
973 976     foreach name [array names row] {
974 977         if { [empty_string_p $row($name)] } {
975 978             array unset row $name
976 979         }
977 980     }
978 981    
979 982     set spec {}
980 983     foreach name [lsort [array names row]] {
981 984         lappend spec $name $row($name)