PHP Nuke + G2

Impervious

Joined: 2005-01-14
Posts: 13
Posted: Fri, 2005-01-14 16:31

I dont know if I missed the search or what, but all I could find was stuff for G1x....

But I installedd G2 (Lovin it by the way), but I want to know how to make it work with PHP Nuke. I installed the Gallery2 directory in PHP Nukes - Modules directory, and the option is there to activate it, but when I click on link it says Main.php isnt found. What do I need to do to fix this? Or how do I embed it into PHP Nuke?

Thanks in advance...

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2005-01-14 19:01

see the embedding & integration sticky topic in this forum..

 
Impervious

Joined: 2005-01-14
Posts: 13
Posted: Fri, 2005-01-14 20:06

Yes sir I saw that, but when I read it is says Tiki, and Post Nuke.....etc

but nothing about PHP Nuke. Unless I am missing something.... I will read again, but I dont think it has my answer. :cry:

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2005-01-14 20:14

i think that means no one is working on php nuke (that we know of..)

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Fri, 2005-01-14 20:42

I have just made a small integration test, but the result was quite fine :D
Tested on phpnuke 7.5, like everybody i started from the given xaraya module:

Assuming you have installed phpnuke at your webroot ( http://mywebsite.com) and Gallery2 in the folder gallery2 ( http://mywebsite.com/gallery2/), after successfully installed both application independently :

Just create a folder gallery2 in your phpnuke module directory, and add it the index.php file given below:


<?php

/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* ======================                                               */
/* Based on Automated FAQ                                               */
/* Copyright (c) 2001 by                                                */
/*    Richard Tirtadji AKA King Richard (rtirtadji@hotmail.com)         */
/*    Hutdik Hermawan AKA hotFix (hutdik76@hotmail.com)                 */
/* http://www.phpnuke.web.id                                            */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/*         Additional security & Abstraction layer conversion           */
/*                           2003 chatserv                              */
/*      http://www.nukefixes.com -- http://www.nukeresources.com        */
/************************************************************************/

if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
    die ("You can't access this file directly...");
}

require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));

  include("header.php");
    
  require_once(dirname(__FILE__) . '\..\..\gallery2\embed.php');
           
		$ret = GalleryEmbed::init(array(
           'embedUri' => 'http://mywebsite.com/modules.php?name=gallery2',
           'relativeG2Path' => '../gallery2/',
           'loginRedirect' => 'index.php',
           'activeUserId' => '0'));
  
    GalleryCapabilities::set('showSidebar', false);
  
    // handle the G2 request
    $g2moddata = GalleryEmbed::handleRequest();
  
    // show error message if isDone is not defined
    if (!isset($g2moddata['isDone'])) 
    {
      echo 'isDone is not defined, something very bad must have happened.';
      exit;
    }
    
    // die if it was a binary data (image) request
    if ($g2moddata['isDone']) 
    {
      exit; /* uploads module does this too */
    }
  
	  if ($ret->isError()) 
	  {
	    echo $ret->getAsHtml();
	  }
  
	  echo $g2moddata['headHtml'];
	  echo $g2moddata['bodyHtml'];
    
    include("footer.php");

?>

It will allow you to browse your Gallery2 directly inside phpnuke.

But this is just a basic test, and had nothing to deal with a real module:
Except browsing, absolutly nothing is supported !

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-01-14 21:21

drumicube, excellt start! i hope you continue your work on this integration. And you could upload your mod somewhere (or upload it to this forum) so that I can include your phpnuke mod to the list of all integrations in the sticky topic.

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Fri, 2005-01-14 21:51

To be honest, i wasn't expected working on G2 at all !
But Gallery give me so much, and working on it will be fun. 8)

I will setup a new phpnuke website this week-end and dedicate it to a phpnuke G2 integration module.

Thank for all your amazing works, guys !

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-01-14 22:03

drumicube, no no, we have to thank you for your contribution :)

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Fri, 2005-01-14 23:02

Hi, Valiant !
I have bought a domain name and a 300MB hosting for this website, but i have to wait 24 to 48 hours for the DNS to propagate the domain... :x

Meanwhile, i will install a fresh phpnuke 7.5 install with the latest G2 snapshot.
If everything is fine a basic demo will be visible for monday !

