Added send email/send new password actions on user list
authorAlexander Ebert <ebert@woltlab.com>
Sun, 23 Jul 2017 09:32:18 +0000 (11:32 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 23 Jul 2017 09:32:26 +0000 (11:32 +0200)
See #2347

wcfsetup/install/files/acp/templates/userList.tpl
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Editor.js
wcfsetup/install/files/lib/acp/form/UserMailForm.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index f4f950d81e7619e4e9d237c4788a70fa4df2f3cd..a74cd028bb596fd209761b4a3ec4e127f345f834 100644 (file)
                        WCF.ACP.User.SendNewPasswordHandler.init();
                {/if}
                
-               require(['WoltLabSuite/Core/Acp/Ui/User/Editor'], function (AcpUiUserList) {
+               require(['Language', 'WoltLabSuite/Core/Acp/Ui/User/Editor'], function (Language, AcpUiUserList) {
+                       Language.addObject({
+                               'wcf.acp.user.action.sendNewPassword.confirmMessage': '{lang}wcf.acp.user.action.sendNewPassword.confirmMessage{/lang}'
+                       });
+                       
                        AcpUiUserList.init();
                });
                
                                                                <ul class="dropdownMenu">
                                                                        {event name='dropdownItems'}
                                                                        
+                                                                       {if $user->userID !== $__wcf->user->userID}
+                                                                               <li><a href="{link controller='UserMail' id=$user->userID}{/link}">{lang}wcf.acp.user.action.sendMail{/lang}</a></li>
+                                                                               
+                                                                               {if $user->accessible && $__wcf->session->getPermission('admin.user.canEditPassword')}
+                                                                                       <li><a href="#" class="jsSendNewPassword">{lang}wcf.acp.user.action.sendNewPassword{/lang}</a></li>
+                                                                               {/if}
+                                                                       {/if}
+                                                                       
                                                                        {if $user->deletable}
                                                                                <li class="dropdownDivider"></li>
                                                                                <li><a href="#" class="jsDispatchDelete">{lang}wcf.global.button.delete{/lang}</a></li>
index 25aa931a1fbccda736a913149e20468f440b867c..89e0a69f5866e31e2fe8b1a12c61f7a10c981564 100644 (file)
@@ -7,7 +7,7 @@
  * @module     WoltLabSuite/Core/Acp/Ui/User/Editor
  * @since       3.1
  */
-define(['Ajax', 'Core', 'Ui/SimpleDropdown'], function(Ajax, Core, UiSimpleDropdown) {
+define(['Ajax', 'Core', 'EventHandler', 'Language', 'Ui/SimpleDropdown'], function(Ajax, Core, EventHandler, Language, UiSimpleDropdown) {
        "use strict";
        
        /**
@@ -46,6 +46,28 @@ define(['Ajax', 'Core', 'Ui/SimpleDropdown'], function(Ajax, Core, UiSimpleDropd
                                        editLink.click();
                                });
                        }
+                       
+                       var sendNewPassword = elBySel('.jsSendNewPassword', dropdownMenu);
+                       if (sendNewPassword !== null) {
+                               sendNewPassword.addEventListener(WCF_CLICK_EVENT, function (event) {
+                                       event.preventDefault();
+                                       
+                                       // emulate clipboard selection
+                                       EventHandler.fire('com.woltlab.wcf.clipboard', 'com.woltlab.wcf.user', {
+                                               data: {
+                                                       actionName: 'com.woltlab.wcf.user.sendNewPassword',
+                                                       parameters: {
+                                                               confirmMessage: Language.get('wcf.acp.user.action.sendNewPassword.confirmMessage'),
+                                                               objectIDs: [userId]
+                                                       }
+                                               },
+                                               responseData: {
+                                                       actionName: 'com.woltlab.wcf.user.sendNewPassword',
+                                                       objectIDs: [userId]
+                                               }
+                                       });
+                               });
+                       }
                },
                
                /**
@@ -117,6 +139,10 @@ define(['Ajax', 'Core', 'Ui/SimpleDropdown'], function(Ajax, Core, UiSimpleDropd
                                        hasItem = true;
                                }
                        }
+               },
+               
+               _sendNewPassword: function (userId) {
+                       
                }
        };
 });
index 4eebd7a1dd7d9565e2bb326f793fe8f88ffee877..bbae5cb86628b45588777c1e708d4dc21a76c965 100755 (executable)
@@ -68,6 +68,12 @@ class UserMailForm extends AbstractForm {
         */
        public $text = '';
        
+       /**
+        * single user id
+        * @var integer
+        */
+       public $userID = 0;
+       
        /**
         * list of user ids
         * @var integer[]
@@ -86,6 +92,8 @@ class UserMailForm extends AbstractForm {
        public function readParameters() {
                parent::readParameters();
                
+               if (isset($_GET['id'])) $this->userID = intval($_GET['id']);
+               
                $this->activeMenuItem = ($this->action == 'all' ? 'wcf.acp.menu.link.user.mail' : ($this->action == 'group' ? 'wcf.acp.menu.link.group.mail' : 'wcf.acp.menu.link.user.management'));
        }
        
@@ -168,20 +176,26 @@ class UserMailForm extends AbstractForm {
                if (empty($_POST)) {
                        // get marked user ids
                        if (empty($this->action)) {
-                               // get type id
-                               $objectTypeID = ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user');
-                               if ($objectTypeID === null) {
-                                       throw new SystemException("Unknown clipboard item type 'com.woltlab.wcf.user'");
+                               if ($this->userID) {
+                                       // single user mail form
+                                       $this->userIDs = [$this->userID];
                                }
-                               
-                               // get user ids
-                               $users = ClipboardHandler::getInstance()->getMarkedItems($objectTypeID);
-                               if (empty($users)) {
-                                       throw new IllegalLinkException();
+                               else {
+                                       // get type id
+                                       $objectTypeID = ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user');
+                                       if ($objectTypeID === null) {
+                                               throw new SystemException("Unknown clipboard item type 'com.woltlab.wcf.user'");
+                                       }
+                                       
+                                       // get user ids
+                                       $users = ClipboardHandler::getInstance()->getMarkedItems($objectTypeID);
+                                       if (empty($users)) {
+                                               throw new IllegalLinkException();
+                                       }
+                                       
+                                       // load users
+                                       $this->userIDs = array_keys($users);
                                }
-                               
-                               // load users
-                               $this->userIDs = array_keys($users);
                        }
                        
                        $this->from = MAIL_FROM_ADDRESS;
index b3dcc17f4a3be5f53ac8b3690bb29facb90f0a3e..3e8d95d2fc242588a91639afdf3c9104fc679278 100644 (file)
@@ -2196,6 +2196,9 @@ Benutzerkontos nun in vollem Umfang nutzen.]]></item>
                <item name="wcf.acp.user.bulkProcessing.success"><![CDATA[Die gewählte Aktion wurde auf {#$affectedObjectCount} Benutzer ausgeführt.]]></item>
                <item name="wcf.acp.user.bulkProcessing.warning"><![CDATA[Die Massenbearbeitung von Benutzern führt die unten ausgewählte Aktion <b>ohne zusätzliche Sicherheitsabfrage</b> bei allen Benutzern aus, die unter die eingestellten Bedingungen fallen.]]></item>
                <item name="wcf.acp.user.profileMenu.sort"><![CDATA[Benutzerprofil-Menü Sortierung]]></item>
+               <item name="wcf.acp.user.action.sendMail"><![CDATA[E-Mail senden]]></item>
+               <item name="wcf.acp.user.action.sendNewPassword"><![CDATA[Neues Passwort zusenden]]></item>
+               <item name="wcf.acp.user.action.sendNewPassword.confirmMessage"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} diesem Benutzer wirklich ein neues Kennwort zusenden?]]></item>
        </category>
        
        <category name="wcf.acp.worker">
index 2dc57a3ebccff6ad1540f60d3079d34692856034..3ac5953b05d3dbf385de504d12c7ddeab7091f07 100644 (file)
@@ -2134,6 +2134,9 @@ full extend.]]></item>
                <item name="wcf.acp.user.bulkProcessing.success"><![CDATA[The selected action has been executed and affected {#$affectedObjectCount} user{if $affectedObjectCount != 1}s{/if}.]]></item>
                <item name="wcf.acp.user.bulkProcessing.warning"><![CDATA[Heads up! The bulk processing executes all actions below on all users matching the selected conditions without any further confirmation prompt!]]></item>
                <item name="wcf.acp.user.profileMenu.sort"><![CDATA[User Profile Menu Show Order]]></item>
+               <item name="wcf.acp.user.action.sendMail"><![CDATA[Send Email]]></item>
+               <item name="wcf.acp.user.action.sendNewPassword"><![CDATA[Send New Password]]></item>
+               <item name="wcf.acp.user.action.sendNewPassword.confirmMessage"><![CDATA[Do you really want to send a new password to this user?]]></item>
        </category>
        
        <category name="wcf.acp.worker">