User Album permission trouble?

shadesdude

Joined: 2009-05-21
Posts: 1
Posted: Thu, 2009-05-21 21:02

What I am trying to accomplish is to have individual user albums created once they activate their account and logs in through my app. But whenever I log in a test user I get the warning "The action you attempted is not permitted."

User creation and id mapping code.

	GalleryEmbed::init(array('embedUri' => $embedUri, 'g2Uri' => $g2Uri, 'activeUserId' => $profile->id));

	$args['fullname'] = $profile->firstName.' '.$profile->lastName;
	$args['username'] = $profile->userName;
	$args['email'] = $profile->email;

	$ret = GalleryEmbed::createUser( $profile->id, $args );

	if (($ret) && ($ret->getErrorCode() & ERROR_COLLISION )){
		// If the user already exists but for some reason wasn't mapped, map them now.
		list( $ret, $user ) = GalleryCoreApi::fetchUserByUserName($profile->userName);

		$ret = GalleryEmbed::addExternalIdMapEntry($profile->id, $user->getId(), 'GalleryUser');
		if ( $ret ) {
			// Record my error to my error_log
			echo 'Failed to add externalIdMap for usename ['.$profile->userName.']';
			return false;
		}
		// Record my error to my error_log
		echo "ERROR_COLLISION, added external ID to map for userId ". $profile->id;
		return false;
	}
	GalleryEmbed::done();

My embed code that I call inside my app

$data = array();
	
 
    // initiate G2 
    $ret = GalleryEmbed::init(array('g2Uri' => $g2Uri, 
				    'embedUri' => $embedUri,
				    'activeUserId' => $user->id,
					'fullInit' => 'false'));
    if ($ret) {
      $data['bodyHtml'] = $ret->getAsHtml();
      return $data;
    }
	
	$ret = GalleryEmbed::login($profile->id);


    // user interface: you could disable sidebar in G2 and get it as separate HTML to put it into a block
    GalleryCapabilities::set('showSidebarBlocks', false);

    // handle the G2 request
    $g2moddata = GalleryEmbed::handleRequest();
  
    // show error message if isDone is not defined
    if (!isset($g2moddata['isDone'])) {
      $data['bodyHtml'] = 'isDone is not defined, something very bad must have happened.';
      return $data;
    }
    // exit if it was an immediate view / request (G2 already outputted some data)
    if ($g2moddata['isDone']) {
	exit; 
    }
   
    // put the body html from G2 into the xaraya template 
    $data['bodyHtml'] = isset($g2moddata['bodyHtml']) ? $g2moddata['bodyHtml'] : '';

    // get the page title, javascript and css links from the <head> html from G2
    $title = ''; $javascript = array();	$css = array();
 
    if (isset($g2moddata['headHtml'])) {
      list($data['title'], $css, $javascript) = GalleryEmbed::parseHead($g2moddata['headHtml']);
	  $data['headHtml'] = $g2moddata['headHtml'];
    }
    
    
    /* Add G2 javascript  */
    $data['javascript'] = '';
    if (!empty($javascript)) {
      foreach ($javascript as $script) {
	     $data['javascript'] .= "\n".$script;
      }
    }

    /* Add G2 css  */
    $data['css'] = '';
    if (!empty($css)) {
      foreach ($css as $style) {
	     $data['css'] .= "\n".$style;
      }
    }


	if (!empty($g2moddata['sidebarBlocksHtml'])) {
		global $g2sidebarHtml;
		$g2sidebarHtml = $g2moddata['sidebarBlocksHtml'];
	}

    // sidebar block
    if (isset($g2moddata['sidebarBlocksHtml']) && !empty($g2moddata['sidebarBlocksHtml'])) {
      $data['sidebarHtml'] = $g2moddata['sidebarBlocksHtml'];
    }
    
    return $data;

my album structure
-Gallery
-Admin Gallery
-User Gallery
-All user galleries get generated under User Gallery

User Gallery has permissions for group Registered Users
-[core] Add sub-album
-[core] View all versions

and finally my user album settings
Create albums - When first accessed (I don't want a bunch of empty albums if I can avoid it)
Albums viewable by - User Only
Full size images viewable - Yes
Location for new user albums - -- User Gallery
Login page - Jump to user album after login
Link to user album - Show link

I'm really confused as to why the user doesn't have permissions to create their album on their first login.