function subscriptions_blog_ui_page_blog in Subscriptions 2.0.x
Same name and namespace in other branches
- 5.2 subscriptions_blog_ui.module \subscriptions_blog_ui_page_blog()
- 6 subscriptions_blog_ui.module \subscriptions_blog_ui_page_blog()
- 7 subscriptions_blog_ui.module \subscriptions_blog_ui_page_blog()
Returns a list of blog subscriptions.
Parameters
array $form:
$uid: ID of a user if >0 or of a role if <0.
Return value
array|mixed|null|string
1 string reference to 'subscriptions_blog_ui_page_blog'
- _subscriptions_blog_ui_types in subscriptions_blog_ui/
subscriptions_blog_ui.module - Implements hook_types(), subhook of hook_subscriptions().
File
- subscriptions_blog_ui/
subscriptions_blog_ui.module, line 71 - Provide a Subscriptions UI for the blog content type subscriptions
Code
function subscriptions_blog_ui_page_blog(array $form, $uid) {
$blogs = array();
// get the blogs
$query = db_select('node', 'n');
$user_alias = $query
->join('users', 'u', 'n.uid = u.uid');
$uids = $query
->fields($user_alias, array(
'uid',
))
->condition('n.type', 'blog')
->condition('n.status', 1)
->groupBy('u.uid')
->groupBy('u.name')
->orderBy('u.name')
->execute()
->fetchCol();
$all_uids = $uids;
if ($uid > 0) {
// possibly additional blog subscription entries (no blog nodes)
$entries = db_select('subscriptions', 's')
->fields('s', array(
'author_uid',
))
->condition('s.module', 'node')
->condition('s.field', 'type')
->condition('s.value', 'blog')
->condition('s.author_uid', 0, '>=')
->condition('s.recipient_uid', $uid)
->groupBy('s.author_uid')
->execute();
foreach ($entries as $entry) {
if (!in_array($entry->author_uid, $all_uids)) {
$all_uids[] = $entry->author_uid;
}
}
}
$accounts = user_load_multiple($all_uids);
foreach ($accounts as $account) {
$user_name = format_username($account);
if (!($has_blog = in_array($account->uid, $uids))) {
$user_name = check_plain($user_name);
}
$blogs[$account->uid] = array(
'uid' => $account->uid,
'name' => $user_name,
'has_blog' => $has_blog,
);
}
if (!empty($blogs)) {
return _subscriptions_blog_ui_blog_form($blogs, $form, $uid);
}
else {
return t('There are no active blogs.');
}
}