I will reply here, as soon as something valuable is available.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-01-14 23:44

I hope this domain and hosting plan wasn't for the phpnuke & G2 integration only! :lol:

 
Impervious

Joined: 2005-01-14
Posts: 13
Posted: Sun, 2005-01-16 09:35

I am having many errors..... but I have my Gallery2 under PHP-Nukes Modules folder..... but I think I will just uninstall it from there and reinstall as you said. Thank you very much.... Hope I get this to work. I will let you know.

Again Thanks

 
Impervious

Joined: 2005-01-14
Posts: 13
Posted: Sun, 2005-01-16 19:15

Well I loaded it seperate, and I still get these errors.

Warning: main(/home/sites/MyWeb.com/public_html/laley/html/modules/gallery2\..\..\gallery2\embed.php): failed to open stream: No such file or directory in /home/sites/MyWeb.com/public_html/laley/html/modules/gallery2/index.php on line 35

Fatal error: main(): Failed opening required '/home/sites/MyWeb.com/public_html/laley/html/modules/gallery2\..\..\gallery2\embed.php' (include_path='.:/usr/local/lib/php') in /home/sites/MyWeb.com/public_html/laley/html/modules/gallery2/index.php on line 35

Can you tell me what I am doing wrong?

 
Impervious

Joined: 2005-01-14
Posts: 13
Posted: Sun, 2005-01-16 19:20

by the way... this is line 35

require_once(dirname(__FILE__) . '\..\..\gallery2\embed.php');

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2005-01-16 19:41

is the path correct? where is your G2 relative to your php nuke g2 module?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-01-16 19:42

change it to:

require_once(dirname(__FILE__) . '/../../gallery2/embed.php');
           
      $ret = GalleryEmbed::init(array(
           'embedUri' => 'modules.php?name=gallery2',
           'relativeG2Path' => '../gallery2/',
           'loginRedirect' => 'index.php',
           'activeUserId' => '0')); 

embedUri and require_once changed.

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Sun, 2005-01-16 22:22

Yes you're right, or it will only works on windows... :x

By the way, i have manage to setup my website, a basic demo of G2 from Phpnuke is available here: http://www.phpnuke-web.com

I was not supposed to launch this before february, so everything is not perfect at the moment, (sorry for this) but it will change soon...

:oops:

PS: At the moment, i have setup a basic integration module including an administration panel for G2.
You can watch this in the screen capture i have posted into my G2 galleries.
By the way, i will propose this alpha module for download during the week.

A forum had also been installed, i will feedback there the evolution of my work.

I hope this will help !

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-01-16 23:00

i added your link to the embedding & integrations sticky topic.
thanks for the effort!

 
Impervious

Joined: 2005-01-14
Posts: 13
Posted: Mon, 2005-01-17 00:07

My Path to PHP Nuke is...

www.mywebthing.net/laley/html/...... then the phpnuke files and folders

My Path to G2 is....

www.mywebthing.net/laley/html/gallery2/..... then the gallery files and folders.....

 
Impervious

Joined: 2005-01-14
Posts: 13
Posted: Mon, 2005-01-17 00:10

valiant I edited the index with what you gave me.... and I get a diff error that says something serious is wrong now.....

isDone is not defined, something very bad must have happened.

I am sorry for being a complete idiot, but I am trying to learn it all.

and thanks for all the help in this.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-01-17 07:18

Impervious, my guess is that it is too early to try the phpnuke integration. right now, it works for only 1 config for 1 person.

what's the error you get, did you enable buffered debug mode in G2?

 
Impervious

Joined: 2005-01-14
Posts: 13
Posted: Mon, 2005-01-17 07:28
Quote:
isDone is not defined, something very bad must have happened.

Is the error.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-01-17 08:32

Impervious, well, that's rather output for the developer.

give me all paths you can get:

- filesystem paths of G2 and phpnuke
- URLs of phpnuke and G2
- do you use alias/symlinks?
- post your require_once and GalleryEmbed::init(array(...)) arguments

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Mon, 2005-01-17 18:58

Impervious ,i know this could be a stupid question but, have you first installed your G2 in the standalone way ?

You must first install G2, as you would have done if phpnuke wasn't there...
Once it's done, then you link your phpnuke (using the module file given here) with your fully INSTALLED copy of G2 !

