Commit 021887b3 authored by Frank Bergmann's avatar Frank Bergmann

Initial Import

parents
Pipeline #25 failed with stages
<?xml version="1.0"?>
<!-- Generated by the OpenACS Package Manager -->
<package key="acs-admin" url="http://openacs.org/repository/apm/packages/acs-admin/" type="apm_service">
<package-name>Site-Wide Administration</package-name>
<pretty-plural>Site-Wide Administration Services</pretty-plural>
<initial-install-p>t</initial-install-p>
<singleton-p>t</singleton-p>
<version name="5.1.5" url="http://openacs.org/repository/download/apm/acs-admin-5.1.5.apm">
<owner url="mailto:dhogaza@pacifier.com">Don Baccus</owner>
<summary>An interface for Site-wide administration of an OpenACS Installation.</summary>
<maturity>3</maturity>
<release-date>2004-02-28</release-date>
<vendor url="http://openacs.org">OpenACS</vendor>
<description format="text/html">Provides a UI for administering site-wide services
(including package installation, cache, authentication, and user accounts) for an OpenACS system.
</description>
<provides url="acs-admin" version="5.1.4"/>
<requires url="acs-kernel" version="5.0.0"/>
<callbacks>
</callbacks>
<parameters>
<!-- No version parameters -->
</parameters>
</version>
</package>
ad_page_contract {
} {
} -validate {
dotlrn_cannot_become_wide_admin {
if { [acs_user::site_wide_admin_p -user_id $user_id] && ![acs_user::site_wide_admin_p] } {
ad_complain "[_ acs-admin.lt_You_dont_have_permiss]"
}
}
}
set return_url [ad_pvt_home]
# Get the password and user ID
if ![db_0or1row password "select password from users where user_id=$user_id"] {
ad_return_error "Couldn't find user $user_id" "Couldn't find user $user_id."
return
}
# just set a session cookie
set expire_state "s"
# note here that we stuff the cookie with the password from Oracle,
# NOT what the user just typed (this is because we want log in to be
# case-sensitive but subsequent comparisons are made on ns_crypt'ed
# values, where string toupper doesn't make sense)
ad_user_login $user_id
ad_returnredirect $return_url
<?xml version="1.0"?>
<queryset>
<fullquery name="password">
<querytext>
select password from users where user_id=$user_id
</querytext>
</fullquery>
</queryset>
<ul>
<li><a href="@acs_admin_url@apm">Package Manager</a>
<li><a href="@acs_admin_url@cache">Cache Info</a>
<if @acs_automated_testing_url@ not nil>
<li><a href="@acs_automated_testing_url@admin">Automated Testing</a>
</if>
<if @acs_service_contract_url@ not nil>
<li><a href="@acs_service_contract_url@">Service Contracts</a>
</if>
<li><a href="@acs_api_browser_url@">API Browser</a>
<li><a href="@acs_core_docs_url@">Documentation</a>
<if @acs_developer_support_url@ not nil>
<li><a href="@acs_developer_support_url@">Developer Support</a>
</if>
</ul>
<p>
set acs_admin_url [site_node::get_package_url -package_key acs-admin]
set acs_automated_testing_url [site_node::get_package_url -package_key acs-automated-testing]
set acs_service_contract_url [site_node::get_package_url -package_key "acs-service-contract"]
set acs_api_browser_url [site_node::get_package_url -package_key "acs-api-browser"]
set acs_core_docs_url [site_node::get_package_url -package_key "acs-core-docs"]
set acs_developer_support_url [site_node::get_package_url -package_key "acs-developer-support"]
<if @message@ not nil>
<div class="general-message">@message@</div>
</if>
<formtemplate id="update"></formtemplate>
# Redirect to HTTPS if so configured
if { [security::RestrictLoginToSSLP] } {
security::require_secure_conn
}
set level [ad_decode [security::RestrictLoginToSSLP] 1 "secure" "ok"]
# If the user is changing passwords for another user, they need to be account ok
set account_status [ad_decode $user_id [ad_conn untrusted_user_id] "closed" "ok"]
auth::require_login \
-level $level \
-account_status $account_status
if { ![auth::password::can_change_p -user_id $user_id] } {
ad_return_error "Not supported" "Changing password is not supported."
}
set page_title [_ acs-subsite.Update_Password]
set context [list [list [ad_pvt_home] [ad_pvt_home_name]] $page_title]
set system_name [ad_system_name]
set site_link [ad_site_home_link]
acs_user::get -user_id $user_id -array user
ad_form -name update -edit_buttons [list [list [_ acs-kernel.common_update] "ok"]] -form {
{user_id:integer(hidden)}
{return_url:text(hidden),optional}
{message:text(hidden),optional}
}
set focus "update.password_old"
ad_form -extend -name update -form {
{password_1:text(password)
{label {[_ acs-subsite.New_Password]}}
{html {size 20}}
}
{password_2:text(password)
{label {[_ acs-subsite.Confirm]}}
{html {size 20}}
}
} -on_request {
} -validate {
{password_1
{ [string equal $password_1 $password_2] }
{ Passwords don't match }
}
} -on_submit {
array set result [auth::password::change \
-user_id $user_id \
-old_password "" \
-new_password $password_1]
switch $result(password_status) {
ok {
# Continue
}
old_password_bad {
if { ![exists_and_not_null old_password] } {
form set_error update password_old $result(password_message)
} else {
# This hack causes the form to reload as if submitted, but with the old password showing
ad_returnredirect [export_vars -base [ad_conn url] -entire_form -exclude { old_password } -override { { password_old $old_password } }]
ad_script_abort
}
ad_return_error $result(password_message) ""
break
}
default {
form set_error update password_1 $result(password_message)
break
}
}
# If the account was closed, it might be open now
if { [string equal [ad_conn account_status] "closed"] } {
auth::verify_account_status
}
} -after_submit {
if { [empty_string_p $return_url] } {
set return_url [ad_pvt_home]
set pvt_home_name [ad_pvt_home_name]
set continue_label [_ acs-subsite.Continue_to_your_account]
} else {
set continue_label [_ acs-subsite.Continue]
}
set message [_ acs-subsite.confirmation_password_changed]
# set continue_url $return_url
# ad_return_template /packages/acs-subsite/www/register/display-message
ad_returnredirect $return_url
}
<?xml version="1.0"?>
<queryset>
<rdbms><type>oracle</type><version>8.1.6</version></rdbms>
<fullquery name="services_select">
<querytext>
select package_id,
ap.package_key,
acs_object.name(package_id) as instance_name,
apm_package_type.num_parameters(ap.package_key) as parameter_count
from apm_packages ap,
apm_package_types
where ap.package_key = apm_package_types.package_key
and package_type = 'apm_service'
and (ap.package_key != 'acs-subsite' or (select parent_id from site_nodes where object_id = package_id) is null)
order by instance_name
</querytext>
</fullquery>
</queryset>
<?xml version="1.0"?>
<queryset>
<rdbms><type>postgresql</type><version>7.1</version></rdbms>
<fullquery name="services_select">
<querytext>
select package_id,
ap.package_key,
acs_object__name(package_id) as instance_name,
apm_package_type__num_parameters(ap.package_key) as parameter_count
from apm_packages ap,
apm_package_types
where ap.package_key = apm_package_types.package_key
and package_type = 'apm_service'
and (ap.package_key != 'acs-subsite' or (select parent_id from site_nodes where object_id = package_id) is null)
order by instance_name
</querytext>
</fullquery>
</queryset>
<p><listtemplate name="packages"></listtemplate></p>
#
# Service parameters list
#
if { ![acs_user::site_wide_admin_p] } {
ad_return_forbidden \
"Permission Denied" \
"<blockquote>You don't have permission to view this page.</blockquote>"
ad_script_abort
}
set user_id [ad_conn user_id]
set swadmin_p 0
db_multirow -extend { url admin_url param_url } packages services_select {} {
if { [file exists "[acs_package_root_dir $package_key]/www/"] } {
catch {
set url [apm_package_url_from_key $package_key]
if { ![empty_string_p $url] && [file exists "[acs_package_root_dir $package_key]/www/admin/"] } {
set admin_url "${url}admin/"
}
if { [file exists "[acs_package_root_dir $package_key]/www/sitewide-admin/"] } {
set sitewide_admin_url "/acs-admin/package/$package_key/"
set swadmin_p 1
}
}
}
if { $parameter_count > 0 } {
set param_url [export_vars -base "/shared/parameters" { package_id { return_url {[ad_return_url]} } }]
}
set instance_name [lang::util::localize $instance_name]
if { [empty_string_p $url] && [empty_string_p $admin_url] && [empty_string_p $param_url] } {
continue
}
}
template::list::create \
-name packages \
-multirow packages \
-elements {
instance_name {
label {Service}
}
www {
label "Pages"
link_url_col url
link_html { title "Visit service pages" }
display_template {<if @packages.url@ not nil>Pages</if>}
}
admin {
label "Administration"
link_url_col admin_url
link_html { title "Service administration" }
display_template {<if @packages.admin_url@ not nil>Administration</if>}
}
sitewide_admin {
label "Site-Wide Admin"
link_url_col sitewide_admin_url
link_html { title "Service administration" }
display_template {<if @packages.sitewide_admin_url@ not nil>Administration</if>}
hide_p {[ad_decode $swadmin_p 1 0 1]}
}
parameters {
label "Parameters"
link_url_col param_url
link_html { title "Service parameters" }
display_template {<if @packages.param_url@ not nil>Parameters</if>}
}
}
<ul>
<li><a href="@acs_admin_url@users">Users</a>
<li><a href="@acs_admin_url@install">Install software</a>
<if @acs_lang_admin_url@ not nil>
<li><a href="@acs_lang_admin_url@">Internationalization/Localization</a>
</if>
<li><a href="@acs_admin_url@auth">Authentication</a>
<li><a href="@acs_core_docs_url@">Documentation</a>
<li><a href="@acs_admin_url@monitor">Active connections</a>
</ul>
<p>
set acs_admin_url [apm_package_url_from_key "acs-admin"]
set acs_lang_admin_url "[apm_package_url_from_key "acs-lang"]admin/"
set acs_core_docs_url [apm_package_url_from_key "acs-core-docs"]
ad_library {
Automated functions for acs-admin
@cvs-id $Id$
}
# Only run this if this is openacs.org
#ad_schedule_proc -thread t -schedule_proc ns_schedule_daily [list 0 0] apm_build_repository
<?xml version="1.0"?>
<queryset>
<rdbms><type>oracle</type><version>8.1.6</version></rdbms>
<fullquery name="apm_higher_version_installed_p.apm_higher_version_installed_p">
<querytext>
select apm_package_version.version_name_greater(:version_name, highest.version_name)
from (select version_name
from apm_package_versions
where version_id = apm_package.highest_version(:package_key)
) highest
</querytext>
</fullquery>
</queryset>
<?xml version="1.0"?>
<queryset>
<rdbms><type>postgresql</type><version>7.1</version></rdbms>
<!-- Note that the IN here generates a better plan than = on 7.3 for some mysterious reason -->
<fullquery name="apm_higher_version_installed_p.apm_higher_version_installed_p">
<querytext>
select apm_package_version__version_name_greater(:version_name, highest.version_name)
from (select version_name
from apm_package_versions
where version_id IN (select apm_package__highest_version(:package_key))
) highest
</querytext>
</fullquery>
</queryset>
This diff is collapsed.
<?xml version="1.0"?>
<queryset>
<fullquery name="apm_parameter_section_slider.apm_parameter_sections">
<querytext>
select distinct(section_name)
from apm_parameters
where package_key = :package_key
</querytext>
</fullquery>
</queryset>
ad_library {
Automated tests.
@author Joel Aufrecht
@creation-date 2 Nov 2003
@cvs-id $Id$
}
aa_register_case -cats smoke acs_admin_trivial_smoke_test {
Minimal smoke test for acs-admin package.
} {
aa_run_with_teardown \
-rollback \
-test_code {
set header_result [apm_header]
aa_true "apm_header returns a non-null string?" [exists_and_not_null header_result]
}
}
aa_register_case -cats {api smoke} apm_higher_version_installed_p {
Test apm_higher_version_installed_p proc.
} {
aa_run_with_teardown \
-rollback \
-test_code {
set is_lower [apm_higher_version_installed_p acs-admin "1"]
aa_equals "is the version of acs-admin higher than 0.1d?" $is_lower -1
set is_higher [apm_higher_version_installed_p acs-admin "1000"]
aa_equals "is the version of acs-admin lower than 1000.1d?" $is_higher 1
}
}
This diff is collapsed.
ad_page_contract {
Installs/enables packages, according to the information prompted for
in <code>packages-select</code>.
} {
{ install:multiple "" }
{ enable:multiple "" }
{ return_text "
<form action=/>
<input type=hidden name=done_p value=1>
<center>
<input type=submit value=\"Finish ->\">
</center>
[install_footer]
"}
}
ns_write "[install_header 200 "Installing Packages"]
<ul>
"
foreach version_id $install {
db_1row version_select {
select pretty_name, version_name, package_key
from apm_package_version_info i
where version_id = :version_id
}
ns_write "<p><li>Installing $pretty_name $version_name...\n"
set ul_p 0
foreach file [apm_version_file_list -type data_model_create $version_id] {
if { [string match *-drop.sql [file tail $file]] } {
continue
}
if { !$ul_p } {
ns_write "<ul>\n"
set ul_p 1
}
ns_write "<li>Loading data model file $file...
<blockquote><pre>
"
cd "[acs_package_root_dir $package_key]"
db_source_sql_file -ns_write "[acs_root_dir]/packages/$package_key/$file"
ns_write "</pre></blockquote>\n"
}
foreach file [apm_version_file_list -type java_code $version_id] {
if { !$ul_p } {
ns_write "<ul>\n"
set ul_p 1
}
ns_write "<li>Loading java code file $file...
<blockquote><pre>
"
ns_write [db_source_sqlj_file "[acs_root_dir]/packages/$package_key/$file"]
ns_write "</pre></blockquote>\n"
}
if { [lsearch $enable $version_id] >= 0 } {
if { !$ul_p } {
ns_write "<ul>\n"
set ul_p 1
}
ns_write "<li>Enabling package.\n"
apm_enable_version $version_id
}
if { $ul_p } {
ns_write "</ul>\n"
}
}
#### TEMPORARY ######
# Because dependencies don't work yet, source the acs-core-ui file here.
ns_write "<li>Loading data model for ACS-Core-UI...
<blockquote><pre>
"
cd "[acs_package_root_dir acs-core-ui]"
db_source_sql_file -ns_write "[acs_root_dir]/packages/acs-core-ui/sql/acs-core-ui-create.sql"
ns_write "</pre></blockquote>\n"
# Redirect to index.tcl?done_p=1. We do this so the user can just hit <i>Reload</i>
# on their browser to get to the real site, once they restart the server.
ns_write "</ul>
Done installing packages.
"
\ No newline at end of file
<?xml version="1.0"?>
<queryset>
<fullquery name="version_select">
<querytext>
select pretty_name, version_name, package_key
from apm_package_version_info i
where version_id = :version_id
</querytext>
</fullquery>
</queryset>
ad_page_contract {
Tells the user what he needs to do to ensure that all packages
he owns are checked into CVS.
@author Jon Salz [jsalz@arsdigita.com]
@cvs-id $Id$
} {
}
db_1row email_by_user_id {}
doc_body_append "[apm_header "Your Non-Up-To-Date Files"]"
set last_version -1
set no_changes [list]
set all_files_to_add [list]
set all_files_to_commit [list]
db_foreach all_packages_owned_by_email "
select v.package_key, v.version_id, v.package_name, v.version_name
from apm_package_version_info v, apm_package_owners o
where o.owner_url = :email
and v.version_id = o.version_id
and v.installed_p = 't'
order by upper(package_name)" {
set files_to_add [list]
set files_to_commit [list]
# Determine which files in this package are not considered up-to-date by CVS.
set counter 0
db_foreach apm_file_path {
select path from apm_package_files where version_id = :version_id
}{
vc_parse_cvs_status [apm_fetch_cached_vc_status "packages/$package_key/$path"]
global vc_file_props
if { [regexp {[a-zA-Z]} $vc_file_props(status)] } {
set status "$vc_file_props(status)"
if { ![string compare $status "Up-to-date"] } {
# It's up to date; don't print anything out.
continue
}
} else {
# CVS hasn't ever heard of it! It probably needs to be added to the
# repository.
set status "Unknown"
lappend files_to_add "packages/$package_key/$path"
}
if { $counter == 0 } {
# This is the first item we're printing out; display the package name too.
doc_body_append "<h3>$package_name $version_name (<code>packages/$package_key</code>)</h3><ul>\n"
}
lappend files_to_commit "packages/$package_key/$path"
doc_body_append "<li>$path: <b>$status</b>"
# Try writing the name of the user who owns the file. Don't sweat it if we can't.
catch { doc_body_append " (owned by [file attributes "[acs_root_dir]/$path" -owner])" }
doc_body_flush
incr counter
}
if { $counter == 0 } {
# No changes at all to this package.
lappend no_changes "$package_name $version_name"
} else {
# Tell the user how to bring everything up to date.
doc_body_append "</ul>To commit these changes:<blockquote><pre>cd [acs_root_dir]\n"
if { [llength $files_to_add] > 0 } {
doc_body_append [apm_shell_wrap [concat [list cvs add] $files_to_add]]
}
doc_body_append [apm_shell_wrap [concat [list cvs commit] $files_to_commit]]
doc_body_append "</pre></blockquote>"
}
doc_body_flush
set all_files_to_add [concat $all_files_to_add $files_to_add]
set all_files_to_commit [concat $all_files_to_commit $files_to_commit]
}
if { [llength $no_changes] > 0 } {
doc_body_append "<h3>No changes to:</h3><ul><li>[join $no_changes "\n<li>"]</ul>\n"
}
if { [llength $all_files_to_commit] > 0 } {
doc_body_append "<h3>To commit all changes:</h3><blockquote><pre>cd [acs_root_dir]\n"
if { [llength $all_files_to_add] > 0 } {
doc_body_append [apm_shell_wrap [concat [list cvs add] $all_files_to_add]]
}
doc_body_append [apm_shell_wrap [concat [list cvs commit] $all_files_to_commit]]
doc_body_append "</pre></blockquote>"
}
doc_body_append "<a href=\"./\">Return to the Package Manager</a>
[ad_footer]"
\ No newline at end of file
<?xml version="1.0"?>
<queryset>
<fullquery name="email_by_user_id">
<querytext>
select email from parties where party_id = [ad_get_user_id]
</querytext>
</fullquery>
<fullquery name="all_packages_owned_by_email">
<querytext>
select v.package_key, v.version_id, v.package_name, v.version_name
from apm_package_version_info v, apm_package_owners o
where o.owner_url = :email
and v.version_id = o.version_id
and v.installed_p = 't'
order by upper(package_name)
</querytext>
</fullquery>
<fullquery name="apm_file_path">
<querytext>
select path from apm_package_files where version_id = :version_id
</querytext>
</fullquery>
</queryset>
ad_page_contract {
Stops watching a particular file or all files if
no file is specified.
@param watch_file The file to stop watching.
@author Jon Salz [jsalz@arsdigita.com]
@creation-date 17 April 2000
@cvs-id $Id$
} {
{watch_file ""}
{return_url ""}
}
apm_file_watch_cancel $watch_file
ad_returnredirect $return_url
ad_page_contract {
Watches a number of files for reload. Note that the
paths given to this page should be relative to package root,
not server root.
@author Peter Marklund
@creation-date 17 April 2000
@cvs-id $Id$
} {
version_id:integer
paths:multiple
{return_url ""}
}
set package_key [apm_package_key_from_version_id $version_id]
foreach path $paths {
apm_file_watch "packages/$package_key/$path"
}
ad_returnredirect $return_url
<?xml version="1.0"?>
<queryset>
<rdbms><type>oracle</type><version>8.1.6</version></rdbms>
<fullquery name="email_by_user_id">
<querytext>
select email from parties where party_id = :user_id
</querytext>
</fullquery>
<fullquery name="apm_table">
<querytext>
select v.version_id, v.package_key, t.pretty_name, v.version_name, v.enabled_p,
v.installed_p, v.distribution_uri,
(select count(*) from apm_package_versions v2
where v2.package_key = v.package_key
and v2.installed_p = 't'
and apm_package_version.sortable_version_name(v2.version_name) > apm_package_version.sortable_version_name(v.version_name)) as superseded_p,
case
when content_item.get_latest_revision(item_id) is null
then 0
else 1
end as tarball_p
from apm_package_versions v, apm_package_types t
where t.package_key = v.package_key
[ad_dimensional_sql $dimensional_list where and]
[ad_order_by_from_sort_spec $orderby $table_def]
</querytext>
</fullquery>
<partialquery name="latest">
<querytext>
(installed_p = 't' or enabled_p = 't' or not exists (
select 1 from apm_package_versions v2
where v2.package_key = v.package_key
and (v2.installed_p = 't' or v2.enabled_p = 't')
and apm_package_version.sortable_version_name(v2.version_name) > apm_package_version.sortable_version_name(v.version_name)))
</querytext>
</partialquery>
</queryset>
<?xml version="1.0"?>
<queryset>
<rdbms><type>postgresql</type><version>7.1</version></rdbms>
<fullquery name="apm_table">
<querytext>
select v.version_id, v.package_key, t.pretty_name, v.version_name, v.enabled_p,
v.installed_p, v.distribution_uri,
(select count(*) from apm_package_versions v2
where v2.package_key = v.package_key
and v2.installed_p
and apm_package_version__sortable_version_name(v2.version_name) >
apm_package_version__sortable_version_name(v.version_name)) as superseded_p,
case
when content_item__get_latest_revision(item_id) is null
then 0
else 1
end as tarball_p
from apm_package_versions v, apm_package_types t
where t.package_key = v.package_key
[ad_dimensional_sql $dimensional_list where and]
[ad_order_by_from_sort_spec $orderby $table_def]
</querytext>
</fullquery>
<partialquery name="latest">
<querytext>
(installed_p = 't' or enabled_p = 't' or not exists (
select 1 from apm_package_versions v2
where v2.package_key = v.package_key
and (v2.installed_p = 't' or v2.enabled_p = 't')
and apm_package_version__sortable_version_name(v2.version_name) >
apm_package_version__sortable_version_name(v.version_name)))
</querytext>
</partialquery>
</queryset>
<master>
<property name="title">@page_title;noquote@</property>
<property name="context">@context;noquote@</property>
@body;noquote@
ad_page_contract {
Index page for the package manager.
@param orderyby The parameter to order everything in the page by.
@param owned_by Display packages owned by whom.
@author Jon Salz (jsalz@arsdigita.com)
@cvs-id $Id$
} {
{ orderby "package_key" }
{ owned_by "everyone" }
{ supertype "all" }
{ reload_links_p 0 }
}
set page_title "Package Manager"
set context [list [list "../developer" "Developer's Administration"] $page_title]
set user_id [ad_get_user_id]
# Determine the user's email address. If its not registered, put in a default.
set my_email [db_string email_by_user_id {
select email from parties where party_id = :user_id
} -default "me"]
set dimensional_list {
{
supertype "Package Type:" all {
{ apm_application "Applications" { where "[db_map apm_application]" } }
{ apm_service "Services" { where "t.package_type = 'apm_service'"} }
{ all "All" {} }
}
}
{
owned_by "Owned by:" everyone {
{ me "Me" {where "[db_map everyone]"} }
{ everyone "Everyone" {where "1 = 1"} }
}
}
{
status "Status:" latest {
{
latest "Latest" {where "[db_map latest]" }
}
{ all "All" {where "1 = 1"} }
}
}
}
# "latest" means that a version is installed or enabled, or there is no more latest version
# which is installed or enabled. Basically, any relevant package on the system.
set missing_text "<strong>No packages match criteria.</strong>"
append body "<center><table><tr><td>[ad_dimensional $dimensional_list]</td></tr></table></center>"
set use_watches_p [expr ! [ad_parameter -package_id [ad_acs_kernel_id] PerformanceModeP request-processor 1]]
set table_def {
{ package_key "Key" "" "<td><a href=\"[export_vars -base version-view { version_id }]\">$package_key</a></td>" }
{ pretty_name "Name" "" "<td><a href=\"[export_vars -base version-view { version_id }]\">$pretty_name</a></td>" }
{ version_name "Ver." "" "" }
{
status "Status" "" {<td align=center>&nbsp;&nbsp;[eval {
if { $installed_p == "t" } {
if { $enabled_p == "t" } {
set status "Enabled"
} else {
set status "Disabled"
}
} elseif { $superseded_p } {
set status "Superseded"
} else {
set status "Uninstalled"
}
format $status
}]&nbsp;&nbsp;</td>}
}
{ maintained "Maintained" "" {<td align=center>[ad_decode $distribution_uri "" "Locally" "Externally"]</td>} }
{
action "" "" {<td>&nbsp;&nbsp;[eval {
set file_link_list [list]
lappend file_link_list "<a href=\"version-files?version_id=$version_id\">view files</a>"
if { $installed_p == "t" && $enabled_p == "t" } {
if { ! [ad_parameter -package_id [ad_acs_kernel_id] PerformanceModeP request-processor 1] } {
lappend file_link_list "<a href=\"package-watch?package_key=$package_key\">watch all files</a>"
}
set reload_links_p [ad_decode [ns_set iget [rp_getform] reload_links_p] \
"" 0 [ns_set iget [rp_getform] reload_links_p]]
if { !$reload_links_p || [string equal [apm_version_load_status $version_id] "needs_reload"]} {
lappend file_link_list "<a href=\"version-reload?version_id=$version_id\">reload changed</a>"
}
}
set format_string [join $file_link_list " | "]
format $format_string
}]&nbsp;&nbsp;</td>}
}
}
doc_body_flush
set table [ad_table -Torderby $orderby -Tmissing_text $missing_text "apm_table" "" $table_def]
db_release_unused_handles
# The reload links make the page slow, so make them optional
set page_url "[ad_conn url]?[export_vars -url {orderby owned_by supertype}]"
if { $reload_links_p } {
set reload_filter "<a href=\"$page_url&reload_links_p=0\">Do not check for changed files</a>"
} else {
set reload_filter "<a href=\"$page_url&reload_links_p=1\">Check for changed files</a>"
}
append body "<h3>Packages</h3>
<table width=\"100%\">
<tr><td align=\"right\">$reload_filter</td</tr>
</table>
$table
<ul>
<li><a href=\"package-add\">Create a new package.</a>
<li><a href=\"write-all-specs\">Write new specification files for all installed, locally generated packages</a>
<li><a href=\"package-load\">Load a new package from a URL or local directory.</a>
<li><a href=\"packages-install\">Install packages.</a>
</ul>
"
# Build the list of files we're watching.
if { $use_watches_p } {
set watch_files [nsv_array names apm_reload_watch]
if { [llength $watch_files] > 0 } {
append body "<h3>Watches</h3><ul>
<li><a href=\"file-watch-cancel\">Stop watching all files</a></li><br />"
foreach file [lsort $watch_files] {
if { [string compare $file "."] } {
append body "<li>$file (<a href=\"file-watch-cancel?watch_file=[ns_urlencode $file]\">stop watching this file</a>)\n"
}
}
append body "</ul>\n"
}
} else {
set kernel_id [ad_acs_kernel_id]
append body "<h3>Watches</h3>
Watching of files is not enabled in performance mode (see the PerformanceModeP parameter on the <a href=\"/admin/site-map/parameter-set?package_id=$kernel_id&package_key=acs-kernel&section_name=all\">ACS Kernel parameter page</a>)"
}
append body "
<h3>Help</h3>
<blockquote>
A package is <b>enabled</b> if it is scheduled to run at server startup
and is deliverable by the request processor.
<p>If a Tcl library file (<tt>*-procs.tcl</tt>) or query file (<tt>*.xql</tt>) is being
<b>watched</b>, the request processor monitors it, reloading it into running interpreters
whenever it is changed. This is useful during development
(so you don't have to restart the server for your changes to take
effect). To watch a file, click its package key above, click <i>Manage file
information</i> on the next screen, and click <i>watch</i> next to
the file's name on the following screen.
</blockquote>
"
<?xml version="1.0"?>
<queryset>
<fullquery name="email_by_user_id">
<querytext>
select email
from parties
where party_id = :user_id
</querytext>
</fullquery>
<partialquery name="apm_application">
<querytext>
t.package_type = 'apm_application'
</querytext>
</partialquery>
<partialquery name="everyone">
<querytext>
exists (select 1 from apm_package_owners o where o.version_id = v.version_id and owner_uri='mailto:$my_email')
</querytext>
</partialquery>
</queryset>
ad_page_contract {
Adds a package to the package manager.
@author Bryan Quinn (bquinn@arsdigita.com)
@creation-date 17 April 2000
@cvs-id $Id$
} {
package_key
pretty_name
pretty_plural
{ package_type "apm_application"}
{ initial_install_p "f" }
{ singleton_p "f" }
{ auto_mount "" }
package_uri
version_name
version_uri
summary
description:html
description_format
package_id:naturalnum
version_id:naturalnum
{ owner_name:multiple }
{ owner_uri:multiple}
{ vendor [db_null] }
{ vendor_uri [db_null] }
{ install_p 0 }
} -validate {
package_key_format -requires {package_key} {
if { [regexp {[^a-z0-9-]} $package_key] } {
ad_complain
}
}
package_key_unique -requires {package_key} {
if {[apm_package_registered_p $package_key] } {
ad_complain "The package key, <tt>$package_key</tt>, you have requested
is already registerd to another package."
}
}
pretty_plural_unique -requires {pretty_plural} {
if {[db_string apm_pretty_plural_unique_ck {
select decode(count(*), 0, 0, 1) from apm_package_types
where pretty_plural = :pretty_plural
} -default 0]} {
ad_complain "A package with the pretty plural of $pretty_plural already exists."
}
}
package_name_unique -requires {pretty_name} {
if { [db_string apm_name_unique_ck {
select decode(count(*), 0, 0, 1) from apm_package_types
where pretty_name = :pretty_name
} -default 0] } {
ad_complain "A package with the name <strong>$pretty_name</strong> already exists."
}
}
package_uri_unique -requires {package_uri} {
if { [db_string apm_uri_unique_ck {
select decode(count(*), 0, 0, 1) from apm_package_types
where package_uri = :package_uri
} -default 0] } {
ad_complain "A package with the URL $package_uri already exists."
}
}
version_uri_unique -requires {version_uri} {
if { [db_string apm_version_uri_unique_ck {
select decode(count(*), 0, 0, 1) from apm_package_versions
where version_uri = :version_uri
} -default 0] } {
ad_complain "A version with the URL $version_uri already exists."
}
}
version_name_ck -requires {version_uri} {
if {![regexp {^[0-9]+((\.[0-9]+)+((d|a|b|)[0-9]?)?)$} $version_name match]} {
ad_complain
}
}
} -errors {
package_key {You must provide a package key to identify your package.}
pretty_name {You must provide a name for your package.}
package_uri {You must indicate a unique URI for your package.}
version_name {You must provide a version number for your package.}
version_name_ck {The version name must fit this format: <strong>major number</strong>.<strong>minor number</strong> with an optional suffix of <strong>d</strong> for development, <strong>a</strong> for alpha, or <strong>b</strong> for beta.}
version_uri {You must provide a unique URI for this version of your package.}
summary {Please summarize your package so that users can determine what it is for.}
description {Please provide a description of your package so that users can consider using it.}
descrption_format {Please indicate if your package is HTML or text.}
package_key_format {The package key should contain only letters, numbers, and hyphens (dashes) and it must be lowercase.}
package_id {You must provide an integer key for your package.}
version_id {You must provide an integer key for your package version.}
}
db_transaction {
# Register the package.
apm_package_register $package_key $pretty_name $pretty_plural $package_uri \
$package_type $initial_install_p $singleton_p
# Insert the version
set version_id [apm_package_install_version -callback apm_dummy_callback -version_id \
$version_id $package_key $version_name $version_uri $summary $description \
$description_format $vendor $vendor_uri $auto_mount]
apm_version_enable -callback apm_dummy_callback $version_id
apm_package_install_owners -callback apm_dummy_callback \
[apm_package_install_owners_prepare $owner_name $owner_uri] $version_id
if { $install_p } {
if {[catch {
apm_package_install_spec $version_id
} errmsg]} {
ad_return_error "Filesystem Error" "
I was unable to create your package for the following reason:
<blockquote><pre>[ns_quotehtml $errmsg]</pre></blockquote>"
}
}
} on_error {
if {[db_string apm_package_add_doubleclick {
select decode(count(*), 0, 0, 1) from apm_package_versions
where version_id = :version_id
} -default 0]} {
ad_returnredirect "version-view?version_id=$version_id"
ad_script_abort
}
ad_return_error "Database Error" "
I was unable to create your package for the following reason:
<blockquote><pre>[ns_quotehtml $errmsg]</pre></blockquote>
"
ad_script_abort
}
db_release_unused_handles
ad_returnredirect "version-view?version_id=$version_id"
<?xml version="1.0"?>
<queryset>
<fullquery name="apm_pretty_plural_unique_ck">
<querytext>
select case when count(*) = 0 then 0 else 1 end from apm_package_types
where pretty_plural = :pretty_plural
</querytext>
</fullquery>
<fullquery name="apm_name_unique_ck">
<querytext>
select case when count(*) = 0 then 0 else 1 end from apm_package_types
where pretty_name = :pretty_name
</querytext>
</fullquery>
<fullquery name="apm_uri_unique_ck">
<querytext>
select case when count(*) = 0 then 0 else 1 end from apm_package_types
where package_uri = :package_uri
</querytext>
</fullquery>
<fullquery name="apm_version_uri_unique_ck">
<querytext>
select case when count(*) = 0 then 0 else 1 end from apm_package_versions
where version_uri = :version_uri
</querytext>
</fullquery>
<fullquery name="apm_package_add_doubleclick">
<querytext>
select case when count(*) = 0 then 0 else 1 end from apm_package_versions
where version_id = :version_id
</querytext>
</fullquery>
</queryset>
ad_page_contract {
Adds a package to the package manager.
@author Jon Salz (jsalz@arsdigita.com)
@creation-date 17 April 2000
@cvs-id $Id$
} {
}
set user_id [ad_verify_and_get_user_id]
db_1row apm_get_name {
select first_names || ' ' || last_name user_name, email from cc_users where user_id = :user_id
}
set package_id [db_nextval acs_object_id_seq]
set version_id [db_nextval acs_object_id_seq]
db_release_unused_handles
doc_body_append "[apm_header -form "action=package-add-2 method=post" "Add a New Package"]
[export_form_vars package_id version_id]
<script language=javascript>
function updateURLs() {
// Update the package and version URL, if the package key and/or version name change.
var form = document.forms\[0\];
if (form.package_uri.value == '')
form.package_uri.value = 'http://openacs.org/repository/apm/packages/' + form.package_key.value;
if ((form.version_name.value != '') && (form.version_uri.value == ''))
form.version_uri.value = 'http://openacs.org/repository/download/apm/' + form.package_key.value + '-' + form.version_name.value + '.apm';
}
</script>
<script language=javascript>
function checkMailto(element) {
// If it looks like an email address without a mailto: (contains an @ but
// no colon) then prepend 'mailto:'.
if (element.value.indexOf('@') >= 0 && element.value.indexOf(':') < 0)
element.value = 'mailto:' + element.value;
}
</script>
<table>
<tr>
<td></td>
<td>Select a package key for your package. This is a unique, short, and lower-case identifier
for your package containing only letters, numbers, and hyphens (e.g., <tt>address-book</tt>
for the address book package or <tt>photo-album</tt> for the Photo Album).
Files for your package will be placed in a directory with this name.</td>
</tr>
<tr>
<th align=right nowrap>Package Key:</th>
<td><input name=package_key size=30 onChange=\"updateURLs()\"></td>
</tr>
<tr>
<td></td>
<td>Select a short, human-readable name for your package, e.g., \"Address Book\" or
\"Photo Album.\"
</tr>
<tr>
<th align=right nowrap>Package Name:</th>
<td><input name=pretty_name size=30></td>
</tr>
<tr>
<td></td>
<td>Please indicate the plural form of the package name, e.g. the plural form of 'Bboard' is 'Bboards.'
</tr>
<tr>
<th align=right nowrap>Package Plural:</th>
<td><input name=pretty_plural size=40></td>
</tr>
<tr>
<td></td>
<td>Indicate whether this package is an application or a service.
Applications are software intended for end-users, e.g. Bboard.
Services are system-level software that extend OpenACS to provide new system-wide functionality,
e.g. Workflow.
</tr>
<tr>
<th align=right nowrap>Package Type:</th>
<td><select name=package_type>
<option value=apm_application>Application
<option value=apm_service>Service
</select>
</td>
</tr>
</tr>
<tr>
<th align=right nowrap>OpenACS Core?</th>
<td><input type=checkbox name=initial_install_p value=t> Is your package part of the OpenACS Core that
forms the set of packages initially installed? If you're not part of the OpenACS Core development team,
it would be best if you'd leave this box unchecked.
</tr>
<tr>
<th align=right nowrap>Singleton?</th>
<td><input type=checkbox name=singleton_p value=t> Is your package a singleton package? Singleton packages
can have at most one instance; attempts to create more instances of the singleton will return the currently
created instance. Singleton packages are appropriate for services that should not have multiple instances,
such as the ACS Kernel.
</tr>
<tr>
<th align=right nowrap>Auto-mount URI</th>
<td><input name=auto_mount size=30></td>
</tr>
<tr>
<td></td>
<td>The URI (name) under the main site where the package will automatically be
mounted upon installation. This feature is typically only used by singleton packages.</td>
</tr>
<tr>
<td></td>
<td>Pick a canonical URL for your package. This should be a URL where the package can be downloaded.
</tr>
<tr>
<th align=right nowrap>Package URL:</th>
<td><input name=package_uri size=60></td>
</tr>
<tr>
<td></td>
<td>Select an initial version number for the package. By convention, this is
<tt>0.1d</tt> if you are just starting to create your package, or
<tt>4.0</tt> if you are creating your package from ACS 4.0 code. The version number
must fit the format of <strong>major number</strong>.<strong>minor number</strong> with
an optional suffix of <strong>d</strong> for development, <strong>a</strong> for alpha, or
<strong>b</strong> for beta.
</tr>
<tr>
<th align=right nowrap>Initial Version:</th>
<td><input name=version_name size=10 onChange=\"updateURLs()\"></td>
</tr>
<tr>
<td></td>
<td>Pick a canonical URL for the initial version of the package. For now, the default
will always be correct.</td>
</tr>
<tr>
<th align=right nowrap>Version URL:</th>
<td><input name=version_uri size=60></td>
</tr>
<tr>
<td></td>
<td>Type a brief, one-sentence-or-less summary of the functionality of your package.
In general, this should be similar to the text introducing the
<a href=\"/doc/\">developer documentation</a>. The summary should begin
with a capital letter and end with a period.
</td>
</tr>
<tr valign=top>
<th align=right><br>Summary:</th>
<td><textarea name=summary cols=60 rows=2 wrap=soft></textarea></td>
</tr>
<tr>
<td></td>
<td>Type a one-paragraph description of your package. This is probably analogous to the
first paragraph in your package's documentation.</td>
</tr>
<tr valign=top>
<th align=right><br>Description:</th>
<td><textarea name=description cols=60 rows=5 wrap=soft></textarea><br>
This description is <select name=description_format>
<option value=text/html>HTML-formatted.
<option value=text/plain>plain text.
</select>
</td>
</tr>
<tr>
<td></td>
<td>Enter the names and URLs of up to two people who own the package.
These should be entered in order of importance: whoever works most heavily
on the package should be first. You'll probably want to use email addresses
for URLs, in which case you should precede them with <tt>mailto:</tt> (e.g.,
<tt>mailto:developername@openacs.org</tt>).
</tr>
<tr>
<th align=right nowrap>Primary Owner:</th>
<td><input name=owner_name size=30 value=\"$user_name\"></td>
</tr>
<tr>
<th align=right nowrap>Primary Owner URL:</th>
<td><input name=owner_uri size=30 value=\"mailto:$email\" onChange=\"checkMailto(this)\"></td>
</tr>
<tr>
<th align=right nowrap>Secondary Owner:</th>
<td><input name=owner_name size=30></td>
</tr>
<tr>
<th align=right nowrap>Secondary Owner URL:</th>
<td><input name=owner_uri size=30 onChange=\"checkMailto(this)\"></td>
</tr>
<tr>
<td></td>
<td>If the package is being released by a company, type in its name and URL here.
<!-- ArsDigita employees should <a href=\"javascript:document.forms\[0\].vendor.value='ArsDigita Corporation';document.forms\[0\].vendor_uri.value='http://www.arsdigita.com/';void(0)\">click here</a> to fill this in automatically.</td> -->
</tr>
<tr>
<th align=right nowrap>Vendor:</th>
<td><input name=vendor size=30></td>
</tr>
<tr>
<th align=right nowrap>Vendor URL:</th>
<td><input name=vendor_uri size=60></td>
</tr>
<tr>
<td></td>
<td>
<table><tr valign=baseline><td><input type=checkbox name=install_p value=1 checked></td><td>
Write a package specification file for this package.
(You almost certainly want to leave this checked.)</td></tr></table>
</td>
</tr>
<tr>
<td colspan=2 align=center><br>
Click \"Create Package\" to register your package. If there are data models for
this package, please load them manually into your database.
<p><input type=submit value=\"Create Package\">
</td>
</tr>
</table>
[ad_footer]
"
<?xml version="1.0"?>
<queryset>
<fullquery name="apm_get_name">
<querytext>
select first_names || ' ' || last_name as user_name, email from cc_users where user_id = :user_id
</querytext>
</fullquery>
</queryset>
ad_page_contract {
Deinstalls a package from the filesystem, but leaves the database intact.
@author Bryan Quinn (bquinn@arsdigita.com)
@creation-date Fri Oct 13 08:45:58 2000
@cvs-id $Id$
} {
version_id:naturalnum
}
apm_version_info $version_id
doc_body_append "[apm_header [list "version-view?version_id=$version_id" "$pretty_name $version_name"] "Deinstall"]"
db_transaction {
doc_body_append "<ul>"
apm_package_deinstall -callback apm_doc_body_callback $package_key
doc_body_append "</ul>"
} on_error {
if {![apm_version_installed_p $version_id] } {
ad_return_complaint 1 "Database Error: The database returned the following error
message <pre><blockquote>[ad_quotehtml $errmsg]</blockquote></pre>"
}
}
doc_body_append "
<p>
Return to the <a href=\"index\">index</a>.
[ad_footer]
"
ad_page_contract {
Deletes a package from the database and the filesystem.
@author Bryan Quinn (bquinn@arsdigita.com)
@creation-date Fri Oct 13 08:42:50 2000
@cvs-id $Id$
} {
version_id:naturalnum
{remove_files:boolean 0}
{sql_drop_scripts:multiple ""}
}
if {![apm_version_installed_p $version_id]} {
doc_body_append "[apm_header "Package Deleted."]
The version you have indicated has been deleted.<p>
Return to the <a href=\"index\">index</a>.
[ad_footer]
"
ad_script_abort
}
apm_version_info $version_id
doc_body_append [apm_header "Delete"]
db_transaction {
apm_package_delete -sql_drop_scripts $sql_drop_scripts -remove_files=0 -callback apm_doc_body_callback $package_key
} on_error {
if {[apm_package_registered_p $package_key] } {
doc_body_append "The database returned the following error
message <pre><blockquote>[ad_quotehtml $errmsg]</blockquote></pre>"
}
}
doc_body_append "
</ul>
<p>
<p>You should restart the server now to make sure the memory footprint and cache of the package is cleared out. <a href=\"../server-restart\">Click here</a> to restart the server now.</p>
[ad_footer]
"
ad_page_contract {
Deletes a package and all of its versions from the package manager.
@author Bryan Quinn (bquinn@arsdigita.com)
@creation-date Fri Oct 13 08:40:54 2000
@cvs-id $Id$
} {
version_id:naturalnum
}
apm_version_info $version_id
# Find the drop scripts.
set db_type [db_type]
set dependent_packages_list [db_list dependency_p {
select package_key
from apm_package_versions av
where av.enabled_p = 't'
and av.installed_p = 't'
and exists (select 1 from
apm_package_dependencies ad
where ad.version_id = av.version_id
and ad.service_uri = :package_key
and ad.dependency_type = 'requires'
)
}]
if { [llength $dependent_packages_list] > 0 } {
set dependency_warning_text "
The following packages depend on package <code>$package_key</code> that you are about to delete:
<p>
<code>
[join $dependent_packages_list "<br />"]
</code>
</p>
"
} else {
set dependency_warning_text ""
}
set initial_install_p [db_string initial_install_p {
select initial_install_p
from apm_package_types
where package_key = :package_key
}]
if { [string equal $initial_install_p "t"] } {
set kernel_deletion_warning "
<p>
You are about to delete package <code>$package_key</code> which is part of the <b>OpenACS core</b>
</p>
"
} else {
set kernel_deletion_warning ""
}
if { ![empty_string_p $dependency_warning_text] || ![empty_string_p $kernel_deletion_warning] } {
set warning_text "
<p>
<b><font color=\"red\">WARNING</font></b>
</p>
$kernel_deletion_warning
$dependency_warning_text
<p>
<b>Proceeding with the deletion of the package may render the system in a broken state.</b>
</p>
"
} else {
set warning_text ""
}
set file_list ""
foreach file [apm_get_package_files -package_key $package_key -file_types data_model_drop] {
append file_list " <tr>
<td><input type=checkbox name=\"sql_drop_scripts\" value=$file checked></td>
<td>$file</td>
</tr>"
}
if {![empty_string_p $file_list]} {
set file_list "
We recommend sourcing all of the drop scripts for the package. Be aware that this will
erase all data associated with this package from the database.
<table cellpadding=3 cellspacing=3>
$file_list
</table>"
}
set body "[apm_header -form "action=\"package-delete-2\" method=\"post\"" [list "version-view?version_id=$version_id" "$pretty_name $version_name"] "Delete"]
$warning_text
<p>Deleting a package removes all record of it from the APM's database.</p>
<p>
[export_form_vars version_id]
$file_list
<p>
<input type=submit value=\"Delete Package\">
</form>
[ad_footer]"
doc_return 200 text/html $body
ad_page_contract {
Loads a package from a URL into the package manager.
@param url The url of the package to load.
@author Bryan Quinn (bquinn@arsdigita.com)
@creation-date 10 October 2000
@cvs-id $Id$
} {
{url ""}
{file_path ""}
{delete 0}
} -validate {
url_xor_file_path {
if {([empty_string_p $url] && [empty_string_p $file_path]) ||
(![empty_string_p $url] && ![empty_string_p $file_path]) } {
ad_complain
}
}
} -errors {
url_xor_file_path {You must specify either a URL to download or a file path, but not both.}
}
if {$delete} {
file delete -force [apm_workspace_install_dir]
}
ad_return_top_of_page "[apm_header -form "package-load" [list "package-load" "Load a New Package"] "View Package Contents"]
"
if {[empty_string_p $file_path]} {
if {[string range $url 0 6] == "http://"} {
set url [string range $url 7 end]
}
ns_write "
<ul>
<li>Downloading <a href=\"http://$url\">http://$url</a>..."
if { [catch {
# Open a destination file.
set file_path [ns_tmpnam].apm
set fileChan [open $file_path w+ 0600]
# Open the channel to the server.
set httpChan [lindex [ns_httpopen GET "http://$url"] 0]
ns_log Debug "APM: Copying data from $url"
# Copy the data
fcopy $httpChan $fileChan
# Clean up.
ns_log Debug "APM: Done copying data."
close $httpChan
close $fileChan
} errmsg] } {
ns_write "Unable to download. Please check your URL.</ul>.
The following error was returned: <blockquote><pre>[ad_quotehtml $errmsg]
</pre></blockquote>[ad_footer]"
return
}
} else {
ns_write "
Accessing $file_path...
<p>
<ul>
"
}
ns_log Debug "APM: Loading $file_path"
# If file_path ends in .apm, then load the single package.
if { ![string compare [string range $file_path [expr [string length $file_path] -3] end] "apm"] } {
apm_load_apm_file -callback apm_ns_write_callback $file_path
} else {
# See if this is a directory.
if { [file isdirectory $file_path] } {
#Find all the .APM and load them.
set apm_file_list [glob -nocomplain "$file_path/*.apm"]
if {[empty_string_p $apm_file_list]} {
ns_write "The directory specified, <code>$file_path</code>, does not contain any APM files. Please <a href=\"package-load\">try again</a>.[ad_footer]"
return
} else {
foreach apm_file $apm_file_list {
ns_write "Loading $apm_file... <ul>"
apm_load_apm_file -callback apm_ns_write_callback $apm_file
ns_write "<li>Done.</ul><p>"
}
}
} else {
# Not sure what to do... stop.
ns_write "The specified file path is not an APM file or a directory. Please try
entering a new file path.[ad_footer]"
return
}
}
ns_write "
</ul>
The package(s) are now extracted into your filesystem. You can <a href=\"package-load\">load
another new package</a> from a URL or proceed to <a href=\"packages-install\">install</a> the package(s).
[ad_footer]
"
ad_page_contract {
Loads a package from a URL into the package manager.
@author Bryan Quinn (bquinn@arsdigita.com)
@creation-date September 1 2000
@cvs-id $Id$
} {
}
doc_body_append "[apm_header -form "action=package-load-2" "Load a New Package"]
<p>
You can retrieve a package archive to prepare for installation by using
one of the options below.
Otherwise, please specify a filesystem location for the packages you want to install.
You can also copy the extracted package files directly into the <code>[acs_root_dir]/packages/</code> directory if you prefer.
<p>
"
doc_body_append "
Load a package from the <tt>.apm</tt> file at this URL:
<blockquote>http:// <input name=url size=50></blockquote><p>
"
doc_body_append "
Specify a local path including a filename for the APM file or a directory containing several APM files.<p>
<blockquote>Path: <input name=file_path size=50></blockquote>
<p>
<input type=checkbox name=delete value=1>Check this box if you want to delete all of the packages
currently in the installation directory.<p>
<center><input type=submit value=Load></blockquote></center>
[ad_footer]
"
ad_page_contract {
Scans the packages directory for new or modified packages.
@author Jon Salz [jsalz@arsdigita.com]
@creation-date 17 April 2000
@cvs-id $Id$
} {
}
# A callback to just write an item to the connection.
proc apm_register_new_packages_callback { message } {
doc_body_append "$message<li>\n"
doc_body_flush
}
doc_body_append "[apm_header "Scan Packages"]
<ul><li>
"
apm_register_new_packages -callback apm_register_new_packages_callback
doc_body_append "
Done.
</ul>
<a href=\"./\">Return to the Package Manager</a>
[ad_footer]
"
\ No newline at end of file
ad_page_contract {
Cancels all watches in given package.
@author Peter Marklund
@cvs-id $Id$
} {
package_key
{return_url "index"}
}
apm_cancel_all_watches $package_key
ad_returnredirect $return_url
ad_page_contract {
Schedules all -procs.tcl and xql files of a package to be watched.
@author Peter Marklund
@cvs-id $Id$
} {
package_key
{return_url "index"}
}
apm_watch_all_files $package_key
ad_returnredirect $return_url
ad_page_contract {
Do a dependency check of the install.
@author Bryan Quinn (bquinn@arsdigita.com)
@creation-date Mon Oct 9 00:13:43 2000
@cvs-id $Id$
} {
{install:multiple ""}
{enable:multiple ""}
{force_p "f"}
}
# Install and enable are sets of keys; need to turn them back into spec files.
set spec_files [ad_get_client_property apm spec_files]
# LARS HACK: I got rid of the separate install/enable checkboxes
set install $enable
# Clear out previous client properties.
ad_set_client_property -clob t apm pkg_install_list ""
ad_set_client_property -clob t apm pkg_enable_list ""
foreach spec_file $spec_files {
# Get package info, and find out if this is a package we should install
if { [catch {
array set package [apm_read_package_info_file $spec_file]
} errmsg] } {
# Unable to parse specification file.
# If we get here, its because someone hacked the archive the loading process
# which checks the info file and displays an error.
# process
ns_log Error "$spec_file could not be parsed correctly. It is not being installed.
The error: $errmsg"
}
# Save the package info, we may need it for dependency satisfaction later
lappend pkg_info_list [pkg_info_new $package(package.key) $spec_file \
$package(provides) $package(requires) ""]
if { [lsearch -exact $install $package(package.key)] != -1 } {
# This is a package which we should install
lappend install_spec_files $spec_file
}
}
if {![info exists install_spec_files]} {
doc_body_append "[apm_header "Package Installation"]<p>
No packages selected.<p>[ad_footer]"
return
}
### Dependency Check
set dependency_results [apm_dependency_check -pkg_info_all $pkg_info_list $install_spec_files]
if { [lindex $dependency_results 0] == 1 && [llength [lindex $dependency_results 2]] > 0 } {
set extra_package_keys [lindex $dependency_results 2]
# Check was good after adding a couple more pacakges
doc_body_append "[apm_header "Package Installation"]
<h2>Additional Packages Automatically Added</h2><p>
Some of the packages you were trying to install required other packages to be installed first.
We've added these additional packages needed, and ask you to review the list of packages below.
<form action=\"packages-install-2\" method=\"post\">
[export_form_vars spec_files]<p>
<blockquote>
<table>
"
set install [concat $install $extra_package_keys]
set enable [concat $enable $extra_package_keys]
doc_body_append [apm_package_selection_widget [lindex $dependency_results 1] $install $enable]
doc_body_append "
</table></blockquote>
<input type=submit value=\"Select Data Model Scripts\">
</form>
[ad_footer]
"
} elseif { ([lindex $dependency_results 0] == 1) || ![string compare $force_p "t"]} {
### Check passed! Initiate install.
# We use client properties to pass along this information as it is fairly large.
ad_set_client_property -clob t apm pkg_install_list [lindex $dependency_results 1]
ad_set_client_property -clob t apm pkg_enable_list $enable
ad_returnredirect packages-install-3
ad_script_abort
} else {
### Check failed. Offer user an explanation and an ability to select unselect packages.
doc_body_append "[apm_header "Package Installation"]
<h2>Select Packages to Install</h2><p>
Some of the packages you are trying to install have unsatisfied dependencies. The packages
with unsatisfied dependencies have been deselected. If you wish to install packages that do
not pass dependencies, please click the \"force\" option below.
<form action=\"packages-install-2\" method=\"post\">
<ul>
<li>To <b>install</b> a package is to load its data model.
<li>To <b>enable</b> a package is to make it available to users.
</ul>
If you think you might want to use a package later (but not right away),
install it but don't enable it.
[export_form_vars spec_files]<p>
<blockquote>
<table>
"
doc_body_append [apm_package_selection_widget [lindex $dependency_results 1] $install $enable]
doc_body_append "
</table></blockquote>
<input type=checkbox name=force_p value=\"t\"> <strong>Force the install<p></strong>
<input type=submit value=\"Select Data Model Scripts\">
</form>
[ad_footer]
"
}
<?xml version="1.0"?>
<queryset>
<rdbms><type>oracle</type><version>8.1.6</version></rdbms>
<fullquery name="apm_package_upgrade_from">
<querytext>
select version_name from apm_package_versions
where package_key = :package_key
and version_id = apm_package.highest_version(:package_key)
</querytext>
</fullquery>
</queryset>
<?xml version="1.0"?>
<queryset>
<rdbms><type>postgresql</type><version>7.1</version></rdbms>
<fullquery name="apm_package_upgrade_from">
<querytext>
select version_name from apm_package_versions
where package_key = :package_key
and version_id = apm_package__highest_version(:package_key)
</querytext>
</fullquery>
</queryset>
ad_page_contract {
Offer user a chance to confirm or deny package creation scripts.
@author Bryan Quinn (bquinn@arsdigita.com)
@creation-date Mon Oct 9 00:15:52 2000
@cvs-id $Id$
} {
}
set pkg_install_list [ad_get_client_property apm pkg_install_list]
set body ""
append body "[apm_header "Package Installation"]
<h2>Select Data Model Scripts to Run</h2>
<p>
Check all the files you want to be loaded into the database.<p>
<form action=\"packages-install-4\" method=\"post\">
"
set sql_file_list [list]
set file_count 0
foreach pkg_info $pkg_install_list {
set package_key [pkg_info_key $pkg_info]
set package_path [pkg_info_path $pkg_info]
array set version [apm_read_package_info_file [pkg_info_spec $pkg_info]]
set final_version_name $version(name)
# Determine if we are upgrading or installing.
if { [apm_package_upgrade_p $package_key $final_version_name] == 1} {
ns_log Debug "Upgrading package [string totitle $version(package-name)] to $final_version_name."
set upgrade_p 1
set initial_version_name [db_string apm_package_upgrade_from {
select version_name from apm_package_versions
where package_key = :package_key
and version_id = apm_package.highest_version(:package_key)
} -default ""]
} else {
set upgrade_p 0
set initial_version_name ""
}
# Find out which script is appropriate to be run.
set data_model_in_package 0
set table_rows ""
set data_model_files [apm_data_model_scripts_find \
-upgrade_from_version_name $initial_version_name \
-upgrade_to_version_name $final_version_name \
-package_path $package_path \
$package_key]
set sql_file_list [concat $sql_file_list $data_model_files]
if {![empty_string_p $data_model_files]} {
foreach file $data_model_files {
set path [lindex $file 0]
set file_type [lindex $file 1]
append table_rows " <tr>
<td><input type=checkbox checked name=\"sql_file\" value=\"$file_count\"></td>
<td>$path</td>
<td>[apm_pretty_name_for_file_type $file_type]</td>
</tr>"
incr file_count
}
if { [empty_string_p $version(auto-mount)] && [string equal $version(package.type) apm_application] } {
set mount_html "<input type=\"checkbox\" name=\"mount_p\" value=\"$version(package.key)\" /> Mount package under the main site at path <input type=\"text\" name=\"mount_path.$version(package.key)\" value=\"$version(package.key)\" />"
} else {
set mount_html ""
}
append body "
Select what data files to load for $version(package-name) $final_version_name
<blockquote>
<table cellpadding=3 cellspacing=3>
<tr>
<th>Load</th>
<th>File Name</th>
<th>File Type</th>
</tr>
$table_rows
</table>
$mount_html
</blockquote> <p>"
}
}
ad_set_client_property -clob t apm sql_file_paths $sql_file_list
if {[empty_string_p $sql_file_list]} {
ad_returnredirect packages-install-4
ad_script_abort
}
append body "
<input type=submit value=\"Install Packages\">
</form>
[ad_footer]
"
doc_return 200 text/html $body
ad_page_contract {
Installs the packages.
@author Bryan Quinn (bquinn@arsdigita.com)
@creation-date Mon Oct 9 00:22:31 2000
@cvs-id $Id$
} {
{sql_file:multiple ""}
{mount_p:multiple ""}
{mount_path:array ""}
}
set pkg_install_list [ad_get_client_property apm pkg_install_list]
set pkg_enable_list [ad_get_client_property apm pkg_enable_list]
set sql_file_paths [ad_get_client_property apm sql_file_paths]
ReturnHeaders
ns_write "[apm_header "Package Installation"]
<h2>Installing packages...</h2>
<p>
<ul>
"
# We have a set of SQL files that need to be sourced at the appropriate time.
set sql_files [list]
foreach index $sql_file {
ns_log Debug "File index: $index: [lindex $sql_file_paths $index]"
lappend sql_files [lindex $sql_file_paths $index]
}
set installed_count 0
foreach pkg_info $pkg_install_list {
set spec_file [pkg_info_spec $pkg_info]
set package_path [pkg_info_path $pkg_info]
if { [catch {
array set version [apm_read_package_info_file $spec_file]
} errmsg] } {
ns_write "<li> Unable to install the [pkg_info_key $pkg_info] package because its specification
file is invalid: <blockquote><pre>[ad_quotehtml $errmsg]</pre></blockquote>"
continue
}
if {[apm_package_version_installed_p $version(package.key) $version(name)] } {
# Already installed.
continue
}
set package_key $version(package.key)
set version_files $version(files)
set data_model_files [list]
# Find the correct data model files for this package.
foreach file $sql_files {
if {![string compare [lindex $file 2] $package_key]} {
# Pass on the file path and its type.
lappend data_model_files $file
}
}
# Mount path of package
if { [lsearch $mount_p $package_key] != -1 && [info exists mount_path($package_key)] && ![empty_string_p $mount_path($package_key)] } {
set selected_mount_path $mount_path($package_key)
} else {
set selected_mount_path ""
}
# Install the packages.
ns_log Debug "APM: Installing package at $package_path."
set enable_p [expr [lsearch -exact $pkg_enable_list $package_key] != -1]
set version_id [apm_package_install \
-enable=$enable_p \
-package_path $package_path \
-callback apm_ns_write_callback \
-load_data_model \
-data_model_files $data_model_files \
-mount_path $selected_mount_path \
$spec_file]
if { $version_id == 0 } {
# Installation of the package failed and we shouldn't continue with installation
# as there might be packages depending on the failed package. Ideally we should
# probably check for such dependencies and continue if there are none.
ns_write "</ul>
[ad_footer]"
ad_script_abort
}
incr installed_count
}
if {$installed_count < 1} {
ns_write "</ul>
All packages in this directory have already been installed.
Please return to the <a href=\"index\">index</a>.<p>
[ad_footer]"
return
} else {
ns_write "</ul><p>
Done installing packages.
<p>You should restart the server now to make installed and upgraded packages available. <a href=\"../server-restart\">Click here</a> to restart the server now.</p>
[ad_footer]
"
}
ad_page_contract {
Select, dependency check, install and enable packages.
@author Bryan Quinn (bquinn@arsdigita.com)
@cvs-id $Id$
} {
{checked_by_default_p:boolean 0}
}
ad_return_top_of_page "[apm_header "Package Installation"]
<p>Please wait while the installer searches your system for packages to install ...<p>
"
### Get all the spec files
# If a package is in the apm_workspace dir then we assume that that is the package that
# should be installed and we ignore any such package in the packages dir.
# TODO: make sure that it's a later version than that in the packages dir?
set packages_root_dir "[acs_root_dir]/packages"
set packages_spec_files [apm_scan_packages $packages_root_dir]
set workspace_spec_files [apm_scan_packages [apm_workspace_install_dir]]
set workspace_filenames [list]
foreach spec_path $workspace_spec_files {
lappend workspace_filenames [file tail $spec_path]
}
set all_spec_files $workspace_spec_files
foreach spec_path $packages_spec_files {
set spec_filename [file tail $spec_path]
if { [lsearch -exact $workspace_filenames $spec_filename] == -1 } {
lappend all_spec_files $spec_path
}
}
# Determine which spec files are new installs; install all of the new items.
set spec_files [list]
set already_installed_list [list]
set not_compatible_list [list]
foreach spec_file $all_spec_files {
array set version [apm_read_package_info_file $spec_file]
set version_name $version(name)
set package_name $version(package-name)
set package_key $version(package.key)
if { [apm_package_supports_rdbms_p -package_key $package_key] } {
if { [apm_package_registered_p $package_key] } {
# This package is already on the system
if { [apm_higher_version_installed_p $package_key $version_name] } {
ns_log Notice "higher version installed of $package_key $version_name"
lappend spec_files $spec_file
} else {
ns_log Notice "need upgrade of package $package_key $version_name"
lappend already_installed_list "Package &quot;$package_name&quot; ($package_key) version $version_name or higher is already installed."
}
} else {
lappend spec_files $spec_file
}
} else {
lappend not_compatible_list "Package &quot;$package_name&quot; ($package_key) doesn't support [db_type]."
}
}
apm_log APMDebug $spec_files
ns_write "Done.<p>
"
if { [empty_string_p $spec_files] } {
# No spec files to work with.
ns_write "
<h2>No New Packages to Install</h2><p>
There are no new packages to install. Please load some
using the <a href=\"package-load\">Package Loader</a>.<p>
Return to the <a href=\"index\">APM</a>.<p>
"
} else {
ns_write "
<h2>Select Packages to Install</h2><p>
<p>Please select the set of packages you'd like to install.</p>"
ns_write "
<script language=javascript>
function uncheckAll() {
for (var i = 0; i < [expr [llength $spec_files] ]; ++i)
document.forms\[0\].elements\[i\].checked = false;
this.href='';
}
function checkAll() {
for (var i = 0; i < [expr [llength $spec_files] ]; ++i)
document.forms\[0\].elements\[i\].checked = true;
this.href='';
}
</script>
<a href=\"packages-install?checked_by_default_p=0\" onclick=\"javascript:uncheckAll();return false\"><b>uncheck all boxes</b></a> |
<a href=\"packages-install?checked_by_default_p=1\" onclick=\"javascript:checkAll(); return false\"><b>check all boxes</b></a>
"
ns_write "<form action=packages-install-2 method=post>"
# Client properties do not deplete the limited URL variable space.
# But they are limited to the maximum length of a varchar ...
ad_set_client_property -clob t apm spec_files $spec_files
set errors [list]
set pkg_info_list [list]
set pkg_key_list [list]
apm_log APMDebug "APM: Specification files available: $spec_files"
foreach spec_file $spec_files {
### Parse the package.
if { [catch {
array set package [apm_read_package_info_file $spec_file]
} errmsg] } {
lappend errors "<li>Unable to parse $spec_file. The following error was generated:
<blockquote><pre>[ad_quotehtml $errmsg]</pre></blockquote><p>"
} else {
apm_log APMDebug "APM: Adding $package(package.key) to list for installation."
lappend pkg_info_list [pkg_info_new $package(package.key) $spec_file \
$package(provides) $package(requires) ""]
lappend pkg_key_list $package(package.key)
}
}
if { $checked_by_default_p } {
set widget [apm_package_selection_widget $pkg_info_list $pkg_key_list $pkg_key_list]
} else {
set widget [apm_package_selection_widget $pkg_info_list]
}
if {[empty_string_p $widget]} {
ns_write "There are no new packages available.<p>
[ad_footer]"
ad_script_abort
}
ns_write $widget
ns_write "
<input type=submit value=\"Next -->\">
</form>
"
if {![empty_string_p $errors]} {
ns_write "The following errors were generated
<ul>
$errors
</ul>
"
}
}
if { [llength $not_compatible_list] > 0 } {
ns_log Notice "APM packages-install: Incompatible Packages\n- [join $not_compatible_list "\n- "]"
}
if { [llength $already_installed_list] > 0 } {
ns_log Notice "APM packages-install: Already Installed Packages\n- [join $already_installed_list "\n- "]"
}
ns_write "
[ad_footer]
"
<?xml version="1.0"?>
<queryset>
<rdbms><type>oracle</type><version>8.1.6</version></rdbms>
<fullquery name="apm_archive_exist_p">
<querytext>
select count(*)
from cr_revisions
where revision_id = (select content_item.get_latest_revision(item_id)
from apm_package_versions
where version_id = :version_id)
</querytext>
</fullquery>
<fullquery name="apm_archive_serve">
<querytext>
select '[cr_fs_path]' || filename as content,
'[set storage_type file]' as storage_type
from cr_revisions
where revision_id = (select content_item.get_latest_revision(item_id)
from apm_package_versions
where version_id = $version_id)
</querytext>
</fullquery>
</queryset>
<?xml version="1.0"?>
<queryset>
<rdbms><type>postgresql</type><version>7.1</version></rdbms>
<fullquery name="apm_archive_exist_p">
<querytext>
select count(*)
from cr_revisions
where revision_id = (select content_item__get_latest_revision(item_id)
from apm_package_versions
where version_id = :version_id)
</querytext>
</fullquery>
<fullquery name="apm_archive_serve">
<querytext>
select '[cr_fs_path]' || r.content as content, i.storage_type
from cr_revisions r, cr_items i
where r.item_id = i.item_id
and r.revision_id = (select content_item__get_latest_revision(item_id)
from apm_package_versions
where version_id = :version_id)
</querytext>
</fullquery>
</queryset>
ad_page_contract {
This page serves .APM tarballs of packages.
Modified to serve tarballs from content repository (Openacs - DanW)
@author Bryan Quinn (bquinn@arsdigita.com)
@creation-date 29 September 2000
@cvs-id $Id$
} {
version_id:naturalnum,notnull
}
if { [db_string apm_archive_exist_p {
select count(*)
from cr_revisions
where revision_id = (select content_item.get_latest_revision(item_id)
from apm_package_versions
where version_id = :version_id)
} -default 0] } {
set file [ns_tmpnam]
db_blob_get_file apm_archive_serve "
select content
from cr_revisions
where revision_id = (select content_item.get_latest_revision(item_id)
from apm_package_versions
where version_id = :version_id)
" -file $file
db_release_unused_handles
ns_returnfile 200 application/octet-stream $file
} else {
ad_return_complaint "No Archive Available" "There is no APM archive for the version you requested."
}
ad_page_contract {
Adds a parameter to a version.
@author Todd Nightingale (tnight@arsdigita.com)
@author Bryan Quinn (bquinn@arsdigita.com)
@creation-date 10 September 2000
@cvs-id $Id$
} {
version_id:naturalnum,notnull
parameter_id:naturalnum,notnull
package_key:notnull
parameter_name:notnull
section_name
description:notnull,nohtml
datatype:notnull
{default_value [db_null]}
{min_n_values:integer 1}
{max_n_values:integer 1}
} -validate {
datatype_type_ck {
if {$datatype != "number" && $datatype != "string"} {
ad_complain
}
}
param_name_unique_ck {
if {[db_string param_name_unique_ck {
select decode(count(*), 0, 0, 1)
from apm_parameters
where parameter_name = :parameter_name
and package_key= :package_key
}]} {
ad_complain "The parameter name $parameter_name already exists for this package"
}
}
} -errors {
datatype_type_ck {The datatype must be either a number or a string.}
}
db_transaction {
apm_parameter_register -parameter_id $parameter_id $parameter_name $description $package_key \
$default_value $datatype $section_name $min_n_values $max_n_values
apm_package_install_spec $version_id
} on_error {
if {![db_string apm_parameter_register_doubleclick_p {
select 1 from apm_parameters where parameter_id = :parameter_id
} -default 0]} {
ad_return_error "Database Error" "The database is complaining about the parameter you entered:<p>
<blockquote><pre>[ad_quotehtml $errmsg]</pre></blockquote>"
ad_script_abort
}
}
# LARS hack
set sections [lindex [lindex [apm_parameter_section_slider $package_key] 0] 3]
foreach section $sections {
if { [string equal $section_name [lindex $section 1]] } {
set section_name [lindex $section 0]
break
}
}
ad_returnredirect [export_vars -base "version-parameters" { version_id section_name }]
<?xml version="1.0"?>
<queryset>
<fullquery name="param_name_unique_ck">
<querytext>
select case when count(*) = 0 then 0 else 1 end
from apm_parameters
where parameter_name = :parameter_name and
package_key = :package_key
</querytext>
</fullquery>
<fullquery name="apm_parameter_register_doubleclick_p">
<querytext>
select 1 from apm_parameters where parameter_id = :parameter_id
</querytext>
</fullquery>
</queryset>
<master>
<property name="title">@page_title;noquote@</property>
<property name="context">@context;noquote@</property>
@body;noquote@
ad_page_contract {
Adds a parameter to a version.
@author Todd Nightingale [tnight@arsdigita.com]
@creation-date 17 April 2000
@cvs-id $Id$
} {
version_id:naturalnum,notnull
{section_name ""}
}
set user_id [ad_get_user_id]
db_1row apm_get_name {
select package_key, pretty_name, version_name, acs_object_id_seq.nextval as parameter_id
from apm_package_version_info
where version_id = :version_id
}
db_release_unused_handles
set page_title "Add Parameter"
set context [list [list "." "Package Manager"] [list [export_vars -base version-view { version_id }] "$pretty_name $version_name"] [list [export_vars -base version-parameters { version_id }] "Parameters"] $page_title]
append body "
<form action=\"parameter-add-2\" method=\"post\">
<blockquote>
<table>
[export_form_vars package_key parameter_id version_id]
<tr>
<td></td>
<td>A parameter can be used to store information that is specific to a package but that needs to
be easily configurable and customized on a package instance basis. The name should be a brief
plain text string that identifies the parameter.
</td>
</tr>
<tr>
<th align=right nowrap>Parameter Name:</th>
<td><input name=parameter_name size=50></td>
</tr>
<tr>
<td></td>
<td>Type a description of your parameter.
</tr>
<tr valign=top>
<th align=right><br>Description:</th>
<td><textarea name=description cols=60 rows=8></textarea>
</td>
</tr>
<tr>
<td></td>
<td>You may enter a section name to identify the parameter. For example, the ACS Kernel has a \"security\" section
to indicate which parameters pertain to security.
</tr>
<tr valign=top>
<th align=right><br>Section Name:</th>
<td><input name=section_name size=50 value=\"[ad_quotehtml $section_name]\"><br>
</td>
</tr>
<tr>
<td></td>
<td>Please indicate what type of parameter it is.
</tr>
<tr>
<th align=right nowrap>Type:</th>
<td><select name=datatype>
[ad_generic_optionlist {number string} {number string}]
</select>
</td>
</tr>
<tr>
<td></td>
<td>The default setting will be the parameter value that applies to any package instance that does
not set its own value.
</td>
</tr>
<tr>
<th align=right nowrap>Default:</th>
<td><input name=default_value size=50></td>
</tr>
<tr><th colspan=2><input type=submit value=\"Add Parameter\"></th>
</tr>
</table>
</blockquote>
</form>
"
<?xml version="1.0"?>
<queryset>
<fullquery name="apm_get_name">
<querytext>
select package_key, pretty_name, version_name, acs_object_id_seq.nextval as parameter_id
from apm_package_version_info
where version_id = :version_id
</querytext>
</fullquery>
</queryset>
#packages/acs-core/admin-www/apm/parameter-delete-2.tcl
ad_page_contract {
Adds a parameter to a version.
@author Todd Nightingale [tnight@arsdigita.com]
@creation-date 17 April 2000
@cvs-id $Id$
} {
parameter_id:naturalnum,notnull
section_name:notnull
version_id:naturalnum,notnull
}
apm_parameter_unregister $parameter_id
db_1row apm_package_by_version_id {
select pretty_name, version_name, package_key
from apm_package_version_info
where version_id = :version_id
}
# LARS hack
set sections [lindex [lindex [apm_parameter_section_slider $package_key] 0] 3]
foreach section $sections {
if { [string equal $section_name [lindex $section 1]] } {
set section_name [lindex $section 0]
break
}
}
ad_returnredirect [export_vars -base "version-parameters" { version_id section_name }]
ad_page_contract {
Adds a parameter to a version.
@author Todd Nightingale (tnight@arsdigita.com)
@author Bryan Quinn (bquinn@arsdigita.com)
@creation-date 10 September 2000
@cvs-id $Id$
} {
version_id:naturalnum,notnull
parameter_id:naturalnum,notnull
package_key:notnull
parameter_name:notnull
section_name
description:notnull,nohtml
datatype:notnull
{default_value [db_null]}
{min_n_values:integer 1}
{max_n_values:integer 1}
} -validate {
datatype_type_ck {
if {$datatype != "number" && $datatype != "string"} {
ad_complain
}
}
} -errors {
datatype_type_ck {The datatype must be either a number or a string.}
}
db_transaction {
ns_log Debug "APM: Updating Parameter: $parameter_id, $parameter_name $description, $package_key, $default_value, $datatype, $section_name, $min_n_values, $max_n_values"
apm_parameter_update $parameter_id $package_key $parameter_name $description \
$default_value $datatype $section_name $min_n_values $max_n_values
apm_package_install_spec $version_id
} on_error {
ad_return_error "Database Error" "The parameter could not be updated.
The database returned the following error:<p>
<blockquote><pre>[ad_quotehtml $errmsg]</pre></blockquote>"
}
# LARS hack
set sections [lindex [lindex [apm_parameter_section_slider $package_key] 0] 3]
foreach section $sections {
if { [string equal $section_name [lindex $section 1]] } {
set section_name [lindex $section 0]
break
}
}
ad_returnredirect [export_vars -base "version-parameters" { version_id section_name }]
<master>
<property name="title">@page_title;noquote@</property>
<property name="context">@context;noquote@</property>
@body;noquote@
ad_page_contract {
Adds a parameter to a version.
@author Todd Nightingale [tnight@arsdigita.com]
@creation-date 17 April 2000
@cvs-id $Id$
} {
parameter_id:notnull,naturalnum
version_id:notnull,naturalnum
}
set user_id [ad_verify_and_get_user_id]
db_1row param_info {
select parameter_name, datatype, description, default_value, min_n_values, max_n_values, parameter_id,
section_name, default_value
from apm_parameters
where parameter_id = :parameter_id
}
db_1row apm_get_name {
select pretty_name, version_name, package_key
from apm_package_version_info
where version_id = :version_id
}
db_release_unused_handles
set page_title "Edit Parameter"
set context [list [list "." "Package Manager"] [list [export_vars -base version-view { version_id }] "$pretty_name $version_name"] [list [export_vars -base version-parameters { version_id }] "Parameters"] $page_title]
append body "
<form action=\"parameter-edit-2\" method=\"post\">
<blockquote>
<table>
[export_form_vars package_key parameter_id version_id]
<tr>
<td></td>
<td>A parameter can be used to store information that is specific to a package but that needs to
be easily configurable and customized on a package instance basis. The name should be a brief
plain text string that identifies the parameter.
</td>
</tr>
<tr>
<th align=right nowrap>Parameter Name:</th>
<td><input name=parameter_name size=50 value=\"[ad_quotehtml $parameter_name]\"></td>
</tr>
<tr>
<td></td>
<td>Type a description of your parameter.
</tr>
<tr valign=top>
<th align=right><br>Description:</th>
<td><textarea name=description cols=60 rows=8>[ad_quotehtml $description]</textarea>
</td>
</tr>
<tr>
<td></td>
<td>You may enter a section name to identify the parameter. For example, the ACS Kernel has a \"security\" section
to indicate which parameters pertain to security.
</tr>
<tr valign=top>
<th align=right><br>Section Name:</th>
<td><input name=section_name value=\"[ad_quotehtml $section_name]\" size=50><br>
</td>
</tr>
<tr>
<td></td>
<td>Please indicate what type of parameter it is.
</tr>
<tr>
<th align=right nowrap>Type:</th>
<td><select name=datatype>
[ad_generic_optionlist {number string} {number string} $datatype]
</select>
</td>
</tr>
<tr>
<td></td>
<td>The default setting will be the parameter value that applies to any package instance that does
not set its own value.
</td>
</tr>
<tr>
<th align=right nowrap>Default:</th>
<td><input name=default_value size=50 value=\"[ad_quotehtml $default_value]\"></td>
</tr>
<tr><th colspan=2><input type=submit value=\"Edit Parameter\"></th>
</tr>
</table>
</blockquote>
</form>
[ad_footer]
"
<?xml version="1.0"?>
<queryset>
<fullquery name="param_info">
<querytext>
select parameter_name, datatype, description, default_value, min_n_values, max_n_values, parameter_id,
section_name, default_value
from apm_parameters
where parameter_id = :parameter_id
</querytext>
</fullquery>
<fullquery name="apm_get_name">
<querytext>
select pretty_name, version_name, package_key
from apm_package_version_info
where version_id = :version_id
</querytext>
</fullquery>
</queryset>
<h2>OpenACS @channel@ Core and compatibile packages</h2>
<p>Packages can be installed with the OpenACS Automated Installer on
your OpenACS site at <code>/acs-admin/install</code>. Only packages
designated compatible with your OpenACS kernel will be shown.</p>
<table border="1" cellpadding="4" cellspacing="0">
<tr>
<th>Package</th>
<th>Description</th>
<th>Release</th>
</tr>
<multiple name="packages">
<tr>
<td style="border-color:gray; text-align:center" valign="center" ><b>@packages.pretty_name@</b></td>
<td style="border-color:gray"><b>@packages.summary@</b><br>@packages.description;noquote@</td>
<td style="border-color:gray">@packages.package_key@ @packages.version@
<br> released @packages.release_date@ by @packages.vendor@</small></td>
</tr>
</multiple>
</table>
<h2>OpenACS Package Repository</h2>
<p> Available channels. </p>
<ul>
<multiple name="channels">
<li><a href="@channels.name@/">@channels.name@</a></li>
</multiple>
</ul>
<master>
<property name="title">@page_title;noquote@</property>
<property name="context">@context;noquote@</property>
<formtemplate id="callback"></formtemplate>
ad_page_contract {
Page for editing and adding callbacks. If type is provided we are in edit
mode.
@author Peter Marklund
@creation-date 28 January 2003
@cvs-id $Id$
} {
version_id:integer,notnull
{type ""}
}
db_1row package_version_info "select pretty_name, version_name from apm_package_version_info where version_id = :version_id"
set return_url "version-callbacks?[export_vars { version_id }]"
# Set default values for type and proc name
if { [empty_string_p $type] } {
# We are in add mode
set edit_mode_p 0
set unused_types [apm_unused_callback_types -version_id $version_id]
set type_options [list]
foreach unused_type $unused_types {
lappend type_options [list $unused_type $unused_type]
}
set type_value [lindex $type_options 0]
set proc_value ""
set page_title "Add Tcl Callback"
} else {
# We are in edit mode
set edit_mode_p 1
set type_options [list [list $type $type]]
set type_value $type
set proc_value [apm_get_callback_proc -type $type -version_id $version_id]
set page_title "Edit Tcl Callback"
}
set context [list [list "." "Package Manager"] [list [export_vars -base version-view { version_id }] "$pretty_name $version_name"] [list $return_url "Tcl Callbacks"] $page_title]
set type_label "Tcl procedure name"
ad_form -name callback -cancel_url $return_url -form {
{version_id:integer(hidden)
{value $version_id}
}
{return_url:text(hidden)
{value $return_url}
}
{edit_mode_p:text(hidden)
{value $edit_mode_p}
}
{type:text(select)
{label "Type"}
{options {$type_options}}
{value $type_value}
}
{proc:text
{label $type_label}
{html {size 40 maxlength 300}}
{value $proc_value}
}
} -validate {
{proc
{ ![empty_string_p [info procs ::${proc}]] }
{The specified procedure name does not exist. Is the -procs.tcl file loaded?}
}
{proc
{ [apm_callback_has_valid_args -type $type -proc_name $proc] }
{The callback proc $proc must be defined with ad_proc [ad_decode [apm_arg_names_for_callback_type -type $type] "" "and should take no arguments" "and have the following required switches: [apm_arg_names_for_callback_type -type $type]"]}
}
} -on_submit {
apm_set_callback_proc -type $type -version_id $version_id $proc
apm_package_install_spec $version_id
ad_returnredirect $return_url
ad_script_abort
}
if { $edit_mode_p } {
element set_properties callback type -mode display
}
ad_return_template
ad_page_contract {
@author Peter Marklund
@creation-date 28 January 2003
@cvs-id $Id$
} {
version_id:integer,notnull
type:notnull
}
set package_key [apm_package_key_from_version_id $version_id]
apm_remove_callback_proc -type $type -package_key $package_key
ad_returnredirect "version-callbacks?version_id=$version_id"
\ No newline at end of file
<master>
<property name="title">@page_title;noquote@</property>
<property name="context">@context;noquote@</property>
<if @result@ not nil>
<h2>Output</h2>
<blockquote><pre>
@result@
</pre></blockquote>
</if>
<else>
The callback has been invoked.
</else>
<p>
<b>&raquo;</b> <a href="@return_url@">Go back</a>
</p>
ad_page_contract {
Invoke a callback.
@author Lars Pind (lars@collaboraid.biz)
@creation-date 11 September 2003
@cvs-id $Id$
} {
version_id:integer,notnull
type:notnull
}
db_1row package_version_info "select pretty_name, version_name from apm_package_version_info where version_id = :version_id"
set return_url "version-callbacks?[export_vars { version_id }]"
# Set default values for type and proc name
set proc_value [apm_get_callback_proc -type $type -version_id $version_id]
set page_title "Invoke Tcl Callback"
set context [list \
[list "." "Package Manager"] \
[list [export_vars -base "version-view" { version_id }] "$pretty_name $version_name"] \
[list $return_url "Tcl Callbacks"] $page_title]
if { [catch $proc_value result] } {
global errorInfo
ns_log Error "Error invoking callback $proc_value: $result\n$errorInfo"
}
<master>
<property name="title">@page_title;noquote@</property>
<property name="context">@context;noquote@</property>
<p><listtemplate name="callbacks"></listtemplate></p>
<h3>Help</h3>
<p>
Below is the list of available callbacks and the parameters they will be called with. Note that the parameters are sent as named parameters.
</p>
<p>
For install, uninstall, and upgrade, the before/after part of the
name refers to before or after the database create/upgrade/drop
scripts have been run. For mounting and instantiating, well, that should be fairly obvious.
</p>
<p>
For the upgrade callbacks, you should definitely check out the proc <a
href="/api-doc/proc-view?proc=apm%5fupgrade%5flogic">apm_upgrade_logic</a>,
which makes it very easy to handle the logic of which things to
process depending on which version you're upgrading from and to.
</p>
<table cellspacing="1" cellpadding="4" bgcolor="#999999">
<tr bgcolor="white">
<th>Callback</th>
<th>Parameters</th>
</tr>
<tr bgcolor="white">
<td>
before-install
</td>
<td>
</td>
</tr>
<tr bgcolor="white">
<td>
after-install
</td>
<td>
</td>
</tr>
<tr bgcolor="white">
<td>
before-upgrade
</td>
<td>
-from_version_name
-to_version_name
</td>
</tr>
<tr bgcolor="white">
<td>
after-upgrade
</td>
<td>
-from_version_name
-to_version_name
</td>
</tr>
<tr bgcolor="white">
<td>
before-uninstall
</td>
<td>
</td>
</tr>
<tr bgcolor="white">
<td>
after-instantiate
</td>
<td>
-package_id
</td>
</tr>
<tr bgcolor="white">
<td>
before-uninstantiate
</td>
<td>
-package_id
</td>
</tr>
<tr bgcolor="white">
<td>
after-mount
</td>
<td>
-package_id
-node_id
</td>
</tr>
<tr bgcolor="white">
<td>
before-unmount
</td>
<td>
-package_id
-node_id
</td>
</tr>
</table>
ad_page_contract {
@author Peter Marklund
@creation-date 28 January 2003
@cvs-id $Id$
} {
version_id:integer,notnull
}
db_1row package_version_info "select pretty_name, version_name from apm_package_version_info where version_id = :version_id"
set page_title "Tcl Callbacks"
set context [list [list "." "Package Manager"] [list [export_vars -base version-view { version_id }] "$pretty_name $version_name"] $page_title]
set unused_callback_types [apm_unused_callback_types -version_id $version_id]
if { [llength $unused_callback_types] > 0 } {
set actions [list "Add callback" [export_vars -base "version-callback-add-edit" { version_id }]]
} else {
set actions [list]
}
template::list::create \
-name callbacks \
-multirow callbacks \
-actions $actions \
-elements {
edit {
label {}
sub_class narrow
display_template {
<img src="/resources/acs-subsite/Edit16.gif" width="16" height="16" border="0">
}
link_url_eval {[export_vars -base "version-callback-add-edit" { version_id type }]}
link_html { title "Edit callback" }
}
type {
label "Type"
}
proc {
label "Tcl Proc"
}
invoke {
label "Invoke"
display_template {<if @callbacks.type@ in "before-install" "after-install" "before-uninstall" "after-uninstall">Invoke</if><else><i style="color: gray;">N/A</i></else>}
link_url_eval {[ad_decode [lsearch { before-install after-install before-uninstall after-uninstall } $type] -1 {} [export_vars -base "version-callback-invoke" { version_id type }]]}
link_html { title "Invoke this callback proc now. Be careful!" }
html { align center }
}
delete {
label {}
sub_class narrow
display_template {
<img src="/resources/acs-subsite/Delete16.gif" width="16" height="16" border="0">
}
link_url_eval {[export_vars -base "version-callback-delete" { version_id type }]}
link_html { title "Delete callback" }
}
}
db_multirow callbacks get_all_callbacks {
select version_id,
type,
proc
from apm_package_callbacks
where version_id = :version_id
order by type
}
ad_return_template
<?xml version="1.0"?>
<queryset>
<rdbms><type>oracle</type><version>8.1.6</version></rdbms>
<fullquery name="apm_package_info_by_version_id">
<querytext>
select package_key, pretty_name, version_name, installed_p
from apm_package_version_info
where version_id = :version_id
</querytext>
</fullquery>
<fullquery name="apm_all_dependencies">
<querytext>
select dependency_id, service_uri, service_version
from apm_package_dependencies
where version_id = :version_id
and dependency_type = :dependency_type_prep
order by service_uri
</querytext>
</fullquery>
<fullquery name="apm_specific_version_dependencies">
<querytext>
select t.pretty_name dep_pretty_name, v.version_name dep_version_name, v.version_id dep_version_id
from apm_package_versions v, apm_package_dependencies d, apm_package_types t
where d.service_uri = :service_uri
and d.dependency_type = :other_dependency_type_prep
and d.version_id = v.version_id
and t.package_key = v.package_key
and apm_package_version.sortable_version_name(d.service_version) $sign apm_package_version.sortable_version_name(:service_version)
</querytext>
</fullquery>
</queryset>
<?xml version="1.0"?>
<queryset>
<rdbms><type>postgresql</type><version>7.1</version></rdbms>
<fullquery name="apm_package_info_by_version_id">
<querytext>
select package_key, pretty_name, version_name, installed_p
from apm_package_version_info
where version_id = :version_id
</querytext>
</fullquery>
<fullquery name="apm_all_dependencies">
<querytext>
select dependency_id, service_uri, service_version
from apm_package_dependencies
where version_id = :version_id
and dependency_type = :dependency_type_prep
order by service_uri
</querytext>
</fullquery>
<fullquery name="apm_specific_version_dependencies">
<querytext>
select t.pretty_name as dep_pretty_name, v.version_name as dep_version_name,
v.version_id as dep_version_id
from apm_package_versions v, apm_package_dependencies d, apm_package_types t
where d.service_uri = :service_uri
and d.dependency_type = :other_dependency_type_prep
and d.version_id = v.version_id
and t.package_key = v.package_key
and apm_package_version__sortable_version_name(d.service_version) $sign
apm_package_version__sortable_version_name(:service_version)
</querytext>
</fullquery>
</queryset>
ad_page_contract {
Views dependency information about a version.
@author Jon Salz [jsalz@arsdigita.com]
@creation-date 17 April 2000
@cvs-id $Id$
} {
{version_id:integer}
}
db_1row apm_package_info_by_version_id {
select package_key, pretty_name, version_name, installed_p
from apm_package_version_info
where version_id = :version_id
}
doc_body_append "[apm_header [list "version-view?version_id=$version_id" "$pretty_name $version_name"] "Dependencies"]
"
foreach dependency_type { provide require } {
set other_dependency_type [ad_decode $dependency_type "provide" "require" "provide"]
doc_body_append "<h3>Services [string totitle $dependency_type]d</h3><ul>\n"
set dependency_type_prep "${dependency_type}s"
db_foreach apm_all_dependencies {
select dependency_id, service_uri, service_version
from apm_package_dependencies
where version_id = :version_id
and dependency_type = :dependency_type_prep
order by service_uri
} {
doc_body_append "<li>[string totitle $dependency_type]s service $service_uri, version $service_version (<a href=\"version-dependency-remove?[export_url_vars dependency_id version_id dependency_type]\">remove</a>)\n"
# If this package provides a service, show a list of all packages that require it,
# or vice versa. If this package provides a service, show other packages requiring
# a *lower* version of the service; if it requires one, show packages providing
# a *higher* version.
set sign [ad_decode $dependency_type "provide" "<=" ">="]
set counter 0
set other_dependency_type_prep "${other_dependency_type}s"
db_foreach apm_specific_version_dependencies "
select t.pretty_name dep_pretty_name, v.version_name dep_version_name, v.version_id dep_version_id
from apm_package_versions v, apm_package_dependencies d, apm_package_types t
where d.service_uri = :service_uri
and d.dependency_type = :other_dependency_type_prep
and d.version_id = v.version_id
and t.package_key = v.package_key
and apm_package_version.sortable_version_name(d.service_version) $sign apm_package_version.sortable_version_name(:service_version)" {
incr counter
if { $counter == 1 } {
doc_body_append "<ul>\n"
}
doc_body_append "<li>[string totitle $other_dependency_type]d by <a href=\"version-view?version_id=$dep_version_id\">$dep_pretty_name, version $dep_version_name</a>\n"
}
if { $counter != 0 } {
doc_body_append "</ul>\n"
}
} else {
doc_body_append "<li>This package does not $dependency_type any services.\n"
}
if { $installed_p == "t" } {
doc_body_append "<li><a href=\"version-dependency-add?[export_url_vars version_id dependency_type]\">Add a service ${dependency_type}d by this package</a>\n"
}
doc_body_append "</ul>\n"
}
db_release_unused_handles
doc_body_append "
</ul>
[ad_footer]
"
<?xml version="1.0"?>
<queryset>
<fullquery name="apm_package_info_by_version_id">
<querytext>
select package_key, pretty_name, version_name, installed_p
from apm_package_version_info
where version_id = :version_id
</querytext>
</fullquery>
<fullquery name="apm_all_dependencies">
<querytext>
select dependency_id, service_uri, service_version
from apm_package_dependencies
where version_id = :version_id
and dependency_type = :dependency_type_prep
order by service_uri
</querytext>
</fullquery>
</queryset>
ad_page_contract {
Adds a dependency to a version of a package.
@author Bryan Quinn
@creation-date 17 April 2000
@cvs-id $Id$
} {
{dependency_id:naturalnum}
{version_id:integer}
dependency_type
service_uri
service_version
}
db_transaction {
switch $dependency_type {
require {
apm_dependency_add -dependency_id $dependency_id $version_id $service_uri $service_version
}
provide {
apm_interface_add -interface_id $dependency_id $version_id $service_uri $service_version
}
default {
ad_return_complaint 1 "Entry error: Depenendencies are either provided or required."
}
}
apm_package_install_spec $version_id
} on_error {
if { ![db_string apm_dependency_doubleclick_check {
select count(*) from apm_package_dependencies
where dependency_id = :dependency_id
} -default 0] } {
ad_return_complaint 1 "The database returned the following error:
<blockquote><pre>[ad_quotehtml $errmsg]</pre></blockquote>"
}
}
ad_returnredirect "version-dependencies?[export_url_vars version_id]"
<?xml version="1.0"?>
<queryset>
<fullquery name="apm_dependency_doubleclick_check">
<querytext>
select count(*) from apm_package_dependencies
where dependency_id = :dependency_id
</querytext>
</fullquery>
</queryset>
<?xml version="1.0"?>
<queryset>
<rdbms><type>oracle</type><version>8.1.6</version></rdbms>
<fullquery name="apm_all_service_uri">
<querytext>
select distinct service_uri, service_version
from apm_package_dependencies
order by service_uri, apm_package_version.sortable_version_name(service_version)
</querytext>
</fullquery>
</queryset>
<?xml version="1.0"?>
<queryset>
<rdbms><type>postgresql</type><version>7.1</version></rdbms>
<fullquery name="apm_all_service_uri">
<querytext>
select distinct service_uri, service_version,
apm_package_version__sortable_version_name(service_version)
from apm_package_dependencies
order by service_uri, apm_package_version__sortable_version_name(service_version)
</querytext>
</fullquery>
</queryset>
ad_page_contract {
Adds a dependency to a version of a package.
@author Jon Salz [jsalz@arsdigita.com]
@creation-date 17 April 2000
@cvs-id $Id$
} {
{version_id:integer}
dependency_type
}
db_1row apm_package_info_by_version_id_and_package {
select p.package_key, p.package_uri,
p.pretty_name, v.version_name
from apm_package_types p, apm_package_versions v
where v.version_id = :version_id
and v.package_key = p.package_key
}
set dependency_id [db_nextval acs_object_id_seq]
doc_body_append "[apm_header -form "action=version-dependency-add-2" [list "version-view?version_id=$version_id" "$pretty_name $version_name"] [list "version-dependencies?version_id=$version_id" "Dependencies"] "Add a Dependency"]
[export_form_vars version_id dependency_type dependency_id]
<script language=javascript>
// Invoked when the user selects a service from the select list.
function selectService(which) {
// Select the radio button next to the list of services.
var form = document.forms\[0\];
form.which\[0\].checked = 1;
// Fill in the text fields according to the service selected (the URL
// is before the semicolon; the version number is after it)
value = which.options\[which.selectedIndex\].value;
semi = value.indexOf(';');
form.service_uri.value = value.substring(0, semi);
form.service_version.value = value.substring(semi + 1);
}
</script>
<blockquote>
<table cellspacing=0 cellpadding=0>
<tr><td><input type=radio name=which value=service>&nbsp;</td><td>$pretty_name ${dependency_type}s the following service:</td></tr>
<tr><td></td><td>
<select name=service_select size=8 onChange=\"selectService(this)\">
"
db_foreach apm_all_service_uri {
select distinct service_uri, service_version
from apm_package_dependencies
order by service_uri, apm_package_version.sortable_version_name(service_version)
} {
doc_body_append "<option value=\"$service_uri;$service_version\">$service_uri, version $service_version\n"
}
db_release_unused_handles
doc_body_append "</select>
</td></tr>
<tr><td><input type=radio name=which value=other>&nbsp;</td><td>$pretty_name ${dependency_type}s the following other service:</td></tr>
<tr><td></td><td><input name=service_uri size=60 onFocus=\"form.which\[1\].checked = 1\">, version <input name=service_version size=10 onFocus=\"form.which\[1\].checked = 1\"></td></tr>
</table>
</blockquote>
<center>
<input type=submit value=\"Add Dependency\">
</center>
[ad_footer]
"
<?xml version="1.0"?>
<queryset>
<fullquery name="apm_package_info_by_version_id_and_package">
<querytext>
select p.package_key, p.package_uri,
p.pretty_name, v.version_name
from apm_package_types p, apm_package_versions v
where v.version_id = :version_id
and v.package_key = p.package_key
</querytext>
</fullquery>
</queryset>
ad_page_contract {
Adds a dependency to a version of a package.
@author Jon Salz (jsalz@arsdigita.com)
@creation-date 17 April 2000
@cvs-id $Id$
} {
{version_id:integer}
{dependency_id:integer}
dependency_type:notnull
}
db_transaction {
switch $dependency_type {
provide {
apm_dependency_remove $dependency_id
}
require {
apm_interface_remove $dependency_id
}
default {
ad_return complaint 1 "Dependency Entry Error: Depenendencies are either interfaces or requirements."
}
}
apm_package_install_spec $version_id
} on_error {
ad_return_complaint 1 "Database Error: The database returned the following error:
<blockquote><pre>[ad_quotehtml $errmsg]</pre></blockquote>"
}
ad_returnredirect "version-dependencies?[export_url_vars version_id]"
ad_page_contract {
Disables a version of a package.
@author Jon Salz [jsalz@arsdigita.com]
@creation-date 17 April 2000
@cvs-id $Id$
} {
version_id:integer
}
apm_version_disable -callback apm_dummy_callback $version_id
ad_returnredirect "version-view?version_id=$version_id"
ad_page_contract {
Edit a package version
@author Bryan Quinn (bquinn@arsdigita.com)
@creation-date 17 April 2000
@cvs-id $Id$
} {
version_id:naturalnum,notnull
version_name
version_uri
summary
description:html
{description_format ""}
{ owner_name:multiple}
{ owner_uri:multiple}
vendor
vendor_uri
{auto_mount ""}
{release_date ""}
{ upgrade_p 0 }
}
if {![regexp {^[0-9]+((\.[0-9]+)+((d|a|b|)[0-9]*)?)$} $version_name match]} {
ad_return_complaint 1 "The version name has invalid characters"
ad_script_abort
}
# Figure out if we're changing version
db_1row old_version_info {}
set version_changed_p [expr ![string equal $version_name $old_version_name]]
if { [string equal $old_version_name $version_name] } {
# The version name didn't change, so don't attempt to upgrade
set upgrade_p 0
}
# The user has to update the URL if he changes the name.
if { $version_changed_p && [string equal $version_uri $old_version_uri] } {
ad_return_complaint 1 {You have changed the version number but not the version URL. When creating
a package for a new version, you must select a new URL for the version.}
}
if { $upgrade_p && [db_string apm_version_uri_unique_ck {
select decode(count(*), 0, 0, 1) from apm_package_versions
where version_uri = :version_uri
} -default 0] } {
ad_return_complaint 1 "A version with the URL $version_uri already exists."
}
db_transaction {
set version_id [apm_version_update $version_id $version_name $version_uri \
$summary $description $description_format $vendor $vendor_uri $auto_mount $release_date]
apm_package_install_owners [apm_package_install_owners_prepare $owner_name $owner_uri] $version_id
apm_package_install_spec $version_id
if {$upgrade_p} {
apm_version_upgrade $version_id
# The package now provides the new version of itself as interface
db_dml update_version_provides {update apm_package_dependencies
set service_version = :version_name
where version_id = :version_id
and service_uri = (select package_key
from apm_package_versions
where version_id = :version_id)
and dependency_type = 'provides'}
}
} on_error {
ad_return_error "Error" "
I was unable to update your version for the following reason:
<blockquote><pre>[ns_quotehtml $errmsg]</pre></blockquote>
"
}
ad_returnredirect "version-generate-info?version_id=$version_id&write_p=1"
<?xml version="1.0"?>
<queryset>
<fullquery name="apm_version_uri_unique_ck">
<querytext>
select case when count(*) = 0 then 0 else 1 end from apm_package_versions
where version_uri = :version_uri
</querytext>
</fullquery>
<fullquery name="old_version_info">
<querytext>
select version_name as old_version_name, version_uri as old_version_uri
from apm_package_versions
where version_id = $version_id
</querytext>
</fullquery>
</queryset>
ad_page_contract {
Edits information for a version of a package.
@param version_id The id of the package to process.
@author Jon Salz (jsalz@arsdigita.com)
@author Bryan Quinn (bquinn@arsdigita.com)
@creation-date 9 May 2000
@cvs-id $Id$
} {
{version_id:integer}
}
db_1row apm_all_version_info {}
doc_body_append "[apm_header -form "action=\"version-edit-2\" method=post" [list "version-view?version_id=$version_id" "$pretty_name $version_name"] "Edit a Version"]
"
# If the version name is incorporated into the version URL (it will almost always be!)
# then generate some JavaScript to automatically update the version URL when the
# version name changes.
set version_name_index [string first $version_name $version_uri]
if { $version_name_index >= 0 } {
set version_uri_prefix [string range $version_uri 0 [expr { $version_name_index - 1 }]]
set version_uri_suffix [string range $version_uri [expr { $version_name_index + [string length $version_name] }] end]
doc_body_append "
<script language=javascript>
function updateVersionURL() {
var form = document.forms\[0\];
form.version_uri.value = '$version_uri_prefix' + form.version_name.value + '$version_uri_suffix';
}
</script>
"
set version_name_on_change "onChange=\"updateVersionURL()\""
} else {
set version_name_on_change ""
}
doc_body_append "
<script language=javascript>
function checkMailto(element) {
// If it looks like an email address without a mailto: (contains an @ but
// no colon) then prepend 'mailto:'.
if (element.value.indexOf('@') >= 0 && element.value.indexOf(':') < 0)
element.value = 'mailto:' + element.value;
}
</script>
[export_form_vars version_id release_date]
<table>
<tr>
<th align=right nowrap>Package Key:</th>
<td><tt>$package_key</tt></td>
</tr>
<tr>
<th align=right nowrap>Package URL:</th>
<td>$package_uri</td>
</tr>
<tr>
<th align=right nowrap>Package Name:</th>
<td>$pretty_name</td>
</tr>
<tr>
<th align=right nowrap>OpenACS Core:</th>
<td>$initial_install_p</td>
</tr>
<tr>
<th align=right nowrap>Singleton:</th>
<td>$singleton_p</td>
</tr>
<tr>
<th align=right nowrap>Auto-mount:</th>
<td><input name=auto_mount size=30 value=\"$auto_mount\" /></td>
</tr>
<tr>
<td></td>
<td>To create a new version of the package, type a new version number and
update the version URL accordingly. Leave the version name and URL alone to
edit the information regarding existing version of the package.</td>
</tr>
<tr>
<th align=right nowrap>Version:</th>
<td><input name=version_name size=10 value=\"$version_name\" $version_name_on_change>
</td>
</tr>
<tr>
<th align=right nowrap>Version URL:</th>
<td><input name=version_uri size=60 value=\"$version_uri\"></td>
</tr>
<tr valign=top>
<th align=right><br>Summary:</th>
<td><textarea name=summary cols=60 rows=2 wrap=soft>[ns_quotehtml $summary]</textarea></td>
</tr>
<tr valign=top>
<th align=right><br>Description:</th>
<td><textarea name=description cols=60 rows=5 wrap=soft>[ns_quotehtml $description]</textarea><br>
This description is <select name=description_format>
<option value=text/html [ad_decode $description_format "text/plain" "" "selected"]>HTML-formatted.
<option value=text/plain [ad_decode $description_format "text/plain" "selected" ""]>plain text.
</select>
</td>
</tr>
"
# Build a list of owners. Ensure that there are at least two.
set owners [db_list_of_lists apm_all_owners {
select owner_name, owner_uri from apm_package_owners where version_id = :version_id
}]
if { [llength $owners] == 0 } {
set owners [list [list "" ""]]
}
# Add an extra one, so an arbitrary number of owners can be assigned to the package.
lappend owners [list "" ""]
set counter 0
foreach owner_info $owners {
set owner_name [lindex $owner_info 0]
set owner_uri [lindex $owner_info 1]
incr counter
if { $counter <= 3 } {
set prompt "[lindex { "" Primary Secondary Tertiary } $counter] Owner"
} else {
set prompt "Owner #$counter"
}
doc_body_append "
<tr>
<th align=right nowrap>$prompt:</th>
<td><input name=owner_name size=30 value=\"$owner_name\"></td>
</tr>
<tr>
<th align=right nowrap>$prompt URL:</th>
<td><input name=owner_uri size=30 value=\"$owner_uri\" onChange=\"checkMailto(this)\"></td>
</tr>
"
}
doc_body_append "
<tr>
<th align=right nowrap>Vendor:</th>
<td><input name=vendor size=30 value=\"$vendor\"></td>
</tr>
<tr>
<th align=right nowrap>Vendor URL:</th>
<td><input name=vendor_uri size=60 value=\"$vendor_uri\"></td>
</tr>
"
doc_body_append "
<tr>
<td></td>
<td>
<table><tr valign=baseline><td><input type=checkbox name=upgrade_p value=1 checked></td><td>
Upgrade the local package $pretty_name to this version and supersede older versions.
</td></tr></table>
</td>
</tr>
<tr>
<td colspan=2 align=center><br>
<input type=submit value=\"Save Information\">
</td>
</tr>
</table>
</form>
[ad_footer]
"
<?xml version="1.0"?>
<queryset>
<fullquery name="apm_all_version_info">
<querytext>
select version_id, package_key, package_uri, pretty_name, version_name, version_uri, auto_mount,
summary, description_format, description, release_date, vendor, vendor_uri,
enabled_p, installed_p, tagged_p, imported_p, data_model_loaded_p, activation_date, tarball_length,
deactivation_date, distribution_uri, distribution_date, singleton_p, initial_install_p
from apm_package_version_info where version_id = :version_id
</querytext>
</fullquery>
<fullquery name="apm_all_owners">
<querytext>
select owner_name, owner_uri from apm_package_owners where version_id = :version_id
</querytext>
</fullquery>
</queryset>
ad_page_contract {
Enables a version of the package.
@param version_id The package to be processed.
@author Jon Salz [jsalz@arsdigita.com]
@creation-date 9 May 2000
@cvs-id $Id$
} {
{version_id:integer}
}
apm_version_enable -callback apm_dummy_callback $version_id
ad_returnredirect "version-view?version_id=$version_id"
<master>
<property name="title">@page_title;noquote@</property>
<property name="context">@context;noquote@</property>
@body;noquote@
This diff is collapsed.
<?xml version="1.0"?>
<queryset>
<fullquery name="apm_package_info">
<querytext>
select p.package_key, p.package_url, v.package_name, v.version_name, v.package_id
from apm_packages p, apm_package_versions v
where v.version_id = :version_id
and v.package_id = p.package_id
</querytext>
</fullquery>
</queryset>
ad_page_contract {
Generates diffs for a version of a package.
@param version_id The package to be processed.
@param context_p Set to 0 if you don't want the diffs to be listed with context.
@author Jon Salz [jsalz@arsdigita.com]
@creation-date 9 May 2000
@cvs-id $Id$
} {
{version_id:integer}
{context_p 1}
}
db_1row apm_package_by_version_id {
select package_name, version_name, package_id from apm_package_version_info where version_id = :version_id
}
set analyze_dir [ns_mktemp "[acs_root_dir]/apm-workspace/diffs-XXXXXX"]
doc_body_append "[apm_header "Create Diffs for $package_name $version_name"]
<ul><li>Extracting the archive into $analyze_dir...<li>
"
doc_body_flush
apm_extract_tarball $version_id $analyze_dir
doc_body_append "Analyzing files...</ul>\n"
doc_body_flush
set no_changes [list]
global errorCode
foreach file [apm_version_file_list $version_id] {
if { ![file isfile "[acs_root_dir]/$file"] } {
doc_body_append "<h3>$file</h3>\n<blockquote>This file has been locally added.</blockquote>\n"
continue
}
if { ![file isfile "$analyze_dir/$file"] } {
doc_body_append "<h3>$file</h3>\n<blockquote>This file has been locally removed.</blockquote>\n"
continue
}
set cmd [list exec /usr/bin/diff]
if { $context_p } {
lappend cmd "-c"
}
lappend cmd "[acs_root_dir]/$file" $analyze_dir/$file
set errno [catch $cmd diffs]
if { $errno == 0 } {
lappend no_changes $file
} else {
set status [lindex $errorCode 2]
if { $status == 1 } {
regsub {child process exited abnormally$} $diffs "" diffs
doc_body_append "<h3>$file</h3>\n<blockquote><pre>[ns_quotehtml $diffs]</pre></blockquote>\n"
} else {
doc_body_append "<h3>$file</h3>\n<blockquote><pre>$diffs</pre></blockquote>\n"
}
}
doc_body_flush
}
if { [llength $no_changes] > 0 } {
doc_body_append "<h3>No changes to:</h3><ul><li>[join $no_changes "\n<li>"]</ul>\n"
}
doc_body_append [ad_footer]
<?xml version="1.0"?>
<queryset>
<fullquery name="apm_package_by_version_id">
<querytext>
select package_name, version_name, package_id from apm_package_version_info where version_id = :version_id
</querytext>
</fullquery>
</queryset>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment