• Publicity: Public Only All

xowiki-callback-procs.tcl

XoWiki - Callback procs

Location:
packages/xowiki/tcl/xowiki-callback-procs.tcl
Created:
2006-08-08
Author:
Gustaf Neumann
CVS Identification:
$Id: xowiki-callback-procs.tcl,v 1.78.2.8 2022/06/22 17:48:38 gustafn Exp $

Procedures in this file

Detailed information

xowiki::before-uninstantiate (public)

 xowiki::before-uninstantiate -package_id package_id

Callback to be called whenever a package instance is deleted.

Switches:
-package_id
(required)
Author:
Gustaf Neumann

Partial Call Graph (max 5 caller/called nodes):
%3 test_xowiki_test_cases xowiki_test_cases (test xowiki) xowiki::before-uninstantiate xowiki::before-uninstantiate test_xowiki_test_cases->xowiki::before-uninstantiate apm_instance_name_from_id apm_instance_name_from_id (public) xowiki::before-uninstantiate->apm_instance_name_from_id general_comments_delete_messages general_comments_delete_messages (public) xowiki::before-uninstantiate->general_comments_delete_messages

Testcases:
xowiki_test_cases
[ hide source ] | [ make this the default ]

Content File Source

::xo::library doc {
  XoWiki - Callback procs

  @creation-date 2006-08-08
  @author Gustaf Neumann
  @cvs-id $Id: xowiki-callback-procs.tcl,v 1.78.2.8 2022/06/22 17:48:38 gustafn Exp $
}

namespace eval ::xowiki {

  ad_proc -private ::xowiki::after-install {} {
    ::xowiki::sc::register_implementations
    ::xowiki::notifications-install
  }

  ad_proc -private ::xowiki::before-uninstall {} {
    ns_log notice "Executing ::xowiki::before-uninstall"
    ::xowiki::sc::unregister_implementations
    ::xowiki::notifications-uninstall

    # Unregister all types from all folders
    ::xowiki::Page folder_type_unregister_all

    # Delete object types
    foreach type [::xowiki::Page object_types -subtypes_first true] {
      ::xo::db::sql::content_type drop_type -content_type $type \
          -drop_children_p t -drop_table_p t -drop_objects_p t
    }
  }

  d_proc -public ::xowiki::before-uninstantiate {
    {-package_id:required}
  } {
    Callback to be called whenever a package instance is deleted.

    @author Gustaf Neumann
  } {
    ns_log notice "Executing before-uninstantiate"
    # Delete the messages of general comments to allow one to
    # uninstantiate the package without violating constraints.
    general_comments_delete_messages -package_id $package_id
    set root_folder_id [::xo::db::CrClass lookup -name "xowiki: $package_id" -parent_id -100]
    if {$root_folder_id ne "0"} {

      # we deal with a correctly installed package
      if {[::xo::dc 0or1row is_transformed_folder {
        select 1 from cr_folders where folder_id = :root_folder_id}
          ]} {
        ::xo::db::sql::content_folder delete -folder_id $root_folder_id -cascade_p 1
      } else {
        ::xo::db::sql::content_item delete -item_id $root_folder_id
      }
    }

    set instance_name [apm_instance_name_from_id $package_id]

    ::xo::xotcl_package_cache flush package_id-$instance_name
    ::xo::xotcl_package_cache flush package_key-$package_id
    ::xo::xotcl_package_cache flush root_folder-$package_id
    ::xo::xotcl_object_type_cache flush -partition_key -100 -100-$instance_name

    ns_log notice "before-uninstantiate DONE"
  }

  #
  # upgrade logic
  #

  d_proc -private ::xowiki::upgrade_callback {
    {-from_version_name:required}
    {-to_version_name:required}
  } {

    Callback for upgrading

    @author Gustaf Neumann (neumann@wu-wien.ac.at)
  } {
    ns_log notice "-- UPGRADE $from_version_name -> $to_version_name"

    set upgrade_file $::acs::rootdir/packages/xowiki/tcl/upgrade/upgrade.tcl
    #
    # The upgrade file contains the upgrade proc of the following form:
    #
    #   proc __upgrade {from_version_name to_version_name} {...}
    #
    source $upgrade_file
    __upgrade $from_version_name $to_version_name

    # The upgrade is done, there is no need to keep this proc in
    # memory around, so we can delete it.
    rename __upgrade ""
  }

  d_proc -public -callback subsite::parameter_changed -impl xowiki {
    -package_id:required
    -parameter:required
    -value:required
  } {
    Implementation of subsite::parameter_changed for xowiki parameters.

    @param package_id the package_id of the package the parameter was changed for
    @param parameter  the parameter name
    @param value      the new value
  } {
    if {[::xowiki::Package is_xowiki_p $package_id]} {
      if {$parameter eq "use_hstore" && $value eq 1} {
        # hstore has been activated: make sure instance attributes are
        # persisted in there
        ::xowiki::hstore::update_hstore $package_id
      }
    }
  }

}
::xo::library source_dependent

#
# Local variables:
#    mode: tcl
#    tcl-indent-level: 2
#    indent-tabs-mode: nil
# End: