Added delete account options
This commit is contained in:
30
Service/DeleteAccount/CodeService.php
Normal file
30
Service/DeleteAccount/CodeService.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace RomhackPlaza\Master\Service\DeleteAccount;
|
||||
|
||||
use XF\Entity\User;
|
||||
use XF\Service\AbstractService;
|
||||
|
||||
class CodeService extends AbstractService
|
||||
{
|
||||
|
||||
private string $masterKey;
|
||||
|
||||
protected function setup()
|
||||
{
|
||||
$this->masterKey = \XF::options()->rhpz_delete_account_master_key;
|
||||
}
|
||||
|
||||
public function generateDeleteAllDataKey( User $user )
|
||||
{
|
||||
$dataString = "delete_data_{$user->user_id}";
|
||||
return hash_hmac('md5', $dataString, $this->masterKey );
|
||||
}
|
||||
|
||||
public function generateDeleteAccountKey( User $user )
|
||||
{
|
||||
$dataString = "delete_account_{$user->user_id}";
|
||||
return hash_hmac('md5', $dataString, $this->masterKey );
|
||||
}
|
||||
|
||||
}
|
||||
25
XF/Admin/Controller/UserController.php
Normal file
25
XF/Admin/Controller/UserController.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace RomhackPlaza\Master\XF\Admin\Controller;
|
||||
|
||||
use RomhackPlaza\Master\Service\DeleteAccount\CodeService;
|
||||
use XF\Mvc\ParameterBag;
|
||||
|
||||
class UserController extends XFCP_UserController
|
||||
{
|
||||
public function actionDeleteAccountCodes(ParameterBag $params)
|
||||
{
|
||||
$user = $this->assertUserExists($params->user_id);
|
||||
|
||||
/** @var CodeService $service */
|
||||
$service = \XF::service('RomhackPlaza\Master:DeleteAccount\CodeService');
|
||||
|
||||
$viewParams = [
|
||||
'user' => $user,
|
||||
'deleteAllDataCode' => $service->generateDeleteAllDataKey( $user ),
|
||||
'deleteAccountCode' => $service->generateDeleteAccountKey( $user ),
|
||||
];
|
||||
|
||||
return $this->view('XF:User\DeleteAccountCodes', 'user_delete_account_codes', $viewParams);
|
||||
}
|
||||
}
|
||||
25
XF/Pub/Controller/AccountController.php
Normal file
25
XF/Pub/Controller/AccountController.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace RomhackPlaza\Master\XF\Pub\Controller;
|
||||
|
||||
use RomhackPlaza\Master\Service\DeleteAccount\CodeService;
|
||||
|
||||
class AccountController extends XFCP_AccountController
|
||||
{
|
||||
public function actionDeleteAccount()
|
||||
{
|
||||
$visitor = \XF::visitor();
|
||||
|
||||
/** @var CodeService $service */
|
||||
$service = \XF::service('RomhackPlaza\Master:DeleteAccount\CodeService');
|
||||
|
||||
$viewParams = [
|
||||
'deleteAllDataCode' => $service->generateDeleteAllDataKey( $visitor ),
|
||||
'deleteAccountCode' => $service->generateDeleteAccountKey( $visitor ),
|
||||
];
|
||||
|
||||
$view = $this->view('XF:Account\DeleteAccount', 'delete_account', $viewParams);
|
||||
return $this->addAccountWrapperParams($view, 'delete_account');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"from_class": "XF\\Admin\\Controller\\UserController",
|
||||
"to_class": "RomhackPlaza\\Master\\XF\\Admin\\Controller\\UserController",
|
||||
"execute_order": 10,
|
||||
"active": true
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"from_class": "XF\\Pub\\Controller\\AccountController",
|
||||
"to_class": "RomhackPlaza\\Master\\XF\\Pub\\Controller\\AccountController",
|
||||
"execute_order": 10,
|
||||
"active": true
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
{
|
||||
"XF-Admin-Controller-UserController_RomhackPlaza-Master-XF-Admin-Controller-UserController.json": {
|
||||
"hash": "542c5dd275e5e26446a9e4a19b3c47b6"
|
||||
},
|
||||
"XF-Entity-ApprovalQueue_RomhackPlaza-Master-XF-Entity-ApprovalQueue.json": {
|
||||
"hash": "f4364e1ec74dfa80ff24368486e66ffb"
|
||||
},
|
||||
@@ -8,6 +11,9 @@
|
||||
"XF-Entity-User_RomhackPlaza-Master-XF-Entity-User.json": {
|
||||
"hash": "811593d6f012a53b9fa2ced871de96a9"
|
||||
},
|
||||
"XF-Pub-Controller-AccountController_RomhackPlaza-Master-XF-Pub-Controller-AccountController.json": {
|
||||
"hash": "b34f519ca78e8977c98e0307125537bc"
|
||||
},
|
||||
"XF-Pub-Controller-MiscController_RomhackPlaza-Master-XF-Pub-Controller-MiscController.json": {
|
||||
"hash": "1071fd498b2958031153de55eb4ca66a"
|
||||
},
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
* @noinspection PhpMultipleClassesDeclarationsInOneFile
|
||||
*/
|
||||
|
||||
namespace RomhackPlaza\Master\XF\Admin\Controller
|
||||
{
|
||||
class XFCP_UserController extends \XF\Admin\Controller\UserController {}
|
||||
}
|
||||
|
||||
namespace RomhackPlaza\Master\XF\Entity
|
||||
{
|
||||
class XFCP_ApprovalQueue extends \XF\Entity\ApprovalQueue {}
|
||||
@@ -17,6 +22,7 @@ namespace RomhackPlaza\Master\XF\Entity
|
||||
|
||||
namespace RomhackPlaza\Master\XF\Pub\Controller
|
||||
{
|
||||
class XFCP_AccountController extends \XF\Pub\Controller\AccountController {}
|
||||
class XFCP_MiscController extends \XF\Pub\Controller\MiscController {}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"romhackplaza.json": {
|
||||
"hash": "02d554f377cebf4d2532162b1c223e64"
|
||||
"hash": "e21c9e1387c95754e243002eaed87e18"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"icon": "",
|
||||
"icon": "fa-umbrella-beach",
|
||||
"display_order": 500,
|
||||
"advanced": false,
|
||||
"debug_only": false
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace XF;
|
||||
|
||||
/**
|
||||
* @property non-negative-int|null $rhpz_club_node_id Club Parent Node ID
|
||||
* @property string|null $rhpz_delete_account_master_key Delete account Master key
|
||||
*/
|
||||
class Options
|
||||
{
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
{
|
||||
"rhpz_club_node_id.json": {
|
||||
"hash": "96114ee498a669ab50a1bc32768d3969"
|
||||
},
|
||||
"rhpz_delete_account_master_key.json": {
|
||||
"hash": "d649af68f404568ba3c06cc0a7121649"
|
||||
}
|
||||
}
|
||||
13
_output/options/rhpz_delete_account_master_key.json
Normal file
13
_output/options/rhpz_delete_account_master_key.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"edit_format": "textbox",
|
||||
"edit_format_params": "",
|
||||
"data_type": "string",
|
||||
"sub_options": [],
|
||||
"validation_class": "",
|
||||
"validation_method": "",
|
||||
"advanced": false,
|
||||
"default_value": "",
|
||||
"relations": {
|
||||
"romhackplaza": 1
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,28 @@
|
||||
{
|
||||
"delete_account.txt": {
|
||||
"global_cache": false,
|
||||
"version_id": 1000000,
|
||||
"version_string": "1.0.0",
|
||||
"hash": "e6e049c44a797fda2a175d07df838e49"
|
||||
},
|
||||
"delete_account_code.txt": {
|
||||
"global_cache": false,
|
||||
"version_id": 1000000,
|
||||
"version_string": "1.0.0",
|
||||
"hash": "9290d474fd3f2bdde27a87d03b99c8d0"
|
||||
},
|
||||
"delete_account_codes.txt": {
|
||||
"global_cache": false,
|
||||
"version_id": 1000000,
|
||||
"version_string": "1.0.0",
|
||||
"hash": "d5fb1c03e7384236ebd589b23155b0c2"
|
||||
},
|
||||
"delete_all_data_code.txt": {
|
||||
"global_cache": false,
|
||||
"version_id": 1000000,
|
||||
"version_string": "1.0.0",
|
||||
"hash": "15d96c48f857b975c051d7c98b13a385"
|
||||
},
|
||||
"nav.about.txt": {
|
||||
"global_cache": false,
|
||||
"version_id": 1000000,
|
||||
@@ -125,12 +149,24 @@
|
||||
"version_string": "1.0.0",
|
||||
"hash": "e73496f262c162a1a35bd9e990b36825"
|
||||
},
|
||||
"option.rhpz_delete_account_master_key.txt": {
|
||||
"global_cache": false,
|
||||
"version_id": 1000000,
|
||||
"version_string": "1.0.0",
|
||||
"hash": "8b275759f2215b3b242de29110f05a4c"
|
||||
},
|
||||
"option_explain.rhpz_club_node_id.txt": {
|
||||
"global_cache": false,
|
||||
"version_id": 1000000,
|
||||
"version_string": "1.0.0",
|
||||
"hash": "d41d8cd98f00b204e9800998ecf8427e"
|
||||
},
|
||||
"option_explain.rhpz_delete_account_master_key.txt": {
|
||||
"global_cache": false,
|
||||
"version_id": 1000000,
|
||||
"version_string": "1.0.0",
|
||||
"hash": "d41d8cd98f00b204e9800998ecf8427e"
|
||||
},
|
||||
"option_group.romhackplaza.txt": {
|
||||
"global_cache": false,
|
||||
"version_id": 1000000,
|
||||
@@ -141,7 +177,7 @@
|
||||
"global_cache": false,
|
||||
"version_id": 1000000,
|
||||
"version_string": "1.0.0",
|
||||
"hash": "d41d8cd98f00b204e9800998ecf8427e"
|
||||
"hash": "11821c85ed03034c1bba4294e357d089"
|
||||
},
|
||||
"permission.romhackplaza_canEditMyEntries.txt": {
|
||||
"global_cache": false,
|
||||
|
||||
1
_output/phrases/delete_account.txt
Normal file
1
_output/phrases/delete_account.txt
Normal file
@@ -0,0 +1 @@
|
||||
Delete account
|
||||
1
_output/phrases/delete_account_code.txt
Normal file
1
_output/phrases/delete_account_code.txt
Normal file
@@ -0,0 +1 @@
|
||||
Delete account code
|
||||
1
_output/phrases/delete_account_codes.txt
Normal file
1
_output/phrases/delete_account_codes.txt
Normal file
@@ -0,0 +1 @@
|
||||
Delete account codes
|
||||
1
_output/phrases/delete_all_data_code.txt
Normal file
1
_output/phrases/delete_all_data_code.txt
Normal file
@@ -0,0 +1 @@
|
||||
Delete all data code
|
||||
@@ -0,0 +1 @@
|
||||
Delete account Master key
|
||||
@@ -0,0 +1 @@
|
||||
These options are specific to Romhack Plaza
|
||||
@@ -1,10 +1,22 @@
|
||||
{
|
||||
"admin/rhpz_helper_criteria_entry_count.json": {
|
||||
"hash": "d94d8b880e79d281df49117a84ae62d7"
|
||||
},
|
||||
"admin/rhpz_user_edit_delete_account_codes_tab.json": {
|
||||
"hash": "16b7ae6dac8dbb6846df3e6eb9cd53b6"
|
||||
},
|
||||
"admin/rhpz_user_edit_delete_account_codes_tab_panes.json": {
|
||||
"hash": "d4f793cfd5ba4b6841bd819a12e596e9"
|
||||
},
|
||||
"public/rhpz_above_thread_list_clubs.json": {
|
||||
"hash": "c261ea6e33cf5eb7ab0a7f6fe934de7c"
|
||||
},
|
||||
"public/rhpz_above_thread_list_clubs_buttons.json": {
|
||||
"hash": "c783001e00f7a63389c9ae988012f5fe"
|
||||
},
|
||||
"public/rhpz_account_wrapper_delete_account.json": {
|
||||
"hash": "6594c0474a9b3e737a10dbd9c531521e"
|
||||
},
|
||||
"public/rhpz_category_view_clubs_submit_button.json": {
|
||||
"hash": "a24a5a4b130b6198de7ef37610aa1a7d"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"template": "helper_criteria",
|
||||
"description": "",
|
||||
"execution_order": 10,
|
||||
"enabled": true,
|
||||
"action": "str_replace",
|
||||
"find": "<!--[XF:user:content_bottom]-->",
|
||||
"replace": "<xf:option name=\"user_criteria[rhpz_entry_count][rule]\" value=\"rhpz_entry_count\" selected=\"{$criteria.rhpz_entry_count}\" label=\"Number of entries:\">\n\t<xf:numberbox name=\"user_criteria[rhpz_entry_count][data][entries]\" value=\"{$criteria.rhpz_entry_count.entries}\" size=\"5\" min=\"0\" step=\"1\" />\n</xf:option>"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"template": "user_edit",
|
||||
"description": "Add Tab for listing delete account codes in User edit",
|
||||
"execution_order": 10,
|
||||
"enabled": true,
|
||||
"action": "str_replace",
|
||||
"find": "<!--[XF:tabs:end]-->",
|
||||
"replace": "<xf:if is=\"$user.user_id\">\n\t<a class=\"tabs-tab\" role=\"tab\" tabindex=\"0\"\n\t id=\"user-delete-account-codes\"\n\t aria-controls=\"user-delete-account-codes\"\n\t href=\"{{ link('users/edit', $user) }}#delete-account-codes\">{{ phrase('delete_account_codes') }}</a>\n</xf:if>\n$0"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"template": "user_edit",
|
||||
"description": "Add Tab panes in User edit page for account deletion codes.",
|
||||
"execution_order": 10,
|
||||
"enabled": true,
|
||||
"action": "str_replace",
|
||||
"find": "<!--[XF:tab_panes:end]-->",
|
||||
"replace": "\n<xf:if is=\"$user.user_id\">\n\t<li data-href=\"{{ link('users/delete-account-codes', $user, {'tabbed':1}) }}\" role=\"tabpanel\" aria-labelledby=\"user-delete-account-codes\">\n\t\t<div class=\"block-body block-row\">{{ phrase('loading...') }}</div>\n\t</li>\n</xf:if>\n$0"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"template": "account_wrapper",
|
||||
"description": "Add Delete account page URL to account details",
|
||||
"execution_order": 10,
|
||||
"enabled": true,
|
||||
"action": "str_replace",
|
||||
"find": "<!--[XF:settings_links:bottom]-->",
|
||||
"replace": "<a class=\"blockLink {{ $pageSelected == 'delete_account' ? 'is-selected' : '' }}\" href=\"{{ link('account/delete-account') }}\">\n\t{{ phrase('delete_account') }}\n</a>\n$0"
|
||||
}
|
||||
@@ -2,7 +2,12 @@
|
||||
"admin/helper_criteria.html": {
|
||||
"version_id": 1000000,
|
||||
"version_string": "1.0.0",
|
||||
"hash": "19cd05c4ab254dbad0abfd0c6b8c3456"
|
||||
"hash": "0d8327297612e3e8eeb17e204e33694d"
|
||||
},
|
||||
"admin/user_delete_account_codes.html": {
|
||||
"version_id": 1000000,
|
||||
"version_string": "1.0.0",
|
||||
"hash": "cf9c69eb1bfa0821778f60e9866626a4"
|
||||
},
|
||||
"public/approval_item_club_request.html": {
|
||||
"version_id": 1000000,
|
||||
|
||||
@@ -188,10 +188,6 @@
|
||||
size="5" min="0" step="1" />
|
||||
</xf:option>
|
||||
|
||||
<xf:option name="user_criteria[rhpz_entry_count][rule]" value="rhpz_entry_count" selected="{$criteria.rhpz_entry_count}" label="Number of entries:">
|
||||
<xf:numberbox name="user_criteria[rhpz_entry_count][data][entries]" value="{$criteria.rhpz_entry_count.entries}" size="5" min="0" step="1" />
|
||||
</xf:option>
|
||||
|
||||
<!--[XF:user:content_bottom]-->
|
||||
</xf:checkboxrow>
|
||||
|
||||
|
||||
15
_output/templates/admin/user_delete_account_codes.html
Normal file
15
_output/templates/admin/user_delete_account_codes.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<xf:title>{$user.username}</xf:title>
|
||||
|
||||
<div class="block">
|
||||
<div class="block-container">
|
||||
<h3 class="block-minorHeader">{{ phrase('delete_account_code') }}</h3>
|
||||
<div class="block-body">
|
||||
<div class="block-row">{$deleteAccountCode}</div>
|
||||
</div>
|
||||
|
||||
<h3 class="block-minorHeader">{{ phrase('delete_all_data_code') }}</h3>
|
||||
<div class="block-body">
|
||||
<div class="block-row">{$deleteAllDataCode}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user