? integrate-og_username_helper-to-OG-6.x-HEAD.patch
Index: og.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og/og.module,v
retrieving revision 1.626
diff -u -p -w -b -r1.626 og.module
--- og.module	19 Mar 2009 22:43:07 -0000	1.626
+++ og.module	20 Mar 2009 10:50:46 -0000
@@ -25,6 +25,13 @@ define('OG_DELETE_ORPHANS', 1);
 define('OG_DELETE_MOVE_NODES', 2);
 define('OG_DELETE_MOVE_NODES_MEMBERSHIPS', 3);
 
+// og forms where username helper is shown
+define('OG_INVITE_FORM', 'og-invite-form');
+define('OG_ADD_USERS', 'og-add-users');
+
+// og username helper permissions string
+define('OG_HELPER_PERM_STRING', 'access og username helper');
+
 function og_help($path, $arg) {
   if ($path) {
     switch ($path) {
@@ -165,6 +172,16 @@ function og_menu() {
     'weight' => 7
   );
 
+  // username helper autocomplete.
+  $items['og/username_helper/autocomplete'] = array(
+    'title' => 'Autocomplete username',
+    'page callback' => 'user_autocomplete',
+    'access arguments' => array('access og username helper'),
+    'type' => MENU_CALLBACK,
+    'file' => 'user.pages.inc',
+    'file path' => drupal_get_path('module', 'user'),
+  );
+
   return $items;
 }
 
@@ -404,7 +421,7 @@ function og_set_language($node) {
  * Implementation of hook_perm().
  */
 function og_perm() {
-  return array('administer organic groups');
+  return array('administer organic groups', OG_HELPER_PERM_STRING);
 }
 
 /**
@@ -1702,6 +1719,33 @@ function og_form_alter(&$form, &$form_st
       og_form_add_og_audience($form, $form_state);
     }
   }
+
+  // Add username helper
+  if (user_access(OG_HELPER_PERM_STRING)) {
+    // Add username helper
+    if ($form['#id'] == OG_INVITE_FORM || $form['#id'] == OG_ADD_USERS) {
+      drupal_add_js(drupal_get_path('module', 'og') .'/og_username_helper.js');
+
+      $form['og_username_helper_text'] = array(
+        '#type' => 'textfield',
+        '#description' => t('Lookup a username and add it to the list below.'),
+        '#autocomplete_path' => 'og/username_helper/autocomplete',
+        '#size' => 40,
+        '#maxlength' => 60,
+        '#weight' => -2,
+        '#prefix' => '<div class="container-inline">',
+      );
+
+      $form['og_username_helper_add_button'] = array(
+        '#type' => 'button',
+        '#value' => t('Add'),
+        '#weight' => -1,
+        '#suffix' => '</div>',
+      );
+
+      return $form;
+    }
+  }
 }
 
 /**
Index: og_username_helper.js
===================================================================
RCS file: og_username_helper.js
diff -N og_username_helper.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ og_username_helper.js	20 Mar 2009 10:50:46 -0000
@@ -0,0 +1,32 @@
+// $Id$
+
+/* Add usernames to the one of the fields supported */
+Drupal.og_username_helperAutoAttach = function() {
+  $("#edit-og-username-helper-add-button").click( function() {
+    $("#edit-og-username-helper-text").val($.trim($("#edit-og-username-helper-text").val()));
+    if ($("#edit-og-username-helper-text").val() !== undefined && $("#edit-og-username-helper-text").val() !== '') {
+      var coma = ',';
+      if ($("#edit-mails").val() !== undefined) {
+        if ($("#edit-mails").val() === '')
+          coma = '';
+
+        if ($("#edit-mails").val().split(",").indexOf($("#edit-og-username-helper-text").val()) < 0)
+          $("#edit-mails").val($("#edit-mails").val() + coma + $("#edit-og-username-helper-text").val());
+      }
+      else if ($("#edit-og-names").val() !== undefined) {
+        if ($("#edit-og-names").val() === '')
+          coma = '';
+
+        if ($("#edit-og-names").val().split(",").indexOf($("#edit-og-username-helper-text").val()) < 0)
+          $("#edit-og-names").val($("#edit-og-names").val() + coma + $("#edit-og-username-helper-text").val());
+      }
+    }
+
+    $("#edit-og-username-helper-text").val('');
+    return false;
+  });
+};
+
+if (Drupal.jsEnabled) {
+  $(document).ready(Drupal.og_username_helperAutoAttach);
+}
Index: theme/og.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og/theme/og.css,v
retrieving revision 1.14
diff -u -p -w -b -r1.14 og.css
--- theme/og.css	9 Nov 2008 17:17:54 -0000	1.14
+++ theme/og.css	20 Mar 2009 10:50:48 -0000
@@ -55,3 +55,12 @@
   font-style: italic;
 }
 
+
+/* og username helper */
+#og-invite-form .container-inline .description, #og-add-users .container-inline .description {
+  float: left;
+}
+
+#og-invite-form .form-item label, #og-add-users .form-item label {
+  clear: left;
+}
