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 -r1.5 -r1.6 --- openacs-4/packages/rules/www/add-action.adp 10 Dec 2004 17:34:27 -0000 1.5 +++ openacs-4/packages/rules/www/add-action.adp 16 Dec 2004 18:44:41 -0000 1.6 @@ -15,7 +15,8 @@
+ Registration Rules - + 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 -r1.3 -r1.4 --- openacs-4/packages/rules/www/add-action.tcl 10 Dec 2004 17:34:27 -0000 1.3 +++ openacs-4/packages/rules/www/add-action.tcl 16 Dec 2004 18:44:41 -0000 1.4 @@ -8,7 +8,7 @@ rule_id:notnull selected_a:optional } - +ad_maybe_redirect_for_registration set default_action 1 # Just while I get the assessment package ready Index: openacs-4/packages/rules/www/add-action.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/add-action.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/add-action.xql 16 Dec 2004 18:47:07 -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-rule.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/add-rule.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/rules/www/add-rule.adp 10 Dec 2004 17:34:27 -0000 1.2 +++ openacs-4/packages/rules/www/add-rule.adp 16 Dec 2004 18:44:41 -0000 1.3 @@ -7,9 +7,8 @@
You don't have permission to admin Rule.

- + Edit Rule - \ 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 -r1.5 -r1.6 --- openacs-4/packages/rules/www/add-rule.tcl 10 Dec 2004 17:34:27 -0000 1.5 +++ openacs-4/packages/rules/www/add-rule.tcl 16 Dec 2004 18:44:41 -0000 1.6 @@ -12,7 +12,7 @@ } # Just while I get the assessment package ready - +ad_maybe_redirect_for_registration set package_id [ad_conn package_id] set user_id [ad_conn user_id] set context [list "Add rule"] 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 -r1.3 -r1.4 --- openacs-4/packages/rules/www/add-trigger.adp 10 Dec 2004 17:34:27 -0000 1.3 +++ openacs-4/packages/rules/www/add-trigger.adp 16 Dec 2004 18:44:41 -0000 1.4 @@ -15,8 +15,9 @@
You don't have permission to admin Rule.

+ Registration Rules - + 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 -r1.5 -r1.6 --- openacs-4/packages/rules/www/add-trigger.tcl 10 Dec 2004 17:34:27 -0000 1.5 +++ openacs-4/packages/rules/www/add-trigger.tcl 16 Dec 2004 18:44:41 -0000 1.6 @@ -8,7 +8,7 @@ rule_id:notnull selected_qs:optional } - +ad_maybe_redirect_for_registration set qs_sel 0 set context [list [list "one-rule?rule_id=$rule_id" "Rule Properties"] "Add Trigger"] set package_id [ad_conn package_id] Index: openacs-4/packages/rules/www/admin-request.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/admin-request.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/admin-request.adp 16 Dec 2004 18:47:07 -0000 1.1 @@ -0,0 +1,52 @@ + +@rule_name@ Waiting List +@context@ + + + + + + + + + + +
+ + + + +
+
+ + + Index: openacs-4/packages/rules/www/admin-request.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/admin-request.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/admin-request.tcl 16 Dec 2004 18:47:07 -0000 1.1 @@ -0,0 +1,200 @@ +ad_page_contract { + + @author Anny Flores (annyflores@viaro.net) + @creation_date 2004-12-03 + +} { + interval:optional + specific_date:optional + state:optional + community:optional + rule:notnull +} + +set rule_name [ db_string name {select rule_name from rules where rule_id=:rule } -default "" ] +set context [list [list "one-rule?rule_id=$rule" "Rule Properties"] "$rule_name"] +set package_id [ad_conn package_id] +set user_id [ad_conn user_id] +set context [list "Add rule"] +set rule_admin "" +set admin [permission::permission_p -object_id $package_id -party_id $user_id -privilege "admin"] +if { [exists_and_not_null rule] } { +set rule_admin [permission::permission_p -object_id $rule -party_id $user_id -privilege "admin"] +} + +if { $rule_admin == 0 && $admin == 0 } { + doc_return 200 text/html "

Permission Denied

+ You don't have permission to admin this Rule. " + ad_script_abort + + +} + + +set communities_list [list] +lappend communities_list [list "All" "all"] +lappend communities_list [list "System" "-1"] +lappend rules_list [list "All" "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 to_date(sysdate,'YYYY-MM-DD') from dual}] +set yesterday [db_string yesterday {select to_date(sysdate-1,'YYYY-MM-DD') from dual}] +set last_week [db_string last_week {select to_date(sysdate-7,'YYYY-MM-DD') from dual}] +set two_days [db_string two_weeks {select to_date(sysdate-2,'YYYY-MM-DD') from dual}] +set last_month [db_string last_month {select to_date(sysdate-30,'YYYY-MM-DD') from dual}] + +set default_interval "all" +set default_specific_date "" +set default_community "all" +set default_state "n" +set default_rule $rule + +set date_options [list [list "All" "all"] [list "Today" $today] [list "Yesterday" $yesterday] [list "Two days ago" $two_days] [list "Last Week" $last_week] [list "Last Month" $last_month]] + +set community_query "" +set rule_query "" + +if {[exists_and_not_null community] && $community != "all" } { + set default_community $community + set community_query " and r.group_id= $default_community" + +} +if {[exists_and_not_null rule] && $rule != "all" } { + + set default_rule $rule + set rule_query " and r.rule_action_id in (select rule_action_id from rules_actions where rule_id = $default_rule)" + +} + +if {[exists_and_not_null state]} { + set default_state $state; +} +set interval_query "" +set specific_date_query "" + +if {[exists_and_not_null interval] && $interval != "all" } { + set default_interval $interval + if { $interval == $today || $interval == $yesterday || $interval== $two_days} { + set interval_query " and to_char(request_date,'YYYY-MM-DD') = '$interval'" + } else { + set interval_query " and to_char(request_date,'YYYY-MM-DD') > '$interval' and to_char(request_date,'YYYY-MM-DD') <= '$today'" + } +} +if {[exists_and_not_null specific_date]} { + set default_specific_date $specific_date + set specific_date_query "and to_char(request_date,'YYYY-MM-DD') = '$default_specific_date'" +} + + set query "select r.rha_id,r.user_id,(select p.first_names || ' ' || p.last_name as name from persons p where p.person_id = r.user_id) as user_name, (select pretty_name from dotlrn_communities_all where community_id=r.group_id) as group_name, r.group_id,r.rule_action_id,to_date(r.request_date,'YYYY-MM-DD') as request_date ,r.approved_p from rule_history_actions r where approved_p='$default_state' $community_query $interval_query $specific_date_query $rule_query" + + + +form create communities -has_submit +element create communities community_id\ + -datatype text\ + -widget select\ + -label "Group Name"\ + -options $communities_list\ + -html { onChange "get_community()"}\ + -value $default_community + +element create communities approved_p\ + -datatype text\ + -widget select\ + -label ""\ + -options $approved_options\ + -html { onChange "get_state()"}\ + -value $default_state + +form create interval -has_submit 1 +element create interval date\ + -datatype text\ + -widget select\ + -label "Date of Request"\ + -options $date_options\ + -html { onChange "get_interval()"}\ + -value $default_interval + +form create specific_date -has_submit 1 +element create specific_date community \ + -datatype text\ + -widget hidden\ + -value $default_community +element create specific_date state \ + -datatype text\ + -widget hidden\ + -value $default_state +element create specific_date rule \ + -datatype text\ + -widget hidden\ + -value $default_rule + +element create specific_date specific_date \ + -label "" \ + -datatype text\ + -widget text \ + -optional\ + -value $default_specific_date\ + -html {id sel2}\ + -after_html {[YYYY-MM-DD]} + +element create specific_date date submit\ + -widget submit\ + -label "Specific Date"\ + -html { onClick "get_specific_date()"} + + +template::list::create -name requests\ +-multirow requests\ +-key rha_id\ +-bulk_actions { + "Bulk Mail" "bulk-mail" "Send mail to all users" + "Approve" "approve-users" "Approve users requests" +}\ +-bulk_action_method post -bulk_action_export_vars { + {interval $default_interval} + {rule $default_rule} + {community $default_community} + {specific_date $default_specific_date} + {state $default_state} +}\ +-no_data "There are no requests"\ +-row_pretty_plural "requests"\ +-elements { + user_id { + label "User" + display_col user_name + } + group_id { + label "Group Name" + display_template { + < if @requests.group_id@ eq -1> + System + + @requests.group_name@ + + } + } + request_date { + label "Request Date" + + } + approved_p { + label "Approved" + display_template { + + Yes + + + No + + } + } +} + +db_multirow requests requests $query Index: openacs-4/packages/rules/www/approve-users-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/approve-users-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/approve-users-oracle.xql 16 Dec 2004 18:47:07 -0000 1.1 @@ -0,0 +1,26 @@ + + + + oracle8.1.6 + + + select group_id from rule_history_actions where rha_id=:r_id + + + + + select user_id from rule_history_actions where rha_id=:r_id + + + + + select to_date (sysdate,'YYYY-MM-DD') from dual + + + + + update rule_history_actions set processing_date=:today, approved_p='y' where rha_id=:r_id + + + + Index: openacs-4/packages/rules/www/approve-users.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/approve-users.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/approve-users.tcl 16 Dec 2004 18:47:07 -0000 1.1 @@ -0,0 +1,50 @@ +ad_page_contract { + Delete rules +} { + rha_id:integer,notnull,multiple + interval + specific_date + state + community + rule + + +} +set package_id [ad_conn package_id] +set user_id [ad_conn user_id] +set context [list "Add rule"] +set rule_admin "" +set admin [permission::permission_p -object_id $package_id -party_id $user_id -privilege "admin"] + if { [exists_and_not_null rule] } { +set rule_admin [permission::permission_p -object_id $rule -party_id $user_id -privilege "admin"] +} + +if { $rule_admin == 0 && $admin == 0 } { + doc_return 200 text/html "

Permission Denied

+ You don't have permission to admin this Rule. " + ad_script_abort + + +} + + + set rules_count [llength $rha_id] + for { set i 0} { $i < $rules_count } { incr i } { + set r_id [lindex $rha_id $i] + set group_id [db_string community { *SQL* }] + if { $group_id != -1 } { + set user_id [db_string user { *SQL* }] + set today [db_string today { *SQL* }] + if {![dotlrn::user_is_community_member_p -user_id $user_id -community_id $group_id]} { + dotlrn_community::add_user $group_id $user_id + } + + db_transaction { + + db_dml add_history { } + } + + } +} + + ad_returnredirect "admin-request?interval=$interval&community=$community&specific_date=$specific_date&rule=$rule&state=$state" 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 -r1.2 -r1.3 --- openacs-4/packages/rules/www/change-actions-result.tcl 10 Dec 2004 17:34:27 -0000 1.2 +++ openacs-4/packages/rules/www/change-actions-result.tcl 16 Dec 2004 18:44:41 -0000 1.3 @@ -30,6 +30,6 @@ db_transaction { - db_dml update_action_result { update rules_actions set group_id=:res where rule_action_id=:action_id} + db_dml update_action_result { *SQL* } } ad_returnredirect "one-rule?rule_id=$rule_id&res=$res" \ No newline at end of file Index: openacs-4/packages/rules/www/change-actions-result.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/change-actions-result.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/change-actions-result.xql 16 Dec 2004 18:47:07 -0000 1.1 @@ -0,0 +1,10 @@ + + + + + + update rules_actions set group_id=:res where + rule_action_id=:action_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 -r1.1 -r1.2 --- openacs-4/packages/rules/www/change-trigger-qs.tcl 3 Dec 2004 17:56:36 -0000 1.1 +++ openacs-4/packages/rules/www/change-trigger-qs.tcl 16 Dec 2004 18:44:41 -0000 1.2 @@ -13,6 +13,6 @@ db_transaction { - db_dml update_trigger { update rules_triggers set qs_id=:qs where rule_id=:rule_id and rule_def_id=:trigger_id} + db_dml update_trigger { *SQL* } } 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-qs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/change-trigger-qs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/change-trigger-qs.xql 16 Dec 2004 18:47:07 -0000 1.1 @@ -0,0 +1,9 @@ + + + + + + update rules_triggers set qs_id=:qs where rule_id=:rule_id and rule_def_id=:trigger_id + + + 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 -r1.1 -r1.2 --- openacs-4/packages/rules/www/change-trigger-result.tcl 3 Dec 2004 17:56:44 -0000 1.1 +++ openacs-4/packages/rules/www/change-trigger-result.tcl 16 Dec 2004 18:44:41 -0000 1.2 @@ -13,6 +13,6 @@ 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} + db_dml update_trigger_result { *SQL* } } ad_returnredirect "one-rule?rule_id=$rule_id&res=$res" \ No newline at end of file Index: openacs-4/packages/rules/www/change-trigger-result.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/change-trigger-result.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/www/change-trigger-result.xql 16 Dec 2004 18:47:07 -0000 1.1 @@ -0,0 +1,9 @@ + + + + + +update rules_triggers set result_id=:res where rule_id=:rule_id and rule_def_id=:trigger_id + + + 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 -r1.4 -r1.5 --- openacs-4/packages/rules/www/process-response-oracle.xql 10 Dec 2004 17:34:27 -0000 1.4 +++ openacs-4/packages/rules/www/process-response-oracle.xql 16 Dec 2004 18:44:41 -0000 1.5 @@ -2,9 +2,71 @@ oracle8.1.6 - - select * from survey_questions where section_id in (select section_id - from survey_sections ss where ss.survey_id=:survey_id) - + + select * from survey_questions where section_id in (select section_id + from survey_sections ss where ss.survey_id=:survey_id) + + + + + select * from rules where asm_id=:survey_id + + + + + select result_id,rule_def_id, qs_id, active_p, rule_id from rules_triggers where rule_id=:rule_id + + + + + select choice_id from survey_question_responses where question_id=:qs_id and response_id=:response_id + + + + + select * from rules_actions where rule_id=:rule_id + + + + + + select pretty_name from dotlrn_communities_all where community_id=:group_id + + + + + select to_date(sysdate,'YYYY-MM-DD') from dual + + + + + select p.first_names || ' ' || p.last_name as name from persons p where p.person_id = :user_id + + + + + select number_answer from survey_question_responses where question_id = :s_id and response_id = :response_id + + + + + insert into rule_history_actions (rha_id,group_id,user_id,rule_action_id,request_date,processing_date,approved_p) values (:rha_id,:group_id,:user_id,:rule_action_id,to_date(:today,'YYYY-MM-DD'),to_date(:today,'YYYY-MM-DD'),'y') + + + + + + insert into rule_history_actions + (rha_id,group_id,user_id,rule_action_id,request_date,processing_date,approved_p) + values + (:rha_id,:group_id,:user_id,:rule_action_id,to_date(:today,'YYYY-MM-DD'),'','n') + + + + + insert into rule_history_actions (rha_id,group_id,user_id,rule_action_id,request_date,processing_date,approved_p) values (:rha_id,-1,:user_id,:rule_action_id,to_date(:today,'YYYY-MM-DD'),to_date(:today,'YYYY-MM-DD'),'y') + + + \ No newline at end of file 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 -r1.7 -r1.8 --- openacs-4/packages/rules/www/process-response.tcl 10 Dec 2004 17:34:27 -0000 1.7 +++ openacs-4/packages/rules/www/process-response.tcl 16 Dec 2004 18:44:41 -0000 1.8 @@ -15,39 +15,39 @@ set message "" set notif_text "" -db_foreach rules_related { select * from rules where asm_id=:survey_id } { +db_foreach rules_related { *SQL* } { if { $active_p == "y"} { - db_foreach rule_triggers {select result_id,rule_def_id, qs_id, active_p, rule_id from rules_triggers where rule_id=:rule_id } { + db_foreach rule_triggers { *SQL* } { if { $active_p == "y" } { - set answer [db_string answer { select choice_id from survey_question_responses where question_id=:qs_id and response_id=:response_id}] + set answer [db_string answer { *SQL* }] 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} { + db_foreach action { *SQL* } { set rha_id [db_nextval rha_seq] - set community_name [db_string name {select pretty_name from dotlrn_communities_all where community_id=:group_id} -default System] - set today [db_string date "select to_date(sysdate,'YYYY-MM-DD') from dual"] - set username [db_string name {select p.first_names || ' ' || p.last_name as name from persons p where p.person_id = :user_id}] + set community_name [db_string name { *SQL* } -default System] + set today [db_string date { *SQL* }] + set username [db_string username { *SQL* }] if { $action_type == 1} { append message "
  • You have joined the $community_name community." append notif_text "The user user has joined the $community_name community." if {![dotlrn::user_is_community_member_p -user_id $user_id -community_id $group_id]} { dotlrn_community::add_user $group_id $user_id } db_transaction { - db_dml add_history { insert into rule_history_actions (rha_id,group_id,user_id,rule_action_id,request_date,processing_date,approved_p) values (:rha_id,:group_id,:user_id,:rule_action_id,to_date(:today,'YYYY-MM-DD'),to_date(:today,'YYYY-MM-DD'),'y')} + db_dml add_history { *SQL* } } } elseif { $action_type == 2 } { append message "
  • Your request to join $community_name has been sent to the administrator of the group." append notif_text "The user $username requested to join $community_name." - set today [db_string date "select sysdate from dual"] + set today [db_string date { *SQL* }] db_transaction { - db_dml add_history { insert into rule_history_actions (rha_id,group_id,user_id,rule_action_id,request_date,processing_date,approved_p) values (:rha_id,:group_id,:user_id,:rule_action_id,to_date(:today,'YYYY-MM-DD'),'','n')} + db_dml add_history_wait { *SQL* } } } elseif { $action_type == 3 } { set s_id "" @@ -56,7 +56,7 @@ set s_id $question_id } } - set user_info [db_string student_id {select number_answer from survey_question_responses where question_id = :s_id and response_id = :response_id}] + set user_info [db_string student_id { *SQL* }] array set user_new_info [auth::create_user -username $user_info -email $user_info@viaro.net -first_names $user_info -last_name $user_info -password $user_info] append message "
  • You have joined the System
    @@ -74,7 +74,7 @@ dotlrn_privacy::set_user_guest_p -user_id $user_id -value "t" dotlrn::user_add -can_browse -user_id $user_id db_transaction { - db_dml add_history { insert into rule_history_actions (rha_id,group_id,user_id,rule_action_id,request_date,processing_date,approved_p) values (:rha_id,-1,:user_id,:rule_action_id,to_date(:today,'YYYY-MM-DD'),to_date(:today,'YYYY-MM-DD'),'y')} + db_dml add_history_system { *SQL* } } } } Index: openacs-4/packages/rules/www/unsubscribe.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/www/Attic/unsubscribe.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/rules/www/unsubscribe.tcl 3 Dec 2004 17:57:45 -0000 1.1 +++ openacs-4/packages/rules/www/unsubscribe.tcl 16 Dec 2004 18:44:41 -0000 1.2 @@ -13,7 +13,7 @@ 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 } + db_dml remove_notify { *SQL* } } }