Commit 727b5d79 authored by greg.1.anderson's avatar greg.1.anderson Committed by Grayside

Issue #1528730 by greg.1.anderson, Grayside: Added Notify when group...

Issue #1528730 by greg.1.anderson, Grayside: Added Notify when group administrator rights for a group are removed.
parent 6d9caf0f
diff --git a/includes/og.admin.inc b/includes/og.admin.inc
index a257ee3..1d646e3 100644
--- a/includes/og.admin.inc
+++ b/includes/og.admin.inc
@@ -184,6 +184,19 @@ function og_admin_settings() {
'#description' => t('The body of the message sent to a new admin for a group. Available variables: @group, @username, !group_url, !invite_url'),
'#default_value' => _og_mail_text('og_new_admin_body')
);
+ $form['og_settings']['notifications']['og_remove_admin_subject'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Admin removal user notification subject'),
+ '#description' => t('The subject of the message sent to a user when their admin access is removed. Available variables: @group, @username, !group_url'),
+ '#default_value' => _og_mail_text('og_remove_admin_subject')
+ );
+ $form['og_settings']['notifications']['og_remove_admin_body'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Admin removal user notification body'),
+ '#rows' => 10,
+ '#description' => t('The body of the message sent to a user when their admin access is removed. Available variables: @group, @username, !group_url, !invite_url'),
+ '#default_value' => _og_mail_text('og_remove_admin_body')
+ );
return system_settings_form($form);
}
diff --git a/modules/og_notifications/og_notifications.module b/modules/og_notifications/og_notifications.module
index ab7612d..3273651 100644
--- a/modules/og_notifications/og_notifications.module
+++ b/modules/og_notifications/og_notifications.module
@@ -165,6 +165,7 @@ function og_notifications_og($op, $gid, $uid, $args) {
case 'user deny':
case 'admin create':
case 'admin new':
+ case 'admin remove':
case 'user broadcast':
$destinations = is_array($uid) ? $uid : array($uid);
foreach ($destinations as $uid) {
@@ -577,4 +578,4 @@ function og_notifications_autosubscribe_map() {
0 => t('Disabled'),
1 => t('Enabled'),
);
-}
\ No newline at end of file
+}
diff --git a/og.api.php b/og.api.php
index d01da83..e7f4124 100644
--- a/og.api.php
+++ b/og.api.php
@@ -20,6 +20,7 @@
* What kind of action is being performed. Possible values (in
* alphabetical order):
* - admin new: A new user is added as an admin to a group.
+ * - admin remove: A user's admin access to a group is removed.
* - user approve: A user has been approved for membership to a group.
* - user broadcast: Send notifications to group members.
* - user delete: A user deletes their subscription to a group.
@@ -40,7 +41,7 @@
* request.
* - is_admin: 1 to create a group administrator subscription, 0 to create a
* typical member subscription.
- * admin new, user broadcast, user deny, user request:
+ * admin new, admin remove, user broadcast, user deny, user request:
* - subject: Subject/Title of a notification message.
* - body: Text of a notification message.
* user broadcast:
diff --git a/og.install b/og.install
index 330c7e4..f421a7d 100644
--- a/og.install
+++ b/og.install
@@ -478,6 +478,7 @@ function og_uninstall() {
'og_deny_user_body', 'og_deny_user_subject',
'og_invite_user_body', 'og_invite_user_subject',
'og_new_admin_body', 'og_new_admin_subject',
+ 'og_remove_admin_body', 'og_remove_admin_subject',
'og_new_node_body', 'og_new_node_subject',
'og_request_user_body', 'og_request_user_subject',
'og_notifications_update_required', 'og_notifications_content_types'
diff --git a/og.module b/og.module
index 4ddd734..9cf144c 100644
--- a/og.module
+++ b/og.module
@@ -250,6 +250,9 @@ function og_hook_info() {
'admin new' => array(
'runs when' => t('A new user is added as an admin to a group'),
),
+ 'admin remove' => array(
+ 'runs when' => t("A user's admin access to a group is removed"),
+ ),
),
),
);
@@ -278,6 +281,7 @@ function og_activity_info() {
'user deny',
'user request',
'admin new',
+ 'admin remove',
)
);
@@ -2261,6 +2265,10 @@ function _og_mail_text($messageid, $variables = array(), $language = NULL) {
return t("You are now an administrator for the group '@group'", $variables, $langcode);
case 'og_new_admin_body':
return t("@username, you are now an administrator for the group '@group'.\n\nYou can administer this group by logging in here:\n !group_url", $variables, $langcode);
+ case 'og_remove_admin_subject':
+ return t("You are no longer an administrator for the group '@group'", $variables, $langcode);
+ case 'og_remove_admin_body':
+ return t("@username, your administrator access for the group '@group' has been removed.", $variables, $langcode);
}
}
}
diff --git a/og.pages.inc b/og.pages.inc
index c054ae5..8cc74fe 100644
--- a/og.pages.inc
+++ b/og.pages.inc
@@ -174,6 +174,11 @@ function og_remove_admin_confirm_submit($form, &$form_state) {
$gid = $form_state['values']['gid'];
og_save_subscription($gid, $account->uid, array('is_admin' => 0));
drupal_set_message(t('%name is no longer a <em>group administrator</em>.', array('%name' => $account->name)));
+ $message = array(
+ 'subject' => _og_mail_text('og_remove_admin_subject', $variables),
+ 'body' => _og_mail_text('og_remove_admin_body', $variables)
+ );
+ module_invoke_all('og', 'admin remove', $gid, $account->uid, array());
$form_state['redirect'] = "og/users/$gid";
}
......@@ -184,6 +184,19 @@ function og_admin_settings() {
'#description' => t('The body of the message sent to a new admin for a group. Available variables: @group, @username, !group_url, !invite_url'),
'#default_value' => _og_mail_text('og_new_admin_body')
);
$form['og_settings']['notifications']['og_remove_admin_subject'] = array(
'#type' => 'textfield',
'#title' => t('Admin removal user notification subject'),
'#description' => t('The subject of the message sent to a user when their admin access is removed. Available variables: @group, @username, !group_url'),
'#default_value' => _og_mail_text('og_remove_admin_subject')
);
$form['og_settings']['notifications']['og_remove_admin_body'] = array(
'#type' => 'textarea',
'#title' => t('Admin removal user notification body'),
'#rows' => 10,
'#description' => t('The body of the message sent to a user when their admin access is removed. Available variables: @group, @username, !group_url, !invite_url'),
'#default_value' => _og_mail_text('og_remove_admin_body')
);
return system_settings_form($form);
}
......@@ -165,6 +165,7 @@ function og_notifications_og($op, $gid, $uid, $args) {
case 'user deny':
case 'admin create':
case 'admin new':
case 'admin remove':
case 'user broadcast':
$destinations = is_array($uid) ? $uid : array($uid);
foreach ($destinations as $uid) {
......@@ -577,4 +578,4 @@ function og_notifications_autosubscribe_map() {
0 => t('Disabled'),
1 => t('Enabled'),
);
}
\ No newline at end of file
}
......@@ -20,6 +20,7 @@
* What kind of action is being performed. Possible values (in
* alphabetical order):
* - admin new: A new user is added as an admin to a group.
* - admin remove: A user's admin access to a group is removed.
* - user approve: A user has been approved for membership to a group.
* - user broadcast: Send notifications to group members.
* - user delete: A user deletes their subscription to a group.
......@@ -40,7 +41,7 @@
* request.
* - is_admin: 1 to create a group administrator subscription, 0 to create a
* typical member subscription.
* admin new, user broadcast, user deny, user request:
* admin new, admin remove, user broadcast, user deny, user request:
* - subject: Subject/Title of a notification message.
* - body: Text of a notification message.
* user broadcast:
......
......@@ -478,6 +478,7 @@ function og_uninstall() {
'og_deny_user_body', 'og_deny_user_subject',
'og_invite_user_body', 'og_invite_user_subject',
'og_new_admin_body', 'og_new_admin_subject',
'og_remove_admin_body', 'og_remove_admin_subject',
'og_new_node_body', 'og_new_node_subject',
'og_request_user_body', 'og_request_user_subject',
'og_notifications_update_required', 'og_notifications_content_types'
......
......@@ -250,6 +250,9 @@ function og_hook_info() {
'admin new' => array(
'runs when' => t('A new user is added as an admin to a group'),
),
'admin remove' => array(
'runs when' => t("A user's admin access to a group is removed"),
),
),
),
);
......@@ -278,6 +281,7 @@ function og_activity_info() {
'user deny',
'user request',
'admin new',
'admin remove',
)
);
......@@ -2261,6 +2265,10 @@ function _og_mail_text($messageid, $variables = array(), $language = NULL) {
return t("You are now an administrator for the group '@group'", $variables, $langcode);
case 'og_new_admin_body':
return t("@username, you are now an administrator for the group '@group'.\n\nYou can administer this group by logging in here:\n !group_url", $variables, $langcode);
case 'og_remove_admin_subject':
return t("You are no longer an administrator for the group '@group'", $variables, $langcode);
case 'og_remove_admin_body':
return t("@username, your administrator access for the group '@group' has been removed.", $variables, $langcode);
}
}
}
......
......@@ -179,6 +179,11 @@ function og_remove_admin_confirm_submit($form, &$form_state) {
$gid = $form_state['values']['gid'];
og_save_subscription($gid, $account->uid, array('is_admin' => 0));
drupal_set_message(t('%name is no longer a <em>group administrator</em>.', array('%name' => $account->name)));
$message = array(
'subject' => _og_mail_text('og_remove_admin_subject', $variables),
'body' => _og_mail_text('og_remove_admin_body', $variables)
);
module_invoke_all('og', 'admin remove', $gid, $account->uid, array());
$form_state['redirect'] = "og/users/$gid";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment