Index: openacs-4/packages/acs-admin/www/auth/authority-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/auth/authority-delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/auth/authority-delete.tcl 10 Sep 2003 14:32:47 -0000 1.1 @@ -0,0 +1,12 @@ +ad_page_contract { + Script that deletes an authority. + + @author Peter Marklund + @creation-date 2003-09-08 +} { + authority_id:integer +} + +auth::authority::delete -authority_id $authority_id + +ad_returnredirect "." Index: openacs-4/packages/acs-admin/www/auth/authority-set-enabled-p.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/auth/authority-set-enabled-p.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/auth/authority-set-enabled-p.tcl 10 Sep 2003 14:32:47 -0000 1.1 @@ -0,0 +1,16 @@ +ad_page_contract { + + Toggles enabled_p of authority + + @author Simon Carstensen (simon@collaboraid.biz) + + @creation-date 2003-09-09 +} { + authority_id + enabled_p:boolean +} + +db_dml set_enabled_p { update auth_authorities set enabled_p = :enabled_p where authority_id = :authority_id } + +ad_returnredirect . +ad_script_abort Index: openacs-4/packages/acs-admin/www/auth/authority-set-sort-order.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/auth/authority-set-sort-order.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/auth/authority-set-sort-order.tcl 10 Sep 2003 14:32:47 -0000 1.1 @@ -0,0 +1,62 @@ +ad_page_contract { + Move authorities up/down to control sort order + + @author Simon Carstensen (simon@collaboraid.biz) + @creation-date 2003-09-09 + @cvs-id $Id: authority-set-sort-order.tcl,v 1.1 2003/09/10 14:32:47 peterm Exp $ +} { + authority_id:integer + direction +} + +# Get the authority's sort_order +db_1row select_sort_order { + select sort_order + from auth_authorities + where authority_id = :authority_id +} + +if { $direction == "up" } { + + db_transaction { + # Increase next authority's sort_order by one + db_dml move_next_authority_down { + update auth_authorities + set sort_order = :sort_order + where sort_order = (select max(sort_order) + from auth_authorities + where sort_order < :sort_order) + } + + # Decrease authority's sort_order by one + db_dml move_authority_up { + update auth_authorities + set sort_order = :sort_order - 1 + where authority_id = :authority_id; + } + } + +} elseif { $direction == "down"} { + + db_transaction { + # Decrease previous authority's sort_order by one + db_dml move_prev_authority_up { + update auth_authorities + set sort_order = :sort_order + where sort_order = (select min(sort_order) + from auth_authorities + where sort_order > :sort_order) + } + + # Increase authority's sort_order by one + db_dml move_authority_down { + update auth_authorities + set sort_order = :sort_order + 1 + where authority_id = :authority_id; + } + } + +} + +ad_returnredirect . +ad_script_abort Index: openacs-4/packages/acs-admin/www/auth/authority.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/auth/authority.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/auth/authority.adp 10 Sep 2003 14:32:47 -0000 1.1 @@ -0,0 +1,15 @@ + +@context;noquote@ +@page_title;noquote@ + +
+ +
+ + +

Batch Jobs

