# A very special library used to support the ACS installer. Sourced only # when there's no database driver available, or [ad_verify_install] # returns false. # # If no database driver is available, the acs-kernel libraries may not have # been loaded (which is fine, since index.tcl will display a message # instructing the user to install the Oracle driver and restart the server # before proceeding any further; in this case we won't use any procedures # depending on the core libraries). Otherwise, all -procs.tcl files in # acs-kernel (but not any -init.tcl files) will have been run. # Return a header for an installation page, suitable for ns_writing. # This procedure engages the installer mutex, as every installer page is a critical section. ad_proc -private install_input_widget { {-type ""} {-size 40} {-extra_attributes ""} {-value ""} param_name } { Return an HTML input widget for a parameter with an indication of whether the param is mandatory. } { set type_attribute [ad_decode $type "" "" "type=\"$type\""] if { $value ne "" } { append extra_attributes " value=\"[ns_quotehtml $value]\"" } set input_widget "" if { [install_param_mandatory_p $param_name] } { append input_widget " \[*\]" } return $input_widget } ad_proc -private install_param_mandatory_p { param_name } { Return 1 if the given parameter with given name is mandatory for OpenACS install and 0 otherwise. @author Peter Marklund } { array set mandatory_params_array [install_mandatory_params] set mandatory_names [array names mandatory_params_array] return [expr {$param_name in $mandatory_names}] } ad_proc -private install_mandatory_params {} { Return information about parameters that are mandatory for OpenACS installation. @return An array list with variable names as values and pretty names as keys. } { return { email "Email" first_names "First names" last_name "Last name" password "Password" password_confirmation "Password confirmation" system_url "System URL" system_name "System name" publisher_name "Publisher name" } } ad_proc -private install_optional_params {} { Return information about parameters that are optional for OpenACS installation. @return An array list with variable names as values and default values as keys. } { return { username "" system_owner "" admin_owner "" host_administrator "" outgoing_sender "" new_registrations "" } } ad_proc -private install_page_contract { mandatory_params optional_params } { Instead of using ad_page_contract that relies on certain acs-subsite libraries that may not be available at all times during installation we use this more primitive proc instead. @param mandatory_params An array list where keys are param names and values are pretty names. @param optional_params An array list with param names as keys and default values as keys. @author Peter Marklund } { array set mandatory_params_array $mandatory_params array set optional_params_array $optional_params set form [ns_getform] set missing_params [list] if { $form eq "" } { # Form is empty - all mandatory params are missing foreach param_name [array names mandatory_params_array] { lappend missing_params $mandatory_params_array($param_name) } } else { # Form is non-empty # Loop over all params set all_param_names [concat [array names mandatory_params_array] \ [array names optional_params_array]] foreach param_name $all_param_names { set param_value [ns_set iget $form $param_name] set mandatory_p [expr {$param_name in $mandatory_params}] if { $param_value ne "" } { # Param in form - set value in callers scope uplevel [list set $param_name $param_value] } else { # Param not in form if { $mandatory_p } { # Mandatory param - complain lappend missing_params $mandatory_params_array($param_name) } else { # Optional param - set default uplevel [list set $param_name $optional_params_array($param_name)] } } } } # If there are missing mandatory params - return a complaint # page and exit if { [llength $missing_params] > 0 } { ns_write "[install_header 200 {Missing parameters}] The following mandatory parameters are missing:
Please back up your browser and provide those parameters. Thank you.
[install_footer] " return -code return } } proc install_header { status title } { # Prefix the page title set page_title_prefix "OpenACS Installation" if { $title ne "" } { set page_title "${page_title_prefix}: $title" } else { set page_title $page_title_prefix } return "HTTP/1.0 $status OK MIME-Version: 1.0 Content-Type: text/html$script
, doesn't exist. Please check
your URL and try again.
"
}
array set errors {}
# Engage a mutex for double-click protection.
ns_mutex lock [nsv_get acs_installer mutex]
if { [catch {
# Source the page and then unlock the mutex.
apm_source $path errors
ns_mutex unlock [nsv_get acs_installer mutex]
} error] } {
# In case of an error, don't forget to unlock the mutex.
ns_mutex unlock [nsv_get acs_installer mutex]
install_return 500 "Error" "The following error occurred in an installation script:\n\
\n" } if {[array size errors] > 0} { install_return 500 "Error" [install_load_errors_formatted errors] } return "filter_return" } proc install_admin_widget {} { return "[ns_quotehtml $::errorInfo]