subscriptions_og_group_subscriptions_form() is showing only subscribers who are members
gustav - April 6, 2008 - 21:41
| Project: | Organic Groups Subscriptions |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
The documentation (and the specifications) says "Gives the subscription controls for each member and each currently subscribed user." but it only gives each member, not all currently subscribed users.
I now realise that it may be a bit tricky to write an sql query to get both members and subscribers. Have you tried?

#1
Oh! sorry, I'd don't taken enough attention to specs, I'm going to review and suggest a fix.
Blessings!
#2
@gustav, current implementation is:
<?php
function subscriptions_og_group_subscriptions_form($group) {
$group_nid = $group->nid;
$query = og_list_users_sql(0, 0, 'ou.is_admin DESC, ou.is_active ASC, u.name ASC');
$rs = pager_query($query, 50, 0, NULL, $group_nid);
$form = array();
$count = array();
while ($row = db_fetch_object($rs)) {
$account = user_load(array('uid' => $row->uid));
$form[] = subscriptions_og_group_member_form($account, $group, count($form));
}
$form['count'] = array(
'#type' => 'value',
'#value' => count($form),
);
$form['#submit']['subscriptions_og_group_subscriptions_form_submit'] = array();
return $form;
}
?>
Certainly, og_list_users_sql() is a friendly way to query users. Now, about performance and code readability, I suggest solution #1;
<?php
function subscriptions_og_group_subscriptions_form($group) {
$group_nid = $group->nid;
$query = "
SELECT
u.uid, u.name, coalesce(ou.is_admin, 0) is_admin,
coalesce(ou.is_active, 0) is_active
FROM
{og_uid} ou INNER JOIN
{users} u ON
ou.uid = u.uid
WHERE
ou.nid = %d AND
u.status > 0 AND
ou.is_active >= 0 AND
ou.is_admin >= 0
UNION
SELECT
u.uid, u.name, coalesce(ou.is_admin, 0) is_admin,
coalesce(ou.is_active, 0) is_active
FROM
{subscriptions} s INNER JOIN
{users} u ON
s.recipient_uid = u.uid LEFT JOIN
{og_uid} ou ON
ou.uid = u.uid
WHERE
s.field = 'group_nid' AND
s.value = %d AND
u.status > 0
GROUP BY uid
ORDER BY
is_admin DESC,
is_active ASC,
name ASC
";
$rs = pager_query($query, 50, 0, NULL, $group_nid);
.....
?>
But that is too long in my opinion, so I suggest solution #2: Create sub-tabs, one for og members and another for all subscribed users, but may cause confusion :/
Some another ideas?
Blessings!
#3
Created new sub-tab for only subscribed but not members.
Blessings!
#4
DevelCuy, thanks for implementing this.
#5
Automatically closed -- issue fixed for two weeks with no activity.