Index: og/og.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og/og.module,v
retrieving revision 1.367
diff -u -p -r1.367 og.module
--- og/og.module	9 Jul 2007 14:58:55 -0000	1.367
+++ og/og.module	29 Jul 2007 14:08:53 -0000
@@ -32,10 +32,10 @@ define('OG_NOTIFICATION_SELECTIVE', 2);
 
 function og_help($section) {
   switch ($section) {
-    case strlen(section) && strstr($section, 'admin/build/block/configure/og'):
+    case strlen(section) && strstr($section, og_url('admin/build/block/configure/og')):
       return t('Group specific blocks are only visible on group pages and not on systemwide pages like the home page or admin pages.');
-    case 'admin/settings/og':
-      return t('In order to let group admins determine their own group theme, you must enable multiple themes using !page.', array('!page' => l(t('theme configuration page'), 'admin/build/themes')));
+    case og_url('admin/settings/og'):
+      return t('In order to let group admins determine their own group theme, you must enable multiple themes using !page.', array('!page' => l(t('theme configuration page'), og_url('admin/build/themes'))));
   }
 }
 
@@ -46,22 +46,22 @@ function og_menu($may_cache) {
 
   if ($may_cache) {
     // anon users should be able to get to the subscribe page
-    $items[] = array('path' => 'og/subscribe', 'type' => MENU_CALLBACK, 'callback' => 'og_subscribe', 'access' => TRUE, 'title' => t('Subscribe to group'));
+    $items[] = array('path' => og_url('og/subscribe'), 'type' => MENU_CALLBACK, 'callback' => 'og_subscribe', 'access' => TRUE, 'title' => t('Subscribe to group'));
     
-    $items[] = array('path' => 'og/opml', 'type' => MENU_CALLBACK, 'callback' => 'og_opml', 'access' => $access, 'title' => t('OPML'));
-    $items[] = array('path' => 'og/unsubscribe', 'type' => MENU_CALLBACK, 'callback' => 'og_unsubscribe', 'access' => $access, 'title' => t('Unsubscribe from group'));
-    $items[] = array('path' => 'og/approve', 'type' => MENU_CALLBACK, 'callback' => 'og_approve', 'access' => $access, 'title' => t('Approve subscription request'));
-    $items[] = array('path' => 'og/deny', 'type' => MENU_CALLBACK, 'callback' => 'og_deny', 'access' => $access, 'title' => t('Deny subscription request'));
-    $items[] = array('path' => 'og/create_admin', 'type' => MENU_CALLBACK, 'callback' => 'og_create_admin', 'access' => $access, 'title' => t('Create group administrator'));
-    $items[] = array('path' => 'og/delete_admin', 'type' => MENU_CALLBACK, 'callback' => 'og_delete_admin', 'access' => $access, 'title' => t('Delete group administrator'));
-    $items[] = array('path' => 'og/feed', 'callback' => 'og_feed', 'title' => t('Group feed'), 'type' => MENU_CALLBACK, 'access' => user_access('access content'));
+    $items[] = array('path' => og_url('og/opml'), 'type' => MENU_CALLBACK, 'callback' => 'og_opml', 'access' => $access, 'title' => t('OPML'));
+    $items[] = array('path' => og_url('og/unsubscribe'), 'type' => MENU_CALLBACK, 'callback' => 'og_unsubscribe', 'access' => $access, 'title' => t('Unsubscribe from group'));
+    $items[] = array('path' => og_url('og/approve'), 'type' => MENU_CALLBACK, 'callback' => 'og_approve', 'access' => $access, 'title' => t('Approve subscription request'));
+    $items[] = array('path' => og_url('og/deny'), 'type' => MENU_CALLBACK, 'callback' => 'og_deny', 'access' => $access, 'title' => t('Deny subscription request'));
+    $items[] = array('path' => og_url('og/create_admin'), 'type' => MENU_CALLBACK, 'callback' => 'og_create_admin', 'access' => $access, 'title' => t('Create group administrator'));
+    $items[] = array('path' => og_url('og/delete_admin'), 'type' => MENU_CALLBACK, 'callback' => 'og_delete_admin', 'access' => $access, 'title' => t('Delete group administrator'));
+    $items[] = array('path' => og_url('og/feed'), 'callback' => 'og_feed', 'title' => t('Group feed'), 'type' => MENU_CALLBACK, 'access' => user_access('access content'));
     
     // members only
-    $items[] = array('path' => "og/invite", 'callback' => 'og_menu_check', 'title' => t('Send invitation'), 'callback arguments' => array('og_invite_page'), 'type' => MENU_CALLBACK, 'access' => $access);
-    $items[] = array('path' => "og/manage", 'callback' => 'og_menu_check', 'title' => t('Manage subscription'), 'callback arguments' => array('og_manage'), 'type' => MENU_CALLBACK, 'access' => $access);
+    $items[] = array('path' => og_url('og/invite'), 'callback' => 'og_menu_check', 'title' => t('Send invitation'), 'callback arguments' => array('og_invite_page'), 'type' => MENU_CALLBACK, 'access' => $access);
+    $items[] = array('path' => og_url('og/manage'), 'callback' => 'og_menu_check', 'title' => t('Manage subscription'), 'callback arguments' => array('og_manage'), 'type' => MENU_CALLBACK, 'access' => $access);
     
     $items[] = array(
-      'path' => 'og/activity', 
+      'path' => og_url('og/activity'), 
       'title' => t('Group activity'), 
       'callback' => 'og_page_activity',  
       'access' => user_access('administer organic groups'), 
@@ -69,7 +69,7 @@ function og_menu($may_cache) {
       'type' => MENU_LOCAL_TASK,
     );
     $items[] = array(
-      'path' => 'admin/og', 
+      'path' => og_url('admin/og'), 
       'title' => t('Organic groups'),
       'description' => t('Administer the suite of Organic groups modules.'),
       'position' => 'right',
@@ -77,7 +77,7 @@ function og_menu($may_cache) {
       'callback' => 'system_admin_menu_block_page',
       'access' => user_access('administer site configuration')
       );
-    $items[] = array('path' => 'admin/og/og', 'callback' => 'drupal_get_form', 'callback arguments' => array('og_admin_settings'), 'title' => t('Organic groups configuration'), 'description' => t('Configure the main Organic groups module (og)'), 'weight' => -5,);
+    $items[] = array('path' => og_url('admin/og/og'), 'callback' => 'drupal_get_form', 'callback arguments' => array('og_admin_settings'), 'title' => t('Organic groups configuration'), 'description' => t('Configure the main Organic groups module (og)'), 'weight' => -5,);
   }
   else {
     drupal_add_css(drupal_get_path('module', 'og'). '/og.css');
@@ -87,22 +87,24 @@ function og_menu($may_cache) {
 
     //subscribers page and its 'add subscribers' tab
     $gid = arg(2);
+    $url_values = array('gid' => $gid);
+    // TODO: the following line should be using og_url('og/users/%gid', $url_values) or similar:
     if (arg(0) == 'og' && arg(1) == 'users' && is_numeric($gid)) {
-      $items[] = array('path' => "og/users/$gid", 'callback' => 'og_menu_check', 'title' => t('Subscribers'), 'callback arguments' => array('og_list_users_page', $gid), 'type' => MENU_CALLBACK, 'access' => $access);
-      $items[] = array('path' => "og/users/$gid/list", 'title' => t('List'), 'type' => MENU_DEFAULT_LOCAL_TASK);
+      $items[] = array('path' => og_url('og/users/%gid', $url_values), 'callback' => 'og_menu_check', 'title' => t('Subscribers'), 'callback arguments' => array('og_list_users_page', $gid), 'type' => MENU_CALLBACK, 'access' => $access);
+      $items[] = array('path' => og_url('og/users/%gid/list', $url_values), 'title' => t('List'), 'type' => MENU_DEFAULT_LOCAL_TASK);
       if (og_is_picture()) {
-        $items[] = array('path' => "og/users/$gid/faces", 'title' => t('Faces'), 'callback' => 'og_menu_check', 'callback arguments' => array('og_list_users_faces_page', $gid), 'type' => MENU_LOCAL_TASK);
+        $items[] = array('path' => og_url('og/users/%gid/faces', $url_values), 'title' => t('Faces'), 'callback' => 'og_menu_check', 'callback arguments' => array('og_list_users_faces_page', $gid), 'type' => MENU_LOCAL_TASK);
       }
       // group admin only
       $node = node_load($gid);
-      $items[] = array('path' => "og/users/$gid/add_user", 'callback' => 'drupal_get_form', 'title' => t('Add subscribers'), 'callback arguments' => array('og_add_users', $gid), 'type' => MENU_LOCAL_TASK, 'weight' => 5, 'access' => node_access('update', $node));
+      $items[] = array('path' => og_url('og/users/%gid/add_user', $url_values), 'callback' => 'drupal_get_form', 'title' => t('Add subscribers'), 'callback arguments' => array('og_add_users', $gid), 'type' => MENU_LOCAL_TASK, 'weight' => 5, 'access' => node_access('update', $node));
     }
     
     // email tab on group node
     if (arg(0) == 'node' && is_numeric(arg(1))) {
       $node = node_load(arg(1));
       if (og_is_group_type($node->type)) {
-        $items[] = array('path' => 'node/'. arg(1). '/email', 'title' => t('E-mail'), 'callback' => 'drupal_get_form', 'callback arguments' => array('og_email_form', arg(1)), 'access' => node_access('update', $node), 'type' => MENU_LOCAL_TASK, 'weight' => 7);
+        $items[] = array('path' => og_url('node/%gid/email', array('gid' => arg(1))), 'title' => t('E-mail'), 'callback' => 'drupal_get_form', 'callback arguments' => array('og_email_form', arg(1)), 'access' => node_access('update', $node), 'type' => MENU_LOCAL_TASK, 'weight' => 7);
       }
     }
   }
@@ -300,7 +302,7 @@ function og_set_theme($nid) {
   $result = db_query(og_list_users_sql(1), $gid);
   $txt = format_plural(db_num_rows($result), 'the sole subscriber', 'all @count subscribers');
   if (!$_POST) {
-    drupal_set_message(t('Your email will be sent to !count in this group. Please use this feature sparingly.', array('!count' => l($txt, "og/users/$gid"))));
+    drupal_set_message(t('Your email will be sent to !count in this group. Please use this feature sparingly.', array('!count' => l($txt, og_url('og/users/%gid', array('gid' => $gid))))));
   }
 
   $form['subject'] = array('#type' => 'textfield', '#title' => t('Subject'), '#size' => 70, '#maxlength' => 250, '#description' => t("Enter a subject for your email."), '#required' => true);
@@ -318,7 +320,7 @@ function og_email_form_submit($form_id, 
     '@body' => $form_values['body'],
     '@site' => variable_get('site_name', drupal),
     '!url_group' => url("node/$node->nid", NULL, NULL, TRUE),
-    '!url_unsubscribe' => url("og/unsubscribe/$node->nid", NULL, NULL, TRUE)
+    '!url_unsubscribe' => url(og_url('og/unsubscribe/%gid', array('gid' => $node->nid)), NULL, NULL, TRUE)
   );
   
   global $user;
@@ -365,7 +367,7 @@ function og_manage_form($group) {
       drupal_set_message(t('You may not unsubscribe from this group because you are its owner. A site administrator can assign ownership to another user and then you may unsubscribe.'));
     }
     else {
-      $links[] = l(t('Unsubscribe from this group'), "og/unsubscribe/$group->nid", NULL, 'destination=og');
+      $links[] = l(t('Unsubscribe from this group'), og_url('og/unsubscribe/%gid', array('gid' => $group->nid)), NULL, 'destination=og');
       $form['unsubscribe'] = array('#type' => 'markup', '#value' => theme('item_list', $links, t('Actions')));
     }
   }
@@ -514,7 +516,7 @@ function og_create_admin_confirm($gid, $
   $form['account'] = array('#type' => 'value', '#value' => $account);
   return confirm_form($form, 
            t('Are you sure you want to make %name a group administrator for the group %title?', array('%name' => $account->name, '%title' => $node->title)),
-           "og/users/$gid", 
+           og_url('og/users/%gid', array('gid' => $gid)),
            ' ',
            t('Confirm'), 
            t('Cancel'));
@@ -538,7 +540,7 @@ function og_create_admin_confirm_submit(
   
   $from = variable_get('site_mail', ini_get('sendmail_from'));
   drupal_mail('og_new_admin', $account->mail, _og_user_mail_text('og_new_admin_subject', $variables), _og_user_mail_text('og_new_admin_body', $variables), $from);
-  return "og/users/$node->nid";
+  return og_url('og/users/%gid', array('gid' => $node->nid));
 }
 
 function og_delete_admin($gid, $uid) {
@@ -560,7 +562,7 @@ function og_remove_admin_confirm($gid, $
   $form['account'] = array('#type' => 'value', '#value' => $account);
   return confirm_form($form, 
                  t('Are you sure you want to remove %name as a group administrator for the group %title?', array('%name' => $account->name, '%title' => $node->title)),
-                 "og/users/$gid",
+                 og_url('og/users/%gid', array('gid' => $gid)),
                  ' ', 
                  t('Remove'), 
                  t('Cancel'));
@@ -574,7 +576,7 @@ function og_remove_admin_confirm_submit(
   $gid = $form_values['gid'];
   og_save_subscription($gid, $account->uid, array('is_admin' => 0));
   drupal_set_message(t('%name is no longer a %ga', array('%name' => $account->name, '%ga' => t('group administrator'))));
-  return "og/users/$gid";
+  return og_url('og/users/%gid', array('gid' => $gid));
 }
 
 
@@ -652,7 +654,7 @@ function og_invite_form_submit($form_id,
     '@group' => $node->title,
     '@description' => $node->og_description,
     '@site' => variable_get('site_name', 'drupal'),
-    '!group_url' => url("og/subscribe/$node->nid", NULL, NULL, TRUE),
+    '!group_url' => url(og_url('og/subscribe/%gid', array('gid' => $node->nid)), NULL, NULL, TRUE),
     '@body' => $form_values['pmessage']
   );
   
@@ -744,12 +746,13 @@ function og_subscribe_user($gid, $accoun
           $admins[] = $row->mail;
         }
       }
-      if ($admins) {        
+      if ($admins) {
+        $url_values = array('gid' => $node->nid, 'uid' => $account->uid);
         $variables = array(
           '@group' => $node->title,
           '@username' => $account->name,
-          '!approve_url' => url("og/approve/$node->nid/$account->uid", NULL, NULL, TRUE),
-          '!group_url' => url("og/users/$node->nid", NULL, NULL, TRUE)
+          '!approve_url' => url(og_url('og/approve/%gid/%uid', $url_values), NULL, NULL, TRUE),
+          '!group_url' => url(og_url('og/users/%gid', $url_values), NULL, NULL, TRUE)
         );
         
         $from = variable_get('site_mail', ini_get('sendmail_from'));
@@ -811,7 +814,7 @@ function og_confirm_unsubscribe($gid, $n
   $account = user_load(array('uid' => $uid));
   return confirm_form($form, 
                t('Are you sure you want to unsubscribe !name from the group %title?', array('!name' => theme('username', $account), '%title' => $node->title)),
-               'og/manage/'. $node->nid, ' ', t('Unsubscribe'), t('Cancel'));
+               og_url('og/manage/%gid', array('gid' => $node->nid)), ' ', t('Unsubscribe'), t('Cancel'));
 }
 
 /**
@@ -914,18 +917,19 @@ function og_list_users_page($gid) {
         elseif ($account->is_admin) { $username .= '&nbsp;<em>'.t('administrator'). '</em>'; }
         $rows[$i][] = $username;
         if ($access) {
+          $url_values = array('gid' => $gid, 'uid' => $account->uid);
           if ($account->is_active) {
-            $rows[$i][] = l(t('unsubscribe'), "og/unsubscribe/$gid/$account->uid", array(), "destination=og/users/$gid");
+            $rows[$i][] = l(t('unsubscribe'), og_url('og/unsubscribe/%gid/%uid', $url_values), array(), 'destination=' . og_url('og/users/%gid', $url_values));
             if ($account->is_admin) {
-              $rows[$i][] = l(t('admin: remove'), "og/delete_admin/$gid/$account->uid", array(), 'destination='. $_GET['q']);
+              $rows[$i][] = l(t('admin: remove'), og_url('og/delete_admin/%gid/%uid', $url_values), array(), 'destination='. $_GET['q']);
             }
             else {
-              $rows[$i][] = l(t('admin: create'), "og/create_admin/$gid/$account->uid", array(), 'destination='. $_GET['q']);
+              $rows[$i][] = l(t('admin: create'), og_url('og/create_admin/%gid/%uid', $url_values), array(), 'destination='. $_GET['q']);
             }
           }
           else {
-            $rows[$i][] = l(t('approve'), "og/approve/$gid/$account->uid", array(), "destination=og/users/$gid");
-            $rows[$i][] = l(t('deny'), "og/deny/$gid/$account->uid", array(), "destination=og/users/$gid");
+            $rows[$i][] = l(t('approve'), og_url('og/approve/%gid/%uid', $url_values), array(), 'destination=' . og_url('og/users/%gid', $url_values));
+            $rows[$i][] = l(t('deny'), og_url('og/deny/%gid/%uid', $url_values), array(), 'destination=' . og_url('og/users/%gid', $url_values));
           }
         }
         $i++;
@@ -995,7 +999,7 @@ function og_opml() {
 
   global $user;
   foreach ($user->og_groups as $gid => $group) {
-    $output .= '<outline text="'. check_plain($group['title']) .'" xmlUrl="'. url("node/$gid/feed", NULL, NULL, TRUE) ."\" />\n";    
+    $output .= '<outline text="'. check_plain($group['title']) .'" xmlUrl="'. url(og_url('node/%gid/feed', array('gid' => $gid)), NULL, NULL, TRUE) ."\" />\n";    
   }
 
   $output .= "</body>\n";
@@ -1086,7 +1090,7 @@ function og_home_empty($node) {
     }
     // TODO: hide this from pending subscribers too
     elseif ($node->og_selective < OG_INVITE_ONLY) {
-      $msg .= ' '. t('Consider <a href="!url">subscribing to this group</a> in order to view its posts.', array('!url' => url("og/subscribe/$node->nid", $dest)));
+      $msg .= ' '. t('Consider <a href="!url">subscribing to this group</a> in order to view its posts.', array('!url' => url(og_url('og/subscribe/%gid', array('gid' => $node->nid)), $dest)));
     }
   }
   drupal_set_message($msg);
@@ -1322,7 +1326,7 @@ function og_nodeapi(&$node, $op, $teaser
           '@group' => $node->title,
           '!group_url' => url("node/$node->nid", NULL, NULL, TRUE),
           '@username' => $account->name,
-          '!invite_url' => url("og/invite/$node->nid", NULL, NULL, TRUE)
+          '!invite_url' => url(og_url('og/invite/%gid', array('gid' => $node->nid)), NULL, NULL, TRUE)
         );
 
         // alert the user that they are now the admin of the group  
@@ -1733,11 +1737,11 @@ function og_mail($type, $id) {
     // Hopefully D6 will avert need to imporesonate.
     // Append these group specific variables.
     $variables['@group'] = $row->group_name;
-    $variables['!group_url'] = url("og/manage/$row->gid", NULL, NULL, TRUE);
+    $variables['!group_url'] = url(og_url('og/manage/%gid', array('gid' => $row->gid)), NULL, NULL, TRUE);
     $variables['@type'] = $type_friendly;
 
     // see http://www.ietf.org/rfc/rfc2369.txt. UTF8 OK?
-    $unsubscribe = url("og/manage/$row->gid", NULL, NULL, TRUE);
+    $unsubscribe = url(og_url('og/manage/%gid', array('gid' => $row->gid)), NULL, NULL, TRUE);
     $ownerurl = url("user/$row->group_uid", NULL, NULL, TRUE);
     $group_home = url("node/$row->gid", NULL, NULL, TRUE);
     $groupheaders = $headers + array('List-Id' => "$row->group_name <$group_home>", 'List-Unsubscribe' => "<$unsubscribe>", 'List-Owner' => "$row->group_owner <$ownerurl>", "List-Archive" => "<$group_home>");
@@ -2038,7 +2042,7 @@ function og_is_omitted_type($type) {
  */
 function og_feed($gid) {
   header("HTTP/1.1 301 Moved Permanently");
-  header('Location: '. url("node/$gid/feed", NULL, NULL, TRUE));
+  header('Location: '. url(og_url('node/%gid/feed', array('gid' => $gid)), NULL, NULL, TRUE));
 }
 
 
@@ -2103,21 +2107,22 @@ function og_block_notifications() {
   if ($groupnode = og_get_group_context()) {
     // only members can see this block
     if (in_array($groupnode->nid, array_keys($user->og_groups))) {
-      $content = t('This group offers a !groupfeed and an !email.', array('!groupfeed' => l(t('RSS feed'), "node/$groupnode->nid/feed"), '!email' => l(t('email subscription'), 'og/manage/'. $groupnode->nid)));
+      $url_values = array('gid' => $groupnode->nid);
+      $content = t('This group offers a !groupfeed and an !email.', array('!groupfeed' => l(t('RSS feed'), og_url('node/%gid/feed', $url_values)), '!email' => l(t('email subscription'), og_url('og/manage/%gid',$url_values))));
       if (module_exists('views') && module_exists('views_rss')) {
         // NOTE: See og.css for styling specific to these lists
         $content .= t(' Or subscribe to these personalized, sitewide feeds:');
         $inline = array('class' => 'links inline');      
-        $l1[] = array('title' => t('feed'), 'href' => 'group/myunread/feed');
-        $l1[] = array('title' => t('page'), 'href' => 'group/myunread');
+        $l1[] = array('title' => t('feed'), 'href' => og_url('group/myunread/feed'));
+        $l1[] = array('title' => t('page'), 'href' => og_url('group/myunread'));
         $links['my_unread'] = t('my unread: '). theme('links', $l1, $inline);
       
-        $l2[] = array('title' => t('feed'), 'href' => 'group/mytracker/feed');
-        $l2[] = array('title' => t('page'), 'href' => 'group/mytracker');
+        $l2[] = array('title' => t('feed'), 'href' => og_url('group/mytracker/feed'));
+        $l2[] = array('title' => t('page'), 'href' => og_url('group/mytracker'));
         $links['my_group'] = t('my group: '). theme('links', $l2, $inline);
       
-        $l3[] = array('title' => t('feed'), 'href' => 'group/tracker/feed');
-        $l3[] = array('title' => t('page'), 'href' => 'group/tracker');
+        $l3[] = array('title' => t('feed'), 'href' => og_url('group/tracker/feed'));
+        $l3[] = array('title' => t('page'), 'href' => og_url('group/tracker'));
         $links['all_posts'] = array('data' => t('all posts: '). theme('links', $l3, $inline));
         $content .= theme('item_list', $links);
       }
@@ -2206,7 +2211,8 @@ function og_user_title_list($result, $gi
       $txt = t('more');
       $title = array('title' => t('View all subscribers.'));
       if ($show_more) {
-        $more = og_is_picture() ? l($txt, "og/users/$gid/faces", $title) : l($txt, "og/users/$gid", $title);
+        $og_user_browser_url = og_is_picture() ? 'og/users/%gid/faces' : 'og/users/%gid';
+        $more = l($txt, og_url($og_user_browser_url, array('gid' => $gid)), $title);
         $append = "<div class=\"more-link\">$more</div>";
       }
     }
@@ -2246,24 +2252,25 @@ function og_og_block_details($node) {
     }
   }
 
+  $url_values = array('gid' => $node->nid);
   if ($subscription == 'active' || user_access('administer nodes')) {
     $links = module_invoke_all('og_create_links', $node);
     if ($node->og_selective < OG_INVITE_ONLY) {
-      $links[] = l(t('Invite friend'), "og/invite/$node->nid");
+      $links[] = l(t('Invite friend'), og_url('og/invite/%gid', $url_values));
     }
     $txt = format_plural($cntall-$cntpending, '1 subscriber', '@count subscribers');
-    $txt = og_is_picture() ? l($txt, "og/users/$node->nid/faces") : l($txt, "og/users/$node->nid");
+    $txt = og_is_picture() ? l($txt, og_url('og/users/%gid/faces', $url_values)) : l($txt, og_url('og/users/%gid', $url_values));
     $txt .= $cntpending ? " ($cntpending)" : '';
     $links[] = $txt;
     $links[] =  t('Manager: '). theme('username', $node);
-    $links[] = isset($subscription) ? l(t('My subscription'), "og/manage/$node->nid") : og_subscribe_link($node);
+    $links[] = isset($subscription) ? l(t('My subscription'), og_url('og/manage/%gid', $url_values)) : og_subscribe_link($node);
     if (module_exists('search') && user_access('search content')) {
       $post = drupal_get_form('og_search_form', $node);
     }
   }
   elseif ($subscription == 'requested') {
     $links[] = t('Your subscription request awaits approval.');
-    $links[] = l(t('delete request'), "og/unsubscribe/$node->nid", array(), 'destination=og');
+    $links[] = l(t('delete request'), og_url('og/unsubscribe/%gid', $url_values), array(), 'destination=' . og_url('og'));
   }
   elseif (!$user->uid) {
     $dest = drupal_get_destination();
@@ -2288,7 +2295,7 @@ function og_subscribe_link($node) {
   elseif ($node->og_selective == OG_OPEN) {
     $txt = t('Subscribe');
   }
-  return l($txt, "og/subscribe/$node->nid", array(), "destination=node/$node->nid");
+  return l($txt, og_url('og/subscribe/%gid', array('gid' => $node->nid)), array(), "destination=node/$node->nid");
 }
 
 // $group is an object containing the group node
@@ -2317,7 +2324,7 @@ function og_search_form($group) {
   );
   $form['#process'] = array('views_filters_process' => array());
   $form['#method'] = 'get';
-  $form['#action'] = url("og/search/$group->nid");
+  $form['#action'] = url(og_url('og/search/%gid', array('gid' => $group->nid)));
   return $form;
 } 
 
@@ -2563,7 +2570,7 @@ function og_requirements($phase) {
     if (!variable_get('og_enabled', FALSE)) {
       $requirements['og_access'] = array(
         'title' => $t('Organic groups access control'),
-        'value' => $t('Organic groups access control is disabled. See the !settings', array('!settings' => l($t('settings page'), 'admin/og/og'))),
+        'value' => $t('Organic groups access control is disabled. See the !settings', array('!settings' => l($t('settings page'), og_url('admin/og/og')))),
         'severity' => REQUIREMENT_INFO
       );
     }
@@ -2574,4 +2581,12 @@ function og_requirements($phase) {
 
 function og_readme() {
   return l('README file', drupal_get_path('module', 'og'). '/README.txt');
-}
\ No newline at end of file
+}
+
+// return the system url path for an OG page - use this instead of hardcoding OG urls
+function og_url($url_key, $substitutions = array()) {
+  foreach ($substitutions as $key => $value) {
+    $url_key = str_replace('%'.$key, $value, $url_key);
+  }
+  return $url_key;
+}
Index: og/og_views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og/og_views.inc,v
retrieving revision 1.34
diff -u -p -r1.34 og_views.inc
--- og/og_views.inc	3 Jul 2007 00:20:44 -0000	1.34
+++ og/og_views.inc	29 Jul 2007 14:08:54 -0000
@@ -299,7 +299,7 @@ function og_views_default_views() {
   $view->page_empty = 'There are no posts in your subscribed groups.';
   $view->page_empty_format = '1';
   $view->page_type = 'table';
-  $view->url = 'group/mytracker';
+  $view->url = og_url('group/mytracker');
   $view->use_pager = TRUE;
   $view->nodes_per_page = '25';
   $view->menu = TRUE;
@@ -403,7 +403,7 @@ function og_views_default_views() {
   $view->page_empty = 'There are no new posts in your subscribed groups.';
   $view->page_empty_format = '1';
   $view->page_type = 'table';
-  $view->url = 'group/myunread';
+  $view->url = og_url('group/myunread');
   $view->use_pager = TRUE;
   $view->nodes_per_page = '25';
   $view->menu = TRUE;
@@ -565,19 +565,20 @@ function og_views_default_views() {
   $view->view_args_php = '';
   $view->page = TRUE;
   $view->page_title = 'My groups';
+  // TODO: /dr5/og/opml looks like it was committed in error:
   $view->page_header = 'You may edit all your email subscriptions using this convenient page. Also, you might be interested in an <a href="/dr5/og/opml" rel="nofollow">OPML feed containing feeds from all your subscribed groups</a>.';
   $view->page_header_format = '1';
-  $view->page_footer = '<?php
+  $view->page_footer = "<?php
 
-  $url = url("og/opml");
-  return theme(\'opml_icon\', $url);
+  $url = url(og_url('og/opml'));
+  return theme('opml_icon', $url);
 
-?>';
+?>";
   $view->page_footer_format = '2';
   $view->page_empty = 'No subscribed groups';
   $view->page_empty_format = '1';
   $view->page_type = 'table';
-  $view->url = 'og/my';
+  $view->url = og_url('og/my');
   $view->use_pager = TRUE;
   $view->nodes_per_page = '50';
   $view->menu = TRUE;
@@ -796,7 +797,7 @@ function og_views_default_views() {
   $view->page_empty = '';
   $view->page_empty_format = '1';
   $view->page_type = 'table';
-  $view->url = 'group/tracker';
+  $view->url = og_url('group/tracker');
   $view->use_pager = TRUE;
   $view->nodes_per_page = '25';
   $view->menu = TRUE;
@@ -901,7 +902,7 @@ function og_views_default_views() {
   $view->page_empty = 'No posts found.';
   $view->page_empty_format = '1';
   $view->page_type = 'teaser';
-  $view->url = 'og/search';
+  $view->url = og_url('og/search');
   $view->use_pager = TRUE;
   $view->nodes_per_page = '50';
   $view->sort = array (
@@ -1038,7 +1039,7 @@ function og_handler_field_count($fieldin
   global $user;
 
   $cnt = db_num_rows(db_query(og_list_users_sql(), $data->nid));
-  return in_array($data->nid, array_keys($user->og_groups)) ? l($cnt, "og/users/$data->nid") : $cnt;
+  return in_array($data->nid, array_keys($user->og_groups)) ? l($cnt, og_url('og/users/%gid', array('gid' => $data->nid))) : $cnt;
 }
 
 /**
@@ -1053,7 +1054,7 @@ function og_handler_field_subscribe($fie
       case OG_INVITE_ONLY:
         return '<em>'. t('Invite only'). '</em>';
       default:
-        return l(t('subscribe'), "og/subscribe/$data->nid", array('rel' => 'nofollow'), drupal_get_destination());  
+        return l(t('subscribe'), og_url('og/subscribe/%gid', array('gid' => $data->nid)), array('rel' => 'nofollow'), drupal_get_destination());  
     }
   }
 }
@@ -1070,7 +1071,7 @@ function og_handler_field_nodelink($fiel
 }
 
 function og_handler_field_managelink($fieldinfo, $fielddata, $value, $data) {
-  return l(t('my subscription'), "og/manage/$data->nid", NULL, drupal_get_destination());
+  return l(t('my subscription'), og_url('og/manage/%gid', array('gid' => $data->nid)), NULL, drupal_get_destination());
 }
 
 function og_handler_field_yesempty($fieldinfo, $fielddata, $value, $data) {
Index: og/tests/og_post.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og/tests/og_post.test,v
retrieving revision 1.4
diff -u -p -r1.4 og_post.test
--- og/tests/og_post.test	24 Oct 2006 18:54:06 -0000	1.4
+++ og/tests/og_post.test	29 Jul 2007 14:08:54 -0000
@@ -20,7 +20,7 @@ class OgPost extends OgTestCase {
     $web_user = $this->drupalCreateUserRolePerm(array('access content', "create page content"));
     $this->drupalLoginUser($web_user);
     
-    $url = url("og/subscribe/$gid");
+    $url = url(og_url('og/subscribe/%gid', array('gid' => $gid)));
     $ret = $this->get($url, FALSE, FALSE, TRUE);
     $this->assertTrue($ret, " [browser] GET $url");
     
@@ -56,4 +56,4 @@ class OgPost extends OgTestCase {
     
     node_delete($gid);
   }
-}
\ No newline at end of file
+}
Index: og/tests/og_subscribe.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og/tests/og_subscribe.test,v
retrieving revision 1.4
diff -u -p -r1.4 og_subscribe.test
--- og/tests/og_subscribe.test	24 Oct 2006 18:54:06 -0000	1.4
+++ og/tests/og_subscribe.test	29 Jul 2007 14:08:54 -0000
@@ -22,7 +22,7 @@ class OgSubscribe extends OgTestCase {
     $this->drupalLoginUser($join_user);
     
     /* Test subscribing a new user */
-    $url = url('og/subscribe/' . $gid, NULL, NULL, TRUE);
+    $url = url(og_url('og/subscribe/%gid', array('gid' => $gid)), NULL, NULL, TRUE);
     $ret = $this->_browser->get($url);
     $this->assertTrue($ret, " [browser] GET $url");
     // No theme, "Text" only
@@ -35,7 +35,7 @@ class OgSubscribe extends OgTestCase {
     $this->assertNoUnwantedRaw(t('Page not found'), 'page not not found.');
 
     /* Find user in list */
-    $url = url('og/users/' . $gid, NULL, NULL, TRUE);
+    $url = url(og_url('og/users/%gid', array('gid' => $gid)), NULL, NULL, TRUE);
     $ret = $b->get($url);
     $this->assertTrue($ret, " [browser] GET $url");
     $this->assert(new TextExpectation($join_user->name),
@@ -44,7 +44,7 @@ class OgSubscribe extends OgTestCase {
     /** @TODO: Test Posting etc... */
     
     // Test subscribing a new user 
-    $url = url('og/unsubscribe/' . $gid, NULL, NULL, TRUE);
+    $url = url(og_url('og/unsubscribe/%gid', array('gid' => $gid)), NULL, NULL, TRUE);
     $ret = $this->_browser->get($url);
     $this->assertTrue($ret, " [browser] GET $url");
     
@@ -59,7 +59,7 @@ class OgSubscribe extends OgTestCase {
     $this->_browser = $b;
     
     // Find user in list */
-    $url = url('og/users/' . $gid, NULL, NULL, TRUE);
+    $url = url(og_url('og/users/%gid', array('gid' => $gid)), NULL, NULL, TRUE);
     $ret = $b->get($url);
     $this->assertTrue($ret, " [browser] GET $url");
     $this->assertNoUnwantedRaw($join_user->name, 'User name not found.');
@@ -73,7 +73,7 @@ class OgSubscribe extends OgTestCase {
     $this->drupalLoginUser($join_user);
 
     // Test subscribing a new user 
-    $url = url('og/subscribe/' . $gid, NULL, NULL, TRUE);
+    $url = url(og_url('og/subscribe/%gid', array('gid' => $gid)), NULL, NULL, TRUE);
     $ret = $this->_browser->get($url);
     $this->assertTrue($ret, " [browser] GET $url");
     $this->assertNoUnwantedRaw(t('Subscribed to the %group group', array('%group' => $node->title)),
@@ -90,7 +90,7 @@ class OgSubscribe extends OgTestCase {
     $this->assertWantedRaw(t('Subscription request to the @group group was rejected, only group administrators can add users to this group.',
                                            array('@group' => $node->title)), 'Rjected text found.');
     // Find user in list 
-    $url = url('og/users/' . $gid, NULL, NULL, TRUE);
+    $url = url(og_url('og/users/%gid', array('gid' => $gid)), NULL, NULL, TRUE);
     $ret = $b->get($url);
     $this->assertTrue($ret, " [browser] GET $url");
     $this->assert(new NoTextExpectation($join_user->name),
@@ -108,7 +108,7 @@ class OgSubscribe extends OgTestCase {
     $this->drupalLoginUser($join_user);
 
     // Test subscribing a new user 
-    $url = url('og/subscribe/' . $gid, NULL, NULL, TRUE);
+    $url = url(og_url('og/subscribe/%gid', array('gid' => $gid)), NULL, NULL, TRUE);
     $ret = $this->_browser->get($url);
     $this->assertTrue($ret, " [browser] GET $url");
     $this->assertNoUnwantedRaw(t('Subscribed to the %group group', array('%group' => $node->title)),
@@ -126,7 +126,7 @@ class OgSubscribe extends OgTestCase {
                                            array('@group' => $node->title)), 'Rjected text found.');
 
                                            // Find user in list 
-    $url = url('og/users/' . $gid, NULL, NULL, TRUE);
+    $url = url(og_url('og/users/%gid', array('gid' => $gid)), NULL, NULL, TRUE);
     $ret = $b->get($url);
     $this->assertTrue($ret, " [browser] GET $url");
     $this->assert(new NoTextExpectation($join_user->name),
@@ -144,7 +144,7 @@ class OgSubscribe extends OgTestCase {
     $this->drupalLoginUser($join_user);
 
     // Test subscribing a new user 
-    $url = url('og/subscribe/' . $gid, NULL, NULL, TRUE);
+    $url = url(og_url('og/subscribe/%gid', array('gid' => $gid)), NULL, NULL, TRUE);
     $ret = $this->_browser->get($url);
     $this->assertTrue($ret, " [browser] GET $url");
     $this->assertNoUnwantedRaw(t('Subscribed to the @group', array('@group' => $node->title)),
@@ -163,7 +163,7 @@ class OgSubscribe extends OgTestCase {
 
     // Find user in list, Inactive users _ARE_ listed
     $this->_browser = $b; // Switch back to admin view
-    $url = url('og/users/' . $gid, NULL, NULL, TRUE);
+    $url = url(og_url('og/users/%gid', array('gid' => $gid)), NULL, NULL, TRUE);
     $this->get($url);
     $this->assertTrue($ret, " [browser] GET $url");
     $this->assertWantedRaw($join_user->name, 'Username found');
@@ -173,7 +173,7 @@ class OgSubscribe extends OgTestCase {
     $this->assertWantedRaw(t('Subscription request denied.'), 'Denied text found.');
     
 
-    $url = url('og/users/' . $gid, NULL, NULL, TRUE);
+    $url = url(og_url('og/users/%gid', array('gid' => $gid)), NULL, NULL, TRUE);
     $this->get($url);
     $this->assertNoUnwantedRaw($join_user->name, 'Username not found');
 
@@ -183,7 +183,7 @@ class OgSubscribe extends OgTestCase {
     $this->drupalLoginUser($join_user);
 
     // Test subscribing a new user 
-    $url = url('og/subscribe/' . $gid, NULL, NULL, TRUE);
+    $url = url(og_url('og/subscribe/%gid', array('gid' => $gid)), NULL, NULL, TRUE);
     $ret = $this->_browser->get($url);
     $this->assertTrue($ret, " [browser] GET $url");
     
@@ -203,7 +203,7 @@ class OgSubscribe extends OgTestCase {
 
     // Find user in list, Inactive users _ARE_ listed
     $this->_browser = $b; // Switch back to admin view
-    $url = url('og/users/' . $gid, NULL, NULL, TRUE);
+    $url = url(og_url('og/users/%gid', array('gid' => $gid)), NULL, NULL, TRUE);
     $ret = $this->_browser->get($url);
     $this->assertTrue($ret, " [browser] GET $url");
     $this->assertWantedRaw($join_user->name, 'Username found');
@@ -212,9 +212,9 @@ class OgSubscribe extends OgTestCase {
 
     $this->assertWantedRaw(t('Subscription request approved.'), 'Approved text found.');
     
-    $url = url('og/users/' . $gid, NULL, NULL, TRUE);
+    $url = url(og_url('og/users/%gid', array('gid' => $gid)), NULL, NULL, TRUE);
     $ret = $this->_browser->get($url);
     $this->assertTrue($ret, " [browser] GET $url");
     $this->assertWantedRaw($join_user->name, 'Username found again');
   }
-}
\ No newline at end of file
+}
