subsite::default::create_app_group (public)

 subsite::default::create_app_group [ -package_id package_id ] \
    [ -name name ]

Defined in packages/acs-subsite/tcl/subsite-procs.tcl

Create the default application group for a subsite.

  • Create application group
  • Create segment "Subsite Users"
  • Create relational constraint to make subsite registration require supersite registration.

Switches:
-package_id (optional)
-name (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 subsite::after_mount subsite::after_mount (private) subsite::default::create_app_group subsite::default::create_app_group subsite::after_mount->subsite::default::create_app_group ad_conn ad_conn (public) subsite::default::create_app_group->ad_conn application_group::group_id_from_package_id application_group::group_id_from_package_id (public) subsite::default::create_app_group->application_group::group_id_from_package_id application_group::new application_group::new (public) subsite::default::create_app_group->application_group::new db_exec_plsql db_exec_plsql (public) subsite::default::create_app_group->db_exec_plsql db_transaction db_transaction (public) subsite::default::create_app_group->db_transaction

Testcases:
No testcase defined.
Source code:
    if { [application_group::group_id_from_package_id -no_complain -package_id $package_id] eq "" } {
        set node_info [site_node::get_from_object_id -object_id $package_id]
        set node_id [dict get $node_info node_id]

        if { $name eq "" } {
            set subsite_name [dict get $node_info instance_name]
        } else {
            set subsite_name $name
        }
        set subsite_name_30 [string range $subsite_name 0 30]
        set subsite_name_89 [string range $subsite_name 0 89]

        db_transaction {

            # Create subsite application group
            set group_name "$subsite_name_89"
            set subsite_group_id [application_group::new  -package_id $package_id  -group_name $group_name]

            # Create segment of registered users
            set segment_name "$subsite_name_89 Members"
            set segment_id [rel_segment::new $subsite_group_id membership_rel $segment_name]

            # Create a constraint that says "to be a member of this subsite you must be a member
            # of the parent subsite.
            set subsite_id [site_node::closest_ancestor_package  -node_id $node_id  -package_key [subsite::package_keys]]
            set subsite [subsite::get -subsite_id $subsite_id]
            set supersite_group_id [application_group::group_id_from_package_id  -package_id $subsite_id]
            set supersite_name_30 [string range [dict get $subsite instance_name] 0 30]

            set constraint_name "Members of $subsite_name_30 must be members of $supersite_name_30"
            set user_id [ad_conn user_id]
            set creation_ip [ad_conn peeraddr]
            db_exec_plsql add_constraint {}

            # Create segment of registered users for administrators
            set segment_name "$subsite_name_89 Administrators"
            set admin_segment_id [rel_segment::new $subsite_group_id admin_rel $segment_name]

            # Grant admin privileges to the admin segment
            permission::grant  -party_id $admin_segment_id  -object_id $package_id  -privilege admin

            # Grant read/write/create privileges to the member segment
            foreach privilege { read create write } {
                permission::grant  -party_id $segment_id  -object_id $package_id  -privilege $privilege
            }

        }
    }
XQL Not present:
Generic
PostgreSQL XQL file:
<fullquery name="subsite::default::create_app_group.add_constraint">
    <querytext>

	select rel_constraint__new(
	  null,
	  'rel_constraint',
	  :constraint_name,
	  :segment_id,
	  'two',
	  rel_segment__get(:supersite_group_id, 'membership_rel'),
	  null,
	  :user_id,
	  :creation_ip
	);

      </querytext>
</fullquery>
packages/acs-subsite/tcl/subsite-procs-postgresql.xql

Oracle XQL file:
<fullquery name="subsite::default::create_app_group.add_constraint">
    <querytext>

		    BEGIN
			:1 := rel_constraint.new(
			constraint_name => :constraint_name,
			rel_segment => :segment_id,
			rel_side => 'two',
			required_rel_segment => rel_segment.get(:supersite_group_id, 'membership_rel'),
			creation_user => :user_id,
			creation_ip => :creation_ip
			);
		    END;

      </querytext>
</fullquery>
packages/acs-subsite/tcl/subsite-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: