Index: openacs-4/packages/acs-admin/www/apm/parameter-add-2.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/parameter-add-2.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-admin/www/apm/parameter-add-2.xql 28 Apr 2001 17:35:30 -0000 1.2
+++ openacs-4/packages/acs-admin/www/apm/parameter-add-2.xql 23 Feb 2002 02:43:45 -0000 1.3
@@ -5,8 +5,8 @@
select case when count(*) = 0 then 0 else 1 end
from apm_parameters
- where parameter_name = :parameter_name
-
+ where parameter_name = :parameter_name and
+ package_key = :package_key
Index: openacs-4/packages/acs-kernel/sql/oracle/groups-body-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/groups-body-create.sql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-kernel/sql/oracle/groups-body-create.sql 11 Aug 2001 21:31:03 -0000 1.2
+++ openacs-4/packages/acs-kernel/sql/oracle/groups-body-create.sql 23 Feb 2002 02:43:45 -0000 1.3
@@ -698,13 +698,41 @@
end name;
function member_p (
- party_id in parties.party_id%TYPE
+ party_id in parties.party_id%TYPE,
+ group_id in groups.group_id%TYPE,
+ cascade_membership char
)
return char
is
+ m_result integer;
begin
- -- TO DO: implement this for real
- return 't';
+
+ if cascade_membership = 't' then
+ select count(*)
+ into m_result
+ from group_member_map
+ where group_id = member_p.group_id and
+ member_id = member_p.party_id;
+
+ if m_result > 0 then
+ return 't';
+ end if;
+ else
+ select count(*)
+ into m_result
+ from acs_rels rels, all_object_party_privilege_map perm
+ where perm.object_id = rels.rel_id
+ and perm.privilege = 'read'
+ and rels.rel_type = 'membership_rel'
+ and rels.object_id_one = member_p.group_id
+ and rels.object_id_two = member_p.party_id;
+
+ if m_result > 0 then
+ return 't';
+ end if;
+ end if;
+
+ return 'f';
end member_p;
function check_representation (
Index: openacs-4/packages/acs-kernel/sql/oracle/groups-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/groups-create.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-kernel/sql/oracle/groups-create.sql 20 Mar 2001 22:51:55 -0000 1.1
+++ openacs-4/packages/acs-kernel/sql/oracle/groups-create.sql 23 Feb 2002 02:43:45 -0000 1.2
@@ -471,7 +471,9 @@
) return varchar2;
function member_p (
- party_id in parties.party_id%TYPE
+ party_id in parties.party_id%TYPE,
+ group_id in groups.group_id%TYPE,
+ cascade_membership char
) return char;
function check_representation (
Index: openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql,v
diff -u -r1.14 -r1.15
--- openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql 29 Dec 2001 02:13:11 -0000 1.14
+++ openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql 23 Feb 2002 02:43:45 -0000 1.15
@@ -837,16 +837,27 @@
end;' language 'plpgsql';
-
--- function member_p
-create function acs_group__member_p (integer)
+create function acs_group__member_p (integer, integer, boolean)
returns boolean as '
declare
- party_id alias for $1;
+ p_party_id alias for $1;
+ p_group_id alias for $2;
+ p_cascade_membership alias for $3;
begin
- -- TO DO: implement this for real
- return ''t'';
-
+ if p_cascade_membership then
+ return count(*) > 0
+ from group_member_map
+ where group_id = p_group_id and
+ member_id = p_party_id;
+ else
+ return count(*) > 0
+ from acs_rels rels, all_object_party_privilege_map perm
+ where perm.object_id = rels.rel_id
+ and perm.privilege = ''read''
+ and rels.rel_type = ''membership_rel''
+ and rels.object_id_one = p_group_id
+ and rels.object_id_two = p_party_id;
+ end if;
end;' language 'plpgsql';
Index: openacs-4/packages/acs-kernel/sql/postgresql/groups-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/groups-create.sql,v
diff -u -r1.9 -r1.10
--- openacs-4/packages/acs-kernel/sql/postgresql/groups-create.sql 20 Aug 2001 21:52:31 -0000 1.9
+++ openacs-4/packages/acs-kernel/sql/postgresql/groups-create.sql 23 Feb 2002 02:43:45 -0000 1.10
@@ -412,123 +412,3 @@
(group_rel_type_id, rel_type, group_type)
values
(acs_object_id_seq.nextval, 'composition_rel', 'group');
-
-
---------------
--- PACKAGES --
---------------
-
--- create or replace package composition_rel
--- as
---
--- function new (
--- rel_id in composition_rels.rel_id%TYPE default null,
--- rel_type in acs_rels.rel_type%TYPE default 'composition_rel',
--- object_id_one in acs_rels.object_id_one%TYPE,
--- object_id_two in acs_rels.object_id_two%TYPE,
--- creation_user in acs_objects.creation_user%TYPE default null,
--- creation_ip in acs_objects.creation_ip%TYPE default null
--- ) return composition_rels.rel_id%TYPE;
---
--- procedure delete (
--- rel_id in composition_rels.rel_id%TYPE
--- );
---
--- function check_path_exists_p (
--- component_id in groups.group_id%TYPE,
--- container_id in groups.group_id%TYPE
--- ) return char;
---
--- function check_representation (
--- rel_id in composition_rels.rel_id%TYPE
--- ) return char;
---
--- end composition_rel;
-
--- show errors
-
-
--- create or replace package membership_rel
--- as
---
--- function new (
--- rel_id in membership_rels.rel_id%TYPE default null,
--- rel_type in acs_rels.rel_type%TYPE default 'membership_rel',
--- object_id_one in acs_rels.object_id_one%TYPE,
--- object_id_two in acs_rels.object_id_two%TYPE,
--- member_state in membership_rels.member_state%TYPE default 'approved',
--- creation_user in acs_objects.creation_user%TYPE default null,
--- creation_ip in acs_objects.creation_ip%TYPE default null
--- ) return membership_rels.rel_id%TYPE;
---
--- procedure ban (
--- rel_id in membership_rels.rel_id%TYPE
--- );
---
--- procedure approve (
--- rel_id in membership_rels.rel_id%TYPE
--- );
---
--- procedure reject (
--- rel_id in membership_rels.rel_id%TYPE
--- );
---
--- procedure unapprove (
--- rel_id in membership_rels.rel_id%TYPE
--- );
---
--- procedure deleted (
--- rel_id in membership_rels.rel_id%TYPE
--- );
---
--- procedure delete (
--- rel_id in membership_rels.rel_id%TYPE
--- );
---
--- function check_representation (
--- rel_id in membership_rels.rel_id%TYPE
--- ) return char;
---
--- end membership_rel;
-
--- show errors
-
-
--- create or replace package acs_group
--- is
--- function new (
--- group_id in groups.group_id%TYPE default null,
--- object_type in acs_objects.object_type%TYPE
--- default 'group',
--- creation_date in acs_objects.creation_date%TYPE
--- default sysdate,
--- creation_user in acs_objects.creation_user%TYPE
--- default null,
--- creation_ip in acs_objects.creation_ip%TYPE default null,
--- email in parties.email%TYPE default null,
--- url in parties.url%TYPE default null,
--- group_name in groups.group_name%TYPE,
--- join_policy in groups.join_policy%TYPE default null,
--- context_id in acs_objects.context_id%TYPE default null
--- ) return groups.group_id%TYPE;
---
--- procedure delete (
--- group_id in groups.group_id%TYPE
--- );
---
--- function name (
--- group_id in groups.group_id%TYPE
--- ) return varchar2;
---
--- function member_p (
--- party_id in parties.party_id%TYPE
--- ) return char;
---
--- function check_representation (
--- group_id in groups.group_id%TYPE
--- ) return char;
---
--- end acs_group;
-
--- show errors
-
Index: openacs-4/packages/acs-subsite/tcl/group-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/group-procs-oracle.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-subsite/tcl/group-procs-oracle.xql 23 Aug 2001 21:09:23 -0000 1.2
+++ openacs-4/packages/acs-subsite/tcl/group-procs-oracle.xql 23 Feb 2002 02:43:45 -0000 1.3
@@ -27,5 +27,11 @@
+
+
+ select acs_group.member_p(:user_id,:group_id, :cascade) from dual
+
+
+
Index: openacs-4/packages/acs-subsite/tcl/group-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/group-procs-postgresql.xql,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/acs-subsite/tcl/group-procs-postgresql.xql 23 Aug 2001 21:09:23 -0000 1.4
+++ openacs-4/packages/acs-subsite/tcl/group-procs-postgresql.xql 23 Feb 2002 02:43:45 -0000 1.5
@@ -30,5 +30,11 @@
+
+
+ select acs_group__member_p(:user_id,:group_id, :cascade) from dual
+
+
+
Index: openacs-4/packages/acs-subsite/tcl/group-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/group-procs.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-subsite/tcl/group-procs.tcl 13 Mar 2001 22:59:26 -0000 1.1
+++ openacs-4/packages/acs-subsite/tcl/group-procs.tcl 23 Feb 2002 02:43:45 -0000 1.2
@@ -253,4 +253,55 @@
return ""
}
+
+
+ ad_proc -public member_p {
+ { -user_id "" }
+ { -group_name "" }
+ { -group_id "" }
+ -cascade:boolean
+ } {
+ Return 1 if the user is a member of the group specified.
+ You can specify a group name or group id.
+ If cascade is true, check to see if the user is
+ a member of the group by virtue of any other component group.
+ (e.g. if group B is a component of group A then if a user
+ is a member of group B then he is automatically a member of A
+ also.)
+ If cascade is false, then the user must have specifically
+ been granted membership on the group in question.
+ } {
+
+ if {[empty_string_p $user_id]} {
+ set user_id [ad_verify_and_get_user_id]
+ }
+
+ if {[empty_string_p $group_name] && [empty_string_p $group_id]} {
+ return 0
+ }
+
+ if {$cascade_p} {
+ set cascade 'f'
+ } else {
+ set cascade 't'
+ }
+
+
+ if {![empty_string_p $group_name]} {
+ set group_id [db_string group_id_from_name "
+ select group_id from groups where group_name=:group_name" -default ""]
+ if {[empty_string_p $group_id]} {
+ return 0
+ }
+ }
+
+ set result [db_string user_is_member "
+ select acs_group.member_p(:user_id,:group_id, :cascade)
+ from dual" -default "f"]
+
+ if { [string equal $result "f"] } { return 0 }
+ if { [string equal $result "t"] } { return 1 }
}
+}
+
+
Index: openacs-4/packages/acs-subsite/tcl/group-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/Attic/group-procs.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-subsite/tcl/group-procs.xql 6 May 2001 21:40:21 -0000 1.1
+++ openacs-4/packages/acs-subsite/tcl/group-procs.xql 23 Feb 2002 02:43:45 -0000 1.2
@@ -31,5 +31,11 @@
+
+
+ select group_id from groups where group_name=:group_name
+
+
+
Index: openacs-4/packages/clickthrough/tcl/clickthrough-init.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/clickthrough/tcl/clickthrough-init.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/clickthrough/tcl/clickthrough-init.tcl 2 Feb 2002 22:17:28 -0000 1.4
+++ openacs-4/packages/clickthrough/tcl/clickthrough-init.tcl 23 Feb 2002 02:43:45 -0000 1.5
@@ -15,6 +15,9 @@
nsv_set clickthrough_mutex mutex [ns_mutex create]
# schedule cache sweeper to run every X seconds
- ad_schedule_proc [ad_parameter -package_id [apm_package_id_from_key clickthrough] CacheSweeperInterval] clickthrough_cache_sweeper
+ # if a clickthrough application has been created.
+ if { [apm_package_id_from_key clickthrough] != 0 } {
+ ad_schedule_proc [ad_parameter -package_id [apm_package_id_from_key clickthrough] CacheSweeperInterval] clickthrough_cache_sweeper
+ }
}