Phorum and Gallery 2.0 Integration
Posted by rheo
Phorum and Gallery 2.0 Integration September 20, 2005 05:24PM |
Registered: 21 years ago Posts: 793 |
I would like to announce to that Gallery 2.0 is now available.
[gallery.menalto.com]
The new API it is built on makes it super easy for you to give your phorum users G2 galleries. (if you have the hard drive space)
From there it would be not to big a task to integrate this with phorum in different ways such as avatars.
I have been doing some work with this the last few days however nothing specific enough to a Phorum integration to post here.
If anyone else wants to get on this though I am avaiable here to discuss what is involved.
Edited 2 time(s). Last edit at 09/20/2005 05:25PM by rheo.
[gallery.menalto.com]
The new API it is built on makes it super easy for you to give your phorum users G2 galleries. (if you have the hard drive space)
From there it would be not to big a task to integrate this with phorum in different ways such as avatars.
I have been doing some work with this the last few days however nothing specific enough to a Phorum integration to post here.
If anyone else wants to get on this though I am avaiable here to discuss what is involved.
Edited 2 time(s). Last edit at 09/20/2005 05:25PM by rheo.
Re: Phorum and Gallery 2.0 Integration September 26, 2005 08:59PM |
Registered: 21 years ago Posts: 793 |
i've written a script to port your phorum users to gallery 2.0
there are some setup parameters you have to set to gallery2 to allow user albums but it's pretty straight forward.
I also wrote a function that will get the thumbnail of the galleries highlighted image out of gallery for any given user_id.
I use this with a modified version of mod_avatar so that the thumbnail is shown as the avatar if the user has set up the album. if not it will continue to use their previous avatar if you had the other avatar module installed before it.
I'll get these files together with a proper procedure when i have time. if there is interest here i will try to make time to do it sooner.
Re: Phorum and Gallery 2.0 Integration September 27, 2005 10:21AM |
Admin Registered: 23 years ago Posts: 4,495 |
Re: Phorum and Gallery 2.0 Integration September 27, 2005 09:04PM |
Registered: 21 years ago Posts: 793 |
Re: Phorum and Gallery 2.0 Integration September 30, 2005 08:01AM |
Registered: 19 years ago Posts: 264 |
Re: Phorum and Gallery 2.0 Integration September 30, 2005 10:13AM |
Registered: 21 years ago Posts: 793 |
Re: Phorum and Gallery 2.0 Integration October 05, 2005 04:22AM |
Registered: 22 years ago Posts: 14 |
Re: Phorum and Gallery 2.0 Integration October 07, 2005 07:21PM |
Registered: 21 years ago Posts: 793 |
as i cannot post an attachment here yet i'll try to explain best i can.
first i had to set up gallery to allow user albums, removed the registration, and made it so the user albums would be created when first accessed.
here is the port script i wrote. you will have to insert your own database wrapper.
then you need to add something like this somewhere in your register script.
my embedded gallery itself looks like this.
you'll have to adjust it yourself a bit as i have my own auth stuff in there.
i think that is about it.
any questions?
:-)
first i had to set up gallery to allow user albums, removed the registration, and made it so the user albums would be created when first accessed.
here is the port script i wrote. you will have to insert your own database wrapper.
<?php include_once($DOCUMENT_ROOT . '/lib/global.inc'); include_once($DOCUMENT_ROOT . '/phpgallery/embed.php'); $ret = GalleryEmbed::init(array( 'embedUri' => "port_users_gallery.php", embedPath => "/admin/port", 'relativeG2Path' => "../../phpgallery", 'loginRedirect' => "{$_SERVER[QUERY_STRING]}&login=1", 'activeUserId' => 6)); #if ($ret->isError()) { # print $ret->getAsHtml(); #has error details.. # exit; #} #$auth->requiredlevel=3; #$auth->checktoken($authdb); $sql = "select user_id,username,password,email,hide_email,active,user_data,signature,date_added, date_last_active from p5_users Order By user_id"; print $sql . "<br>\n"; $result=$db->execsql($sql); while ($udata=$result->getrow()) { $unserialized = unserialize($udata[user_data]); # print "<pre>"; # var_dump($unserialized); # print "</pre>"; if ($unserialized[real_name]) $fullname = $unserialized[real_name]; else $fullname = ""; set_time_limit(30); #['username' => string, 'email' => string, 'fullname' => string, # 'language' => string, 'password' => string, # 'hashedpassword' => string, 'hashmethod' => string, # 'creationtimestamp' => integer] $args = array ("username" => $udata[username], "fullname" => $fullname, "email"=>$udata); print "<pre>"; print "first name: " . $fullname . "\n<br>"; print_r($args); print "</pre>"; GalleryEmbed::updateUser($udata[user_id],$args); # $db->execsql($newsql); print $newsql . "<br> \n"; unset($udata); } ?>
then you need to add something like this somewhere in your register script.
include_once($DOCUMENT_ROOT . '/phpgallery/embed.php'); $ret = GalleryEmbed::init(array( 'embedUri' => "main.php", embedPath => "/gallery", 'relativeG2Path' => "phpgallery", 'loginRedirect' => "{$_SERVER[QUERY_STRING]}&login=1")); $phorumdata = array("user_id"=>$userid, "username"=>$newlogin, "password"=>$newpasshash, "password_temp"=>$newpasshash,"email"=>$newemail, "email_temp"=>$newemail, "date_added"=>$date_added, "hide_email"=>0, "active"=>1); # # Put User in Gallery user table GalleryEmbed::createUser($userid,$phorumdata);
my embedded gallery itself looks like this.
you'll have to adjust it yourself a bit as i have my own auth stuff in there.
<?php include_once($DOCUMENT_ROOT . '/lib/global.inc'); $auth->requiredlevel=3; $auth->checktoken($db); if ($auth->securitylevel) $uo->fetchperms($db); $galleryActiveUser = ($auth->securitylevel > 0) ? $auth->uid : ''; ######### require_once(dirname(__FILE__) . '/../phpgallery/embed.php'); $ret = GalleryEmbed::init(array( 'embedUri' => "main.php", embedPath => "/gallery", 'relativeG2Path' => "../phpgallery", 'loginRedirect' => "{$_SERVER[QUERY_STRING]}&login=1", 'activeUserId' => $galleryActiveUser)); if ($ret->isError()) { print $ret->getAsHtml(); #has error details.. exit; } // Use $g2data['headHtml'] and $g2data['bodyHtml'] // to display G2 content inside embedding application // if you don't want to use $g2data['headHtml'] directly, you can get the css, // javascript and page title separately by calling... $g2data = GalleryEmbed::handleRequest(); if ($g2data['isDone']) { exit; // G2 has already sent output (redirect or binary data) } if (isset($g2moddata['headHtml'])) { list($title, $css, $javascript) = GalleryEmbed::parseHead($g2moddata['headHtml']); } ############## $title = Gallery; include($DOCUMENT_ROOT . '/templates/header.html'); print $g2data['bodyHtml']; ?> <?php include($DOCUMENT_ROOT . '/templates/footer.html'); ?>
i think that is about it.
any questions?
:-)
Re: Phorum and Gallery 2.0 Integration November 18, 2005 08:12PM |
Registered: 21 years ago Posts: 793 |
I guess someon somewhere down the road might want to know how you then take the thumbnail from the user gallery and turn it into an avatar in the phorum.
First I created this library I include in mod_avatar...
then I change the mod_avatar_read function in the avatar module to:
this should give your users a really sweet avatar and gallery system.
First I created this library I include in mod_avatar...
<?php require_once('../phpgallery/embed.php'); # Initialize Gallery $galleryActiveUser = 6; $ret = GalleryEmbed::init(array( 'embedUri' => "main.php", embedPath => "/gallery", 'relativeG2Path' => "../phpgallery", 'fullInit' => true, 'loginRedirect' => "{$_SERVER[QUERY_STRING]}&login=1", 'activeUserId' => $galleryActiveUser)); if ($ret->isError()) { # print $ret->getAsHtml(); #has error details.. # exit; } function getGalleryAvatar ($userid) { list ($ret, $galleryuser) = GalleryCoreApi::loadEntityByExternalId($userid,'GalleryUser'); if ($ret->isError()) { # print $ret->getAsHtml(); # exit; } global $gallery; if(is_object($galleryuser)) { list ($ret, $albumId) = GalleryCoreApi::getPluginParameter('module', 'useralbum', 'albumId', $galleryuser->getId()); if ($ret->isError()) { # print $ret->getAsHtml(); # exit; } #print "AlbumID: $albumId \n<br>"; $Ids= array($albumId); if (!empty($albumId)) { $Ids= array($albumId); list ($ret,$thumbnails) = GalleryCoreApi::fetchThumbnailsByItemIds($Ids); if ($ret->isError()) { # print $ret->getAsHtml(); # exit; } list($id,$thumbnail)=each($thumbnails); #print "<pre>"; #print_r($thumbnail); #print "thumbid: " . $thumbnail->getId(); #print "</pre>"; $urlGenerator =& $gallery->getUrlGenerator(); if (is_object($thumbnail)) { $imgSrc = $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'itemId' => $thumbnail->getId(), 'serialNumber' => $thumbnail->getSerialNumber())); $imgSrc = str_replace("phpgallery","gallery",$imgSrc); } else { $imgSrc = false; } } else { $imgSrc = false; } ## # print $imgSrc; return $imgSrc; } } ?>
then I change the mod_avatar_read function in the avatar module to:
function mod_avatar_read($messages){ GLOBAL $PHORUM; // if the user doesn't want to show avatars, we can disable them here $disable = false; if (isset($PHORUM["user"]["mod_avatar"]["disable_avatar_display"])) { $disable = $PHORUM["user"]["mod_avatar"]["disable_avatar_display"]; } $userid = $PHORUM["user"]["user_id"]; require_once($_SERVER[DOCUMENT_ROOT] . '/lib/gallery.inc'); $page_avatars=array(); foreach ($messages as $messageid => $message) { if (!isset($page_avatars[$message["user_id"]])) { $avatarurl=getGalleryAvatar($message["user_id"]); $page_avatars[$message["user_id"]]=$avatarurl; print $url; } // if the user has avatars disabled, don't display them if ($disable){ $messages[$messageid]["mod_avatar"] = false; } elseif ($page_avatars[$message["user_id"]]) { $messages[$messageid]["mod_avatar"] = $page_avatars[$message["user_id"]]; } elseif (!$page_avatars[$message["user_id"]] && isset($message["meta"]["mod_avatar"])) { // first we should check if the avatar still exists // if it does, no problem $filelist = phorum_db_get_user_file_list($message["user_id"]); if (isset($filelist[$message["meta"]["mod_avatar"]])) { $messages[$messageid]["mod_avatar"] = phorum_get_url(PHORUM_FILE_URL, "file=" . $message["meta"]["mod_avatar"]); } // if not, we will show the users default one instead (if they have one of those) else { $user = phorum_user_get($message["user_id"], false); if (isset($user["mod_avatar"]["default_avatar"]) && isset($filelist[$user["mod_avatar"]["default_avatar"]])) { $messages[$messageid]["meta"]["mod_avatar"] = $user["mod_avatar"]["default_avatar"]; // update the post so we don't have to constantly do this extra work $messagetemp = phorum_db_get_message($messageid); $messagetemp["meta"]["mod_avatar"] = $user["mod_avatar"]["default_avatar"]; phorum_db_update_message($messageid, $messagetemp); } else { $messages[$messageid]["mod_avatar"] = false; } } } else { $messages[$messageid]["mod_avatar"] = false; } } return $messages; }
this should give your users a really sweet avatar and gallery system.
Re: Phorum and Gallery 2.0 Integration January 20, 2006 03:32AM |
Registered: 21 years ago Posts: 868 |
Rheo, could you post them files here? Also do you have a live example. I am very interested.
Thnx.
Sergej
------------------------------------------
^AU^ Assassins United
[www.assassinsunited.com]
------------------------------------------
Thnx.
Sergej
------------------------------------------
^AU^ Assassins United
[www.assassinsunited.com]
------------------------------------------
Sorry, only registered users may post in this forum.