HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Tips/Tricks/Mods (http://www.howtoforge.com/forums/forumdisplay.php?f=19)
-   -   Roundcubemail 0.4.3 HOWTO for ISP 2.x (http://www.howtoforge.com/forums/showthread.php?t=49619)

necromncr 24th October 2010 12:09

Roundcubemail 0.4.3 HOWTO for ISP 2.x
 
*EDIT* what an embarasment - there is no Roundcube 0.4.3, just 0.4.2.

Hi,

Being stuck on 2.x myself and noticing Roundcube got really good lately I decided to upgrade / switch my webmail solution. While there I didn't find any good solutions for authentication with ISPConfig except for virtuser_file plugin so I decided to do some work to make a plugin for setting real user's name and email into Roundcube settings.

Result is very user-friendly experience as there is no "new user identity" settings to be done.

Being in serious lack of time here I ask of you, does any of you need a howto / this plugin to be installed so I know to take the time and share it with you?

Let me know :-)

falko 25th October 2010 14:23

Quote:

Originally Posted by necromncr (Post 242627)
Being in serious lack of time here I ask of you, does any of you need a howto / this plugin to be installed so I know to take the time and share it with you?

Let me know :-)

That would be great! :)

BTW, do you have a download link?

walkero 26th October 2010 12:21

That would be great

ressel 26th October 2010 17:00

Sounds nice, looking forward to it already.


Quote:

Originally Posted by necromncr (Post 242627)
*EDIT* what an embarasment - there is no Roundcube 0.4.3, just 0.4.2.

Hi,

Being stuck on 2.x myself and noticing Roundcube got really good lately I decided to upgrade / switch my webmail solution. While there I didn't find any good solutions for authentication with ISPConfig except for virtuser_file plugin so I decided to do some work to make a plugin for setting real user's name and email into Roundcube settings.

Result is very user-friendly experience as there is no "new user identity" settings to be done.

Being in serious lack of time here I ask of you, does any of you need a howto / this plugin to be installed so I know to take the time and share it with you?

Let me know :-)


necromncr 29th October 2010 20:11

Due to extreme interest (3 people ;-) awesome!) here is my ISPConfig 2.x for Roundcube 0.4.2 integration plugin.

1.) Make a MySQL user to access ISPConfig database. I myself prefer to give just the right amount of privileges - in my case I used username "roundcube":
Code:

GRANT SELECT (web_domain, doc_id, doctype_id) ON `db_ispconfig`.`isp_isp_web` TO 'roundcube'@'localhost'
GRANT SELECT (user_username, doc_id, user_emailalias, user_name) ON `db_ispconfig`.`isp_isp_user` TO 'roundcube'@'localhost'
GRANT SELECT (child_doctype_id, child_doc_id, parent_doctype_id, parent_doc_id) ON `db_ispconfig`.`isp_dep` TO 'roundcube'@'localhost'

Don't forget to set a password!

2.) First make a folder in your Roundcube installation called "ispconfig_addons".

3.) Make two files, "config.inc.php" and "ispconfig_addons.php".

4.) Fill config.inc.php with this code:
Code:

<?php                                                                                                                                                                                                         
$rcmail_config['isp_db_name'] = 'db_ispconfig'; // your ISPConfig database
$rcmail_config['isp_db_user'] = 'roundcube'; // username for ISPConfig database from step #1
$rcmail_config['isp_db_pass'] = '<password>'; // extremly long, complicated and just impossible to guess password from step #1
?>

5.) Fill ispconfig_addons.php with this code:
Code:

<?php

/**                                                                                                                                                                                                           
 * ISPConfig v2.x integration for Roundcube 0.4.2 plugin                                                                                                                                                     
 *                                                                                                                                                                                                           
 * Adds ability to authenticate against ISPConfig 2.x user database.                                                                                                                                         
 *                                                                                                                                                                                                           
 * To use you must have config.inc.php file following settings:                                                                                                                                               
 * isp_db_name - ISPConfig database name                                                                                                                                                                     
 * isp_db_user - user with access to only selected fields in selected tables                                                                                                                                 
 * isp_db_pass - password for that user                                                                                                                                                                       
 *                                                                                                                                                                                                           
 * Code is tested however there is no waranty for it. Use at your own risk. Feedback is welcome!                                                                                                             
 *                                                                                                                                                                                                           
 * @version 0.1                                                                                                                                                                                               
 * @author Janez Dolinar s.p., <info@tuksi.net>                                                                                                                                                               
 */ 
