{
parent::content();
- $action = (string) $this->parameters['action'] ?? '';
- $uid = (int) $this->parameters['uid'] ?? 0;
-
- if ($uid !== 0) {
- $user = User::getById($uid, ['username', 'blocked']);
- if (!$user) {
- $this->systemMessages->addNotice($this->t('User not found'));
- $this->baseUrl->redirect('moderation/users');
- }
- }
-
- switch ($action) {
- case 'delete':
- if ($this->session->getLocalUserId() != $uid) {
- self::checkFormSecurityTokenRedirectOnError('moderation/users/active', 'moderation_users_active', 't');
- // delete user
- User::remove($uid);
-
- $this->systemMessages->addNotice($this->t('User "%s" deleted', $user['username']));
- } else {
- $this->systemMessages->addNotice($this->t('You can\'t remove yourself'));
- }
+ $this->processGetActions();
- $this->baseUrl->redirect('moderation/users/active');
- break;
- case 'block':
- self::checkFormSecurityTokenRedirectOnError('moderation/users/active', 'moderation_users_active', 't');
- User::block($uid);
- $this->systemMessages->addNotice($this->t('User "%s" blocked', $user['username']));
- $this->baseUrl->redirect('moderation/users/active');
- break;
- }
$pager = new Pager($this->l10n, $this->args->getQueryString(), 100);
$valid_orders = [
'$pager' => $pager->renderFull($count),
]);
}
+
+ /**
+ * @return void
+ * @throws \Friendica\Network\HTTPException\FoundException
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \Friendica\Network\HTTPException\MovedPermanentlyException
+ * @throws \Friendica\Network\HTTPException\NotFoundException
+ * @throws \Friendica\Network\HTTPException\TemporaryRedirectException
+ */
+ private function processGetActions(): void
+ {
+ $action = (string)$this->parameters['action'] ?? '';
+ $uid = (int)$this->parameters['uid'] ?? 0;
+
+ if ($uid === 0) {
+ return;
+ }
+
+ $user = User::getById($uid, ['username']);
+ if (!$user) {
+ $this->systemMessages->addNotice($this->t('User not found'));
+ $this->baseUrl->redirect('moderation/users');
+ }
+
+ switch ($action) {
+ case 'delete':
+ if ($this->session->getLocalUserId() != $uid) {
+ self::checkFormSecurityTokenRedirectOnError('moderation/users/active', 'moderation_users_active', 't');
+ // delete user
+ User::remove($uid);
+
+ $this->systemMessages->addNotice($this->t('User "%s" deleted', $user['username']));
+ } else {
+ $this->systemMessages->addNotice($this->t('You can\'t remove yourself'));
+ }
+
+ $this->baseUrl->redirect('moderation/users/active');
+ case 'block':
+ self::checkFormSecurityTokenRedirectOnError('moderation/users/active', 'moderation_users_active', 't');
+ User::block($uid);
+ $this->systemMessages->addNotice($this->t('User "%s" blocked', $user['username']));
+ $this->baseUrl->redirect('moderation/users/active');
+ }
+ }
}
{
parent::content();
- $action = (string) $this->parameters['action'] ?? '';
- $uid = (int) $this->parameters['uid'] ?? 0;
-
- if ($uid !== 0) {
- $user = User::getById($uid, ['username', 'blocked']);
- if (!$user) {
- $this->systemMessages->addNotice($this->t('User not found'));
- $this->baseUrl->redirect('moderation/users');
- }
- }
-
- switch ($action) {
- case 'delete':
- if ($this->session->getLocalUserId() != $uid) {
- self::checkFormSecurityTokenRedirectOnError('/moderation/users/blocked', 'moderation_users_blocked', 't');
- // delete user
- User::remove($uid);
-
- $this->systemMessages->addNotice($this->t('User "%s" deleted', $user['username']));
- } else {
- $this->systemMessages->addNotice($this->t('You can\'t remove yourself'));
- }
- $this->baseUrl->redirect('moderation/users/blocked');
- break;
- case 'unblock':
- self::checkFormSecurityTokenRedirectOnError('/moderation/users/blocked', 'moderation_users_blocked', 't');
- User::block($uid, false);
- $this->systemMessages->addNotice($this->t('User "%s" unblocked', $user['username']));
- $this->baseUrl->redirect('moderation/users/blocked');
- break;
- }
+ $this->processGetActions();
$pager = new Pager($this->l10n, $this->args->getQueryString(), 100);
'$pager' => $pager->renderFull($count)
]);
}
+
+ /**
+ * @return void
+ * @throws \Friendica\Network\HTTPException\FoundException
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \Friendica\Network\HTTPException\MovedPermanentlyException
+ * @throws \Friendica\Network\HTTPException\NotFoundException
+ * @throws \Friendica\Network\HTTPException\TemporaryRedirectException
+ */
+ private function processGetActions(): void
+ {
+ $action = (string)$this->parameters['action'] ?? '';
+ $uid = (int)$this->parameters['uid'] ?? 0;
+
+ if ($uid === 0) {
+ return;
+ }
+
+ $user = User::getById($uid, ['username']);
+ if (!$user) {
+ $this->systemMessages->addNotice($this->t('User not found'));
+ $this->baseUrl->redirect('moderation/users');
+ }
+
+ switch ($action) {
+ case 'delete':
+ if ($this->session->getLocalUserId() != $uid) {
+ self::checkFormSecurityTokenRedirectOnError('/moderation/users/blocked', 'moderation_users_blocked', 't');
+ // delete user
+ User::remove($uid);
+
+ $this->systemMessages->addNotice($this->t('User "%s" deleted', $user['username']));
+ } else {
+ $this->systemMessages->addNotice($this->t('You can\'t remove yourself'));
+ }
+ $this->baseUrl->redirect('moderation/users/blocked');
+ case 'unblock':
+ self::checkFormSecurityTokenRedirectOnError('/moderation/users/blocked', 'moderation_users_blocked', 't');
+ User::block($uid, false);
+ $this->systemMessages->addNotice($this->t('User "%s" unblocked', $user['username']));
+ $this->baseUrl->redirect('moderation/users/blocked');
+ }
+ }
}
{
parent::content();
- $action = (string) $this->parameters['action'] ?? '';
- $uid = (int) $this->parameters['uid'] ?? 0;
-
- if ($uid !== 0) {
- $user = User::getById($uid, ['username', 'blocked']);
- if (!$user) {
- $this->systemMessages->addNotice($this->t('User not found'));
- $this->baseUrl->redirect('moderation/users');
- }
- }
-
- switch ($action) {
- case 'delete':
- if ($this->session->getLocalUserId() != $uid) {
- self::checkFormSecurityTokenRedirectOnError($this->baseUrl, 'moderation_users', 't');
- // delete user
- User::remove($uid);
-
- $this->systemMessages->addNotice($this->t('User "%s" deleted', $user['username']));
- } else {
- $this->systemMessages->addNotice($this->t('You can\'t remove yourself'));
- }
-
- $this->baseUrl->redirect('moderation/users');
- break;
- case 'block':
- self::checkFormSecurityTokenRedirectOnError('moderation/users', 'moderation_users', 't');
- User::block($uid);
- $this->systemMessages->addNotice($this->t('User "%s" blocked', $user['username']));
- $this->baseUrl->redirect('moderation/users');
- break;
- case 'unblock':
- self::checkFormSecurityTokenRedirectOnError('moderation/users', 'moderation_users', 't');
- User::block($uid, false);
- $this->systemMessages->addNotice($this->t('User "%s" unblocked', $user['username']));
- $this->baseUrl->redirect('moderation/users');
- break;
- }
+ $this->processGetActions();
$pager = new Pager($this->l10n, $this->args->getQueryString(), 100);
'$pager' => $pager->renderFull($count),
]);
}
+
+ /**
+ * @return void
+ * @throws \Friendica\Network\HTTPException\FoundException
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \Friendica\Network\HTTPException\MovedPermanentlyException
+ * @throws \Friendica\Network\HTTPException\NotFoundException
+ * @throws \Friendica\Network\HTTPException\TemporaryRedirectException
+ */
+ private function processGetActions(): void
+ {
+ $action = (string) $this->parameters['action'] ?? '';
+ $uid = (int) $this->parameters['uid'] ?? 0;
+
+ if ($uid === 0) {
+ return;
+ }
+
+ $user = User::getById($uid, ['username']);
+ if (!$user) {
+ $this->systemMessages->addNotice($this->t('User not found'));
+ $this->baseUrl->redirect('moderation/users');
+ }
+
+ switch ($action) {
+ case 'delete':
+ if ($this->session->getLocalUserId() != $uid) {
+ self::checkFormSecurityTokenRedirectOnError($this->baseUrl, 'moderation_users', 't');
+ // delete user
+ User::remove($uid);
+
+ $this->systemMessages->addNotice($this->t('User "%s" deleted', $user['username']));
+ } else {
+ $this->systemMessages->addNotice($this->t('You can\'t remove yourself'));
+ }
+
+ $this->baseUrl->redirect('moderation/users');
+ case 'block':
+ self::checkFormSecurityTokenRedirectOnError('moderation/users', 'moderation_users', 't');
+ User::block($uid);
+ $this->systemMessages->addNotice($this->t('User "%s" blocked', $user['username']));
+ $this->baseUrl->redirect('moderation/users');
+ case 'unblock':
+ self::checkFormSecurityTokenRedirectOnError('moderation/users', 'moderation_users', 't');
+ User::block($uid, false);
+ $this->systemMessages->addNotice($this->t('User "%s" unblocked', $user['username']));
+ $this->baseUrl->redirect('moderation/users');
+ }
+ }
}