By the way, Valiant is right. It is to soon to use this module, it was just provided here to help developpers...

:cry:

 
Impervious

Joined: 2005-01-14
Posts: 13
Posted: Tue, 2005-01-18 04:46

require_once(dirname(__FILE__) . '/../../gallery2/embed.php');

$ret = GalleryEmbed::init(array(
'embedUri' => 'modules.php?name=gallery2',
'relativeG2Path' => '../gallery2/',
'loginRedirect' => 'index.php',
'activeUserId' => '0'));
=======================================
- filesystem paths of G2 and phpnuke
-----/public_html/laley/html/ <-- IS PHPNUKE
-----/public_html/laley/html/gallery2 <--- IS G2

- URLs of phpnuke and G2
-----www.laley.jordall.net <---- IS URL TO PHPNUKE
-----www.laley.jordall.net/gallery2 <----- IS STRAIGHT URL TO GALLERY

- do you use alias/symlinks? <---- DONT KNOW WHAT THAT IS?????

- post your require_once and GalleryEmbed::init(array(...)) arguments
------ AT TOP OF POST

======================================

I installed PHPNUKE, then I installed Gallery and set it all up and then I try to add that Module and index.php.... but to no avail.... failed. And I understand that it is to new to do the module... but isnt that what this is all about is to get the bugs out?

Not only that I tried the G1x and it wont make thumbnails... but this one works and is a sweet app, just need to try to get it into the phpnuke.

Sorry for all the headaches...
But thank you for all the help...

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-01-18 07:34

in what folder is the G2 module for phpnuke?
something like
-----/public_html/laley/html/modules/gallery2/
?

I guess, in your case, 'relativeG2Path' => './gallery2/',
is the right path (or just 'relativeG2Path' => 'gallery2/', ).

 
Impervious

Joined: 2005-01-14
Posts: 13
Posted: Tue, 2005-01-18 14:01
Quote:
in what folder is the G2 module for phpnuke?
something like
-----/public_html/laley/html/modules/gallery2/
?

that is the path to the module gallery2

but I changed the index to what you said adn I still get this error

Quote:
isDone is not defined, something very bad must have happened.

 
Impervious

Joined: 2005-01-14
Posts: 13
Posted: Wed, 2005-01-19 14:24

Ok how does drumicube get it to work and I cant? Do I have a php prob? or just am I an idiot?

I am guessing the # 2 option.

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Thu, 2005-01-20 00:35

Impervious, To tell you the truth , there is only 4 or 5 parameters in the embed function call, but i spend easily two or three hours setting them up !
This is not so easy it seems to be ! :lol:

By the way, i have uploaded a zip of my module on my website, so please come and check, it could help you a lot !

The admin panel on this module will allow you to customize directly those parameters and save them, i have checked them on phpnuke 7.5 and 7.6 both Linux and Windows. It was working fine.

If you use phpnuke 7.6, don't rename your admin.php file, because this feature is not supported yet :-?

Of course any feedback is really welcome, even if i'm perfectly aware a lot of work had to be done !

Cheers.

 
Impervious

Joined: 2005-01-14
Posts: 13
Posted: Thu, 2005-01-20 05:10

Thank you very much for that Module Drum...
It makes it easier, but I still get errors.

Do I keep trying all those other commands that are in that Embeded Readme file? are those the only ones or are there more?

I got this one to say OK in the admin panel...
Gallery2 Full filepath:

But I need to try the other 3 to get them off of the Required.... or are they supposed to stay that way? They need to say 'OK' right?

Thanks for the easy way to admin it.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-01-20 10:45

Impervious, in the nuke forum you asked if you should rather give it up. i'd say, suspend it for a week or two, there's no hurry.

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Thu, 2005-01-20 12:37

Again valiant is right ! :wink:
You should wait for a week, new versions of this module will be available, with more features, more configuration checks !

In the next version, i will also add a usual README file, with tips on how to install and get it to work.

PS: Concerning the "Ok" response in the Gallery2 Full filepath:, only this field is tested for now, the others will follow soon, if it is possible to test them of course !

 
Impervious

Joined: 2005-01-14
Posts: 13
Posted: Thu, 2005-01-20 14:10

