? .cvsignore ? privatemsg_allow_disabling_setting.patch ? privatemsg_allow_disabling_setting2.patch ? privatemsg_disable_fix.patch Index: privatemsg.admin.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg.admin.inc,v retrieving revision 1.5 diff -u -p -r1.5 privatemsg.admin.inc --- privatemsg.admin.inc 20 Feb 2010 08:56:58 -0000 1.5 +++ privatemsg.admin.inc 11 Mar 2010 12:28:29 -0000 @@ -28,6 +28,13 @@ function privatemsg_admin_settings() { '#description' => t('This option can safely be disabled if the "New message indication" block is used instead.'), '#weight' => -5, ); + $form['privatemsg_display_disabled_message'] = array( + '#type' => 'checkbox', + '#title' => t('Inform the user on /messages pages that he can not write new messages when privatemsg is disabled.'), + '#default_value' => variable_get('privatemsg_display_disabled_message', TRUE), + '#description' => t('Users can (if given the permission) disable Privatemsg which disallows writing messages to them and they can not write messages themself. If enabled, those users are informed on the relevant pages why they are not allowed to write messages.'), + '#weight' => -8, + ); $form['integration'] = array( '#type' => 'fieldset', Index: privatemsg.module =================================================================== RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg.module,v retrieving revision 1.120 diff -u -p -r1.120 privatemsg.module --- privatemsg.module 25 Feb 2010 18:33:50 -0000 1.120 +++ privatemsg.module 11 Mar 2010 12:28:29 -0000 @@ -26,6 +26,7 @@ function privatemsg_perm() { return array( 'read privatemsg', 'read all private messages', + 'allow disabling privatemsg', 'administer privatemsg settings', 'write privatemsg', 'delete privatemsg', @@ -231,6 +232,7 @@ function privatemsg_menu() { * @ingroup api */ function privatemsg_user_access($permission = 'read privatemsg', $account = NULL) { + static $disabled_displayed = FALSE; if ( $account === NULL ) { global $user; $account = $user; @@ -239,6 +241,10 @@ function privatemsg_user_access($permiss return FALSE; } if (privatemsg_is_disabled($account) && ($permission == 'write privatemsg') ) { + if (arg(0) == 'messages' && variable_get('privatemsg_display_disabled_message', TRUE) && !$disabled_displayed) { + $disabled_displayed = TRUE; + drupal_set_message(t('You have disabled Privatemsg and are not allowed to write messages. Go to your Account settings to enable it again.', array('@settings_url' => url('user/' . $account->uid . '/edit'))), 'warning'); + } return FALSE; } if (!user_access($permission, $account)) { @@ -945,7 +951,7 @@ function privatemsg_user($op, &$edit, &$ case 'form': // We have to use user_acces() because privatemsg_user_access() would // return FALSE when privatemsg is disabled. - if ($category == 'account' && user_access('write privatemsg')) { + if ($category == 'account' && user_access('write privatemsg') && user_access('allow disabling privatemsg')) { $form['privatemsg'] = array( '#type' => 'fieldset', '#title' => t('Privatemsg settings'), @@ -960,12 +966,11 @@ function privatemsg_user($op, &$edit, &$ '#default_value' => (int) !privatemsg_is_disabled($account), '#description' => t('Disabling private messages prevents you from sending or receiving messages from other users.'), ); - + return $form; } - return $form; case 'submit': - if ($category == 'account' && user_access('write privatemsg')) { + if ($category == 'account' && user_access('write privatemsg') && user_access('allow disabling privatemsg')) { $current = privatemsg_is_disabled($account); $disabled = (!$edit['pm_enable']); unset($edit['pm_enable']); Index: privatemsg.test =================================================================== RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg.test,v retrieving revision 1.7 diff -u -p -r1.7 privatemsg.test --- privatemsg.test 17 Feb 2010 10:05:45 -0000 1.7 +++ privatemsg.test 11 Mar 2010 12:28:29 -0000 @@ -369,7 +369,7 @@ class PrivatemsgTestCase extends DrupalW function testDisablePrivatemsg() { $enableduser = $this->drupalCreateUser(array('read privatemsg', 'write privatemsg')); // set up user with read/write privatemsg permissions $enableduser2 = $this->drupalCreateUser(array('read privatemsg', 'write privatemsg')); // set up user with read/write privatemsg permissions - $disableduser = $this->drupalCreateUser(array('read privatemsg', 'write privatemsg')); // set up user with read/write privatemsg permissions + $disableduser = $this->drupalCreateUser(array('read privatemsg', 'write privatemsg', 'allow disabling privatemsg')); // set up user with read/write privatemsg permissions // Create a message between the users that we can use to test $return = privatemsg_new_thread(array($disableduser), $this->randomName(20), $this->randomName(100), array('author' => $enableduser)); @@ -626,7 +626,7 @@ class PrivatemsgTestCase extends DrupalW $this->assertNoText($edit['body'], t('Reply of deleted user is not displayed anymore')); // Test if deleting a user does not produce any errors. - user_delete(array(), $dummy); + user_delete(array(), $dummy->uid); } /**