diff --git a/src/Controller/UserPanel.php b/src/Controller/UserPanel.php index ae565ad438..94f488a101 100644 --- a/src/Controller/UserPanel.php +++ b/src/Controller/UserPanel.php @@ -38,6 +38,7 @@ use App\Core\Form; use function App\Core\I18n\_m; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; +use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextType; @@ -88,23 +89,33 @@ class UserPanel extends AbstractController [_m('emailnotifyfav'), CheckboxType::class, ['help' => 'Send me email when someone adds my notice as a favorite.', 'label_format' => 'Notify favorites']], ['save', SubmitType::class, ['label' => _m('Save')]], ]); - $acc->handleRequest($request); - if ($acc->isSubmitted()) { - $data = $acc->getData(); - if ($prof->isValid()) { - $user = DB::find('\App\Entity\User', ['id' => 2]); - foreach (['outgoing_email', 'password', 'emailnotifysub', 'emailnotifymsg', 'emailnotifyattn', 'emailnotifynudge', 'emailnotifyfav'] as $key) { - $method = "set{$key}"; - $user->{$method}($data[_m($key)]); - } - DB::flush(); - } else { - // Display error - } - } - return $this->render('settings/account.html.twig', [ 'acc' => $acc->createView(), ]); } -} + + public function avatar(Request $request) + { + $avatar = Form::create([ + [_m('avatar'), FileType::class, ['help' => 'You can upload your personal avatar. The maximum file size is 64MB.', 'label_format' => 'Avatar']], + ['save', SubmitType::class, ['label' => _m('Submit')]], ]); + + return $this->render('settings/avatar.html.twig', [ + 'avatar' => $avatar->createView(), + ]); + } + + public function misc(Request $request) + { + $misc = Form::create([ + [_m('transport'), TextType::class, ['help' => 'Address used to send and receive notices through IM.', 'label_format' => 'XMPP/Jabber']], + [_m('post_on_status_change'), CheckboxType::class, ['help' => 'Post a notice when my status changes.', 'label_format' => 'Status change']], + [_m('mention'), CheckboxType::class, ['help' => 'Send me replies from people I\'m not subscribed to.', 'label_format' => 'Mentions']], + [_m('posts_by_followed'), CheckboxType::class, ['help' => 'Send me notices.', 'label_format' => 'Notices']], + ['save', SubmitType::class, ['label' => _m('Save')]], ]); + + return $this->render('settings/misc.html.twig', [ + 'misc' => $misc->createView(), + ]); + } +} \ No newline at end of file diff --git a/src/Routes/Main.php b/src/Routes/Main.php index 0677056f76..ab1c6eb62d 100644 --- a/src/Routes/Main.php +++ b/src/Routes/Main.php @@ -48,12 +48,22 @@ abstract class Main } // Settings pages - foreach (['profile', 'avatar'] as $s) { + foreach (['profile', 'avatar', 'misc', 'account'] as $s) { $r->connect('settings_' . $s, 'settings/' . $s, [C\UserPanel::class, 'profile']); - } - - foreach (['account'] as $s) { - $r->connect('settings_' . $s, 'settings/' . $s, [C\UserPanel::class, 'account']); + switch ($s) { + case 'profile': + $r->connect('settings_' . $s, 'settings/' . $s, [C\UserPanel::class, 'profile']); + break; + case 'avatar': + $r->connect('settings_' . $s, 'settings/' . $s, [C\UserPanel::class, 'avatar']); + break; + case 'misc': + $r->connect('settings_' . $s, 'settings/' . $s, [C\UserPanel::class, 'misc']); + break; + case 'account': + $r->connect('settings_' . $s, 'settings/' . $s, [C\UserPanel::class, 'account']); + break; + } } } } diff --git a/templates/settings/account.html.twig b/templates/settings/account.html.twig index 6c18d914db..8d1ec5aba9 100644 --- a/templates/settings/account.html.twig +++ b/templates/settings/account.html.twig @@ -22,7 +22,7 @@ Account
  • - Misc + Misc
  • diff --git a/templates/settings/avatar.html.twig b/templates/settings/avatar.html.twig index 8215b148e2..962e1dbb34 100644 --- a/templates/settings/avatar.html.twig +++ b/templates/settings/avatar.html.twig @@ -6,52 +6,40 @@ {% endblock %} -{% block nav %} - - -{% endblock %} +{% block title %}Avatar Settings{% endblock %} + +{% block header %}{{ parent() }}{% endblock %} {% block body %} +
    -
    -
    {{ form_label(prof.Nickname) }}
    {{ form_widget(prof.Nickname) }} -
    -
    -
    {{ form_label(prof.FullName) }}
    {{ form_widget(prof.FullName) }} -
    -
    -
    {{ form_label(prof.Homepage) }}
    {{ form_widget(prof.Homepage) }} -
    -
    -
    {{ form_label(prof.Bio) }}
    {{ form_widget(prof.Bio) }} -
    -
    -
    {{ form_label(prof.Location) }}
    {{ form_widget(prof.Location) }} -
    -
    - {{ form_widget(prof.save) }} -
    + + + {% block form %} +
    + {{ form(avatar) }} +
    + {% endblock %}
    -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/templates/settings/misc.html.twig b/templates/settings/misc.html.twig new file mode 100644 index 0000000000..a1a12e4225 --- /dev/null +++ b/templates/settings/misc.html.twig @@ -0,0 +1,39 @@ +{% extends 'base.html.twig' %} +{% block stylesheets %} + {{ parent() }} + + + +{% endblock %} + +{% block title %}Misc Settings{% endblock %} + +{% block header %}{{ parent() }}{% endblock %} + +{% block body %} + +
    + + + {% block form %} + +
    + {{ form(misc) }} +
    + + {% endblock %} +
    + +{% endblock %} diff --git a/templates/settings/profile.html.twig b/templates/settings/profile.html.twig index 1d48b9609c..8cf58251d2 100644 --- a/templates/settings/profile.html.twig +++ b/templates/settings/profile.html.twig @@ -22,7 +22,7 @@ Account
  • - Misc + Misc