function og_save_subscription in Organic groups 6.2
Same name and namespace in other branches
- 5.8 og.module \og_save_subscription()
- 5 og.module \og_save_subscription()
- 5.2 og.module \og_save_subscription()
- 5.3 og.module \og_save_subscription()
- 5.7 og.module \og_save_subscription()
- 6 og.module \og_save_subscription()
Save changes to a user's group membership.
This function is intended primarily for internal use.
Parameters
$gid: Node ID of a group.
$uid: User ID of the user.
$args: An array with details of this membership. Recognized array keys are:
- is_active: Membership should be saved as active. (as in, approved).
- is_admin: Membership should be saved with administrative privileges.
- created: Membership is to be created.
Other values are passed to hook implementations.
14 calls to og_save_subscription()
- og_add_users_submit in ./
og.pages.inc - og_approve in ./
og.module - Activate a user's membership in a group.
- og_approve_user_action in modules/
og_actions/ og_actions.module - A configurable action to approve a user from a group administrator.
- og_create_admin_confirm_submit in ./
og.pages.inc - Confirm og create admin form
- og_demote_user_action in modules/
og_actions/ og_actions.module - A configurable action to demote a user from a group administrator.
File
- ./
og.module, line 859 - Code for the Organic Groups module.
Code
function og_save_subscription($gid, $uid, $args = array()) {
if ($uid > 0) {
$sql = "SELECT COUNT(*) FROM {og_uid} WHERE nid = %d AND uid = %d";
$cnt = db_result(db_query($sql, $gid, $uid));
$time = time();
$subscription = array(
'nid' => $gid,
'uid' => $uid,
'created' => isset($args['created']) ? $args['created'] : $time,
'changed' => $time,
);
unset($args['created']);
$subscription += $args;
if ($cnt == 0) {
drupal_write_record('og_uid', $subscription);
module_invoke_all('og', 'user insert', $gid, $uid, $args);
}
else {
drupal_write_record('og_uid', $subscription, array(
'nid',
'uid',
));
module_invoke_all('og', 'user update', $gid, $uid, $args);
}
}
}