Skip to content

Commit 9ade21b

Browse files
committed
fix edit access url - refs BT#22639
1 parent d10cef6 commit 9ade21b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

public/main/admin/access_url_edit.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
$httpRequest = HttpRequest::createFromGlobals();
2121
$urlRepo = Container::getAccessUrlRepository();
22+
$urlHelper = Container::getAccessUrlUtil();
2223

2324
$form = new FormValidator('add_url');
2425

@@ -63,18 +64,18 @@
6364

6465
$form->addHidden(
6566
'parentResourceNodeId',
66-
Container::getAccessUrlUtil()->getFirstAccessUrl()->resourceNode->getId()
67+
$urlHelper->getFirstAccessUrl()->resourceNode->getId()
6768
);
6869

6970
//the first url with id = 1 will be always active
7071
if ($httpRequest->query->has('url_id')) {
71-
if (1 !== $httpRequest->query->getInt('url_id')) {
72+
if ($urlHelper->getFirstAccessUrl()?->getId() !== $httpRequest->query->getInt('url_id')) {
7273
$form->addElement('checkbox', 'active', null, get_lang('active'));
7374
}
74-
} else {
75-
$form->addCheckBox('login_only', get_lang('Login only'), get_lang('Yes'));
7675
}
7776

77+
$form->addCheckBox('login_only', get_lang('Login only'), get_lang('Yes'));
78+
7879
$form->addButtonCreate(get_lang('Save'));
7980

8081
if ($form->validate()) {
@@ -105,7 +106,7 @@
105106
->setDescription($description)
106107
->setActive($active)
107108
->setCreatedBy(api_get_user_id())
108-
->setTms(api_get_utc_datetime())
109+
->setTms(api_get_utc_datetime(null, false, true))
109110
->setIsLoginOnly($isLoginOnly)
110111
;
111112

src/CoreBundle/Entity/Listener/AccessUrlListener.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
use Chamilo\CoreBundle\Entity\AccessUrl;
1010
use Chamilo\CoreBundle\Helpers\AccessUrlHelper;
1111
use Chamilo\CoreBundle\Repository\Node\AccessUrlRepository;
12+
use Doctrine\ORM\Event\PostFlushEventArgs;
1213
use Doctrine\ORM\Event\PostPersistEventArgs;
14+
use Doctrine\ORM\Event\PostUpdateEventArgs;
1315
use Doctrine\ORM\Event\PrePersistEventArgs;
16+
use Doctrine\Persistence\ObjectManager;
1417

1518
readonly class AccessUrlListener
1619
{
@@ -55,8 +58,6 @@ public function postPersist(AccessUrl $currentAccessUrl, PostPersistEventArgs $a
5558
return;
5659
}
5760

58-
$om = $args->getObjectManager();
59-
6061
/** @var array<int, AccessUrl> $all */
6162
$all = $this->accessUrlRepo->findAll();
6263

@@ -73,6 +74,6 @@ public function postPersist(AccessUrl $currentAccessUrl, PostPersistEventArgs $a
7374
;
7475
}
7576

76-
$om->flush();
77+
$args->getObjectManager()->flush();
7778
}
7879
}

0 commit comments

Comments
 (0)