+ +
+ +
+
Index: openacs-4/packages/acs-admin/www/auth/authority.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/auth/authority.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/auth/authority.tcl 10 Sep 2003 14:32:47 -0000 1.1 @@ -0,0 +1,219 @@ +ad_page_contract { + Page for adding and editing an authority. + + @author Peter Marklund + @creation-date 2003-09-08 +} { + authority_id:integer,optional + {ad_form_mode display} +} + +if { [exists_and_not_null authority_id] } { + # Initial request in display or edit mode or a submit of the form + set page_title "One Authority" + set authority_exists_p [db_string authority_exists_p { + select count(*) + from auth_authorities + where authority_id = :authority_id + }] +} else { + # Initial request in add mode + set page_title "New Authority" + set ad_form_mode edit + set authority_exists_p 0 +} + +set context [list [list "." "Authentication"] $page_title] + +set form_widgets_full { + + authority_id:key(acs_object_id_seq) + + {short_name:text + {html {size 50}} + {label "Short name"} + {help_text "This is a string which can be used to identify this authority. Use lower-case, and no spaces."} + } + + {pretty_name:text + {html {size 50}} + {label "Pretty name"} + } + + {enabled_p:text(radio) + {label "Enabled"} + {options {{Yes t} {No f}}} + {value t} + } + + {auth_impl_id:integer(select),optional + {label "Authentication implementation"} + {options {[acs_sc::impl::get_options -exclude_names local -empty_option -contract_name auth_authentication]}} + } + + {pwd_impl_id:integer(select),optional + {label "Password implementation"} + {options {[acs_sc::impl::get_options -exclude_names local -empty_option -contract_name auth_password]}} + } + + {register_impl_id:integer(select),optional + {label "Register implementation"} + {options {[acs_sc::impl::get_options -exclude_names local -empty_option -contract_name auth_registration]}} + } + + {forgotten_pwd_url:text,optional + {html {size 50}} + {label "Forgotten password URL"} + {help_text "URL that users are sent to when they have forgotten their password. Any username in this url must be on the syntax foo={username} and {username} will be replaced with the real username"} + } + {change_pwd_url:text,optional + {html {size 50}} + {label "Change password URL"} + {help_text "URL where users can change their password. Any username in this url must be on the syntax foo={username} and {username} will be replaced with the real username"} + } + {register_url:text,optional + {html {size 50}} + {label "Register URL"} + {help_text "URL where users register for a new account."} + } + + {help_contact_text:text(textarea),optional + {html {cols 60 rows 13}} + {label "Help contact text"} + {help_text "Contact information (phone, email, etc.) to be displayed as a last resort when people are having problems with an authority."} + } + + {batch_sync_enabled_p:text(radio) + {label "Batch sync enabled"} + {options {{Yes t} {No f}}} + {value f} + {section {Batch Synchronization}} + } + + {snapshot_p:text(radio) + {label "Use snapshot synchronization?"} + {options {{Yes t} {No f}}} + {value f} + } + + {get_doc_impl_id:integer(select),optional + {label "GetDocument implementation"} + {options {[acs_sc::impl::get_options -empty_option -contract_name auth_getdoc]}} + } + + {process_doc_impl_id:integer(select),optional + {label "ProcessDocument implementation"} + {options {[acs_sc::impl::get_options -empty_option -contract_name auth_processdoc]}} + } +} + +# For the local authority we allow only limited editing +# Is this the local authority? +set local_authority_p 0 +if { $authority_exists_p && [string equal $authority_id [auth::authority::local]] } { + set local_authority_p 1 +} +if { $local_authority_p } { + # Local authority + # The form elements we use for local authority + set local_editable_elements { + authority_id + pretty_name + forgotten_pwd_url + change_pwd_url + register_url + } + + foreach element $form_widgets_full { + regexp {^[a-zA-Z_]+} [lindex $element 0] element_name + + if { [lsearch -exact $local_editable_elements $element_name] != -1 } { + lappend form_widgets $element + } + } +} else { + # Not local authority - use full form + set form_widgets $form_widgets_full +} + +ad_form -name authority_form \ + -mode $ad_form_mode \ + -form $form_widgets \ + -edit_request { + + auth::authority::get -authority_id $authority_id -array element_array + + foreach element_name [array names element_array] { + set $element_name $element_array($element_name) + } + +} -new_data { + + foreach var_name [template::form::get_elements -no_api authority_form] { + set element_array($var_name) [set $var_name] + } + + set element_array(sort_order) "" + + auth::authority::create \ + -authority_id $authority_id \ + -array element_array + +} -edit_data { + + foreach var_name [template::form::get_elements -no_api authority_form] { + if { ![string equal $var_name "authority_id"] } { + set element_array($var_name) [set $var_name] + } + } + + auth::authority::edit \ + -authority_id $authority_id \ + -array element_array +} + +# Show recent batch jobs for existing authorities +set display_batch_history_p [expr $authority_exists_p && [string equal $ad_form_mode "display"]] +if { $display_batch_history_p } { + + list::create \ + -name batch_jobs \ + -multirow batch_jobs \ + -key job_id \ + -elements { + job_id { + label "Job ID" + link_url_eval {$job_url} + } + pretty_start_time { + label "Start time" + } + pretty_end_time { + label "End time" + } + num_actions { + label "Number of actions" + } + num_problems { + label "Number of problems" + } + } + + db_multirow -extend { job_url } batch_jobs select_batch_jobs { + select job_id, + to_char(job_start_time, 'YYYY-MM-DD HH24:MI:SS') as pretty_start_time, + to_char(job_end_time, 'YYYY-MM-DD HH24:MI:SS') as pretty_end_time, + snapshot_p, + (select count(e1.entry_id) + from auth_batch_job_entries e1 + where e1.job_id = auth_batch_jobs.job_id) as num_actions, + (select count(e2.entry_id) + from auth_batch_job_entries e2 + where e2.job_id = auth_batch_jobs.job_id + and e2.success_p = 'f') as num_problems + from auth_batch_jobs + where authority_id = :authority_id + } { + set job_url [export_vars -base batch-job { job_id }] + } +} Index: openacs-4/packages/acs-admin/www/auth/batch-action.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/auth/batch-action.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/auth/batch-action.adp 10 Sep 2003 14:32:47 -0000 1.1 @@ -0,0 +1,7 @@ + +@context;noquote@ +@page_title;noquote@ + +
+ +
Index: openacs-4/packages/acs-admin/www/auth/batch-action.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/auth/batch-action.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/auth/batch-action.tcl 10 Sep 2003 14:32:47 -0000 1.1 @@ -0,0 +1,68 @@ +ad_page_contract { + Display all information about a certain batch import operation. + + @author Peter marklund (peter@collaboraid.biz) + @creation-date 2003-09-10 +} { + entry_id:integer +} + +auth::sync::entry::get -entry_id $entry_id -array batch_action + +set page_title "Batch Action \"$batch_action(entry_id)\"" + +set context [list [list "." "Authentication"] \ + [list [export_vars -base authority { {authority_id $batch_action(authority_id)} }] \ + "Authority\"$batch_action(authority_pretty_name)\""] \ + [list [export_vars -base batch-job {{job_id $batch_action(job_id)}}] "One Job"] \ + $page_title] + +ad_form -name batch_action_form \ + -mode display \ + -display_buttons {} \ + -form { + {entry_id:text(inform) + {label "Entry ID"} + } + {entry_time:text(inform) + {label "Timestamp"} + } + {operation:text(inform) + {label "Action type"} + } + {username:text(inform) + {label "Username"} + } + {user_id:text(inform) + {label "User"} + } + {success_p:text(inform) + {label "Success"} + } + {message:text(inform) + {label "Message"} + } + {element_messages:text(inform) + {label "Element messages"} + } + } -on_request { + foreach element_name [array names batch_action] { + # Prettify certain elements + if { [regexp {_p$} $element_name] } { + set $element_name [ad_decode $batch_action($element_name) "t" "Yes" "No"] + } elseif { [string equal $element_name "user_id"] && ![empty_string_p $batch_action($element_name)] } { + if { [catch {set $element_name [acs_community_member_link -user_id $batch_action($element_name)]}] } { + set $element_name $batch_action($element_name) + } + } elseif { [string equal $element_name "element_messages"] && ![empty_string_p $batch_action($element_name)] } { + array set messages_array $batch_action($element_name) + append $element_name "" + } else { + set $element_name $batch_action($element_name) + } + } + } Index: openacs-4/packages/acs-admin/www/auth/batch-document-download.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/auth/batch-document-download.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/auth/batch-document-download.tcl 10 Sep 2003 14:32:47 -0000 1.1 @@ -0,0 +1,15 @@ +ad_page_contract { + Download a whole batch xml document. + + @author Peter Marklund +} { + job_id:integer +} + +set document [db_string select_document { + select document + from auth_batch_jobs + where job_id = :job_id +}] + +ns_return 200 text/plain $document Index: openacs-4/packages/acs-admin/www/auth/batch-job.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/auth/batch-job.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/auth/batch-job.adp 10 Sep 2003 14:32:47 -0000 1.1 @@ -0,0 +1,13 @@ + +@context;noquote@ +@page_title;noquote@ + +
+

+ +

+ +

+ +

+
Index: openacs-4/packages/acs-admin/www/auth/batch-job.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/auth/batch-job.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/auth/batch-job.tcl 10 Sep 2003 14:32:47 -0000 1.1 @@ -0,0 +1,154 @@ +ad_page_contract { + Page displaying info about a single batch job. + + @author Peter Marklund + @creation-date 2003-09-09 +} { + job_id + page:optional +} + +auth::sync::job::get -job_id $job_id -array batch_job + +set page_title "Batch Job \"$batch_job(job_id)\"" +set context [list [list "." "Authentication"] [list [export_vars -base authority { {authority_id $batch_job(authority_id)} }] "Authority \"$batch_job(authority_pretty_name)\""] $page_title] + +ad_form -name batch_job_form \ + -mode display \ + -display_buttons {} \ + -form { + {job_id:text(inform) + {label "Job ID"} + } + {authority_pretty_name:text(inform) + {label "Authority name"} + } + {job_start_time:text(inform) + {label "Start time"} + } + {job_end_time:text(inform) + {label "End time"} + } + {interactive_p:text(inform) + {label "Interactive"} + } + {snapshot_p:text(inform) + {label "Snapshot"} + } + {message:text(inform) + {label "Message"} + } + {creation_user:text(inform) + {label "Creation user"} + } + {doc_start_time:text(inform) + {label "Document start time"} + } + {doc_end_time:text(inform) + {label "Document end time"} + } + {doc_status:text(inform) + {label "Document status"} + } + {doc_message:text(inform) + {label "Document message"} + } + {document_download:text(inform) + {label "Document"} + } + {run_time_seconds:text(inform) + {label "Runtime seconds"} + } + {num_actions:text(inform) + {label "Number of actions"} + } + {num_problems:text(inform) + {label "Number of problems"} + } + } -on_request { + foreach element_name [array names batch_job] { + # Make certain columns pretty for display + if { [regexp {_p$} $element_name] } { + set $element_name [ad_decode $batch_job($element_name) "t" "Yes" "No"] + } elseif { [string equal $element_name "creation_user"] && ![empty_string_p $batch_job($element_name)] } { + set $element_name [acs_community_member_link -user_id $batch_job($element_name)] + } else { + set $element_name $batch_job($element_name) + } + } + + set document_download "download" + } + +set pagination_sql { + select entry_id + from auth_batch_job_entries + where job_id = :job_id +} + +list::create \ + -name batch_actions \ + -multirow batch_actions \ + -key entry_id \ + -page_query $pagination_sql \ + -page_size 100 \ + -elements { + entry_id { + label "Action ID" + link_url_eval {$entry_url} + } + entry_time { + label "Timestamp" + } + operation { + label "Type of operation" + } + username { + label "Username" + } + success_p { + label "Success" + display_template { + + Yes + + + No + + } + } + short_message { + label "Message" + } + } -filters { + job_id {} + } + +db_multirow -extend { entry_url short_message } batch_actions select_batch_actions { + select entry_id, + to_char(entry_time, 'YYYY-MM-DD HH24:MI:SS') as entry_time, + operation, + username, + user_id, + success_p, + message, + element_messages + from auth_batch_job_entries + where job_id = :job_id +} { + set entry_url [export_vars -base batch-action { entry_id }] + + # Use message and element_messages to display one short message in the table + if { ![empty_string_p $message] } { + set short_message $message + } elseif { [llength $element_messages] == 1} { + # Only one element message - use it + set short_message [lindex $element_messages 1] + } elseif { [llength $element_messages] > 1 } { + # Several element messages + set short_message "Problems with elements" + } else { + set short_message "" + } + set short_message [string_truncate -len 25 $short_message] +} Index: openacs-4/packages/acs-admin/www/auth/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/auth/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/auth/index.adp 10 Sep 2003 14:32:47 -0000 1.1 @@ -0,0 +1,17 @@ + +@context;noquote@ +@page_title;noquote@ + +
+ + +

+ » New authority +

+ +

+ [*] The drop down menu of authorities on the login page will be sorted accordingly. +

+ +
+ Index: openacs-4/packages/acs-admin/www/auth/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/auth/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/auth/index.tcl 10 Sep 2003 14:32:47 -0000 1.1 @@ -0,0 +1,103 @@ +ad_page_contract { + Index page for External Authentication listing + available authorities. + + @author Peter Marklund + @creation-date 2003-09-08 +} + +set page_title "Authentication" +set context [list $page_title] + +list::create \ + -name "authorities" \ + -multirow "authorities" \ + -key authority_id \ + -elements { + edit { + label "" + display_template { + Edit + } + link_url_eval {[export_vars -base authority { authority_id {ad_form_mode edit}}]} + link_html {title "Edit this authority"} + sub_class narrow + } + pretty_name { + label "Name" + link_url_eval {[export_vars -base authority { authority_id }]} + } + enabled { + label "Enabled" + display_template { + + + + + + + + + + Yes + + } + } + move { + label "Order*" + display_template { + + + + + + + } + } + auth_impl { + label "Authentication" + } + pwd_impl { + label "Password" + } + reg_impl { + label "Registration" + } + delete { + label "" + display_template { + + Delete + + } + sub_class narrow + } + } + +db_multirow -extend { + enabled_p_url + sort_order_url_up + sort_order_url_down + delete_url +} authorities authorities_select { + select authority_id, + short_name, + pretty_name, + enabled_p, + sort_order, + (select max(sort_order) from auth_authorities) as lowest_sort_order, + (select min(sort_order) from auth_authorities) as highest_sort_order, + (select impl_pretty_name from acs_sc_impls where impl_id = auth_impl_id) as auth_impl, + (select impl_pretty_name from acs_sc_impls where impl_id = pwd_impl_id) as pwd_impl, + (select impl_pretty_name from acs_sc_impls where impl_id = register_impl_id) as reg_impl + from auth_authorities + order by sort_order +} { + set toggle_enabled_p [ad_decode $enabled_p "t" "f" "t"] + set enabled_p_url "authority-set-enabled-p?[export_vars { authority_id {enabled_p $toggle_enabled_p} }]" + set delete_url [export_vars -base authority-delete { authority_id }] + set sort_order_url_up "authority-set-sort-order?[export_vars { authority_id {direction up} }]" + set sort_order_url_down "authority-set-sort-order?[export_vars { authority_id {direction down} }]" +}