[pLog-svn] r3950 - plog/trunk/class/dao/userdata
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Sat Sep 9 11:53:15 GMT 2006
Author: oscar
Date: 2006-09-09 11:53:15 +0000 (Sat, 09 Sep 2006)
New Revision: 3950
Modified:
plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php
plog/trunk/class/dao/userdata/simplepostnukeuserdataprovider.class.php
Log:
same in the trunk/1.2
Modified: plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php 2006-09-09 11:51:43 UTC (rev 3949)
+++ plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php 2006-09-09 11:53:15 UTC (rev 3950)
@@ -21,9 +21,6 @@
{
$this->BaseUserDataProvider( $providerConfig );
- // disable all caching for userdata
- CacheManager::disableCache( CACHE_USERINFO );
-
// initialize the database connection based on our parameters
$config = $this->getProviderConfiguration();
$user = $config->getValue( "user" );
Modified: plog/trunk/class/dao/userdata/simplepostnukeuserdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/simplepostnukeuserdataprovider.class.php 2006-09-09 11:51:43 UTC (rev 3949)
+++ plog/trunk/class/dao/userdata/simplepostnukeuserdataprovider.class.php 2006-09-09 11:53:15 UTC (rev 3950)
@@ -1,77 +1,74 @@
-<?php
-
- include_once( PLOG_CLASS_PATH."class/dao/userdata/baseuserdataprovider.class.php" );
- include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/dao/userdata/baseuserdataprovider.class.php" );
+ include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/userinfo.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/userstatus.class.php" );
-
- /**
- * Model representing the users in our application. Provides the methods such as
- * authentication and querying for users.
- *
- * \ingroup User_Data_Providers
- */
- class SimplePostNukeUserDataProvider extends BaseUserDataProvider
- {
- var $_dbc;
- var $_postnukedbprefix;
- var $_blogtitle_postfix;
- /**
- * Initializes the model
- */
- function SimplePostNukeUserDataProvider( $providerConfig )
- {
- $this->BaseUserDataProvider( $providerConfig );
- $this->table = $this->getPrefix()."users";
-
- // disable all caching for userdata
- CacheManager::disableCache( CACHE_USERINFO );
-
- // 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->_postnukedbprefix = $config->getValue( "prefix" );
- $this->_dbc =& Db::getNewDb( $host, $user, $pass, $db );
-
- $this->_blogtitle_postfix = $config->getValue( "blogtitle_postfix" );
- }
-
- /**
- * Returns true if the user is in the database and the username
- * and password match
- *
- * First, we check if the user exists as a standard lt user. If not, we check if he
- * has an PostNuke account, validate username/password and open a lt account for him.
- * This is the only time we interact with the postnuke db. Password changes, user removal and
- * and everything else possible within LifeType does not affect the PostNuke database in any way.
- *
- * @param username Username of the user who we'd like to authenticate
- * @param pass Password of the user
- * @return true if user and password correct or false otherwise.
- */
- function authenticateUser( $username, $pass )
- {
- // Check if we find the user in the LifeType DB
+ include_once( PLOG_CLASS_PATH."class/dao/userstatus.class.php" );
+
+ /**
+ * Model representing the users in our application. Provides the methods such as
+ * authentication and querying for users.
+ *
+ * \ingroup User_Data_Providers
+ */
+ class SimplePostNukeUserDataProvider extends BaseUserDataProvider
+ {
+ var $_dbc;
+ var $_postnukedbprefix;
+ var $_blogtitle_postfix;
+ /**
+ * Initializes the model
+ */
+ function SimplePostNukeUserDataProvider( $providerConfig )
+ {
+ $this->BaseUserDataProvider( $providerConfig );
+ $this->table = $this->getPrefix()."users";
+
+ // 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->_postnukedbprefix = $config->getValue( "prefix" );
+ $this->_dbc =& Db::getNewDb( $host, $user, $pass, $db );
+
+ $this->_blogtitle_postfix = $config->getValue( "blogtitle_postfix" );
+ }
+
+ /**
+ * Returns true if the user is in the database and the username
+ * and password match
+ *
+ * First, we check if the user exists as a standard lt user. If not, we check if he
+ * has an PostNuke account, validate username/password and open a lt account for him.
+ * This is the only time we interact with the postnuke db. Password changes, user removal and
+ * and everything else possible within LifeType does not affect the PostNuke database in any way.
+ *
+ * @param username Username of the user who we'd like to authenticate
+ * @param pass Password of the user
+ * @return true if user and password correct or false otherwise.
+ */
+ function authenticateUser( $username, $pass )
+ {
+ // Check if we find the user in the LifeType DB
$user = $this->getUserInfoFromUsername( $username );
- if( $user ) {
+ if( $user ) {
return( $user->getPassword() == md5($pass));
}
-
- // Check if the user is available in the PostNuke database...
+
+ // Check if the user is available in the PostNuke database...
else {
- $query = "SELECT * FROM ".$this->_postnukedbprefix."users WHERE pn_uname = '".Db::qstr( $username )."' AND pn_pass = '".md5( $pass )."'";
- $result = $this->_dbc->Execute( $query );
-
- if( (!$result) || ($result == false) ) {
- return false;
- }
- // let's add the user to the lt userbase
- elseif ( $result->RecordCount() == 1 ) {
+ $query = "SELECT * FROM ".$this->_postnukedbprefix."users WHERE pn_uname = '".Db::qstr( $username )."' AND pn_pass = '".md5( $pass )."'";
+ $result = $this->_dbc->Execute( $query );
+
+ if( (!$result) || ($result == false) ) {
+ return false;
+ }
+ // let's add the user to the lt userbase
+ elseif ( $result->RecordCount() == 1 ) {
$result->Close();
- $pnUserdata = $this->getUserInfoFromPostNukeUser( $username );
+ $pnUserdata = $this->getUserInfoFromPostNukeUser( $username );
$user = new UserInfo( $pnUserdata["pn_uname"],
$pnUserdata["pn_pass"],
@@ -79,103 +76,103 @@
"",
$pnUserdata["pn_name"],
0,
- serialize(Array())
- );
+ serialize(Array())
+ );
$user->setStatus( USER_STATUS_ACTIVE );
-
- $newUserId = $this->addUser( $user );
+
+ $newUserId = $this->addUser( $user );
if( !$newUserId ) {
- return false;
- }
-
- //add Blog
- $this->_PostNukeAddBlog($username, $newUserId);
-
- return true;
+ return false;
+ }
+
+ //add Blog
+ $this->_PostNukeAddBlog($username, $newUserId);
+
+ return true;
}
else{
// TODO: shouldn't ever happen?
$result->Close();
}
-
- // return false if user authentication failed on both databases
+
+ // return false if user authentication failed on both databases
return false;
- }
- } // authenticateUser
-
- /**
- *
- * @param username Username of the user who we'd like to get all info from the PN DB
- * @return Returns an array with all userinformation
- */
- function getUserInfoFromPostNukeUser( $username )
- {
- $query = "SELECT * FROM ".$this->_postnukedbprefix."users WHERE pn_uname = '".Db::qstr( $username )."'";
-
- $result = $this->_dbc->Execute( $query );
-
- if( !$result )
- return false;
-
- $row = $result->FetchRow();
+ }
+ } // authenticateUser
+
+ /**
+ *
+ * @param username Username of the user who we'd like to get all info from the PN DB
+ * @return Returns an array with all userinformation
+ */
+ function getUserInfoFromPostNukeUser( $username )
+ {
+ $query = "SELECT * FROM ".$this->_postnukedbprefix."users WHERE pn_uname = '".Db::qstr( $username )."'";
+
+ $result = $this->_dbc->Execute( $query );
+
+ if( !$result )
+ return false;
+
+ $row = $result->FetchRow();
$result->Close();
- return( $row );
- }
-
- /**
- *
- * @param username Username for having a meaningful Blogname
- * @param userid UserID to link the blog to the new created user
- * @return Returns true if blog is created successfully and false otherwise
- */
- function _PostNukeAddBlog( &$username, &$userid )
- {
- include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
-
- $config =& Config::getConfig();
- $locale =& Locales::getLocale( $config->getValue( "default_locale" ));
-
- // create a new blog
- $blogs = new Blogs();
- $blog = new BlogInfo( $username.$this->_blogtitle_postfix, // name of the new blog
- $userid, // id of the owner
- "", // no about
- Array()); // no properties either
- $newBlogId = $blogs->addBlog( $blog );
-
- // add a default category and a default post
- $articleCategories = new ArticleCategories();
- $articleCategory = new ArticleCategory( $locale->tr( "register_default_category" ), "", $newBlogId, true );
- $catId = $articleCategories->addArticleCategory( $articleCategory );
-
- $articleTopic = $locale->tr( "register_default_article_topic" );
- $articleText = $locale->tr( "register_default_article_text" );
- $article = new Article( $articleTopic,
- $articleText,
- Array( $catId ),
- $userid,
- $newBlogId,
- POST_STATUS_PUBLISHED,
- 0,
- Array(),
- "welcome" ); // slug
- $t = new Timestamp();
- $article->setDateObject( $t );
- $articles = new Articles();
- $articles->addArticle( $article );
- }
-
- //------------
- // NOTE: Everything below is copy&paste from LifeTypeUserdataprovider.class.php
- //------------
-
+ return( $row );
+ }
+
/**
+ *
+ * @param username Username for having a meaningful Blogname
+ * @param userid UserID to link the blog to the new created user
+ * @return Returns true if blog is created successfully and false otherwise
+ */
+ function _PostNukeAddBlog( &$username, &$userid )
+ {
+ include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
+
+ $config =& Config::getConfig();
+ $locale =& Locales::getLocale( $config->getValue( "default_locale" ));
+
+ // create a new blog
+ $blogs = new Blogs();
+ $blog = new BlogInfo( $username.$this->_blogtitle_postfix, // name of the new blog
+ $userid, // id of the owner
+ "", // no about
+ Array()); // no properties either
+ $newBlogId = $blogs->addBlog( $blog );
+
+ // add a default category and a default post
+ $articleCategories = new ArticleCategories();
+ $articleCategory = new ArticleCategory( $locale->tr( "register_default_category" ), "", $newBlogId, true );
+ $catId = $articleCategories->addArticleCategory( $articleCategory );
+
+ $articleTopic = $locale->tr( "register_default_article_topic" );
+ $articleText = $locale->tr( "register_default_article_text" );
+ $article = new Article( $articleTopic,
+ $articleText,
+ Array( $catId ),
+ $userid,
+ $newBlogId,
+ POST_STATUS_PUBLISHED,
+ 0,
+ Array(),
+ "welcome" ); // slug
+ $t = new Timestamp();
+ $article->setDateObject( $t );
+ $articles = new Articles();
+ $articles->addArticle( $article );
+ }
+
+ //------------
+ // NOTE: Everything below is copy&paste from LifeTypeUserdataprovider.class.php
+ //------------
+
+ /**
* Retrieves the user information but given only a username
*
* @param username The username of the user
@@ -184,8 +181,8 @@
function getUserInfoFromUsername( $username )
{
return( $this->get( "user", $username, CACHE_USERIDBYNAME, Array( CACHE_USERINFO => "getId" )));
- }
-
+ }
+
/**
* Retrieves the user infromation but given only a userid
@@ -526,5 +523,5 @@
return( "(user LIKE '%".$searchTerms."%' OR full_name LIKE '%".$searchTerms."%')");
}
- }
-?>
+ }
+?>
More information about the pLog-svn
mailing list