Skip to content

Commit e093f97

Browse files
committed
Fixing multiple URL list see BT#1555
1 parent af46a97 commit e093f97

File tree

2 files changed

+40
-49
lines changed

2 files changed

+40
-49
lines changed

main/admin/access_urls.php

Lines changed: 39 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -113,57 +113,48 @@
113113
echo Display::url(Display::return_icon('session.png', get_lang('ManageSessions'), array(), 32), api_get_path(WEB_CODE_PATH).'admin/access_url_edit_sessions_to_url.php');
114114
echo '</div>';
115115

116-
$table = new SortableTable('urls', 'url_count_mask', 'get_url_data_mask',2);
117-
$table->set_additional_parameters($parameters);
118-
$table->set_header(0, '', false);
119-
120-
$table->set_header(1, get_lang('URL'));
121-
$table->set_header(2, get_lang('Description'));
122-
$table->set_header(3, get_lang('Active'));
123-
$table->set_header(4, get_lang('Modify'));
124-
125-
$table->set_column_filter(3, 'active_filter');
126-
$table->set_column_filter(4, 'modify_filter');
127-
128-
129-
$table->display();
130-
131-
function modify_filter($active, $url_params, $row) {
132-
global $charset;
133-
$url_id = $row['0'];
134-
$result .= '<a href="access_url_edit.php?url_id='.$url_id.'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), 22).'</a>&nbsp;';
135-
if ($url_id != '1') {
136-
$result .= '<a href="access_urls.php?action=delete_url&amp;url_id='.$url_id.'&amp;sec_token='.$_SESSION['sec_token'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'), array(), 22).'</a>';
137-
}
138-
return $result;
116+
//$table = new SortableTable('urls', 'url_count_mask', 'get_url_data_mask',2);
117+
$sortable_data = UrlManager::get_url_data();
118+
$urls = array();
119+
foreach($sortable_data as $row) {
120+
//title
121+
$url = Display::url($row['url'], $row['url'], array('target'=>'_blank'));
122+
$description = $row['description'];
123+
124+
//Status
125+
$active = $row['active'];
126+
if ($active=='1') {
127+
$action='lock';
128+
$image='right';
129+
}
130+
if ($active=='0') {
131+
$action='unlock';
132+
$image='wrong';
133+
}
134+
// you cannot lock the default
135+
if ($row['id']=='1') {
136+
$status = Display::return_icon($image.'.gif', get_lang(ucfirst($action)));
137+
} else {
138+
$status = '<a href="access_urls.php?action='.$action.'&amp;url_id='.$row['id'].'&amp;sec_token='.$_SESSION['sec_token'].'">'.Display::return_icon($image.'.gif', get_lang(ucfirst($action))).'</a>';
139+
}
140+
//Actions
141+
$url_id = $row['id'];
142+
$actions = '<a href="access_url_edit.php?url_id='.$url_id.'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), 22).'</a>&nbsp;';
143+
if ($url_id != '1') {
144+
$actions = '<a href="access_urls.php?action=delete_url&amp;url_id='.$url_id.'&amp;sec_token='.$_SESSION['sec_token'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'), array(), 22).'</a>';
145+
}
146+
$urls[] = array($url, $description, $status, $actions);
139147
}
140148

141-
function active_filter($active, $url_params, $row) {
142-
$active = $row['3'];
143-
if ($active=='1') {
144-
$action='lock';
145-
$image='right';
146-
}
147-
if ($active=='0') {
148-
$action='unlock';
149-
$image='wrong';
150-
}
151-
// you cannot lock the default
152-
if ($row['0']=='1') {
153-
$result = Display::return_icon($image.'.gif', get_lang(ucfirst($action)));
154-
} else {
155-
$result = '<a href="access_urls.php?action='.$action.'&amp;url_id='.$row['0'].'&amp;sec_token='.$_SESSION['sec_token'].'">'.Display::return_icon($image.'.gif', get_lang(ucfirst($action))).'</a>';
156-
}
157-
return $result;
158-
}
149+
$table = new SortableTableFromArrayConfig($urls, 2, 50, 'urls');
150+
$table->set_additional_parameters($parameters);
159151

160-
// this 2 "mask" function are here just because the SortableTable
161-
function get_url_data_mask($id, $url_params=null, $row=null) {
162-
return UrlManager::get_url_data();
163-
}
164-
function url_count_mask() {
165-
return UrlManager::url_count();
166-
}
152+
//$table->set_header(0, '');
153+
$table->set_header(0, get_lang('URL'));
154+
$table->set_header(1, get_lang('Description'));
155+
$table->set_header(2, get_lang('Active'));
156+
$table->set_header(3, get_lang('Modify'), false);
157+
$table->display();
167158

168159
/* FOOTER */
169160
Display :: display_footer();

main/inc/lib/urlmanager.lib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public static function url_count()
122122
public static function get_url_data()
123123
{
124124
$table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
125-
$sql = "SELECT id, url, description, active FROM $table_access_url";
125+
$sql = "SELECT id, url, description, active FROM $table_access_url ORDER BY id";
126126
$res = Database::query($sql);
127127
$urls = array ();
128128
while ($url = Database::fetch_array($res)) {

0 commit comments

Comments
 (0)