diff --git a/ext/drupal/7.x/pydio/class.DrupalPydio.php b/ext/drupal/7.x/pydio/class.DrupalPydio.php index 84f4c969f0..641346d537 100644 --- a/ext/drupal/7.x/pydio/class.DrupalPydio.php +++ b/ext/drupal/7.x/pydio/class.DrupalPydio.php @@ -22,7 +22,7 @@ public function __construct( $params ) * @return boolean True on success * @since 1.5 */ - public function onLoginUser($name, $password) + public function onLoginUser($name, $password, $roles) { // Initialize variables $success = false; @@ -33,7 +33,7 @@ public function onLoginUser($name, $password) $AJXP_GLUE_GLOBALS["secret"] = $this->secret; $AJXP_GLUE_GLOBALS["autoCreate"] = $this->autoCreate; $AJXP_GLUE_GLOBALS["plugInAction"] = "login"; - $AJXP_GLUE_GLOBALS["login"] = array("name"=>$name, "password"=>""); + $AJXP_GLUE_GLOBALS["login"] = array("name"=>$name, "password"=>"", "roles"=>$roles); include($this->glueCode); return true; @@ -77,7 +77,7 @@ public function onLogout($user) * @param boolean true if user was succesfully stored in the database * @param string message */ - public function onAfterStoreUser($name, $password, $isAdmin, $isnew) + public function onAfterStoreUser($name, $password, $roles, $isnew) { // convert the user parameters passed to the event // to a format the external application @@ -87,10 +87,12 @@ public function onAfterStoreUser($name, $password, $isAdmin, $isnew) //global $plugInAction, $result, $secret, $user; $AJXP_GLUE_GLOBALS["secret"] = $this->secret; + $isAdmin = in_array('administrator', $roles); $AJXP_GLUE_GLOBALS["user"] = array(); $AJXP_GLUE_GLOBALS["user"]['name'] = $name; $AJXP_GLUE_GLOBALS["user"]['password'] = $password; $AJXP_GLUE_GLOBALS["user"]['right'] = ($isAdmin?'admin':''); + $AJXP_GLUE_GLOBALS["user"]['roles'] = $roles; $AJXP_GLUE_GLOBALS["plugInAction"] = ($isnew?"addUser":"updateUser"); include($this->glueCode); diff --git a/ext/drupal/7.x/pydio/pydio.module b/ext/drupal/7.x/pydio/pydio.module index 3ee0eb253a..376ea7d8df 100644 --- a/ext/drupal/7.x/pydio/pydio.module +++ b/ext/drupal/7.x/pydio/pydio.module @@ -41,6 +41,9 @@ function pydio_user_delete($account){ } +function pydio_map_roles($role) { + return user_role_load($role)->name; +} function pydio_user_func($op, &$edit, $account, $category = null){ require_once("class.DrupalPydio.php"); @@ -50,10 +53,13 @@ function pydio_user_func($op, &$edit, $account, $category = null){ "ajxp_auto_create" => (variable_get('pydio_auto_create', "0") == "0"?true:false) ); $drupHandler = new DrupalPydio($params); + + $roles = array_map("pydio_map_roles", array_keys($account->roles)); + if(!$drupHandler->glueCodeFound) return ; switch ($op) { case "login": - $drupHandler->onLoginUser($edit["input"]["name"], $edit["input"]["pass"]); + $drupHandler->onLoginUser($edit["input"]["name"], $edit["input"]["pass"], $roles); break; case "logout": @@ -61,13 +67,11 @@ function pydio_user_func($op, &$edit, $account, $category = null){ break; case "insert": - $admin = in_array('3', array_values($account->roles)) || in_array('administrator', array_values($account->roles)); - $result = $drupHandler->onAfterStoreUser($edit['name'], $edit['pass'], $admin, true); + $result = $drupHandler->onAfterStoreUser($account->name, $account->pass, $roles, true); break; case "update": - $admin = in_array('3', array_values($account->roles)) || in_array('administrator', array_values($account->roles)); - $result = $drupHandler->onAfterStoreUser($account->name, $account->pass, $admin, false); + $result = $drupHandler->onAfterStoreUser($account->name, $account->pass, $roles, false); break; case "delete": @@ -127,4 +131,4 @@ function pydio_admin() { ); return system_settings_form($form); -} \ No newline at end of file +} diff --git a/ext/drupal/Drupal.Pydio-HOWTO.html b/ext/drupal/Drupal.Pydio-HOWTO.html index 760a9800f8..f9e79b90a4 100644 --- a/ext/drupal/Drupal.Pydio-HOWTO.html +++ b/ext/drupal/Drupal.Pydio-HOWTO.html @@ -15,7 +15,7 @@

2/ Pydio configuration

done, with the standard pydio authentication mechanism, be sure that at least an "admin" user is created.

If you intend to allow guest browsing, set the "Allow Guest Browsing" option to -true in the Pydio Settings > Global Options > Core Options > Authentication, and if you are logged, log out. This should create the +true in the Pydio Settings > Application Options > Application Core > Authentication, and if you are logged, log out. This should create the "guest" user. As admin, log back to the interface and create a "Guest" Repository. Go to the users section and grant access (read only may be better) to this repository to the @@ -27,8 +27,8 @@

2/ Pydio configuration

users. Considering the acces rights, the trick here would be to set a "Default Right" value to "rw", so that you don't have to manually edit the users rights each time you add them.

-

2.4 Auth.remote configuration

Logged as admin, go to Settings > Global Options > Core Options > Authentication, and set the -Authentication "Main Instance" driver to be the "Remote Authentication" ( = auth.remote plugin) :

+

2.4 Auth.remote configuration

Logged as admin, go to Settings > Application Options > Application Core > Authentication, and set the +Authentication "Main Instance" driver to be the "Remote Authentication" ( = auth.remote plugin) :

Other options should be left to default values, otherwise put your mouse on the options label to get more info. For the secret key, warning, if you want to use a "$" sign in your key, you have to put a \ before.

Also make sure NOT to set a secondary instance, this plugin does not support multi-auth configuration yet.

@@ -39,8 +39,8 @@

3/ Drupal Configuration

"Pydio Bridge" module under the "Other" section. Enable the plugin.

3.2 Configure the module

Go to "Site -Configuration > Pydio Settings" (click on the module -"Help" for v7). There are three parameters to configure for +Configuration > Pydio Settings" or for Drupal 7 Click the "Pydio Settings" link +under the admin menu. There are three parameters to configure for this plugin : 

Save the module configuration.