Index: openacs-4/packages/rules/tcl/apm-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/tcl/Attic/apm-callback-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/tcl/apm-callback-procs.tcl 3 Dec 2004 18:02:56 -0000 1.1 @@ -0,0 +1,99 @@ +ad_library { + + Procedures to do a new impl and aliases in the acs-sc. + @creation date 2004-11-24 + @author Anny Flores (annyflores@viaro.net) +} + +namespace eval rules::apm_callback {} + +ad_proc -private rules::apm_callback::package_install { +} { + Does the integration whith the notifications package. +} { + db_transaction { + + # Create the impl and aliases for one rule action + set impl_id [create_rule_impl] + + # Create the notification type for one specific action + set type_id [create_rule_type $impl_id] + + # Enable the delivery intervals and delivery methods for a specific RULE + enable_intervals_and_methods $type_id + + } +} + +ad_proc -private rules::apm_callback::package_uninstall { +} { + Remove the integration whith the notification package +} { + + db_transaction { + + # Delete the type_id for a specific RULE + notification::type::delete -short_name rule_notif + + # Delete the implementation for the notification of one specific RULE + delete_rule_impl + + } +} + +ad_proc -public rules::apm_callback::delete_rule_impl {} { + Unregister the NotificationType implementation for rule_notif_type. +} { + acs_sc::impl::delete \ + -contract_name "NotificationType" \ + -impl_name rule_notif_type +} +ad_proc -public rules::apm_callback::create_rule_impl {} { + Register the service contract implementation and return the impl_id + @return impl_id of the created implementation +} { + return [acs_sc::impl::new_from_spec -spec { + name rule_notif_type + contract_name NotificationType + owner rule + aliases { + GetURL rules::notification::get_url + ProcessReply rules::notification::process_reply + } + }] +} + +ad_proc -public rules::apm_callback::create_rule_type {impl_id} { + Create the notification type for one specific RULE + @return the type_id of the created type +} { + return [notification::type::new \ + -sc_impl_id $impl_id \ + -short_name rule_notif \ + -pretty_name "One RULE" \ + -description "Notification of execution of one specific action in the rule"] +} + +ad_proc -public rules::apm_callback::enable_intervals_and_methods {type_id} { + Enable the intervals and delivery methods of a specific type +} { + # Enable the various intervals and delivery method + + notification::type::interval_enable \ + -type_id $type_id \ + -interval_id [notification::interval::get_id_from_name -name hourly] + + notification::type::interval_enable \ + -type_id $type_id \ + -interval_id [notification::interval::get_id_from_name -name daily] + + notification::type::interval_enable \ + -type_id $type_id \ + -interval_id [notification::interval::get_id_from_name -name instant] + # Enable the delivery methods + notification::type::delivery_method_enable \ + -type_id $type_id \ + -delivery_method_id [notification::delivery::get_id -short_name email] +} + + Index: openacs-4/packages/rules/tcl/rules-apm-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/tcl/Attic/rules-apm-procs-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/tcl/rules-apm-procs-oracle.xql 3 Dec 2004 18:02:56 -0000 1.1 @@ -0,0 +1,22 @@ + + + + + + select rule_name from + rules where rule_id = :rule_id + + + + + + select persons.first_names || ' ' || persons.last_name as name, + parties.email + from persons, parties + where person_id = :user_id + and person_id = party_id + + + + + Index: openacs-4/packages/rules/tcl/rules-apm-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/tcl/Attic/rules-apm-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/tcl/rules-apm-procs.tcl 3 Dec 2004 18:02:56 -0000 1.1 @@ -0,0 +1,46 @@ +ad_library { + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + + Rule Library - Reply Handling +} + + +namespace eval rules::notification_delivery { + + ad_proc -public do_notification { + -rule_id + -user_id + -interval_id + } { + } { + + + + db_1row select_rule_name {*SQL*} + db_1row select_user_name {*SQL*} + set text "" + + set package_id [ad_conn package_id] + + # Notifies the users that requested notification for the specific RULE + + set method_id [notification::get_delivery_method_id -name "email"] + + notification::new \ + -type_id [notification::type::get_type_id -short_name rule_notif] \ + -object_id $rule_id \ + -notif_subject "Testing notification"\ + -notif_text "I works" + + notification::request::new \ + -type_id [notification::type::get_type_id \ + -short_name rule_notif] \ + -object_id $rule_id \ + -user_id $user_id \ + -interval_id $interval_id \ + -delivery_method_id $method_id + + + } +} Index: openacs-4/packages/rules/tcl/rules-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/tcl/Attic/rules-procs-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/tcl/rules-procs-oracle.xql 3 Dec 2004 18:02:56 -0000 1.1 @@ -0,0 +1,80 @@ + + + + + + select survey_id as asm_id,name as asm_name from surveys + + + + + declare begin + :1 := rule.new( + rule_name => :rule_name, + asm_id => :asm_id, + active_p => :active_p + + ); + end; + + + + + + select rule_name + from rules + where rule_id=$rule_id + + + + + + + select a.asm_name + from rules r, assessments a + where a.asm_id=r.asm_id and r.rule_id=:rule_id + + + + + + select survey_id as asm_id,name as asm_name from surveys + + + + + begin + rule.del(:rule_id); + end; + + + + + + insert into rules_triggers (rule_def_id,qs_id,result_id,active_p,rule_id) + values (trigger_seq.nextval, :qs_id, :result_id, :active_p, :rule_id) + + + + + + delete from rules_triggers where rule_def_id=:rule_def_id + + + + + + + insert into rules_actions (rule_action_id,action_type,group_id,rule_id,active_p) + values (action_seq.nextval, :action_type, :group_id, :rule_id,:active_p) + + + + + + delete from rules_actions where rule_action_id=:rule_action_id + + + + + Index: openacs-4/packages/rules/tcl/rules-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/tcl/Attic/rules-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/tcl/rules-procs.tcl 3 Dec 2004 18:02:56 -0000 1.1 @@ -0,0 +1,120 @@ +ad_library { + + Rules Library + @author Anny Flores (annyflores@viaro.net) + @creation-date 2004-11-16 +} + + +namespace eval rules::rule { + + ad_proc -public get_assessments { + } { + Get all assessments + } { + set assessment [list] + + db_foreach assessment { *SQL* } { + lappend assessment [list $asm_name $asm_id] + } + + return $assessment + + } + + ad_proc -public new_rule { + -rule_name + -asm_id + -active_p + } { + Add new rule + } { + set rule_id [db_exec_plsql add_rule { *SQL*}] + return $rule_id + } + ad_proc delete_rule { + -rule_id + } { + Delete one rule + } { + db_exec_plsql delete_rule { *SQL*} + } + + ad_proc -public get_asm_name { + -rule_id + } { + Gets the name of the assessment related to this rule + + } { + set asm_name [db_string get_asm_name { *SQL* }] + return $asm_name + } + + ad_proc -public get_rule_name { + -rule_id + + } { + Gets the name of the this rule + } { + set rule_name [db_string get_rule_name { *SQL* }] + return $rule_name + } + + ad_proc -public add_trigger { + -rule_def_id + -qs_id + -active_p + -rule_id + -result_id + + } { + Add new trigger + } { + db_transaction { + + db_dml add_trigger { *SQL* } + } + } + + ad_proc -public add_action { + -rule_action_id + -action_type + -rule_id + -group_id + -active_p + + } { + Add new action + } { + db_transaction { + + db_dml add_action { *SQL* } + } + } + + ad_proc -public delete_action { + -rule_action_id + + } { + Delete an action + } { + db_transaction { + + db_dml delete_action { *SQL* } + } + } + ad_proc -public delete_trigger { + -rule_def_id + + } { + Delete a trigger + } { + db_transaction { + + db_dml delete_trigger { *SQL* } + } + } + + + + } Index: openacs-4/packages/rules/www/add-action-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/add-action-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/add-action-oracle.xql 3 Dec 2004 17:55:36 -0000 1.1 @@ -0,0 +1,10 @@ + + + + oracle8.1.6 + + + select community_id,pretty_name from dotlrn_communities_all + + + \ No newline at end of file Index: openacs-4/packages/rules/www/add-action.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/add-action.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/add-action.adp 3 Dec 2004 17:55:36 -0000 1.1 @@ -0,0 +1,3 @@ + +@context@ + \ No newline at end of file Index: openacs-4/packages/rules/www/add-action.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/add-action.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/add-action.tcl 3 Dec 2004 17:55:36 -0000 1.1 @@ -0,0 +1,52 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + + Add new rule related to an Assessment +} { + rule_id:notnull +} + +# Just while I get the assessment package ready +set context [list [list "one-rule?rule_id=$rule_id" "Rule Properties"] "Add Action"] + + +set actions { {"add user to" 1} {"add to list of" 2} } +set results [list] +db_foreach communities { *SQL* } { + lappend results [list $pretty_name $community_id] +} + + + +form create add_action + +element create add_action rule_id\ + -datatype text\ + -widget hidden \ + -value $rule_id + +element create add_action action_type\ + -datatype text\ + -widget select\ + -label "Action"\ + -options $actions + +element create add_action group_id\ + -datatype text\ + -widget select\ + -label "Community"\ + -options $results + +element create add_action active_p\ + -datatype text\ + -widget select\ + -label "Active"\ + -options {{Yes y} { No n}} + + if {[template::form is_valid add_action]} { + template::form get_values add_action action_type group_id active_p + rules::rule::add_action -action_type $action_type -group_id $group_id -rule_id $rule_id -active_p $active_p + ad_returnredirect "one-rule?rule_id=$rule_id" +} Index: openacs-4/packages/rules/www/add-rule.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/add-rule.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/add-rule.adp 3 Dec 2004 17:55:36 -0000 1.1 @@ -0,0 +1,3 @@ + +@context@ + \ No newline at end of file Index: openacs-4/packages/rules/www/add-rule.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/add-rule.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/add-rule.tcl 3 Dec 2004 17:56:02 -0000 1.1 @@ -0,0 +1,40 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + + Add new rule related to an Assessment +} { + +} -properties { + context +} + +# Just while I get the assessment package ready + +set context [list "Add rule"] + +set assessments [rules::rule::get_assessments] +form create add_rule +element create add_rule rule_name \ + -datatype text\ + -widget text\ + -label "Rule Name" + +element create add_rule asm_id\ + -datatype text\ + -widget select\ + -label "Assessment Related"\ + -options $assessments + +element create add_rule active_p\ + -datatype text\ + -widget select\ + -label "Active"\ + -options {{Yes y} { No n}} + +if {[template::form is_valid add_rule]} { + template::form get_values add_rule rule_name asm_id active_p + rules::rule::new_rule -rule_name $rule_name -asm_id $asm_id -active_p $active_p + ad_returnredirect "index" +} Index: openacs-4/packages/rules/www/add-trigger-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/add-trigger-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/add-trigger-oracle.xql 3 Dec 2004 17:56:02 -0000 1.1 @@ -0,0 +1,22 @@ + + + + oracle8.1.6 + + + select question_id as qs_id, question_text as description + from survey_questions + where section_id = (select section_id from survey_sections where + survey_id=(select asm_id from rules where rule_id=:rule_id)) + + + + + + select choice_id as result_id, label as value + from survey_question_choices + where question_id = :selected_qs + + + + Index: openacs-4/packages/rules/www/add-trigger.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/add-trigger.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/add-trigger.adp 3 Dec 2004 17:56:02 -0000 1.1 @@ -0,0 +1,12 @@ + +@context@ + + + \ No newline at end of file Index: openacs-4/packages/rules/www/add-trigger.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/add-trigger.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/add-trigger.tcl 3 Dec 2004 17:56:02 -0000 1.1 @@ -0,0 +1,69 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + + Add new rule related to an Assessment +} { + rule_id:notnull + selected_qs:optional +} + +set qs_sel 0 +set context [list [list "one-rule?rule_id=$rule_id" "Rule Properties"] "Add Trigger"] +# Just while get the assessment package ready +if { ![exists_and_not_null selected_qs]} { + set selected_qs 01 + set qs_sel $selected_qs +} else { + set qs_sel $selected_qs +} + +set questions [list] +set results [list] + +db_foreach questions { *SQL* } { + set question [list $description $qs_id] + lappend questions $question +} +db_foreach results { *SQL* } { + set result [list $value $result_id] + lappend results $result +} + + + + +form create add_trigger + +element create add_trigger rule_id\ + -datatype text\ + -widget hidden \ + -value $rule_id + +element create add_trigger qs_id\ + -datatype text\ + -widget select\ + -label "Question"\ + -options $questions\ + -value $selected_qs\ + -html { onChange go()} + +element create add_trigger result_id\ + -datatype text\ + -widget select\ + -label "Result"\ + -options $results + + +element create add_trigger active_p\ + -datatype text\ + -widget select\ + -label "Active"\ + -options {{Yes y} { No n}} + +if {[template::form is_valid add_trigger]} { + template::form get_values add_trigger qs_id result_id active_p + rules::rule::add_trigger -qs_id $qs_id -result_id $result_id -rule_id $rule_id -active_p $active_p + ad_returnredirect "one-rule?rule_id=$rule_id" +} Index: openacs-4/packages/rules/www/add-user.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/add-user.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/add-user.adp 3 Dec 2004 17:56:11 -0000 1.1 @@ -0,0 +1,2 @@ + +@users_list@ \ No newline at end of file Index: openacs-4/packages/rules/www/add-user.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/add-user.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/add-user.tcl 3 Dec 2004 17:56:11 -0000 1.1 @@ -0,0 +1,18 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation-date 2004-11-25 + +} { + user_id:integer,notnull + object_id:integer,notnull + type_id:integer,notnull + return_url + users_list:optional +} +if { $users_list == "" } { + set users_list $user_id +} else { + append users_list "-$user_id" +} + ad_returnredirect "request-notification?object_id=$object_id&type_id=$type_id&return_url=$return_url&users_list=$users_list" \ No newline at end of file Index: openacs-4/packages/rules/www/change-actions-result.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/change-actions-result.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/change-actions-result.tcl 3 Dec 2004 17:56:11 -0000 1.1 @@ -0,0 +1,18 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + + +} { + rule_id:notnull + action_id:notnull + res:notnull + +} + +db_transaction { + + db_dml update_action_result { update rules_actions set group_id=:res where rule_action_id=:action_id} +} +ad_returnredirect "one-rule?rule_id=$rule_id&res=$res" \ No newline at end of file Index: openacs-4/packages/rules/www/change-active-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/change-active-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/change-active-oracle.xql 3 Dec 2004 17:56:11 -0000 1.1 @@ -0,0 +1,11 @@ + + + + oracle8.1.6 + + + update rules set active_p= :active_p where rule_id=:rule_id + + + + Index: openacs-4/packages/rules/www/change-active-trigger-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/change-active-trigger-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/change-active-trigger-oracle.xql 3 Dec 2004 17:56:28 -0000 1.1 @@ -0,0 +1,11 @@ + + + + oracle8.1.6 + + + update rules_triggers set active_p= :active_p where rule_def_id=:rule_def_id + + + + Index: openacs-4/packages/rules/www/change-active-trigger.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/change-active-trigger.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/change-active-trigger.tcl 3 Dec 2004 17:56:28 -0000 1.1 @@ -0,0 +1,22 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + + Change to active or not-active +} { + res:notnull + rule_def_id:integer,notnull + rule_id +} + set active_p "y" + + if { $res == "y"} { + set active_p "n" + } + + db_transaction { + db_dml change_active_trigger { *SQL* } + } + + ad_returnredirect "one-rule?rule_id=$rule_id" Index: openacs-4/packages/rules/www/change-active.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/change-active.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/change-active.tcl 3 Dec 2004 17:56:28 -0000 1.1 @@ -0,0 +1,21 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + + Change to active or not-active +} { + res:notnull + rule_id:integer,notnull +} + set active_p "y" + + if { $res == "y"} { + set active_p "n" + } + + db_transaction { + db_dml change_active_rule { *SQL* } + } + + ad_returnredirect "index" Index: openacs-4/packages/rules/www/change-notify-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/change-notify-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/change-notify-oracle.xql 3 Dec 2004 17:56:36 -0000 1.1 @@ -0,0 +1,11 @@ + + + + oracle8.1.6 + + + update rules_actions set notify_p= :notify_p where rule_action_id=:action_id + + + + Index: openacs-4/packages/rules/www/change-notify.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/change-notify.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/change-notify.tcl 3 Dec 2004 17:56:36 -0000 1.1 @@ -0,0 +1,26 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + + Change to active or not-active +} { + res:notnull + action_id:integer,notnull + rule_id +} + set notify_p "y" + + if { $res == "y"} { + set notify_p "n" + } + + db_transaction { + db_dml change_notify { *SQL* } + } +if { $res == "n" } { + ad_returnredirect "request-notification?object_id=$rule_id&type_id=[notification::type::get_type_id -short_name rule_notif]&return_url=index" +} + + + ad_returnredirect "one-rule?rule_id=$rule_id" Index: openacs-4/packages/rules/www/change-trigger-qs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/change-trigger-qs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/change-trigger-qs.tcl 3 Dec 2004 17:56:36 -0000 1.1 @@ -0,0 +1,18 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + + +} { + rule_id:notnull + trigger_id:notnull + qs:notnull + +} + +db_transaction { + + db_dml update_trigger { update rules_triggers set qs_id=:qs where rule_id=:rule_id and rule_def_id=:trigger_id} +} +ad_returnredirect "one-rule?rule_id=$rule_id&trigger=$trigger_id&qs=$qs" \ No newline at end of file Index: openacs-4/packages/rules/www/change-trigger-result.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/change-trigger-result.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/change-trigger-result.tcl 3 Dec 2004 17:56:44 -0000 1.1 @@ -0,0 +1,18 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + + +} { + rule_id:notnull + trigger_id:notnull + res:notnull + +} + +db_transaction { + + db_dml update_trigger_result { update rules_triggers set result_id=:res where rule_id=:rule_id and rule_def_id=:trigger_id} +} +ad_returnredirect "one-rule?rule_id=$rule_id&res=$res" \ No newline at end of file Index: openacs-4/packages/rules/www/delete-action.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/delete-action.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/delete-action.tcl 3 Dec 2004 17:56:44 -0000 1.1 @@ -0,0 +1,18 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + + Delete actions +} { + rule_action_id:integer,notnull,multiple + rule_id:integer,notnull +} + + set rules_count [llength $rule_action_id] + for { set i 0} { $i < $rules_count } { incr i } { + + rules::rule::delete_action -rule_action_id [lindex $rule_action_id $i] + } + + ad_returnredirect "one-rule?rule_id=$rule_id" Index: openacs-4/packages/rules/www/delete-actions.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/delete-actions.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/delete-actions.tcl 3 Dec 2004 17:56:44 -0000 1.1 @@ -0,0 +1,17 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + + Delete actions +} { + rule_action_id:integer,notnull,multiple + rule_id:integer,notnull +} + + set rules_count [llength $rule_id] + for { set i 0} { $i < $rules_count } { incr i } { + rules::rule::delete_action -rule_action_id [lindex $rule_action_id $i] + } + + ad_returnredirect "one-rule?rule_id=$rule_id" Index: openacs-4/packages/rules/www/delete-rule-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/delete-rule-2.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/delete-rule-2.tcl 3 Dec 2004 17:56:54 -0000 1.1 @@ -0,0 +1,16 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + + Delete rules +} { + rule_id +} + +set rules_count [llength $rule_id] + for { set i 0} { $i < $rules_count } { incr i } { + rules::rule::delete_rule -rule_id [lindex $rule_id $i] + } + +ad_returnredirect "index" \ No newline at end of file Index: openacs-4/packages/rules/www/delete-rule.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/delete-rule.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/delete-rule.adp 3 Dec 2004 17:56:54 -0000 1.1 @@ -0,0 +1,17 @@ + + + +Are you sure you want to delete the following items? + + + +@rules_table;noquote@ + + + + + + + + + Index: openacs-4/packages/rules/www/delete-rule.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/delete-rule.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/delete-rule.tcl 3 Dec 2004 17:56:54 -0000 1.1 @@ -0,0 +1,25 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + + Delete rules +} { + rule_id:integer,notnull,multiple + +} + +set rules $rule_id +set rules_count [llength $rule_id] + +set rules_table "Rule NameAssessment Related" + +for { set i 0} { $i < $rules_count } { incr i } { + set rule_name [rules::rule::get_rule_name -rule_id [lindex $rule_id $i]] + set asm_name [rules::rule::get_asm_name -rule_id [lindex $rule_id $i]] + append rules_table "$rule_name$asm_name" +} +append rules_table "" + + + Index: openacs-4/packages/rules/www/delete-trigger.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/delete-trigger.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/delete-trigger.tcl 3 Dec 2004 17:56:54 -0000 1.1 @@ -0,0 +1,17 @@ +ad_page_contract { + Delete rules +} { + rule_def_id:integer,notnull,multiple + rule_id:integer,notnull +} + + set rules_count [llength $rule_def_id] + for { set i 0} { $i < $rules_count } { incr i } { + rules::rule::delete_trigger -rule_def_id [lindex $rule_def_id $i] + } + + ad_returnredirect "one-rule?rule_id=$rule_id" + + + + Index: openacs-4/packages/rules/www/index-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/index-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/index-oracle.xql 3 Dec 2004 17:57:03 -0000 1.1 @@ -0,0 +1,13 @@ + + + + oracle8.1.6 + + + select r.rule_id,r.rule_name, s.survey_id as asm_id,s.name as asm_name,r.active_p + from rules r, surveys s + where r.asm_id=s.survey_id + + + + \ No newline at end of file Index: openacs-4/packages/rules/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/index.adp 3 Dec 2004 17:57:03 -0000 1.1 @@ -0,0 +1,13 @@ + + + + + Add New Rule + + + + + + + + \ No newline at end of file Index: openacs-4/packages/rules/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/index.tcl 3 Dec 2004 17:57:03 -0000 1.1 @@ -0,0 +1,52 @@ +ad_page_contract { + Display of rules + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + +} { + +} + + +template::list::create -name rules\ +-multirow all_rules\ +-key rule_id\ +-bulk_actions { + "Delete" "delete-rule" "Delete checked rules" +}\ +-bulk_action_method post -bulk_action_export_vars { + rule_id +}\ +-no_data "There are no rules"\ +-row_pretty_plural "all rules"\ +-elements { + rule_name { + label "Rule Name" + link_url_eval {[export_vars -base one-rule { rule_id}]} + + } + asm_name { + label "Assessment Related" + link_url_eval {../survey/admin/one?survey_id=$asm_id} + } + active_p { + label "Active" + display_template { + + Yes / No + + + Yes / No + + } + } + rule_id { + label "Notify" + display_template { + Notify + + } + } +} +db_multirow all_rules all_rules { *SQL* } + Index: openacs-4/packages/rules/www/one-rule-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/one-rule-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/one-rule-oracle.xql 3 Dec 2004 17:57:03 -0000 1.1 @@ -0,0 +1,45 @@ + + + oracle8.1.6 + + + select r.rule_id, r.rule_name, rt.result_id, rt.qs_id, + rt.rule_def_id, rt.active_p,r.asm_id,q.question_text as + description, (select label value from survey_question_choices + where question_id=rt.qs_id and choice_id=rt.result_id) as value + from rules r,rules_triggers rt,survey_questions q,survey_sections ss + where rt.rule_id=r.rule_id and rt.rule_id=:rule_id + and q.question_id = rt.qs_id and ss.survey_id = r.asm_id and ss.section_id = q.section_id + + + + + select + ra.rule_id,ra.group_id,ra.notify_p,ra.active_p,ra.rule_action_id,ra.action_type, (select pretty_name from dotlrn_communities_all where + community_id=ra.group_id) as name + from rules r,rules_actions ra + where ra.rule_id=r.rule_id and ra.rule_id=:rule_id + + + + + select question_id as qs_id, question_text as description + from survey_questions + where section_id = (select section_id from survey_sections where + survey_id=(select asm_id from rules where rule_id=:rule_id)) + + + + + + + select choice_id as result_id, label as value + from survey_question_choices + where question_id = :selected_qs + + + + + + + \ No newline at end of file Index: openacs-4/packages/rules/www/one-rule.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/one-rule.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/one-rule.adp 3 Dec 2004 17:57:03 -0000 1.1 @@ -0,0 +1,74 @@ + +@context@ +Rules Properties + + + + + + + + + + + + + + + + + Add a + Trigger to the Rule + + + + + Add Notification + + + + + + + + + + + + + + + + + Add an + action to the Rule + + + + + + + + + + + Index: openacs-4/packages/rules/www/one-rule.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/one-rule.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/one-rule.tcl 3 Dec 2004 17:57:14 -0000 1.1 @@ -0,0 +1,132 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + + Display of rules + +} { + rule_id:notnull + qs:optional + trigger:optional +} + +set context [list "Rule Properties"] +set qs_id_2 0 +if { ![exists_and_not_null qs]} { + set qs "" +} +if { ![exists_and_not_null trigger]} { + set trigger "" +} +set type_id [notification::type::get_type_id -short_name rule_notif] +template::list::create -name triggers\ +-multirow rule_triggers\ +-key rule_def_id\ +-bulk_actions { + "Delete" "delete-trigger" "Delete checked triggers" +}\ +-bulk_action_method post -bulk_action_export_vars { + rule_def_id + rule_id + qs +}\ +-no_data "There are no triggers "\ +-row_pretty_plural "triggers"\ +-elements { + qs_id { + label "Question" + display_template { + + + <% set qs_id_2 @rule_triggers.qs_id@ + db_multirow questions question {select question_id as qs_id, question_text as description + from survey_questions where section_id = (select section_id from survey_sections where + survey_id=(select asm_id from rules where rule_id=$rule_id)) +} %> + @rule_triggers.description@ + + @questions.description@ + + + + } + } + result_id { + label "Result" + display_template { + + + + <% set q_id @rule_triggers.qs_id@ + db_multirow answers answers {select choice_id as result_id, label as value from survey_question_choices where question_id = :q_id} %> + @rule_triggers.value@ + + @answers.value@ + + + + } + } + active_p { + label "Active" + display_template { + + Yes / No + + + Yes / No + + } + } +} +db_multirow rule_triggers get_triggers { *SQL* } + + + + +template::list::create -name actions\ +-multirow rule_actions\ +-key rule_action_id\ +-bulk_actions { + "Delete" "delete-action" "Delete checked actions" +}\ +-bulk_action_method post -bulk_action_export_vars { + rule_action_id + rule_id +}\ +-no_data "There are no actions "\ +-row_pretty_plural "actions"\ +-elements { + action_type { + label "Action" + display_template { + + Add user to + + + Add to list for + + } + + + } + group_id { + label "Result" + display_template { + + <% + db_multirow communities communities {select community_id,pretty_name from dotlrn_communities_all} + %> @rule_actions.name@ + + @communities.pretty_name@ + + + } + + + + } +} +db_multirow rule_actions get_actions { *SQL* } + Index: openacs-4/packages/rules/www/process-response-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/process-response-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/process-response-oracle.xql 3 Dec 2004 17:57:14 -0000 1.1 @@ -0,0 +1,34 @@ + + + oracle8.1.6 + + + select * from survey_questions where section_id=(select section_id + from survey_sections ss where ss.survey_id=:survey_id) + + + + + select * from survey_responses where survey_id=:survey_id + + + + + select * from survey_questions_responses where response_id=:response_id + and question_id=:question_id + + + + select * from rules where asm_id=:survey_id + + + select * from rules_triggers where rule_id=:rule_id + + + + select choice_id from survey_questions_responses where + question_id=:qs_id and response_id= (select response_id from survey_responses where survey_id=:survey_id) + + + + \ No newline at end of file Index: openacs-4/packages/rules/www/process-response.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/process-response.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/process-response.adp 3 Dec 2004 17:57:14 -0000 1.1 @@ -0,0 +1,2 @@ + + Index: openacs-4/packages/rules/www/process-response.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/process-response.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/process-response.tcl 3 Dec 2004 17:57:30 -0000 1.1 @@ -0,0 +1,46 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + +} { + survey_id:notnull + response_id:notnull +} + +set user_id [ad_conn user_id] +set perform_actions 0 +set rest "" + +db_foreach rules_related {select * from rules where asm_id=:survey_id} { + db_foreach rule_triggers { select * from rules_triggers where rule_id=:rule_id } { + set answer [db_string answer { select choice_id from survey_question_responses where question_id=:qs_id and response_id=:response_id}] + if { $answer == $result_id } { + set perform_actions 1 + } else { + set perform_actions 0 + } + } + if { $perform_actions == 1 } { + db_foreach action { select * from rules_actions where rule_id=:rule_id} { + set rha_id [db_nextval rha_seq] + set today [db_string date "select sysdate from dual"] + if { $action_type == 1} { + dotlrn_community::add_user $group_id $user_id + + db_transaction { + + db_dml add_history { insert into rule_history_actions (rha_id,group_id,rule_action_id,request_date,processing_date,approved_p) values (:rha_id,:group_id,:rule_action_id,:today,:today,'y')} + } + } elseif {$action_type == 2} { + set today [db_string date "select sysdate from dual"] + db_transaction { + db_dml add_history { insert into rule_history_actions (rha_id,group_id,rule_action_id,request_date,processing_date,approved_p) values (:rha_id,:group_id,:rule_action_id,:today,'','n')} + + + } + } + } + +} + } Index: openacs-4/packages/rules/www/request-notification-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/request-notification-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/request-notification-oracle.xql 3 Dec 2004 17:57:30 -0000 1.1 @@ -0,0 +1,15 @@ + + + + + + select p.first_names || ' ' || p.last_name as name,nr.request_id + from persons p, notification_requests nr + where p.person_id = nr.user_id and + nr.object_id = :object_id + + + + + + Index: openacs-4/packages/rules/www/request-notification.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/request-notification.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/request-notification.adp 3 Dec 2004 17:57:30 -0000 1.1 @@ -0,0 +1,18 @@ + +@context@ + + + + + + + + + +User alredy subscribed: + + + + + + Index: openacs-4/packages/rules/www/request-notification.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/request-notification.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/request-notification.tcl 3 Dec 2004 17:57:45 -0000 1.1 @@ -0,0 +1,100 @@ +ad_page_contract { + + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + + Request a new notification + + +} { + type_id:integer,notnull + object_id:integer,notnull + {pretty_name ""} + users_list:optional + + +} +# Check that the object can be subcribed to +notification::security::require_notify_object -object_id $object_id + +if {[empty_string_p $pretty_name]} { + set page_title "[_ notifications.Request_Notification]" +} else { + set page_title "[_ notifications.lt_Request_Notification_]" +} + +set context [list [list "one-rule?rule_id=$object_id" "Rule Properties"] "[_ notifications.Request_Notification]"] + +set intervals [notification::get_intervals -type_id $type_id] +set delivery_methods [notification::get_delivery_methods -type_id $type_id] + + +form create request + +element create request party_id\ + -datatype party_search \ + -widget party_search\ + -label "User to Notify"\ + -value " " +element create request object_id\ + -datatype integer\ + -widget hidden\ + -value $object_id + +element create request type_id\ + -datatype integer\ + -widget hidden\ + -value $type_id + +element create request return_url\ + -datatype text\ + -widget hidden\ + -value "index" +element create request interval_id\ + -datatype integer \ + -widget select\ + -label "[_ notifications.lt_Notification_Interval]"\ + -options $intervals\ + -value 0 + +element create request delivery_method_id\ + -datatype integer \ + -widget select\ + -label "[_ notifications.Delivery_Method]"\ + -options $delivery_methods\ + -value [lindex [lindex $delivery_methods 0] 1] + +if {[template::form is_valid request]} { + template::form get_values request party_id interval_id delivery_method_id type_id object_id + # Add the subscribe + notification::request::new \ + -type_id $type_id \ + -user_id $party_id \ + -object_id $object_id \ + -interval_id $interval_id \ + -delivery_method_id $delivery_method_id + + + ad_returnredirect "request-notification?type_id=$type_id&object_id=$object_id" +} + +template::list::create -name notify_users\ +-multirow notify_users\ +-key request_id\ +-bulk_actions\ + { + "Unsubscribe" "unsubscribe" "Unsubscribe user to this rule" + }\ + -bulk_action_method post -bulk_action_export_vars { + object_id + type_id + }\ +-no_data "There are no users to notify"\ +-row_pretty_plural "notify_users"\ +-elements { + name { + label "UserName" + } +} + db_multirow notify_users notify_users { *SQL* } \ No newline at end of file Index: openacs-4/packages/rules/www/unsubscribe.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/unsubscribe.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/unsubscribe.tcl 3 Dec 2004 17:57:45 -0000 1.1 @@ -0,0 +1,20 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + +} { +object_id:notnull +request_id:multiple +type_id +} + + set request_count [llength $request_id] + for { set i 0} { $i < $request_count } { incr i } { + db_transaction { + set r_id [lindex $request_id $i] + db_dml remove_notify { delete from notification_requests where request_id=:r_id } + } + } + + ad_returnredirect "request-notification?object_id=$object_id&type_id=$type_id&return_url=one-rule?rule_id=$object_id" Index: openacs-4/packages/rules/www/admin/admin-master.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/admin/Attic/admin-master.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/admin/admin-master.adp 3 Dec 2004 18:01:18 -0000 1.1 @@ -0,0 +1,37 @@ +<% + + # + # Copyright (C) 2001, 2002 MIT + # + # This file is part of dotLRN. + # + # dotLRN is free software; you can redistribute it and/or modify it under the + # terms of the GNU General Public License as published by the Free Software + # Foundation; either version 2 of the License, or (at your option) any later + # version. + # + # dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY + # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + # details. + # + +%> + + + 1 + @focus;noquote@ + @context;noquote@ + @context_bar;noquote@ + @doc_type;noquote@ + + + + + + Index: openacs-4/packages/rules/www/admin/admin-request.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/admin/Attic/admin-request.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/admin/admin-request.adp 3 Dec 2004 18:01:18 -0000 1.1 @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file Index: openacs-4/packages/rules/www/admin/admin-request.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/admin/Attic/admin-request.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/admin/admin-request.tcl 3 Dec 2004 18:01:18 -0000 1.1 @@ -0,0 +1,50 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + +} { +} + +set communities_list [list] + +lappend communities_list [list "All" ""] + +db_foreach community {select community_id,pretty_name from dotlrn_communities_all} { + lappend communities_list [list $pretty_name $community_id] +} + +set approved_options [list [list "Not Approved" n] [list "Approved" y]] + +set today [db_string today {select sysdate from dual}] +set yesterday [db_string yesterday {select (sysdate-1) from dual}] +set last_week [db_string last_week {select (sysdate-7) from dual}] +set two_days [db_string two_weeks {select (sysdate-2) from dual}] +set last_month [db_string last_month {select (sysdate-30) from dual}] + +set date_options [list [list "All" ""] [list "Today" $today] [list "Yesterday" $yesterday] [list "Two days ago" $two_days] [list "Last Week" $last_week] [list "Last Month" $last_month]] +form create communities -has_submit +element create communities community_id\ + -datatype text\ + -widget select\ + -label "Group Name"\ + -options $communities_list +element create communities approved_p\ + -datatype text\ + -widget select\ + -label ""\ + -options $approved_options + +form create date -has_submit 1 +element create date date\ + -datatype text\ + -widget select\ + -label "Date of Request"\ + -options $date_options + +element create date submit\ + -widget submit\ + -label "Specific Date" + + +