function og_save_subscription in Organic groups 6
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.2 og.module \og_save_subscription()
Low level function for managing membership
Parameters
$gid node ID of a group:
$uid user ID of user:
$args an array with details of this membership. Recognized array keys are:: is_active, is_admin, created. Other values are passed to hook implementations.
14 calls to og_save_subscription()
- og_add_users_submit in ./
og.module - og_approve in ./
og.module - 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.module - 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 701
Code
function og_save_subscription($gid, $uid, $args = array()) {
$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);
}
}