prestaForumConnectorPlugin - 1.0.1

Provide an easy way to connect an user management system to the forum solution of your choice.

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

prestaForumConnectorPlugin

The prestaForumConnectorPlugin aims to provide an easy way to connect an user management system to the forum solution of your choice.

Just choose the connectors of your choice for the user management system on one part and for the forum solution, follow the install instructions and you will be able to use the same user database and the same login process.

For example, this will allow you to connect sfGuard to phpBB3. Currently only sfGuard (Propel or Doctrine versions) and phpBB3 are supported. More will come.

Extending the plugin in order to create a connector to an other user management system can be done very quickly.

Installation

  • Install the plugin

    ./symfony plugin:install prestaForumConnectorPlugin
    ./symfony cc
  • Be sure to have the plugin enabled in /config/ProjectConfiguration.class.php

  • In /config/ProjectConfiguration.class.php in setup method add a connector to the clear:cache task event in order to clear forum cache when clearing project's cache

    // listen to symfony's clear:cache task's event
    $this->dispatcher->connect( 'task.cache.clear', array( 'prestaForumFactory', 'listenToClearCacheEvent' ) );
  • In /config/database.yml be sure to have a connection for the database that will contain forum's tables (can be the same database as for the project or a different one).

  • In /config/app.yml add the following options (and personalize them for your needs)

    all:
      prestaForumConnector:
        userConnector:
          class:  presta%%UsedUserConnectorName%%Connector  # the name of the connector to use (here we use sfGuardPropel as user management tools)
          # param:
            # for the required parameters see the help related to the connector that you're using 
     
        forumConnector:
          class:  presta%%UsedForumConnectorName%%Connector  # the name of the connector to use (here we use phpBB3 as forum platform tools)
          # param: 
            # for the required parameters see the help related to the connector that you're using
     
        forumWebDir:             <?php echo sfConfig::get('sf_web_dir');?>/forum/ # path to the forum directory 
     
        forumDatabaseId:        default  # the identifier of the database connection to use for the forum solution as defined in database.yml
  • If necessary add the following line to .htaccess file under the "RewriteEngine On" line

    # redirect to the index file if index.php in not present in url for the forum
    RewriteRule ^forum/$ forum/index.php [QSA,L]
  • See the help related to the connectors you use for continuing the installation.

  • Once the connector installation is finished launch the patchForum task, that will patch you're forum solution in order to link it with user management system.

    ./symfony prestaForumConnector:patchForum frontend --env=dev
  • Once this task is finished and has succeed, you can synchronize your user database.

    ./symfony prestaForumConnector:synchUser frontend all --env=dev

Forum Connectors

PHPBB3

Installation

  • In /config/app.yml define the following options for the forumConnector

    all:
      prestaForumConnector:
        forumConnector:
          class:  prestaPhpBB3Connector
  • In /web/index.php Replace

    sfContext::createInstance($configuration)->dispatch();

    With

    if(!defined('SYMFONY_FORUM'))
    {
        sfContext::createInstance($configuration)->dispatch();
    }
  • Copy all the forum files inside you're web directory (eg: /web/forum/). Use here the name that will appears in the URL (no .htacess redirection on directory name are actually possible).

  • Commit your project, in order to have an original version of you're forum code.

  • Add svn:ignore * (or similar command for your versionning tool) to "/cache/", "/files/", "/store/" and "/images/avatars/upload/" forum's sub-directories (and other cache directories of the eventually installed mod)

  • Access to the forum in you're navigator and follow the installation instruction of phpBB3.

  • Commit your project again, in order to have the freshly installed version of you're forum code.

  • Delete the phpBB3's "install" directory and commit again you're project.

Usage

Promote a user as super admin

In order to promote a user as a super admin, launch the following task once everything has be installed. The user id given here is the user ID of the user management tools

./symfony prestaForumConnector:promoteUser frontend %userIdToPromote% --env=dev

This taks will ask for user's password, and ask if the user should be considered as the forum's founder

User Connectors

sfGuard - Propel version

