From cbc1aa2f4c5f7746c43b57ab2af197448d3c2bd1 Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Sat, 18 Mar 2017 23:52:01 +0300 Subject: [PATCH] Some fixes (ChangePasswordCustomSql Plugin) --- .../ChangePasswordCustomSqlDriver.php | 61 ++++++++----------- .../LICENSE | 0 .../README | 0 .../README.md | 4 +- .../VERSION | 0 .../index.php | 20 +++--- 6 files changed, 35 insertions(+), 50 deletions(-) rename plugins/{change-passwords-customsql/change-passwords-customsql => change-password-custom-sql}/ChangePasswordCustomSqlDriver.php (66%) rename plugins/{change-passwords-customsql/change-passwords-customsql => change-password-custom-sql}/LICENSE (100%) rename plugins/{change-passwords-customsql/change-passwords-customsql => change-password-custom-sql}/README (100%) rename plugins/{change-passwords-customsql => change-password-custom-sql}/README.md (70%) rename plugins/{change-passwords-customsql/change-passwords-customsql => change-password-custom-sql}/VERSION (100%) rename plugins/{change-passwords-customsql/change-passwords-customsql => change-password-custom-sql}/index.php (67%) diff --git a/plugins/change-passwords-customsql/change-passwords-customsql/ChangePasswordCustomSqlDriver.php b/plugins/change-password-custom-sql/ChangePasswordCustomSqlDriver.php similarity index 66% rename from plugins/change-passwords-customsql/change-passwords-customsql/ChangePasswordCustomSqlDriver.php rename to plugins/change-password-custom-sql/ChangePasswordCustomSqlDriver.php index 4a60dc7fe..c0dd532b4 100644 --- a/plugins/change-passwords-customsql/change-passwords-customsql/ChangePasswordCustomSqlDriver.php +++ b/plugins/change-password-custom-sql/ChangePasswordCustomSqlDriver.php @@ -117,7 +117,7 @@ class ChangePasswordCustomSqlDriver implements \RainLoop\Providers\ChangePasswor return $this; } - + /** * @param \RainLoop\Account $oAccount * @@ -125,8 +125,7 @@ class ChangePasswordCustomSqlDriver implements \RainLoop\Providers\ChangePasswor */ public function PasswordChangePossibility($oAccount) { - return $oAccount && $oAccount->Email() && - \RainLoop\Plugins\Helper::ValidateWildcardValues($oAccount->Email(), $this->sAllowedEmails); + return $oAccount && $oAccount->Email(); } /** @@ -157,45 +156,35 @@ class ChangePasswordCustomSqlDriver implements \RainLoop\Providers\ChangePasswor $conn = new PDO($dsn,$this->mUser,$this->mPass,$options); //prepare SQL varaibles - $sEmail = $oAccount->Email(); + $sEmail = $oAccount->Email(); $sEmailUser = \MailSo\Base\Utils::GetAccountNameFromEmail($sEmail); $sEmailDomain = \MailSo\Base\Utils::GetDomainFromEmail($sEmail); //simple check - $old = array(':email', ':oldpass', ':newpass', ':domain', ':username', ':table' ); - $new = array($sEmail, $sPrevPassword, $sNewPassword, $sEmailDomain, $sEmailUser, $this->mTable); - - $this->mSql = str_replace($old, $new, $this->mSql); - - $update = $conn->prepare($this->mSql); - $mSqlReturn = $update->execute(array()); -/* $mSqlReturn = $update->execute(array( - ':email' => $sEmail, - ':oldpass' => $sPrevPassword, - ':newpass' => $sNewPassword, - ':domain' => $sEmailDomain, - ':username' => $sEmailUser, - ':table' => $this->mTable - )); -*/ - if ($mSqlReturn == true) - { - $bResult = true; - if ($this->oLogger) - { - $this->oLogger->Write('Success! Password changed.'); - } - } - else - { - $bResult = false; - if ($this->oLogger) - { - $this->oLogger->Write('Something went wrong. Either current password is incorrect, or new password does not match criteria.'); - } - } + $old = array(':email', ':oldpass', ':newpass', ':domain', ':username', ':table' ); + $new = array($sEmail, $sPrevPassword, $sNewPassword, $sEmailDomain, $sEmailUser, $this->mTable); + $this->mSql = str_replace($old, $new, $this->mSql); + + $update = $conn->prepare($this->mSql); + $mSqlReturn = $update->execute(array()); + if ($mSqlReturn == true) + { + $bResult = true; + if ($this->oLogger) + { + $this->oLogger->Write('Success! Password changed.'); + } + } + else + { + $bResult = false; + if ($this->oLogger) + { + $this->oLogger->Write('Something went wrong. Either current password is incorrect, or new password does not match criteria.'); + } + } } catch (\Exception $oException) { diff --git a/plugins/change-passwords-customsql/change-passwords-customsql/LICENSE b/plugins/change-password-custom-sql/LICENSE similarity index 100% rename from plugins/change-passwords-customsql/change-passwords-customsql/LICENSE rename to plugins/change-password-custom-sql/LICENSE diff --git a/plugins/change-passwords-customsql/change-passwords-customsql/README b/plugins/change-password-custom-sql/README similarity index 100% rename from plugins/change-passwords-customsql/change-passwords-customsql/README rename to plugins/change-password-custom-sql/README diff --git a/plugins/change-passwords-customsql/README.md b/plugins/change-password-custom-sql/README.md similarity index 70% rename from plugins/change-passwords-customsql/README.md rename to plugins/change-password-custom-sql/README.md index 3f3d265bb..df03331b8 100644 --- a/plugins/change-passwords-customsql/README.md +++ b/plugins/change-password-custom-sql/README.md @@ -5,6 +5,6 @@ This plugin adds change password capability to Rainloop webmail by write your ow ##### Installation is simple: -1. Drop the change-password-customsql in the plugins directory (eg. _RainLoopDir_/data/data_xxxxx/_default/plugins/*) -2. In rainloop admin panel go to Plugins, and activate change-password-customsql. +1. Drop the change-password-custom-sql in the plugins directory (eg. _RainLoopDir_/data/data_xxxxx/_default/plugins/*) +2. In rainloop admin panel go to Plugins, and activate change-password-custom-sql. 3. Enter mysql details on the plugin config screen. diff --git a/plugins/change-passwords-customsql/change-passwords-customsql/VERSION b/plugins/change-password-custom-sql/VERSION similarity index 100% rename from plugins/change-passwords-customsql/change-passwords-customsql/VERSION rename to plugins/change-password-custom-sql/VERSION diff --git a/plugins/change-passwords-customsql/change-passwords-customsql/index.php b/plugins/change-password-custom-sql/index.php similarity index 67% rename from plugins/change-passwords-customsql/change-passwords-customsql/index.php rename to plugins/change-password-custom-sql/index.php index 8a04177f5..ad7f7e222 100644 --- a/plugins/change-passwords-customsql/change-passwords-customsql/index.php +++ b/plugins/change-password-custom-sql/index.php @@ -16,21 +16,17 @@ class ChangePasswordCustomSqlPlugin extends \RainLoop\Plugins\AbstractPlugin switch ($sName) { case 'change-password': - include_once __DIR__.'/ChangePasswordCustomSqlDriver.php'; - $oProvider = new ChangePasswordCustomSqlDriver(); - $oProvider - ->SetLogger($this->Manager()->Actions()->Logger()) - ->SetmHost($this->Config()->Get('plugin', 'mHost', '')) - ->SetmUser($this->Config()->Get('plugin', 'mUser', '')) - ->SetmPass($this->Config()->Get('plugin', 'mPass', '')) - ->SetmDatabase($this->Config()->Get('plugin', 'mDatabase', '')) - ->SetmTable($this->Config()->Get('plugin', 'mTable', '')) - ->SetmSql($this->Config()->Get('plugin', 'mSql', '')) + ->SetLogger($this->Manager()->Actions()->Logger()) + ->SetmHost($this->Config()->Get('plugin', 'mHost', '')) + ->SetmUser($this->Config()->Get('plugin', 'mUser', '')) + ->SetmPass($this->Config()->Get('plugin', 'mPass', '')) + ->SetmDatabase($this->Config()->Get('plugin', 'mDatabase', '')) + ->SetmTable($this->Config()->Get('plugin', 'mTable', '')) + ->SetmSql($this->Config()->Get('plugin', 'mSql', '')) ; - break; } } @@ -50,7 +46,7 @@ class ChangePasswordCustomSqlPlugin extends \RainLoop\Plugins\AbstractPlugin \RainLoop\Plugins\Property::NewInstance('mTable')->SetLabel('MySQL Table'), \RainLoop\Plugins\Property::NewInstance('mSql')->SetLabel('SQL statement') ->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT) - ->SetDescription('SQL statement (allowed wildcards :table, :email, :oldpass, :newpass, :domain, :username).When using MD5 OR SHA1 at tables, write it directly here as SQL functions. Fro non-SQL encryptions use another plugin or wait for new version.') + ->SetDescription('SQL statement (allowed wildcards :table, :email, :oldpass, :newpass, :domain, :username). When using MD5 OR SHA1 at tables, write it directly here as SQL functions. Fro non-SQL encryptions use another plugin or wait for new version.') ->SetDefaultValue('UPDATE :table SET password = md5(:newpass) WHERE domain = :domain AND username = :username and oldpass = md5(:oldpass)') ); }