Announcement

  •  » Requests
  •  » FOR SCRIPT COMPATIBILITY: "user_id" needs to change to "pwg_user_id"

#1 2016-08-23 22:51:48

KungFuJosh
Member
2016-08-21
28

FOR SCRIPT COMPATIBILITY: "user_id" needs to change to "pwg_user_id"

Hi,

I, along with many other users of Piwigo, would like to be able to integrate Piwigo with other systems; forums, CMS, etc... Using user_id throughout your script creates a significant amount of compatibility issues with doing that.

In my case, I'm integrating Piwigo with phpBB forums. By string replacing "user_id" with "pwg_user_id" in Piwigo, and the Community plugin, I was able to integrate with phpBB without any problems. Without making that change, it simply doesn't function properly.

Here's the full story:

I decided to go ahead and do a test install of Piwigo, first replacing user_id with pwg_user_id in all the source code. Then I did a fresh install of my modified Piwigo version. I did the same string replace of user_id with pwg_user_id on the Community plugin that was also causing errors.

I then exported my phpbb_users table with over 30,000 users in it, and imported it into my new Piwigo database.

I modified the config_default.inc.php file with the following code (note that my password hash is for phpBB 3.1.x, phpBB 3.0.x uses md5 instead of password_hash):

Code:

// +-----------------------------------------------------------------------+
// | phpBB MODS                                                            |
// +-----------------------------------------------------------------------+

$conf['users_table'] = 'phpbb_users';
$conf['external_authentification'] = true;
$conf['user_fields'] = array(
  'id' => 'user_id',
  'username' => 'username',
  'password' => 'user_password',
  'email' => 'user_email'
  );
$conf['password_hash'] = create_function('$s', 'return password_hash($s);');
$conf['password_verify'] = 'pwg_password_verify';
$conf['guest_id'] = 1;
$conf['default_user_id'] = $conf['guest_id'];
$conf['browser_language'] = true;
$conf['webmaster_id'] = 2;
$conf['guest_access'] = false; // change this one if you want
$conf['insensitive_case_logon'] = true;

I would not recommend using "username_clean" for the username field because that would result in all the new user albums being created with lowercase names.

I did the following as recommended, even though most of it is not necessary on a fresh install:

Code:

delete from piwigo_user_access;
delete from piwigo_user_cache;
delete from piwigo_user_feed;
delete from piwigo_user_group;
delete from piwigo_user_infos;
delete from piwigo_sessions;
delete from piwigo_rate;
update piwigo_images set rating_score = null, added_by = <webmaster_id>;
delete from piwigo_caddie;
delete from piwigo_favorites;

I then logged in with my phpBB admin username. It worked flawlessly. I was able to view the user manager page in the admin fine.

I activated the Community plugin and the user manager in the admin still worked fine. I did not need to do the other mods done before to fix the Community plugin. All errors were a result of the use of user_id in the Piwigo source code.

Obviously doing this method on the user end will need to be repeated for future updates, and Piwigo should implement it themselves and save us the trouble. I'm going to see if I can manipulate the way Piwigo is accessing the database to work better with phpBB, but I'm not sure if it will work or not. Most of what I've seen is already being aliased.

THREE NOTES:

1. Make sure NOT to change default_user_id to default_pwg_user_id in your auto find&replace.

2. Do NOT make any changes to config_default.inc.php for the clean install prior to bridging the scripts.

3. If you don't want to edit config_default.inc.php (since you're technically not supposed to), you can instead create a file called config.inc.php and put it in the /local/config folder within your Piwigo installation. That will override any of the default file's settings, and be safe from future updates.

I activated the Community plugin and the user manager in the admin still worked fine. I did not need to do the other mods done before to fix the Community plugin. All errors were a result of the use of user_id in the Piwigo source code.

UPDATE:

I've since tested this with a live phpBB board, and it works great. The next step is to make it work with a single sign-on, but making this change to Piwigo would be a good first step to improving compatibility with other scripts.

Piwigo version: 2.8.2
PHP version: 5.6
MySQL version: 5.5

Last edited by KungFuJosh (2016-10-03 15:54:11)

Offline

 

#2 2016-08-25 04:34:36

KungFuJosh
Member
2016-08-21
28

Re: FOR SCRIPT COMPATIBILITY: "user_id" needs to change to "pwg_user_id"

I've heard you also have other ID tags in common with other scripts like SMF. If you append pwg_ to those IDs you will significantly increase your compatibility with other scripts, and that will certainly help the popularity of Piwigo grow.

Offline

 

#3 2016-10-03 15:56:08

KungFuJosh
Member
2016-08-21
28

Re: FOR SCRIPT COMPATIBILITY: "user_id" needs to change to "pwg_user_id"

