Commit 9e6b9178 authored by kiz_0987's avatar kiz_0987

#62335 - Added return out of role sync function if a gallery2 error is detected.

parent f829e0d6
......@@ -22,6 +22,7 @@ function gallery_sync_groups_for_user($user) {
if ($ret) {
$msg = t('Error retrieving Gallery group Id for \'Everybody\' group');
gallery_error($msg, $ret);
return;
}
// Get the Gallery groups for this user
......@@ -31,6 +32,7 @@ function gallery_sync_groups_for_user($user) {
$msg = t('Error getting Gallery User info from Drupal Id');
$msg .= ' ' . t('Drupal User Id: ') . $user->uid;
gallery_error($msg, $ret);
return;
}
// Then get the groups for this user currently set in G2
list ($ret, $g2_cur_groups) = GalleryCoreApi::fetchGroupsForUser($g2_user->getId());
......@@ -38,6 +40,7 @@ function gallery_sync_groups_for_user($user) {
$msg = t('Error getting Gallery group info for user');
$msg .= ' ' . t('Drupal User Id: ') . $user->uid;
gallery_error($msg, $ret);
return;
}
// Now convert the new Drupal role Ids into Gallery Group Ids(for comparison)
foreach ($user->roles as $rid=>$role_name) {
......@@ -46,6 +49,7 @@ function gallery_sync_groups_for_user($user) {
$msg = t('Error getting Gallery Group Id from Drupal Role Id');
$msg .= ' ' . t('Drupal Role Id: ') . $rid;
gallery_error($msg, $ret);
return;
}
$g2_rid[$rid] = $g2_group->getId();
}
......@@ -59,6 +63,7 @@ function gallery_sync_groups_for_user($user) {
$msg = t('Error removing user from Gallery group');
$msg .= ' ' . t('Gallery Group Id: ') . $gid . ' ' . t('Gallery Group Name: ') . $gname;
gallery_error($msg, $ret);
return;
}
}
}
......@@ -71,6 +76,7 @@ function gallery_sync_groups_for_user($user) {
$msg = t('Error adding user to Gallery group');
$msg .= ' ' . t('Gallery Group Id: ') . $gid;
gallery_error($msg, $ret);
return;
}
}
}
......@@ -100,12 +106,14 @@ function gallery_sync_groups() {
if ($ret) {
$msg = t('Error retrieving Gallery group Id for \'Everybody\' group');
gallery_error($msg, $ret);
return;
}
$ret = GalleryEmbed::addExternalIdMapEntry($rid, $g2_gid, 'GalleryGroup');
if ($ret) {
$msg = t('Error creating new Drupal role <-> Gallery group mapping (for \'anonymous user\' role)');
$msg .= ' ' . t('Drupal Role Id: ') . $rid . ' ' . t('Gallery Group Id: ') . $g2_gid;
gallery_error($msg, $ret);
return;
}
break;
// Add mapping for authenticated users role and get the G2 group Id
......@@ -114,12 +122,14 @@ function gallery_sync_groups() {
if ($ret) {
$msg = t('Error retrieving Gallery group Id for \'Registered Users\' group');
gallery_error($msg, $ret);
return;
}
$ret = GalleryEmbed::addExternalIdMapEntry($rid, $g2_gid, 'GalleryGroup');
if ($ret) {
$msg = t('Error creating new Drupal role <-> Gallery group mapping (for \'authenticated user\' role)');
$msg .= ' ' . t('Drupal Role Id: ') . $rid . ' ' . t('Gallery Group Id: ') . $g2_gid;
gallery_error($msg, $ret);
$msg = t('Error creating new Drupal role <-> Gallery group mapping (for \'authenticated user\' role)');
$msg .= ' ' . t('Drupal Role Id: ') . $rid . ' ' . t('Gallery Group Id: ') . $g2_gid;
gallery_error($msg, $ret);
return;
}
break;
default:
......@@ -132,6 +142,7 @@ function gallery_sync_groups() {
$msg = t('Error creating new Drupal role <-> Gallery group mapping (by name)');
$msg .= ' ' . t('Drupal Role Id: ') . $rid . ' ' . t('Gallery Group Id: ') . $g2_gid;
gallery_error($msg, $ret);
return;
}
} else {
// If not, create a new group
......@@ -140,6 +151,7 @@ function gallery_sync_groups() {
$msg = t('Error creating new Gallery group');
$msg .= ' ' . t('Drupal Role Id: ') . $rid . ' ' . t('Drupal Role Name: ') . $role_name;
gallery_error($msg, $ret);
return;
}
}
break;
......@@ -152,6 +164,7 @@ function gallery_sync_groups() {
$msg = t('Error retrieving Gallery Group Id from Drupal Role Id');
$msg .= ' ' . t('Drupal Role Id: ') . $rid;
gallery_error($msg, $ret);
return;
}
if (($rid != $authenticated_role) && ($rid != $anonymous_role) && ($role_name != $g2_group->getGroupName())) {
$ret = GalleryEmbed::updateGroup($rid, array('groupname'=>$role_name));
......@@ -159,6 +172,7 @@ function gallery_sync_groups() {
$msg = t('Error updating Gallery group');
$msg .= ' ' . t('Drupal Role Id: ') . $rid . ' ' . t('Drupal Role Name: ') . $role_name;
gallery_error($msg, $ret);
return;
}
}
}
......@@ -167,8 +181,9 @@ function gallery_sync_groups() {
// (just in case other groups have been defined which are not meant to be sync'd with Drupal)
list ($ret, $g2_map) = GalleryEmbed::getExternalIdMap('entityId');
if ($ret) {
$msg = t('Error retrieving all Drupal<->Gallery Map Ids');
gallery_error($msg, $ret);
$msg = t('Error retrieving all Drupal<->Gallery Map Ids');
gallery_error($msg, $ret);
return;
}
$g2_mapped_groups = gallery_get_mapped_groups();
foreach ($g2_mapped_groups as $rid=>$g2_gid) {
......@@ -180,6 +195,7 @@ function gallery_sync_groups() {
$msg = t('Error deleting Gallery group');
$msg .= ' ' . t('Gallery Group Id: ') . $g2_gid;
gallery_error($msg, $ret);
return;
}
}
}
......@@ -191,8 +207,9 @@ function gallery_sync_groups() {
function gallery_get_mapped_groups() {
list ($ret, $g2_map) = GalleryEmbed::getExternalIdMap('entityId');
if ($ret) {
$msg = t('Error retrieving all Drupal<->Gallery Map Ids');
gallery_error($msg, $ret);
$msg = t('Error retrieving all Drupal<->Gallery Map Ids');
gallery_error($msg, $ret);
return;
}
/*
* getExternalIdMap returns groups and user mappings.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment