2020-06-22 07:56:26 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// {{{ License
|
|
|
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
|
|
|
//
|
|
|
|
// GNU social is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// GNU social is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
// }}}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle network public feed
|
|
|
|
*
|
|
|
|
* @package GNUsocial
|
|
|
|
* @category Controller
|
|
|
|
*
|
2020-06-27 07:44:53 +09:00
|
|
|
* @author Hugo Sales <hugo@fc.up.pt>
|
2020-07-01 01:35:38 +09:00
|
|
|
* @author Eliseu Amaro <eliseu@fc.up.pt>
|
2020-06-22 07:56:26 +09:00
|
|
|
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
|
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
2020-07-07 05:51:08 +09:00
|
|
|
use App\Core\Controller;
|
2020-07-05 08:48:35 +09:00
|
|
|
// use App\Core\Event;
|
|
|
|
// use App\Util\Common;
|
|
|
|
use App\Core\DB\DB;
|
2020-06-27 07:44:53 +09:00
|
|
|
use App\Core\Form;
|
2020-06-22 07:56:26 +09:00
|
|
|
use function App\Core\I18n\_m;
|
|
|
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
|
2020-07-07 05:51:08 +09:00
|
|
|
class UserAdminPanel extends Controller
|
2020-06-22 07:56:26 +09:00
|
|
|
{
|
2020-07-07 05:51:08 +09:00
|
|
|
public function handle(Request $request)
|
2020-06-22 07:56:26 +09:00
|
|
|
{
|
2020-06-29 07:50:05 +09:00
|
|
|
$prof = Form::create([
|
2020-06-28 07:47:18 +09:00
|
|
|
[_m('Nickname'), TextType::class],
|
|
|
|
[_m('FullName'), TextType::class],
|
|
|
|
[_m('Homepage'), TextType::class],
|
2020-07-07 05:51:08 +09:00
|
|
|
[_m('Bio'), TextType::class],
|
2020-06-28 07:47:18 +09:00
|
|
|
[_m('Location'), TextType::class],
|
2020-07-07 05:51:08 +09:00
|
|
|
['save', SubmitType::class, ['label' => _m('Save')]],
|
|
|
|
]);
|
2020-06-22 07:56:26 +09:00
|
|
|
|
2020-06-29 07:50:05 +09:00
|
|
|
$prof->handleRequest($request);
|
2020-07-05 08:48:35 +09:00
|
|
|
if ($prof->isSubmitted()) {
|
|
|
|
$data = $prof->getData();
|
|
|
|
if ($prof->isValid()) {
|
|
|
|
$profile = DB::find('\App\Entity\Profile', ['id' => 2]);
|
|
|
|
foreach (['Nickname', 'FullName', 'Homepage', 'Bio', 'Location'] as $key) {
|
|
|
|
$method = "set{$key}";
|
|
|
|
$profile->{$method}($data[_m($key)]);
|
|
|
|
}
|
|
|
|
DB::flush();
|
|
|
|
} else {
|
|
|
|
// Display error
|
|
|
|
}
|
|
|
|
}
|
2020-06-22 07:56:26 +09:00
|
|
|
|
2020-07-07 05:51:08 +09:00
|
|
|
return [
|
|
|
|
'_template' => 'settings/profile.html.twig',
|
|
|
|
'prof' => $prof->createView(),
|
|
|
|
];
|
2020-06-22 07:56:26 +09:00
|
|
|
}
|
2020-06-27 07:44:53 +09:00
|
|
|
}
|