I updated the OP. I'm no longer considering running Piwigo without these mods. This is a simple mod that shouldn't cause any conflicts, while at the same time removing a lot of conflicts with other scripts.

Last edited by KungFuJosh (2016-10-03 15:57:00)

Offline

 

#4 2016-11-25 20:02:16

KungFuJosh
Member
2016-08-21
28

Re: FOR SCRIPT COMPATIBILITY: "user_id" needs to change to "pwg_user_id"

I have my pwg_user_id modified gallery updated to 2.8.3. I can supply the files if you'd like them for testing.

Implementing this simple change adds much better script compatibility.

Offline

 

#5 2017-02-07 13:08:21

in8sworld
Member
2017-02-07
1

Re: FOR SCRIPT COMPATIBILITY: "user_id" needs to change to "pwg_user_id"

I'm really surprised that there aren't more posts on this thread since phpBB is quite a popular forum software (although I note that piwigo isn't using it here) and forums are notoriously bad when it comes to serving as photo galleries.  There apparently is an extension that allow(ed) piwigo users to be registered on a phpBB forum (http://piwigo.org/ext/extension_view.php?eid=129) but now that phpBB has moved to a different password hash that might no longer function.

I'm interested, as the OP was to have users which are registered in phpBB be granted access to a piwigo database without having them set up another account.  Since both softwares are on the same domain, the intent is to have the two softwares appear to be integrated from the user's perspective, but separate for the purposes of maintaining each with patches going forward.

My concern with manually updating the source to change the user_id field is that I'll have to bother with that every time there is an update to piwigo and now that piwigo has such a nice update feature that makes it a non-starter sort of solution for me. 

My question for piwigo maintainers is whether such a federated login could be effected with an extension easily or not, and whether there is any interest in looking at it since I think the phpBB community would benefit greatly from it if it were to work well.

Last edited by in8sworld (2017-02-07 13:09:52)

Offline

 

#6 2017-02-07 14:29:01

KungFuJosh
Member
2016-08-21
28

Re: FOR SCRIPT COMPATIBILITY: "user_id" needs to change to "pwg_user_id"

The funny thing is that it's an easy change that requires very little modification to Piwigo. I already run my live site this way (over 31,000 users), and I manually update Piwigo using WinMerge to compare folders for changes.

Updating Piwigo this way is obviously tedious, and it's going to be a race between whether or not Piwigo starts to care about script compatibility, or another gallery software replaces Piwigo with a proper import function so I don't lose data or images.

Since I already spent so much time customizing and theming Piwigo for my site, I would obviously prefer they update their script to work with phpBB.

Coppermine gallery integrates great with phpBB, but their gallery system didn't work well for me. It would be cool if somebody with more free time learned from Coppermine's integration script to get Piwigo to work with phpBB signing in only one time.

Offline

 

#7 2017-02-07 15:21:54

eliz82
Member
Romania
2016-04-27
235

Re: FOR SCRIPT COMPATIBILITY: "user_id" needs to change to "pwg_user_id"

in8sworld wrote:

whether there is any interest in looking at it since I think the phpBB community would benefit greatly from it if it were to work well.

I don't want to scare you but the bugs where reported 4 years ago :)
http://piwigo.org/forum/viewtopic.php?p … 26#p141626
And they are not fixed yet.

You can post an issue here (I already post it)
https://github.com/plegall/Piwigo-community/issues
The discussions in the forums are buried more fast. And maybe the developers will give more importance if they see more users are affected.

Offline

 

#8 2017-02-07 16:11:49

KungFuJosh
Member
2016-08-21
28

Re: FOR SCRIPT COMPATIBILITY: "user_id" needs to change to "pwg_user_id"

eliz82 wrote:

in8sworld wrote:

whether there is any interest in looking at it since I think the phpBB community would benefit greatly from it if it were to work well.

I don't want to scare you but the bugs where reported 4 years ago :)
http://piwigo.org/forum/viewtopic.php?p … 26#p141626
And they are not fixed yet.

You can post an issue here (I already post it)
https://github.com/plegall/Piwigo-community/issues
The discussions in the forums are buried more fast. And maybe the developers will give more importance if they see more users are affected.

lol, I know, you and I were the only ones who bothered to do anything about it. And I literally gave them the answer in this thread and others (an EASY ANSWER!!!). And yet, still nothing.

I've been running my modified version of Piwigo for a while now with no issues. The manual updating is annoying, but if Piwigo ever decides to be smart, they could easily have a much better script on their hands.

Offline

 
  •  » Requests
  •  » FOR SCRIPT COMPATIBILITY: "user_id" needs to change to "pwg_user_id"

Board footer

Powered by FluxBB

github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2018 · Contact