diff --git a/app/DoctrineMigrations/Version20160329035248.php b/app/DoctrineMigrations/Version20160329035248.php new file mode 100644 index 0000000..5ac9be5 --- /dev/null +++ b/app/DoctrineMigrations/Version20160329035248.php @@ -0,0 +1,34 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE users.rename_log DROP new_login'); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE users.rename_log ADD new_login TEXT DEFAULT \'\''); + } +} diff --git a/src/Skobkin/Bundle/PointToolsBundle/Controller/UserController.php b/src/Skobkin/Bundle/PointToolsBundle/Controller/UserController.php index e622303..e328161 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Controller/UserController.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Controller/UserController.php @@ -32,7 +32,8 @@ class UserController extends Controller return $this->render('SkobkinPointToolsBundle:User:show.html.twig', [ 'user' => $user, 'subscribers' => $em->getRepository('SkobkinPointToolsBundle:User')->findUserSubscribersById($user->getId()), - 'log' => $em->getRepository('SkobkinPointToolsBundle:SubscriptionEvent')->getUserLastSubscribersEventsById($user, 10), + 'subscriptions_log' => $em->getRepository('SkobkinPointToolsBundle:SubscriptionEvent')->getUserLastSubscribersEventsById($user, 10), + 'rename_log' => $em->getRepository('SkobkinPointToolsBundle:UserRenameEvent')->findBy(['user' => $user], ['date' => 'DESC'], 10), 'avatar_url' => $userApi->getAvatarUrl($user, UserApi::AVATAR_SIZE_LARGE), ]); } diff --git a/src/Skobkin/Bundle/PointToolsBundle/Entity/UserRenameEvent.php b/src/Skobkin/Bundle/PointToolsBundle/Entity/UserRenameEvent.php index 46edae2..caf7367 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Entity/UserRenameEvent.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Entity/UserRenameEvent.php @@ -47,19 +47,11 @@ class UserRenameEvent */ private $oldLogin; - /** - * @var string - * - * @ORM\Column(name="new_login", type="text") - */ - private $newLogin; - - public function __construct(User $user, $old, $new) + public function __construct(User $user, $old) { $this->user = $user; $this->oldLogin = $old; - $this->newLogin = $new; } /** @@ -126,29 +118,6 @@ class UserRenameEvent return $this->oldLogin; } - /** - * Set newLogin - * - * @param string $newLogin - * @return UserRenameEvent - */ - public function setNewLogin($newLogin) - { - $this->newLogin = $newLogin; - - return $this; - } - - /** - * Get newLogin - * - * @return string - */ - public function getNewLogin() - { - return $this->newLogin; - } - /** * Set user * diff --git a/src/Skobkin/Bundle/PointToolsBundle/EventListener/UserRenameSubscriber.php b/src/Skobkin/Bundle/PointToolsBundle/EventListener/UserRenameSubscriber.php index fc9636b..90a97c2 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/EventListener/UserRenameSubscriber.php +++ b/src/Skobkin/Bundle/PointToolsBundle/EventListener/UserRenameSubscriber.php @@ -36,10 +36,7 @@ class UserRenameSubscriber implements EventSubscriber } if ($event->hasChangedField('login')) { - $old = $event->getOldValue('login'); - $new = $event->getNewValue('login'); - - $this->items[] = new UserRenameEvent($entity, $old, $new); + $this->items[] = new UserRenameEvent($entity, $event->getOldValue('login')); } } diff --git a/src/Skobkin/Bundle/PointToolsBundle/Resources/translations/messages.ru.yml b/src/Skobkin/Bundle/PointToolsBundle/Resources/translations/messages.ru.yml index e1e9d66..8aa3477 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Resources/translations/messages.ru.yml +++ b/src/Skobkin/Bundle/PointToolsBundle/Resources/translations/messages.ru.yml @@ -27,9 +27,13 @@ Subscriptions log: Лог подписок User: Пользователь Action: Действие Date: Дата +Rename log: Лог переименований +Old login: Старый логин +New login: Новый логин No subscribers data found: Информация о подписчиках отсутствует -No log data found: Лог отсутствует +No rename log data found: Лог переименований отсутствует +No subscribers log data found: Лог подписчиков отсутствует # Топ пользователей Top users: Популярные пользователи diff --git a/src/Skobkin/Bundle/PointToolsBundle/Resources/views/User/show.html.twig b/src/Skobkin/Bundle/PointToolsBundle/Resources/views/User/show.html.twig index 7630503..038b949 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Resources/views/User/show.html.twig +++ b/src/Skobkin/Bundle/PointToolsBundle/Resources/views/User/show.html.twig @@ -35,8 +35,51 @@ {% endif %} +
+ {% if rename_log|length > 0 %} +
+
+ +
+
+ + + + + + + + + {% for event in rename_log %} + + + + + {% endfor %} + +
{{ 'Date'|trans }}{{ 'Old login'|trans }}
+ {# @todo Use DateTime helper: https://sonata-project.org/bundles/intl/master/doc/reference/datetime.html #} + {{ event.date|date('d F Y H:i:s') }} + + {{ event.oldLogin }} +
+
+
+
+
+ {% else %} + + {% endif %} +
+
- {% if log|length > 0 %} + {% if subscriptions_log|length > 0 %}
@@ -57,7 +100,7 @@ - {% for event in log %} + {% for event in subscriptions_log %} @{{ event.subscriber.login }} @@ -78,7 +121,7 @@
{% else %} - + {% endif %}