Ok I will wait.... :(

But thank you all for you help and time. Usually I am not this dumb and I catch on to the code, but I am trying to learn PHP.

But again thank you.

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Sat, 2005-01-22 02:20

Inspired on Xaraya integration , i managed to synchronized Language settings based on the Phpnuke language block, it works great !

The only trick was to map the language definitions from phpnuke to the ones in G2, (yes there not the same!)

I basically used this simple array:

// --------------------------------------------------------
// Mapping between Phpnuke and Gallery2 language definition
// --------------------------------------------------------

$Phpnuke2G2Lang = array(
'danish' 		=> 'da',
'dutch' 		=> 'de',
'el' 			=> 'el',
'english' 		=> 'en',
'spanish' 		=> 'es',
'finnish' 		=> 'fi',
'french' 		=> 'fr',
'galego' 		=> 'ga',
'italian' 		=> 'it',
'ja' 			=> 'ja',
'nl' 			=> 'nl',
'norwegian' 	=> 'no',
'polish' 		=> 'pl',
'portuguese'	=> 'pt',
'slovenian' 	=> 'sv',
'zh' 			=> 'zh',
);

Please notice this array is not fully correct. You get it, i don't speak all those languages and some abbreviation are totally unknown to me !
So if you got some of them, it will make me gain precious time seeking this on the net... :D

The next step was to try the sidebar block, and here comes the bad news:
I didn't success at all. the idea used in Xaraya is great: Using a glogal variable to pass block content is nice, but it seems in phpnuke the blocks are processed before the module, so the content of the block is always empty !

I will update this new version of the module at the end of the week.
Please give me any feedback possible, i don't even know is someone had sucessfully installed it.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-01-22 11:45

i don't know why dutch is two times on the list. dutch = nl, as far as I know.
so
dutch' => 'de',
is wrong. de is from germany, not the netherlands/holland.

see http://www.w3.org/WAI/ER/IG/ert/iso639.htm
the keyword to search for in google is "language codes".

@sidebar:
you're right, in xaraya, this works, because the blocks are requested from the CMS after the module contents.
if this works the other way 'round in phpnuke, you have two options.
a) do 2 requests (long page loading times), 1 for the sidebar, 1 for the rest of G2
b) do the real request not in the module request, but in the sidebar request. instead of storing the sidebar contents in a global variable, store all the rest in a global variable.
in the module request, you check the global variable, if it's already there (= if the sidebar was requested before). if yes, render the contents from the global variable, else: do a normal G2 request.
i don't like a), go for b).

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Sat, 2005-01-22 18:38

Thanks for your w3 link (nice document), i have update the language list, it should be ok now.
I have also done your "b" request, and it works.
I'm still having issues but i haven't finished all i wanted... :lol:
It should be ok soon.

I have now a basic project containing a module, and admin module and a block, i will stop adding more stuff, and mainly focus myself on cleaning all this:

-1- I will match as close as possible your Xaraya project template, including comments, function names and all the rest.

-2- Priority is now to implement all the Xaraya stuff i skipped in phpnuke (for instance i have skip the adding of G2 Javascript to phpnuke template because it's not as easy as in Xaraya, it's the same concerning the UTF issue)

-3- i need to follow stricty the rules given in the EMBEDDING document you provided.

-4- I'm wondering myseft if it's worth setup up a CVS repository:
it shoud be ok, i have a Debian server to manage this ! But is somebody interessed now ?

I have updated my demo on http://www.phpnuke-web.com:
Don't be so surprised if it's loosy, i'm still on it, it was just done to show a G2 block !
And of course no download provided this time...

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-01-22 20:00

sounds great.

@-1-: no need for matching the structure of the xaraya integration. this structure is the xaraya module structure. i know that xaraya is a fork of postnuke and postnuke was a fork of phpnuke, but a long time has past since then. choose function names and a structure appropriate to phpnuke, whatever that means.

@-2-: what you do now is definitely not good. you echo the headHtml into the body part of the page. this is not standards compliant and has no effect. either find a way to add the css and the javascript to the page or do it somehow manually.

@-3-: the EMBEDDING document was authored by mindless, not me.
but following these rules is a good idea :)

