* fixed hook_user('update') to fully update the user data on the g2 side
authorJames Walker
Thu, 15 Sep 2005 23:56:32 +0000 (23:56 +0000)
committerJames Walker
Thu, 15 Sep 2005 23:56:32 +0000 (23:56 +0000)
* set the drupal title to the current g2 title

gallery.module

index 9dd79cd..dccf58f 100644 (file)
@@ -1,10 +1,9 @@
 <?php
-  // $Id$
-  // This version is from Bharat on Sep 5
+// $Id$
 
-  /**
-   * Implementation of hook_help
-   */
+/**
+ * Implementation of hook_help
+ */
 function gallery_help($section) {
   switch($section) {
   case 'admin/modules#description':
@@ -85,15 +84,27 @@ function gallery_user($op, &$edit, &$user, $category = NULL) {
       return;
     }
 
+    // on update we can't be sure how much info $edit will contain.
+    $name = ($edit['name']) ? $edit['name'] : $user->name;
+    $language = ($edit['language']) ? $edit['language'] : $user->language;
+    $pass = ($edit['pass']) ? md5($edit['pass']) : $user->pass;
+    $email = ($edit['email']) ? $edit['mail'] : $user->mail;
     $ret = GalleryEmbed::updateUser($user->uid,
-                                   array('username' => $edit['name'],
-                                         'email' => $edit['mail']));
+                                   array('username' => $name,
+                                          'fullname' => $name,
+                                         'email' => $mail,
+                                          'language' => $language,
+                                          'hashedpassword' => $pass,
+                                          'hashmethod' => 'md5'));
     if ($ret->isError()) {
       // try to create user then.
       $ret = GalleryEmbed::createUser($user->uid,
-                                     array('username' => $edit['name'],
-                                           'email' => $edit['mail'],
-                                           'language' => $edit['language'],
+                                     array('username' => $name,
+                                            'fullname' => $name,
+                                           'email' => $mail,
+                                           'language' => $language,
+                                            'hashedpassword' => $pass,
+                                            'hashmethod' => 'md5'
                                            ));
       if ($ret->isError()) {
        gallery_error(t('Error updating Gallery user'), $ret);
@@ -269,7 +280,7 @@ function gallery_page() {
       drupal_set_html_head(implode("\n",$javascript));
     }
     drupal_set_html_head(implode("\n",$css));
-
+    drupal_set_title($title);
     print theme('page', $result['bodyHtml']);
   }
 }