Index: openacs-4/packages/acs-tcl/tcl/acs-kernel-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/acs-kernel-procs.tcl,v diff -u -r1.10.2.1 -r1.10.2.2 --- openacs-4/packages/acs-tcl/tcl/acs-kernel-procs.tcl 10 Sep 2015 08:21:55 -0000 1.10.2.1 +++ openacs-4/packages/acs-tcl/tcl/acs-kernel-procs.tcl 5 Jul 2016 16:35:23 -0000 1.10.2.2 @@ -10,10 +10,47 @@ @return 1 if a user with admin privileges exists, 0 otherwise. } { - return [db_string admin_exists_p {} -default 0] + ad_acs_require_basic_schemata + + return [db_string admin_exists_p { + select 1 as admin_exists_p + from dual + where exists ( + select 1 + from acs_permissions p, + party_approved_member_map m, + users u, + acs_magic_objects amo + where amo.name = 'security_context_root' + and p.object_id = amo.object_id + and p.grantee_id = m.party_id + and u.user_id = m.member_id + and acs_permission.permission_p(amo.object_id, u.user_id, 'admin') + ) + } -default 0] } +ad_proc -private ad_acs_require_basic_schemata {} { + This is a transitional code to ensure that the SQL schemata + required for botostrapping (i.e. before the upgrade script) are + already installed. + +} { + set schema_name "acs_permission" + if {![db_string has_schema {}]} { + set kernelSqlDir "$::acs::rootdir/packages/acs-kernel/sql/[db_driverkey {}]/upgrade" + set files "upgrade-5.9.1d10-5.9.1d11.sql" + foreach file $files { + set fn $kernelSqlDir/$file + if {[file readable $fn]} { + ns_log notice "bootstrap: upgrading sql file $fn" + db_source_sql_file -callback apm_dummy_callback $fn + } + } + } +} + ad_proc -public ad_acs_admin_node {} { @return The node id of the ACS administration service if it is mounted, 0 otherwise.