@-4: why not let me add it to the gallery cvs on sourceforge? of course you can manage your own cvs too, but we'd be glad to add it to the project cvs too.

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Sun, 2005-01-23 20:10

@1 - I should have been more precise: i was talking about the fact to release a good indented and commented code, concerning the structure itself as you guess it: it's phpnuke module format which rules everything, my choices are rather limited !

@2 - I have look a little bit more this headerhtml thing.
Damn !!! You're totally right, i have removed my trash and temporaly add this to the custom_head.php file:

<style type="text/css" media="all">@import url(http://localhost/gallery2/layouts/matrix/layout.css.php);</style>
		<style type="text/css" media="all">@import url(http://localhost/gallery2/themes/matrix/styles/theme.css);</style>

Now, this is inserted just before </head> of the phpnuke header system, and only once.
Of course, this is not a good solution: It's static, and won't take in consideration any user template choices.
But at least, this is compliant as long as we use the standard template !

@4 - Done, check you're mails ! :wink:

The block is better now, but far from perfect !
i'm actually watching what's wrong with the css, it seems phpnuke and g2 css are overlapping each other.
You can watch this bug on phpnuke-web.com.
I'm sure it's nothing, certainly class redefinition in css.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-01-23 20:37

@-2-:
custom_head.php seems to be php -> parsed dynamically. is it a per module file?
is it requested before or after the module contents?
You could do the same thing as with the sidebar. use a global var to store the headHtml and use GalleryEmbed::parseHead($headHtml); in custom_head.php.

@css overlaps:
right. that's a known problem. someone is working on this or will soon be working on this.

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Mon, 2005-01-31 22:12

This post to feedback my progression:

Concerning the block menu, i will wait a little bit before updating it: I still have CSS problems and the blocks becomes empty half the time when i select an option (as the view card for instance).
I prefer to postpone this for later.

I have started the users integration, and for now i can create phpnuke users in G2 :D
This is really basic, but it works.

Concerning the groups and the Admin users:
Phpnuke managed this like hell :evil: ! This CMS use two different tables to store Users & what they called Authors...
You have the ability to log yourself in two different pages, one for the Admin and another one for the users, and most of all: The both accounts at the same using the same Username ! Great ! :x

There will be severe issues there, for sure.
Nothing impossible, but some choice will have to be taken, i think a total mapping as given with Xaraya or postnuke won't be possible.

By the way, i will update my code this week with the new stuff available:
I hope a basic user login mapped to the default group.

Cheers.

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Mon, 2005-01-31 23:43

This post to feedback my progression:

Concerning the block menu, i will wait a little bit before updating it: I still have CSS problems and the blocks becomes empty half the time when i select an option (as the view card for instance).
I prefer to postpone this for later.

I have started the users integration, and for now i can create phpnuke users in G2 :D
This is really basic, but it works.

Concerning the groups and the Admin users:
Phpnuke managed this like hell :evil: ! This CMS use two different tables to store Users & what they called Authors...
You have the ability to log yourself in two different pages, one for the Admin and another one for the users, and most of all: The both accounts at the same using the same Username ! Great ! :x

There will be severe issues there, for sure.
Nothing impossible, but some choice will have to be taken, i think a total mapping as given with Xaraya or postnuke won't be possible.

By the way, i will update my code this week with the new stuff available:
I hope a basic user login mapped to the default group.

Cheers.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-02-01 06:36

AFAIK groups in phpnuke are not real groups as we know them from other CMS or G2, are they? Integrating groups is quite troublesome and advantage of integrated groups is really small. I'd recommend to not integrate groups for pretty every integration. What I did with xaraya was an experiment.
So, integrating groups would be the last thing.

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Wed, 2005-02-09 13:09

Well i'm a bit more used to G2 now, but i have still strong problem to manager G2 users in phpnuke, i added in my module an "Import Phpnuke USers to G2" and it worked in some manner (some users are not visible) in G2 Users list page.

But the worst comes from the fact i have NEVER be able to log as a user in the embedded G2 !
For instance, i manually create a G2 user called "drumicube" in G2 Users management page.
When i browse G2 in phpnuke i'm always a guest !
Even if i'm logged as drumicube in phpnuke and patch the activeUserId to 'drumicube' ( I quite sure it had to deal with the external ID stuff...)

By the way valiant: the Xaraya module helps me right, but i rather started again from scratch:
First because i'm not using Xaraya of course, so i don't need half of what is available from your module , but also coz there is a real lack about the documentation, and believe me after 10 hours working on it, it's still not easy to anderstand !
Adding the fact i don't know anything about Xaraya API, i hope you will anderstand my problem :lol:

All this to comes to one important point: Is a documentation of the way ?
I think we really needs it ! If this is not the case, i'm ready to help for this...

Cheers.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2005-02-09 15:47

drumicube, if you create a user in G2's user page it does not store a mapping for phpnuke user id <-> G2 user id.. it doesn't know anything about the phpnuke user. you can manually add a mapping in the g2_ExternalIdMap table or you can create your test user using the GalleryEmbed::createUser function which always adds the id mapping.
@documentation.. you've looked at docs/EMBEDDING and the phpdoc above each function in embed.php, right?

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Wed, 2005-02-09 22:59

Ok Thanks a lot for your answer mindless, you're right my problem should comes from the mapping !
Concerning the docs, Yes i have read both docs/EMBEDDING (a lot of times) and the JAVADOC (the xaraya module source is always open when i work on my module, this is my reference).

I will give it a more harder try in the following days, and i thing i should solve this problem soon...

thanks a lot for your answer !

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-02-09 23:03

I hope you get it done because you'll have to wait for a documented example of how to integrate a CMS for some time, I'm so darn busy these months.
The docs from mindless in EMBEDDING and embed.php are a good start, docs from the CMS point of view would make it easier though.

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Wed, 2005-02-09 23:13

The reference mindless gave me about the g2_externalidmap table allow me to solve this problem in 5 minutes !
This is working like a charm now, i can browse G2 inside phpnuke logged with my nuke account ! (Time to pop a beer :D)
THANKS A LOT GUYS.

I will clean all my stuff now, and release a code sample as soon as it's ok !

THANKS ! THANKS ! THANKS !
:D

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Sat, 2005-02-12 19:48

Ok ! I'm about to release a new version allowing a basic user integration:
It works fine even if there is no group integration available.
But i have still two minor bugs to clean up:

1- For now, no Hook is available (You've got to use the admin panel to refresh G2 user) so when a new user register phpnuke, there is no ExternalId for newcomers in the init embed call.

global $db,$user_prefix;
cookiedecode($user);
$uname = $cookie[1];
$uid='';  
if (is_user($user)) 
{
    $row3 = $db->sql_fetchrow($db->sql_query("SELECT user_id FROM $user_prefix"._users." WHERE username='$uname'"));
	$uid = intval($row3[user_id]);
} 
				$ret = GalleryEmbed::init(array(
		           'embedUri' => $g2embedparams[embedUri],
		           'relativeG2Path' => $g2embedparams[relativeG2Path],
		           'loginRedirect' => $g2embedparams[loginRedirect],
		           'activeUserId' => "$uid",
		           'activeLanguage' =>$g2currentlang));

The init call return me an error if this user is not mapped, is there a way to log him as a guest instead ? I could do a first init with 'activeUserId' => '' check if an external mapping exist for him then recall init with the correct id or guest id but two calls is a high CPU time cost !
Some ideas ?

2 - I have a problem with the password mapping !

	// Export all phpnuke users (except anonymous) to G2 defaut group if non existant
	 
	$query='SELECT user_id, name, username, user_password, user_email, user_lang,  user_regdate FROM '.$user_prefix."_users WHERE `user_id`>'1'";
	$result=$db->sql_query($query);
	$numrows = $db->sql_numrows($result);
			// Get Arguments for the new user:
			$args['fullname']  	=	$nukeuser_name;
			$args['name']		=	$nukeuser_uname;
			$args['username'] 	= 	$nukeuser_uname;
			//$args['password']	=	'';
			$args['cryptpass'] 	=	$sqluserdata['user_password'];
			$args['hashmethod'] = 	'md5';
			$args['email'] 		=	$nukeuser_email;
			$args['language']	=	$g2nukeuser_lang;
			$args['creationtimestamp']	=	$regphpusertimestamp;

			$ret = GalleryEmbed :: createUser($nukeuser_id, $args);

I can't log myseft directly in G2 with the phpnuke password, and if i check the mysql database, i noticed the user hash password is different for phpnuke et G2. I have tested many methods (using args['password'], removing medthod md5 etc...) nothing work, no login ? Where is my mistake ?

Except this , it's really working very well, nice job guys !
Thansk for your help !

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sat, 2005-02-12 22:14

1) this should work, but it's a bit hacky:
call init() with the correct active user id.. if you get back ERROR_MISSING_OBJECT then call GalleryEmbed::checkActiveUser(''); (you can't call init twice)

2) it's not actually required to sync the password.. this just allows users to log directly into G2 standalone with the same password, if you want to allow that. you can either pass 'password' which is plain text password, or you can pass 'hashedpassword' and 'hashmethod' (only md5 is supported).. there is no 'cryptpass'.

 
drumicube

Joined: 2005-01-07
Posts: 32
Posted: Sun, 2005-02-13 19:30

Thanks for your help !

1) I have simply removed the error notification: if the mapping doesn't exist, i'm log as a guest.

2) Fixed: i can now log both from phpnuke and G2.

I'm now working on the Admin authentication. As you know phpnuke have quite a strange way to manage this:
Admin is managed totally differently from users, they are not users will special rights allowing them more control. They are stored in a different table from users, don't use the user login form to authenticate etc...
So you can be log as a user and an admin at the same time !

My idea to map phpnuke admins to G2 is very simple:
I create a fake ExternalIdMap using this:

In the Admin Page:

	// Map the ExternalmapId "admin" to the admin account
	
	if (!isset ($mapsbyexternalid["admin"])) 
	{
		if (!g2addexternalMapEntry("admin", 5, 0)) 
		{
 			return false;
		}
	}

If the admin is log in phpnuke i don't care about user mapping, instead i use the fake admin mapping just created above.

In the call of G2 module:


	if (is_admin($admin)) 
	{
		// we log as an admin
		$uid='admin';
	}
	else
	{
		// we log as a normal user (get uid from phpnuke)
		$uid=....
	}

				$ret = GalleryEmbed::init(array(
		           'embedUri' => $g2embedparams[embedUri],
		           'relativeG2Path' => $g2embedparams[relativeG2Path],
		           'loginRedirect' => $g2embedparams[loginRedirect],
		           'activeUserId' => "$uid",
		           'activeLanguage' =>$g2currentlang));

And it worked fine ! as soon as i passed the admin login form in phpnuke, i'm log as admin in G2, even if i'm logged as a basic user in phpnuke.