Installation

  • Be sure to have sfGuardPlugin installed and configured

  • In /config/app.yml define the following option for the userConnector:

    all:
      prestaForumConnector:
        userConnector:
          class:  prestaSfGuardPropelConnector
          param: 
            getUsernameMethod:  getUsername # define here the name of the sfGuardUser's method to use for retrieving the username
            getEmailMethod:     getEmail    # define here the name of the sfGuardUser's method to use for retrieving the email. Can be getUsername if the username is the email. If needed create yourself this method if the email is stored in another table like the profile table.
            getCultureMethod:   getCulture  # define here the name of the sfGuardUser's method to use for retrieving the user's preferred culture. If needed create yourself this method if the culture is stored in another table like the profile table or if it is a constant.
  • Change the parent class in myUser.class.php

    class myUser extends prestaForumConnectorSfGuardPropelSecurityUser
    {
    }    
  • Add the following methods to sfGuardUser.php in order to synchronize forum's users when sfGuard's users are updated

    /**
     * Override save method in order to update the forum's user
     * 
     * @see     sfGuardPlugin/lib/model/om/BasesfGuardUser#save($con)
     * @param   PropelPDO $con  optional connection parameter
     * @return  void
     */
    public function save(PropelPDO $con = null)
    {
        parent::save($con);
        prestaForumFactory::getForumConnectorInstance()->synchUser( $this->getId() );
    }
     
    /**
     * Override delete method in order to update the forum's user
     * 
     * @see     sfGuardPlugin/lib/model/plugin/PluginsfGuardUser#delete($con)
     * @param   PropelPDO $con  optional connection parameter
     * @return  void
     */
    public function delete(PropelPDO $con = null)
    {
        $userId = $this->getId();
        parent::delete($con);
        prestaForumFactory::getForumConnectorInstance()->deleteForumUser( $userId );
    }

sfGuard - Doctrine version

Installation

  • Be sure to have sfDoctrineGuardPlugin installed and configured

  • In /config/app.yml define the following option for the userConnector:

    all:
      prestaForumConnector:
        userConnector:
          class:  prestaSfGuardDoctrineConnector
          param: 
            getUsernameMethod:  getUsername # define here the name of the sfGuardUser's method to use for retrieving the username
            getEmailMethod:     getEmail    # define here the name of the sfGuardUser's method to use for retrieving the email (should be getEmailAddress for latest sfDoctrineGuardPlugin). Can be getUsername if the username is the email. If needed create yourself this method if the email is stored in another table like the profile table.
            getCultureMethod:   getCulture  # define here the name of the sfGuardUser's method to use for retrieving the user's preferred culture. If needed create yourself this method if the culture is stored in another table like the profile table or if it is a constant.

    Warning: If you use latest sfDoctrineGuardPlugin version with email field included, be sure to redefine the 'getEmailMethod' to 'getEmailAddress'.

  • Change the parent class in myUser.class.php

    class myUser extends prestaForumConnectorSfGuardDoctrineSecurityUser
    {
    }    
  • Add the following methods to sfGuardUser.php in order to synchronize forum's users when sfGuard's users are updated

    /**
     * Override save method in order to update the forum's user
     * 
     * @param   Doctrine_Connection $conn   optional connection parameter
     * @return  void
     */
    public function save(Doctrine_Connection $conn = null)
    {
        parent::save( $conn );
        prestaForumFactory::getForumConnectorInstance()->synchUser( $this->getId() );
    } 
     
    /**
     * Override delete method in order to update the forum's user
     * 
     * @param   Doctrine_Connection $conn   optional connection parameter
     * @return  void
     */
    public function delete(Doctrine_Connection $conn = null)
    {
        $userId = $this->getId();
        parent::delete( $conn );
        prestaForumFactory::getForumConnectorInstance()->deleteForumUser( $userId );
    }

Changelog

2009-12-29 | 1.0.1

  • Tested with latest sfDoctrineGuardPlugin version that include email field in sf_guard_user

2009-11-24 | 1.0.0

  • First public version
  • Tested successfully on production for one project
  • Tested in symfony 1.2 and 1.4

2009-11-09 | 0.0.1

  • First internal beta version