i am trying to build a listtemplate with all the groups created in the
system.
##################################
template::list::create \
-name groups \
-multirow groups \
-key group_id \
-elements {
group_name {
label { Group Name }
display_template {
href="../groups/one?group_id=@groups.group_id@">@groups.group_name@
}
}
group_id {
label { ID }
display_col group_id
}
member_count {
label { \# Members }
display_col member_count
}
}
###########################
which has this complicated db_multirow
is there a way to simplify it?
i searched on api-doc but i didn't find any API that matches with what i
need.
Plus other samples of code i saw returns more results such as "registred
users" and non desired groups.
################################
db_multirow -extend { member_count } groups select_groups {
select DISTINCT g.group_id as member_count, g.group_name
from (select group_id, group_name
from groups g, acs_objects o
where g.group_id = o.object_id
and o.object_type = :group_type) g,
(select object_id
from all_object_party_privilege_map
where party_id = :user_id and privilege = 'read') perm,
application_group_element_map m
where perm.object_id = g.group_id
and m.package_id = :package_id
and m.element_id = g.group_id
order by lower(g.group_name)
} {
set member_count [llength [group::get_members $group_id]]
}
################################
things even get worst when i try to count how many members exist in each
group. That API doesn't return the correct quantity. I debugged it and
saw that it returns only results cached
So i went to the file
/packages/acs-subsite/www/admin/groups/element-by-rel-type that has an
include call to the page:
/packages/acs-subsite/www/admin/groups/element-display-list, (which
shows group's features including its members).
then I look how the members from the respective group is retrieved.
To retieve them it uses this db_multirow
###################################
db_multirow rels relations_query "
select r.rel_id,
party_names.party_name as element_name
from (select /*+ ORDERED */ DISTINCT rels.rel_id, object_id_two
from $extra_tables acs_rels rels, all_object_party_privilege_map perm
where perm.object_id = rels.rel_id
and perm.party_id = :user_id
and perm.privilege = 'read'
and rels.rel_type = :rel_type
and rels.object_id_one = :group_id $extra_where_clauses) r,
party_names
where r.object_id_two = party_names.party_id
order by lower(element_name)
"
############################
this code has some filters and relations to another vars set among the
pages, and it would turn into a very complicated way to simply get
members from groups.
is there a simpler way to get members from a group?
My intuition is that there's a much simpler way to build this multirow,
however i am just blind at it because i am focused on those complicated queries.
best,