[pLog-svn] r2187 - plog/trunk/class/dao/userdata

Oscar Renalias phunkphorce at gmail.com
Fri Jun 10 09:44:08 GMT 2005


yeah keep an eye on it... I will work on it, little by little and see
how far we can get :)

There are already two issues that I am facing:

1) there are some fields in the plog_users table that are not
available in the phpbb_users table (different statuses, full_name,
about, etc). I am thinking that the only way is to create a new
plog_phpbb_users where we can store that "extra" info and load it
every time we load a user from phpbb.

2) phpbb only knows about users, but in plog we need a user *and* a
blog so when a new user is registered in phpbb we should also somehow
create a new blog for this person as long as there isn't already one.
I thought about implementing this in the PhpBB2UserDataProvider class
so that when a user is loaded, it checks for his/her blogs and creates
them automatically. Any other ideas?

I suppose these will be the same problems with every other integration...

Oscar

On 6/10/05, Mark Wu <markplace at gmail.com> wrote:
> Great, I follow follow the example and make the pLog-Mambo integration.
> 
> Mark
> 
> > -----Original Message-----
> > From: plog-svn-bounces at devel.plogworld.net
> > [mailto:plog-svn-bounces at devel.plogworld.net] On Behalf Of
> > oscar at devel.plogworld.net
> > Sent: Friday, June 10, 2005 5:00 PM
> > To: plog-svn at devel.plogworld.net
> > Subject: [pLog-svn] r2187 - plog/trunk/class/dao/userdata
> >
> > Author: oscar
> > Date: 2005-06-10 09:00:01 +0000 (Fri, 10 Jun 2005) New Revision: 2187
> >
> > Modified:
> >    plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php
> > Log:
> > this is already *roughly* working. It will work with a phpbb
> > installation as long as the user ids in both databases match.
> > You can authenticate against it, but not add update or remove
> > new users. User statuses won't work yet, either.
> >
> >
> > Modified:
> > plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php
> > ===================================================================
> > ---
> > plog/trunk/class/dao/userdata/phpbb2userdataprovider.cl
> > ass.php       2005-06-09 14:09:09 UTC (rev 2186)
> > +++
> > plog/trunk/class/dao/userdata/phpbb2userdataprovider.cl
> > ass.php       2005-06-10 09:00:01 UTC (rev 2187)
> > @@ -1,10 +1,7 @@
> >  <?php
> >
> >      include_once(
> > PLOG_CLASS_PATH."class/dao/userdata/baseuserdataprovider.class.php" );
> > -    include_once( PLOG_CLASS_PATH."class/dao/userinfo.class.php" );
> > -    include_once(
> > PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
> > -    include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
> > -    include_once( PLOG_CLASS_PATH."class/dao/userstatus.class.php" );
> > +    include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
> >
> >      /**
> >       * Model representing the users in our application.
> > Provides the methods such as @@ -14,6 +11,8 @@
> >       */
> >      class PhpBB2UserDataProvider extends BaseUserDataProvider
> >      {
> > +         var $_db;
> > +         var $_prefix;
> >
> >          /**
> >           * Initializes the model
> > @@ -21,6 +20,18 @@
> >          function PhpBB2UserDataProvider( $providerConfig )
> >          {
> >              $this->BaseUserDataProvider( $providerConfig );
> > +
> > +            // initialize the database connection based on
> > our parameters
> > +            $config = $this->getProviderConfiguration();
> > +            $user = $config->getValue( "user" );
> > +            $pass = $config->getValue( "password" );
> > +            $host = $config->getValue( "host" );
> > +            $db = $config->getValue( "database" );
> > +            $this->_phpbbprefix = $config->getValue( "prefix" );
> > +
> > +
> > +
> > +            $this->_dbc =& Db::getNewDb( $host, $user,
> > $pass, $db );
> >          }
> >
> >          /**
> > @@ -32,7 +43,22 @@
> >           * @return true if user and password correct or
> > false otherwise.
> >           */
> >          function authenticateUser( $user, $pass )
> > -        {
> > +        {
> > +             $query = "SELECT * FROM
> > ".$this->_phpbbprefix."users WHERE username = '".Db::qstr( $user )."'
> > +                       AND user_password = '".md5( $pass )."' AND
> > +user_active = 1";
> > +
> > +             $result = $this->_dbc->Execute( $query );
> > +
> > +             if( !$result )
> > +                     return false;
> > +
> > +            if( $result == false )
> > +                return false;
> > +
> > +            if( $result->RecordCount() == 1 )
> > +                return true;
> > +            else
> > +                return false;
> >          }
> >
> >          /**
> > @@ -44,6 +70,17 @@
> >           */
> >          function getUserInfo( $user, $pass )
> >          {
> > +             $query = "SELECT * FROM
> > ".$this->_phpbbprefix."users WHERE username = '".Db::qstr( $user )."'
> > +                       AND user_password = '".md5( $pass )."'";
> > +
> > +             $result = $this->_dbc->Execute( $query );
> > +
> > +             if( !$result )
> > +                     return false;
> > +
> > +             $row = $result->FetchRow();
> > +
> > +             return( $this->_mapUserInfoObject( $row ));
> >          }
> >
> >          /**
> > @@ -54,6 +91,16 @@
> >           */
> >          function getUserInfoFromUsername( $username )
> >          {
> > +             $query = "SELECT * FROM
> > ".$this->_phpbbprefix."users WHERE
> > +username = '".Db::qstr( $username )."'";
> > +
> > +             $result = $this->_dbc->Execute( $query );
> > +
> > +             if( !$result )
> > +                     return false;
> > +
> > +             $row = $result->FetchRow();
> > +
> > +             return( $this->_mapUserInfoObject( $row ));
> >          }
> >
> >          /**
> > @@ -64,7 +111,29 @@
> >           */
> >          function getUserInfoFromId( $userid, $extendedInfo = false )
> >          {
> > +             $query = "SELECT * FROM
> > ".$this->_phpbbprefix."users WHERE
> > +user_id = '".Db::qstr( $userid )."'";
> > +
> > +             $result = $this->_dbc->Execute( $query );
> > +
> > +             if( !$result )
> > +                     return false;
> > +
> > +             $row = $result->FetchRow();
> > +
> > +             return( $this->_mapUserInfoObject( $row ));
> >          }
> > +
> > +        function _mapUserInfoObject( $row )
> > +        {
> > +             $user = new UserInfo( $row["username"],
> > $row["user_password"], $row["user_email"],
> > +                                   "", // TODO: this is the
> > 'about myself' field that should be got from somewhere!
> > +                                   "", // TODO: the user
> > full name is not available in phpbb
> > +                                   0, // TODO: the resource
> > picture id is not available in phpbb
> > +                                   Array(), // TODO: the
> > user properties are not available in phpbb
> > +                                   $row["user_id"] );
> > +
> > +             return( $user );
> > +        }
> >
> >          /**
> >           * Returns an array with all the users available in
> > the database @@ -136,6 +205,7 @@
> >           */
> >          function userExists( $userName )
> >          {
> > +             return( $this->getUserInfoFromUsername( $userName ));
> >          }
> >
> >          /**
> >
> > _______________________________________________
> > pLog-svn mailing list
> > pLog-svn at devel.plogworld.net
> > http://devel.plogworld.net/mailman/listinfo/plog-svn
> 
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.plogworld.net
> http://devel.plogworld.net/mailman/listinfo/plog-svn
>



More information about the pLog-svn mailing list