|
9 | 9 | * @author Yannick Warnier <[email protected]>
|
10 | 10 | */
|
11 | 11 |
|
| 12 | +use Chamilo\CoreBundle\Entity\AccessUrl; |
12 | 13 | use Chamilo\CoreBundle\Enums\ActionIcon;
|
13 | 14 | use Chamilo\CoreBundle\Enums\StateIcon;
|
| 15 | +use Chamilo\CoreBundle\Framework\Container; |
14 | 16 | use Symfony\Component\HttpFoundation\Request as HttpRequest;
|
15 | 17 |
|
16 | 18 | $cidReset = true;
|
|
26 | 28 |
|
27 | 29 | $my_user_url_list = api_get_access_url_from_user(api_get_user_id());
|
28 | 30 | $current_access_url_id = api_get_current_access_url_id();
|
29 |
| -$url_list = UrlManager::get_url_data(); |
| 31 | +/** @var array<int, AccessUrl> $url_list */ |
| 32 | +$url_list = Container::getAccessUrlRepository()->findAll(); |
30 | 33 |
|
31 | 34 | // Actions
|
32 | 35 | if ($httpRequest->query->has('action')) {
|
|
55 | 58 | if (api_is_platform_admin() && -1 != $current_access_url_id) {
|
56 | 59 | $url_str = '';
|
57 | 60 | foreach ($url_list as $u) {
|
58 |
| - if (!in_array($u['id'], $my_user_url_list)) { |
59 |
| - UrlManager::add_user_to_url(api_get_user_id(), $u['id']); |
60 |
| - $url_str .= $u['url'] . '<br />'; |
| 61 | + if (!in_array($u->getId(), $my_user_url_list)) { |
| 62 | + UrlManager::add_user_to_url(api_get_user_id(), $u->getId()); |
| 63 | + $url_str .= $u->getUrl() . '<br />'; |
61 | 64 | }
|
62 | 65 | }
|
63 | 66 | echo Display::return_message(
|
|
76 | 79 | // Checking if the admin is registered in all sites
|
77 | 80 | $url_string = '';
|
78 | 81 | foreach ($url_list as $u) {
|
79 |
| - if (!in_array($u['id'], $my_user_url_list)) { |
80 |
| - $url_string .= $u['url'] . '<br />'; |
| 82 | + if (!in_array($u->getId(), $my_user_url_list)) { |
| 83 | + $url_string .= $u->getUrl() . '<br />'; |
81 | 84 | }
|
82 | 85 | }
|
83 | 86 | if (!empty($url_string)) {
|
|
110 | 113 | // 1) Find the default URL (ID = 1)
|
111 | 114 | $defaultUrl = 'http://localhost/';
|
112 | 115 | foreach ($url_list as $u) {
|
113 |
| - if ((string)$u['id'] === '1') { |
114 |
| - $defaultUrl = trim($u['url']); |
| 116 | + if ($u->getId() === 1) { |
| 117 | + $defaultUrl = trim($u->getUrl()); |
115 | 118 | break;
|
116 | 119 | }
|
117 | 120 | }
|
|
182 | 185 |
|
183 | 186 | $rows = [];
|
184 | 187 | foreach ($url_list as $u) {
|
185 |
| - $link = Display::url($u['url'], $u['url'], ['target' => '_blank']); |
186 |
| - $desc = $u['description']; |
187 |
| - $ts = api_get_local_time($u['tms']); |
188 |
| - $active = ($u['active'] === '1'); |
| 188 | + $link = Display::url($u->getUrl(), $u->getUrl(), ['target' => '_blank']); |
| 189 | + $desc = $u->getDescription(); |
| 190 | + $ts = api_get_local_time($u->getTms()); |
| 191 | + $active = ($u->getActive() === 1); |
189 | 192 |
|
190 | 193 | $iconAction = $active ? 'lock' : 'unlock';
|
191 | 194 | $stateIcon = $active ? StateIcon::ACTIVE : StateIcon::INACTIVE;
|
192 | 195 |
|
193 |
| - if ((string)$u['id'] === '1') { |
| 196 | + if ($u->getId() === 1) { |
194 | 197 | $status = Display::getMdiIcon($stateIcon, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang(ucfirst($iconAction)));
|
195 | 198 | } else {
|
196 |
| - $status = '<a href="access_urls.php?action=' . $iconAction . '&url_id=' . $u['id'] . '">' . |
| 199 | + $status = '<a href="access_urls.php?action=' . $iconAction . '&url_id=' . $u->getId() . '">' . |
197 | 200 | Display::getMdiIcon($stateIcon, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang(ucfirst($iconAction))) .
|
198 | 201 | '</a>';
|
199 | 202 | }
|
200 | 203 |
|
201 | 204 | $rowActions = Display::url(
|
202 | 205 | Display::getMdiIcon(ActionIcon::EDIT, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Edit')),
|
203 |
| - "access_url_edit.php?url_id={$u['id']}" |
| 206 | + "access_url_edit.php?url_id={$u->getId()}" |
204 | 207 | );
|
205 | 208 |
|
206 |
| - if ((string)$u['id'] !== '1') { |
207 |
| - $rowActions .= '<a href="access_urls.php?action=delete_url&url_id=' . $u['id'] . '" ' . |
| 209 | + if ($u->getId() !== 1) { |
| 210 | + $rowActions .= '<a href="access_urls.php?action=delete_url&url_id=' . $u->getId() . '" ' . |
208 | 211 | 'onclick="return confirm(\'' . addslashes(get_lang('Please confirm your choice')) . '\');">' .
|
209 | 212 | Display::getMdiIcon('delete', 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Delete')) .
|
210 | 213 | '</a>';
|
|
0 commit comments