Contribution to phpwebgallery & wordpress integration

février 10, 2006

My objective is to contribute to enhance an already existing wonderfull wordpress plugin. Its name is Photon and has been developped by Jillij. It is a nice solution to integrate phpwebgallery and wordpress through a common set of templates.

THIS DOCUMENT IS UNDER CONSTRUCTION AND NOT YET VALIDATED

This solution gives to any visitor the feeling to have one single interface for both applications. Nevertheless, there is not yet any common user management. You still have to log twice (phpwebgallery AND wordpress) to take benefit of all functionnalities provided by both systems. And on administrator point of view, you have to manage two lists of users with their respective rights.

In a firts step, let me propose one solution to simplify user management. My solution is based on one common user table shared by both systems. I will use phpwebgallery mapping functionnality to share this famous table. And I will adapt a little bit Jillij templates to redirect all user mamagement tasks under wordpress control.

Partie A – Configuration

  1. Create a guest account in wordpress and get its respective ID.
  2. The only way I found so far to create this account and to get this ID is to insert manually one row in wp_users table (with phpMyAdmin). I think it is possible to create this specific account from Photon plugin itself and specific options that we can developped and embended in the admin panel of wordpress. This needs more investigation and I will work on that later.

  3. According to step 1, update config_local.inc.php as described below:
  4. $conf['guest_id'] = 25;
    guest_ id is obtained from step 1 and 25 is used as an example.

    Use following parameters to map WP users table from PWG:

    $conf['users_table'] = 'wp_users';
    $conf['user_fields'] = array(
    'id' => 'ID',
    'username' => 'user_login',
    'password' => 'user_pass',
    'email' => 'user_email'
    );

Partie B – Photon update

Add following code at the end of photon-func.php file:

<code><br />function Photon_pwg_delete_user ($user_id) {<br />  include_once( PHPWG_ROOT_PATH.'admin/include/functions.php' );<br />  delete_user($user_id);<br />}<br />add_action ('delete_user', 'Photon_pwg_delete_user');<br /></code></pre><br /><pre><code><br />function Photon_pwg_logout () {<br />  setcookie( 'id', '', 0, cookie_path() );<br />}<br />add_action ('wp_logout', 'Photon_pwg_logout');<br /></code></pre><br /><pre><code><br />function Photon_pwg_identification ($username, $password, $remember_me = 1) {<br />  global $conf;<br />  $query = '<br />    SELECT '.$conf['user_fields']['id'].' AS id,<br />       '.$conf['user_fields']['password'].' AS password<br />    FROM '.USERS_TABLE.'<br />    WHERE '.$conf['user_fields']['username'].' = ''.$username.''<br />    ;';<br />  $row = mysql_fetch_array(pwg_query($query));<br />  if ($row['password'] == $conf['pass_convert']($password))<br />  {<br />    $session_length = $conf['session_length'];<br />    if ($conf['authorize_remembering']<br />      and isset($remember_me)<br />      and $remember_me == 1)<br />    {<br />      $session_length = $conf['remember_me_length'];<br />    }<br />    $session_id = session_create($row['id'], $session_length);<br />  }<br />}<br />add_action ('wp_authenticate', 'Photon_pwg_identification');<br /></code></pre><br /><strong>Partie C - PWG Jillij template update</strong><br /><br />In file <em>category.tpl</em> at line 7 replace:<br /><pre><code><br /></code><br />	<li><a href="{ECHOPHPSELF}"><strong>{L_HOME}</strong></a></li><br /></pre><br />by:<br /><pre><code><br /></code><br />	<li><a href="{ECHOPHPSELF}"><strong>{L_HOME}</strong></a><br /><ul><br />    {WPREGISTER}<br />	<li>{WPLOGINOUT}</li><br /></ul><br /></li><br /></pre><br /><strong>Partie D - WP Jillij template update</strong><br /><br />In file <em>sidebar.php</em> at line 7 replace:<br /><pre><code><br /></code><br />	<li><a href=""></li><br /></pre><br />by:<br /><pre><code><br /></code><br />	<li><a href=""><br /><ul><br />	<li></li><br /></ul><br /></li><br />
Publicités

2 Responses to “Contribution to phpwebgallery & wordpress integration”


  1. Merci de cet article. En venant visiter ton blog depuis les commentaires que tu as laissé sur le mien, je suis tombé sur cette aide. Je ne connaissais pas du tout, mais j’aime déjà !

  2. Ustrici Says:

    Je t’invite à visiter le blog de Jillij à l’origine de ce fameux plugin Photon. Ma contribution fut plus prospective qu’autre chose (bien que déjà en place sur mon site « familial »). J’ai soumis les résultats de mes investigations à Jillij qui devrait prochainement livrer une nouvelle version de Photon tirant entre autre profit des ces résultats.


Laisser un commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion / Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion / Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion / Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion / Changer )

Connexion à %s

%d blogueurs aiment cette page :