--- banner.module	Mon Aug  9 21:33:42 2004
+++ modules/banner.module	Mon Aug  9 22:09:03 2004
@@ -61,19 +61,6 @@
                    'type' => MENU_CALLBACK,
                    'access' => $view_access);
 
-  if ($admin_access) {
-    $items[] = array('path' => 'admin/banner/edit',
-                     'title' => t('edit'),
-                     'type' => MENU_CALLBACK,
-                     'callback' => 'banner_admin',
-                     'callback arguments' => 'edit');
-    $items[] = array('path' => 'admin/banner/view',
-                     'title' => t('view'),
-                     'type' => MENU_CALLBACK,
-                     'callback' => 'banner_admin',
-                     'callback arguments' => 'view');
-  }
-
   // Menu items
   if ($manage_access) {
     $items[] = array('path' => 'banner/user',
@@ -90,10 +77,15 @@
                      'callback' => 'banner_admin',
                      'callback arguments' => 'list',
                      'access' => $admin_access);
+    $items[] = array('path' => 'admin/banner/' . arg(2),
+                     'title' => t('banner'),
+                     'callback' => 'banner_admin',
+                     'callback arguments' => 'view ' . arg(2),
+                     'access' => $admin_access);
   }
 
   // Tabs
-  if ($manage_access) {
+  if ($manage_access && arg(0) == 'banner') {
     $items[] = array('path' => 'banner/user/view',
                      'title' => t('view'),
                      'type' => MENU_DEFAULT_LOCAL_TASK,
@@ -105,9 +97,23 @@
                      'callback arguments' => 'user add');
   }
 
-  if ($admin_access) {
+  if ($admin_access && arg(0) == 'admin' && is_numeric(arg(2))) {
+    $items[] = array('path' => 'admin/banner/' . arg(2) . '/edit',
+                     'title' => t('edit'),
+                     'type' => MENU_LOCAL_TASK,
+                     'callback' => 'banner_admin',
+                     'callback arguments' => 'edit ' . arg(2));
+    $items[] = array('path' => 'admin/banner/' . arg(2) . '/view',
+                     'title' => t('view'),
+                     'type' => MENU_DEFAULT_LOCAL_TASK,
+                     'callback' => 'banner_admin',
+                     'callback arguments' => 'view ' . arg(2),
+                     'weight' => -10);
+  }
+
+  if ($admin_access && arg(0) == 'admin') {
     $items[] = array('path' => 'admin/banner/list',
-                     'title' => 'list',
+                     'title' => t('list'),
                      'type' => MENU_DEFAULT_LOCAL_TASK,
                      'weight' => -10);
     $items[] = array('path' => 'admin/banner/add',
@@ -124,13 +130,13 @@
 
 
   // Subtabs
-  if ($manage_access) {
+  if ($manage_access && arg(0) == 'banner') {
     $items[] = array('path' => 'banner/user/view/user',
                      'title' => t('mine'),
                      'type' => MENU_DEFAULT_LOCAL_TASK,
                      'weight' => -10);
   }
-  if ($admin_access) {
+  if ($admin_access && arg(0) == 'banner') {
     $items[] = array('path' => 'banner/user/view/all',
                      'title' => t('all'),
                      'type' => MENU_LOCAL_TASK,
@@ -585,11 +591,18 @@
 function banner_admin() {
 
   $op = $_POST['op'];
-  if (!$op) {
-    $op = arg(2);
+  if (!$op && arg(2)) {
+    if (is_numeric(arg(2))) {
+      $id = arg(2);
+      $op = arg(3);
+      !$op && $op = 'view';
+    }
+    else {
+      $id = arg(3);
+      $op = arg(2);
+    }
   }
   $edit = $_POST['edit'];
-  $id = arg(3);
 
   $output = '';
   if (user_access('administer banners')) {
@@ -723,8 +736,6 @@
              array('data' => $banner->chance, 'align' => 'center')
            ));
     $output .= theme('table', $headers, $row);
-
-    $output .= '<hr>['. l(t('edit'), "admin/banner/edit/$banner->id") ."]\n";
   }
   else {
     $output = 'No banner selected.';
@@ -898,7 +909,7 @@
     $row[] = array('data' => $banner->views, 'align' => 'center');
     $row[] = array('data' => $banner->clicks, 'align' => 'center');
     // TODO: update "edit" page to offer ability to edit all attributes
-    $row[] = array('data' => '['. l(t('view'), "admin/banner/view/$banner->id") .'] ['. l(t('edit'), "admin/banner/edit/$banner->id") .']', 'align' => 'center');
+    $row[] = array('data' => '['. l(t('view'), "admin/banner/{$banner->id}/view") .'] ['. l(t('edit'), "admin/banner/{$banner->id}/edit") .']', 'align' => 'center');
     $rows[] = $row;
   }
   if($pager = theme('pager', NULL, 20, 0, tablesort_pager())) {
