Useralbum in Advanced Profile

autoberater

Joined: 2009-05-18
Posts: 26
Posted: Fri, 2009-07-17 10:33

Hi
I use the Gallery Bridge to connect Gallery2 with Drupal.
Erverything works fine.
Now I have added the modul "Advanced Profile" in Drupal so that every user can create a advanced profile.
My question is, how can I get the user preview of thier pictures, which they have in their standard drupal profile, to the new profile so that when i look at a users profile i can see its pictures of gallery2.
Is there any code or something i can use?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2009-07-17 14:22
	/**
	* Return the last N items a user created
	*
	* @param int $userId
	* @param int $offset
	* @param int $count
	* @param string $orderDirection (optional)
	* @return array (object GalleryStatus a status code,
	*                array (GalleryItem, GalleryItem, ...))
	*/
    function G2B_fetchLastUserItems($userId, $offset, $count, $orderDirection=ORDER_DESCENDING) {
	global $gallery;

	switch($orderDirection) {
	case ORDER_ASCENDING:
	    $direction = 'ASC';
	    break;

	case ORDER_DESCENDING:
	    $direction = 'DESC';
	    break;

	default:
	    return array(GalleryCoreApi::error(ERROR_BAD_PARAMETER), null);
	}

	list ($ret, $aclIds) =
	    GalleryCoreApi::fetchAccessListIds('core.view', $gallery->getActiveUserId());
	if ($ret) {
	    return array($ret, null);
	}
	if (empty($aclIds)) {
	    return array(null, array());
	}
	$aclMarkers = GalleryUtilities::makeMarkers(count($aclIds));

	$query = sprintf('
	SELECT
	  [GalleryItem::id], [GalleryEntity::creationTimestamp]
	FROM
	  [GalleryItem], [GalleryEntity], [GalleryAccessSubscriberMap]
	WHERE
	  [GalleryItem::id] = [GalleryEntity::id]
	  AND
	  [GalleryItem::ownerId] = ?
	  AND
	  [GalleryAccessSubscriberMap::itemId] = [GalleryItem::id]
	  AND
	  [GalleryAccessSubscriberMap::accessListId] IN (%s)
	ORDER BY
	  [GalleryEntity::creationTimestamp] ' . $direction . '
	', $aclMarkers);

	$data = array();
	$data[] = (int)$userId;
	$data = array_merge($data, $aclIds);

	$options = array();
	$options['limit'] = array('count' => (int)$count, 'offset' => (int)$offset);

	list ($ret, $searchResults) = $gallery->search($query, $data, $options);
	if ($ret) {
	    return array($ret, null);
	}

	/* Get all of our item ids */
	$itemIds = array();
	while ($result = $searchResults->nextResult()) {
	    $itemIds[] = (int)$result[0];
	}

	/* Convert them to entities */
	if (sizeof($itemIds) > 0) {
	    list ($ret, $items) = GalleryCoreApi::loadEntitiesById($itemIds, 'GalleryItem');
	    if ($ret) {
		return array($ret, null);
	    }
	} else {
	    $items = array();
	}

	return array(null, $items);
    }

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
autoberater

Joined: 2009-05-18
Posts: 26
Posted: Mon, 2009-07-20 10:53

Can you tell we where I have to insert the code.
The Advanced Profile ist constructed by Panels, I tried to add the code there but it doesn't work.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2009-07-20 11:37

This returns the $item objects you would still have to convert them to something displayable.
You could return the $itemIds instead and use the imageblock to display the items if they are photos.
Or use my mediaBlock which would cover all mimetypes.

Quote:
Can you tell we where I have to insert the code

Sorry, I'm not familiar with Drupal.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2