Index: openacs-4/packages/cronjob/sql/oracle/cronjob-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cronjob/sql/oracle/cronjob-create.sql,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/cronjob/sql/oracle/cronjob-create.sql 30 Sep 2003 12:10:06 -0000 1.3 +++ openacs-4/packages/cronjob/sql/oracle/cronjob-create.sql 29 May 2009 09:11:28 -0000 1.4 @@ -6,12 +6,12 @@ -- create table cronjobs ( - cronjob_id integer not null + cronjob_id integer not null constraint cj_cronjob_id_fk references acs_objects(object_id) constraint cj_cronjob_id_pk primary key, user_id integer not null constraint cj_user_id_fk references users, - description varchar2(100) not null, + description varchar2(100) not null, approved_p char(1) default 'f' not null constraint cj_approved_p_ck check (approved_p in ('f','t')), disabled_p char(1) default 'f' not null Index: openacs-4/packages/cronjob/sql/postgresql/cronjob-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cronjob/sql/postgresql/cronjob-create.sql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/cronjob/sql/postgresql/cronjob-create.sql 15 Nov 2001 20:29:36 -0000 1.2 +++ openacs-4/packages/cronjob/sql/postgresql/cronjob-create.sql 29 May 2009 09:11:28 -0000 1.3 @@ -6,12 +6,12 @@ -- create table cronjobs ( - cronjob_id integer not null + cronjob_id integer not null constraint cj_cronjob_id_fk references acs_objects(object_id) constraint cj_cronjob_id_pk primary key, user_id integer not null constraint cj_user_id_fk references users, - description varchar(100) not null, + description varchar(100) not null, approved_p char(1) default 'f' not null constraint cj_approved_p_ck check (approved_p in ('f','t')), disabled_p char(1) default 'f' not null Index: openacs-4/packages/cronjob/tcl/cronjob-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cronjob/tcl/cronjob-init.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/cronjob/tcl/cronjob-init.tcl 30 Nov 2002 17:29:40 -0000 1.3 +++ openacs-4/packages/cronjob/tcl/cronjob-init.tcl 29 May 2009 09:11:28 -0000 1.4 @@ -14,164 +14,164 @@ ad_proc qd_write_query_select {package attrs} { -

Returns Postgresql function with: -

+

Returns Postgresql function with: +

} { - ns_log Debug "Running qd_write_query_select with $package $attrs" - set query [list] - set in_args [list] - set args [concat $attrs] - foreach {attr sign value} $args { - lappend in_args $attr - set attr_array($attr) $value - } - set attrs_and_defaults [eval qd_choose_function $package $in_args] - foreach {attr default_value} $attrs_and_defaults { - # see if attr was passed in with value - if {![info exists attr_array($attr)]} { - - if {[string match "" $default_value]} { - ns_log Debug "Attempt to call $package with no value for $attr" - return -code error - } - lappend query $default_value - } else { - lappend query "$attr_array($attr)" - } - } - ns_log Debug "${package}([join $query ",\n"]);" - return "${package}([join $query ",\n"]);" + ns_log Debug "Running qd_write_query_select with $package $attrs" + set query [list] + set in_args [list] + set args [concat $attrs] + foreach {attr sign value} $args { + lappend in_args $attr + set attr_array($attr) $value + } + set attrs_and_defaults [eval qd_choose_function $package $in_args] + foreach {attr default_value} $attrs_and_defaults { + # see if attr was passed in with value + if {![info exists attr_array($attr)]} { + + if {[string match "" $default_value]} { + ns_log Debug "Attempt to call $package with no value for $attr" + return -code error + } + lappend query $default_value + } else { + lappend query "$attr_array($attr)" + } + } + ns_log Debug "${package}([join $query ",\n"]);" + return "${package}([join $query ",\n"]);" } ad_proc qd_add_package {package args} { -

Adds a package with all the attributes for every function of the same name. -

For example, if you have two functions that could be called - foo(a,b,c) and foo(a,c,d), - the package would be registered using: -

-
-	qd_add_package foo a b c d
-	
-
+

Adds a package with all the attributes for every function of the same name. +

For example, if you have two functions that could be called + foo(a,b,c) and foo(a,c,d), + the package would be registered using: +

+
+        qd_add_package foo a b c d
+        
+
} { - nsv_set qd_pg_packages $package $args - set n 1 - foreach attr $args { - nsv_set $package $attr $n - set n [expr $n * 2] - } + nsv_set qd_pg_packages $package $args + set n 1 + foreach attr $args { + nsv_set $package $attr $n + set n [expr $n * 2] + } } ad_proc qd_total_attributes {package attributes} { -

Totals the attribute values. +

Totals the attribute values. } { - upvar $package package_array - upvar $attributes attrs - set total 0 - foreach attribute $attrs { - incr total $package_array($attribute) - ns_log Debug "Adding $package_array($attribute) $total" - } - return $total + upvar $package package_array + upvar $attributes attrs + set total 0 + foreach attribute $attrs { + incr total $package_array($attribute) + ns_log Debug "Adding $package_array($attribute) $total" + } + return $total } ad_proc qd_add_function {package args} { -

Adds a single function, including defaults to a package. -

If one foo function has three attributes: a, b and c, where - a is required and b can be null and c default to 't', +

Adds a single function, including defaults to a package. +

If one foo function has three attributes: a, b and c, where + a is required and b can be null and c default to 't', the function would be - registered using: -

-
-	qd_add_function foo a "" b "null" c "'t'"
-	
-
+ registered using: +
+
+        qd_add_function foo a "" b "null" c "'t'"
+        
+
} { - + - # total up the function value. - array set temp_package [nsv_array get $package] - set i 1 - foreach {attr default} $args { - lappend attr_list $attr - } - set total [qd_total_attributes temp_package attr_list] - nsv_set ${package}_functions $total $args + # total up the function value. + array set temp_package [nsv_array get $package] + set i 1 + foreach {attr default} $args { + lappend attr_list $attr + } + set total [qd_total_attributes temp_package attr_list] + nsv_set ${package}_functions $total $args } ad_proc qd_choose_function {package args} { -

Used to choose a function based on passed in attributes. +

Used to choose a function based on passed in attributes. } { - - array set temp_package [nsv_array get $package] - set total [qd_total_attributes temp_package args] - if {[nsv_exists ${package}_functions $total]} { - ns_log Debug "Found matching sig: '$total'" - return [nsv_get ${package}_functions $total] - } - set functions [nsv_array names ${package}_functions] - foreach sig $functions { - ns_log Debug "checking sig '$total' against '$sig'" - if {$total == [expr $sig & $total]} { - ns_log Debug "Found match '$total' in '$sig'" - return [nsv_get ${package}_functions $sig] - } - } - return "!NO MATCH: $total not in $functions" + + array set temp_package [nsv_array get $package] + set total [qd_total_attributes temp_package args] + if {[nsv_exists ${package}_functions $total]} { + ns_log Debug "Found matching sig: '$total'" + return [nsv_get ${package}_functions $total] + } + set functions [nsv_array names ${package}_functions] + foreach sig $functions { + ns_log Debug "checking sig '$total' against '$sig'" + if {$total == [expr $sig & $total]} { + ns_log Debug "Found match '$total' in '$sig'" + return [nsv_get ${package}_functions $sig] + } + } + return "!NO MATCH: $total not in $functions" } proc qd_write_query {package args} { - - set query [list] - set attrs_and_defaults [eval qd_choose_function $package $args] - foreach {attr default_value} $attrs_and_defaults { - if {[lsearch $args $attr] < 0 } { - if {[string match "" $default_value]} { - ns_log Debug "Attempt to call $package with no value for $attr" - return -code error - } - lappend query $default_value - } else { - lappend query ":${attr}" - } - } - return [join $query ",\n"] + + set query [list] + set attrs_and_defaults [eval qd_choose_function $package $args] + foreach {attr default_value} $attrs_and_defaults { + if {[lsearch $args $attr] < 0 } { + if {[string match "" $default_value]} { + ns_log Debug "Attempt to call $package with no value for $attr" + return -code error + } + lappend query $default_value + } else { + lappend query ":${attr}" + } + } + return [join $query ",\n"] } proc qd_write_query_upvar {package listvar} { - - set query [list] - upvar $listvar args - set attrs_and_defaults [eval qd_choose_function $package $args] - if {[string match "!NO MATCH:*" $attrs_and_defaults ]} { - ns_log Debug "$attrs_and_defaults" - return -code error - } - foreach {attr default_value} $attrs_and_defaults { - if {[lsearch $args $attr] < 0 } { - if {[string match "" $default_value]} { - ns_log Debug "Attempt to call $package with no value for $attr" - return -code error - } - lappend query $default_value - } else { - lappend query ":${attr}" - } - } - return [join $query ",\n"] + + set query [list] + upvar $listvar args + set attrs_and_defaults [eval qd_choose_function $package $args] + if {[string match "!NO MATCH:*" $attrs_and_defaults ]} { + ns_log Debug "$attrs_and_defaults" + return -code error + } + foreach {attr default_value} $attrs_and_defaults { + if {[lsearch $args $attr] < 0 } { + if {[string match "" $default_value]} { + ns_log Debug "Attempt to call $package with no value for $attr" + return -code error + } + lappend query $default_value + } else { + lappend query ":${attr}" + } + } + return [join $query ",\n"] } } Index: openacs-4/packages/cronjob/www/admin/cronjob-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cronjob/www/admin/cronjob-add.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/cronjob/www/admin/cronjob-add.tcl 29 May 2009 09:02:48 -0000 1.5 +++ openacs-4/packages/cronjob/www/admin/cronjob-add.tcl 29 May 2009 09:11:28 -0000 1.6 @@ -25,26 +25,6 @@ set disabled_p "t" -db_exec_plsql add_cronjob { - - declare - v_cronjob_id integer; - begin - v_cronjob_id := cronjob.new( - user_id => :user_id, - description => :description, - approved_p => :approved_p, - disabled_p => :disabled_p, - minute => :minute, - hr => :hr, - mon => :mon, - day => :day, - dayofweek => :dayofweek, - run_sql => :run_sql, - run_tcl => :run_tcl, - email => :email - ); - end; -} +db_exec_plsql add_cronjob {} ad_returnredirect cronjobs Index: openacs-4/packages/cronjob/www/admin/cronjob-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cronjob/www/admin/cronjob-edit.tcl,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/cronjob/www/admin/cronjob-edit.tcl 29 May 2009 09:02:48 -0000 1.4 +++ openacs-4/packages/cronjob/www/admin/cronjob-edit.tcl 29 May 2009 09:11:28 -0000 1.5 @@ -1,5 +1,5 @@ ad_page_contract { - + Cronjobs Edit Page 2 @author tom@junom.com @creation-date 22 Sept 2001 @@ -20,23 +20,6 @@ {disabled_p:trim ""} } -db_exec_plsql edit_cronjob { - - begin - cronjob.set_attrs( - cronjob_id => :cronjob_id, - description => :description, - approved_p => :approved_p, - disabled_p => :disabled_p, - minute => :minute, - hr => :hr, - mon => :mon, - day => :day, - dayofweek => :dayofweek, - run_sql => :run_sql, - run_tcl => :run_tcl, - email => :email); - end; -} +db_exec_plsql edit_cronjob {} ad_returnredirect cronjobs Index: openacs-4/packages/cronjob/www/admin/cronjob.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cronjob/www/admin/cronjob.tcl,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/cronjob/www/admin/cronjob.tcl 29 May 2009 09:02:48 -0000 1.6 +++ openacs-4/packages/cronjob/www/admin/cronjob.tcl 29 May 2009 09:11:28 -0000 1.7 @@ -1,5 +1,5 @@ ad_page_contract { - + Cronjobs List and Add Page @author tom@junom.com @creation-date 22 Sept 2001 @@ -34,60 +34,61 @@ foreach {value name} [list "\*" "Every Month" 01 January 02 February 03 March 04 April 05 May 06 June 07 July 08 August 09 September 10 October 11 November 12 December] { if {[string match $mon $value]} { - append month_option " + append month_option " " } else { - append month_option " + append month_option " " } } foreach {value name} [list "\*" "Every Day of Week" 0 Sunday 1 Monday 2 Tuesday 3 Wednesday 4 Thursday 5 Friday 6 Saturday] { if {"$dayofweek" eq "$value"} { - append dayofweek_option " + append dayofweek_option " " } else { - append dayofweek_option " + append dayofweek_option " " } } foreach {value name} [list "\*" "Every Day" 01 1 02 2 03 3 04 4 05 5 06 6 07 7 08 8 09 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31] { - if {[string match $day $value]} { - append day_option " + if {[string match $day $value]} { + append day_option " " } else { - append day_option " + append day_option " " - + } } foreach {value name} [list "\*" "Every Hour" 00 0 01 1 02 2 03 3 04 4 05 5 06 6 07 7 08 8 09 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23] { - if {[string match $hr $value]} { - append hour_option " + if {[string match $hr $value]} { + append hour_option " " } else { - append hour_option " + append hour_option " " - + } } -foreach {value name} [list "\*" "Every Minute" 00 0 01 1 02 2 03 3 04 4 05 5 06 6 07 7 08 8 09 9 10 10\ - 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20\ - 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30\ - 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40\ - 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50\ - 51 51 52 52 53 53 54 54 55 55 56 56 57 57 58 58 59 59 ] { - if {[string match $minute $value]} { - append minute_option " +foreach {value name} [list "\*" "Every Minute" \ + 00 0 01 1 02 2 03 3 04 4 05 5 06 6 07 7 08 8 09 9 10 10\ + 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20\ + 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30\ + 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40\ + 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50\ + 51 51 52 52 53 53 54 54 55 55 56 56 57 57 58 58 59 59 ] { + if {[string match $minute $value]} { + append minute_option " " } else { - append minute_option " + append minute_option " " - + } }