But the real Question about all this, is the following:
-1- If someone register the phpnuke website with "admin" user name (which is not forbidden) , he won't be mapped at all !

-2- You noticed i have used the G2Id 5 to retrieve the g2 admin user. Is there a better way to handle this ? I hate it, it's really 'hacky' !
I have thought about retrieving it by name, but you can rename the admin account in G2 !
And more over, isn't too dangerous to use ? I don't even know if this number will permanently map the g2 admin account...
I hate that ! :lol:

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2005-02-13 19:43
list ($ret, $adminGroupId) = GalleryCoreApi::getPluginParameter('module', 'core', 'id.adminGroup');
if ($ret->isError()) {
    return ..
}
list ($ret, $adminList) = GalleryCoreApi::fetchUsersForGroup($adminGroupId, 1);
if ($ret->isError()) {
    return ..
}

$adminList is now an array containing one entry, id => username of an admin user.. note there can be multiple admins in G2 but the "1" parameter in fetchUsersForGroup asks for just one of them.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-02-14 19:06

drumicube, i can't believe that you have to query uid for the active user in phpnuke with a sql statement. there must be a phpnuke function or global variable to get the active user (object), his data or just his id. i'm sure this uid is already somewhere stored at the point where the module gallery2 does its job.

mindless, you have there an interesting approach to handle user synchronization in CMS where no events/hooks are available.

Quote:
1) this should work, but it's a bit hacky:
call init() with the correct active user id.. if you get back ERROR_MISSING_OBJECT then call GalleryEmbed::checkActiveUser(''); (you can't call init twice)

We could add a note to docs to use gallerycoreapi::getentitybyexternalid if an error was returned and if getentitybyexternalid returns no entity, galleryembed::createuser can be called, followed by galleryembed::checkactiveuser and handlerequest.