Index: gallery.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/gallery/gallery.module,v retrieving revision 1.15 diff -u -F^f -r1.15 gallery.module --- gallery.module 16 Dec 2005 02:24:26 -0000 1.15 +++ gallery.module 13 Mar 2006 21:59:02 -0000 @@ -84,7 +84,7 @@ function gallery_user($op, &$edit, &$use 'hashedpassword' => $user->pass, 'hashmethod' => 'md5' )); - if ($ret->isError()) { + if ($ret) { gallery_error(t('Error creating Gallery user'), $ret); return; } @@ -110,7 +110,7 @@ function gallery_user($op, &$edit, &$use 'language' => $language, 'hashedpassword' => $pass, 'hashmethod' => 'md5')); - if ($ret->isError()) { + if ($ret) { // try to create user then. $ret = GalleryEmbed::createUser($user->uid, array('username' => $name, @@ -120,7 +120,7 @@ function gallery_user($op, &$edit, &$use 'hashedpassword' => $pass, 'hashmethod' => 'md5' )); - if ($ret->isError()) { + if ($ret) { gallery_error(t('Error updating Gallery user'), $ret); return; } @@ -136,7 +136,7 @@ function gallery_user($op, &$edit, &$use } $ret = GalleryEmbed::deleteUser($user->uid); - if ($ret->isError()) { + if ($ret) { gallery_error(t('Error deleting Gallery user'), $ret); } GalleryEmbed::done(); @@ -211,7 +211,7 @@ function gallery_block($op = 'list', $de $block = array(); list($ret, $content, $head) = GalleryEmbed::getImageBlock($params); - if ($ret->isError()) { + if ($ret) { gallery_error(t('Unable to get Gallery image block'), $ret); return; } else { @@ -230,7 +230,7 @@ function gallery_block($op = 'list', $de } $ret = GalleryEmbed::done(); - if ($ret->isError()) { + if ($ret) { gallery_error(t('Unable to complete Gallery request'), $ret); return; } @@ -255,7 +255,7 @@ function gallery_search($op = 'search', } list ($ret, $results) = GalleryEmbed::searchScan($keys, 20); - if (!$ret->isError()) { + if (!$ret) { $urlGenerator =& $GLOBALS['gallery']->getUrlGenerator(); foreach ($results as $name => $module) { if (count($module['results']) > 0) { @@ -341,14 +341,22 @@ function _gallery_init($full = false) { 'activeLanguage' => $user->language, 'fullInit' => $full); $ret = GalleryEmbed::init($params); + + if (!$ret) { + return array(true, null); + } + if ($ret->getErrorCode() & ERROR_MISSING_OBJECT) { + // Our user mapping is missing. Make a mapping, or create a new user. $g2_user = null; // Get the G2 user that matches the Drupal username list ($ret, $g2_user) = GalleryCoreApi::fetchUserByUsername($user->name); - if ($ret->isError() && !($ret->getErrorCode() & ERROR_MISSING_OBJECT)) { - return array(false, $ret); + if ($ret) { + if (!$ret->getErrorCode() & ERROR_MISSING_OBJECT) { + return array(false, $ret); + } } if (!isset($g2_user)) { @@ -357,19 +365,19 @@ function _gallery_init($full = false) { if ($user->uid == 1) { list ($ret, $admin_group_id) = GalleryCoreApi::getPluginParameter('module', 'core', 'id.adminGroup'); - if ($ret->isError()) { + if ($ret) { return array(false, $ret); } list ($ret, $g2_users) = GalleryCoreApi::fetchUsersForGroup($admin_group_id); - if ($ret->isError()) { + if ($ret) { return array(false, $ret); } $keys = array_keys($g2_users); $g2_user_name = $g2_users[$keys[0]]; list ($ret, $g2_user) = GalleryCoreApi::fetchUserByUsername($g2_user_name); - if ($ret->isError()) { + if ($ret) { return array(false, $ret); } } @@ -377,7 +385,7 @@ function _gallery_init($full = false) { if (isset($g2_user)) { $ret = GalleryEmbed::addExternalIdMapEntry($user->uid, $g2_user->getId(), 'GalleryUser'); - if ($ret->isError()) { + if ($ret) { return array(false, $ret); } } else { @@ -388,13 +396,12 @@ function _gallery_init($full = false) { 'language' => $user->language, 'hashedpassword' => $user->pass, 'hashmethod' => 'md5')); - if ($ret->isError()) { + if ($ret) { return array(false, $ret); } } } - - return array(true, GalleryStatus::success()); + return array(true, null); } function gallery_error($message, $ret) {