class ispconfig_addons extends rcube_plugin

  function init()
  {
    $this->add_hook('user_create', array($this, 'usercreate'));
    $this->add_hook('login_after', array($this, 'loginafter'));

    $this->load_config();
  }
                                                                                                                                                                                                             
  function loginafter($query) {                                                                                                                                                                               
    $rcmail = rcmail::get_instance();                                                                                                                                                                         
                                                                                                                                                                                                             
    if (isset($_SESSION['userFullName'])) {                                                                                                                                                                   
      $sql = 'UPDATE identities SET name=?, email=? WHERE identity_id = ?';                                                                                                                                   
                                                                                                                                                                                                             
      $rcmail->db->query($sql,$_SESSION['userFullName'], $_SESSION['userEmail'], $rcmail->user->data['user_id']);                                                                                             
                                                                                                                                                                                                             
      unset($_SESSION['userFullName']);                                                                                                                                                                       
      unset($_SESSION['userEmail']);                                                                                                                                                                         
    }                                                                                                                                                                                                         
    return $query;
  }
 
 
  function usercreate($args)
  {
    $rcmail = rcmail::get_instance();
    if (($rcmail->config->get('isp_db_name')=='') || ($rcmail->config->get('isp_db_user')=='') || ($rcmail->config->get('isp_db_pass')=='')) {
      return $args;
    } else {
      $sql = "SELECT iiu.user_username, iiu.user_emailalias, iiu.user_name, iid.web_domain FROM isp_isp_user iiu, isp_dep id, isp_isp_web iid "
            ."WHERE iiu.user_username = '%s'  AND iiu.doc_id = id.child_doc_id  AND id.child_doctype_id = 1014  AND iid.doc_id = id.parent_doc_id";
           
      $mysql = new MySQLi('localhost', $rcmail->config->get('isp_db_user'), $rcmail->config->get('isp_db_pass'), $rcmail->config->get('isp_db_name'));
     
      if ($mysql->connect_error) return false;
      $result = $mysql->query(sprintf($sql,addslashes($args['user'])));

      if ($result) {
        $row = $result->fetch_object();
        $userEmail = explode("\n",str_replace("\r","",$row->user_emailalias));
        $args['alias'] = $userEmail[0].'@'.$row->web_domain;
        $_SESSION['userFullName'] = $row->user_name;
        $_SESSION['userEmail'] = $userEmail[0].'@'.$row->web_domain;
        $result->close();
      }
     
      $mysql->close();
    }
 
    return $args;
  }

}
?>

6.a) make sure it's web-server readable!

7.) Add the plugin to your Roundcube config file /config/main.inc.php :
Code:

// ----------------------------------                                                                                                                                                                         
// PLUGINS                                                                                                                                                                                                   
// ----------------------------------                                                                                                                                                                         
                                                                                                                                                                                                             
// List of active plugins (in plugins/ directory)                                                                                                                                                             
$rcmail_config['plugins'] = array('virtuser_file','ispconfig_addons');

Also don't forget to configure virtuser_file plugin. Add this to the end of config/main.inc.php file:

Code:

                                                                                                                                                                                                             
$rcmail_config['virtuser_file'] = '/etc/postfix/virtusertable';

This is valid for Ubuntu / Debian users. This is just a guess, find your location and modify this line accordingly.

Code uses MySQLi extension so you'll need that as well however I think it should be no problem changing it to MySQL extension.

That should be it! You / your clients can now login with any email set for their account and their password! Their names should already be set to ther ISPConfig full names and default email address.

Please note I made this after a long hard working day and was tired. There could be some room for improvement or even some flaws. I ask for your feedback, I'll be glad to fix the code. Oh, and no waranty :)

Enjoy!

necromncr 29th October 2010 20:29

Quote:

Originally Posted by falko (Post 242677)
That would be great! :)

BTW, do you have a download link?

Here you go: http://www.tuksi.net/datoteke/ispcon...n_v0.1.tar.bz2

necromncr 3rd November 2010 16:15

Now I'm worried - no replies!

Anyone else tried this? Did it work? Was it worth installing?

I need feedback people!

Re!

falko 4th November 2010 19:04

I'll test it soon and let you know. :)

madmucho 29th November 2010 13:22

test
 
Heloo.
I tested your addon on ISPCONFIG 2 with roundcubemail package from ispconfig.com webpage currently 3.1.
So i login using email address but have problem that new profile have created as name web2_pok2 with correct email, du u thing that can be corrected ? or if i can test that somehow?

i using ispconfig with mysql database and user for connection is same as in script config.inc.php.

necromncr 5th December 2010 15:55

Quote:

Originally Posted by madmucho (Post 245352)
Heloo.
So i login using email address but have problem that new profile have created as name web2_pok2 with correct email, du u thing that can be corrected ? or if i can test that somehow?

Did you use this on your existing profile or a new profile? This solution will work only for new profiles, old ones will still have their settings intact. You will be able to authenticate though.


All times are GMT +2. The time now is 13:34.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.