Modified the postfixadmin-change-password plugin to give users these additional options for MySQL:

* Specify the table name
* Specify the column name for user names
* Specify the column name for the passwords
This commit is contained in:
Zaffke 2015-08-13 15:44:03 -05:00
parent 91f3c05d5e
commit ef5231decd
3 changed files with 60 additions and 2 deletions

3
.gitignore vendored
View file

@ -15,4 +15,5 @@
/build/local
/build/dist
/build/tmp
/data
/data
.DS_Store

View file

@ -17,6 +17,21 @@ class ChangePasswordPostfixAdminDriver implements \RainLoop\Providers\ChangePass
*/
private $sDatabase = 'postfixadmin';
/**
* @var string
*/
private $sTable = 'mailbox';
/**
* @var string
*/
private $sUsercol = 'usercol';
/**
* @var string
*/
private $sPasscol = 'passcol';
/**
* @var string
*/
@ -75,6 +90,39 @@ class ChangePasswordPostfixAdminDriver implements \RainLoop\Providers\ChangePass
return $this;
}
/**
* @param string $sTable
*
* @return \ChangePasswordPostfixAdminDriver
*/
public function SetTable($sTable)
{
$this->sTable = $sTable;
return $this;
}
/**
* @param string $sUsercol
*
* @return \ChangePasswordPostfixAdminDriver
*/
public function SetUserColumn($sUsercol)
{
$this->sUsercol = $sUsercol;
return $this;
}
/**
* @param string $sPasscol
*
* @return \ChangePasswordPostfixAdminDriver
*/
public function SetPasswordColumn($sPasscol)
{
$this->sPasscol = $sPasscol;
return $this;
}
/**
* @param string $sUser
*
@ -173,7 +221,7 @@ class ChangePasswordPostfixAdminDriver implements \RainLoop\Providers\ChangePass
$sUpdatePassword = $this->cryptPassword($sNewPassword, $oPdo);
if (0 < \strlen($sUpdatePassword))
{
$oStmt = $oPdo->prepare('UPDATE mailbox SET password = ? WHERE username = ?');
$oStmt = $oPdo->prepare("UPDATE $this->sTable SET $this->sPasscol = ? WHERE $this->sUsercol = ?");
$bResult = (bool) $oStmt->execute(array($sUpdatePassword, $oAccount->Email()));
}
else

9
plugins/postfixadmin-change-password/index.php Normal file → Executable file
View file

@ -44,6 +44,9 @@ class PostfixAdminChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
->SetHost($this->Config()->Get('plugin', 'host', ''))
->SetPort((int) $this->Config()->Get('plugin', 'port', 3306))
->SetDatabase($this->Config()->Get('plugin', 'database', ''))
->SetTable($this->Config()->Get('plugin', 'table', ''))
->SetUserColumn($this->Config()->Get('plugin', 'usercol', ''))
->SetPasswordColumn($this->Config()->Get('plugin', 'passcol', ''))
->SetUser($this->Config()->Get('plugin', 'user', ''))
->SetPassword($this->Config()->Get('plugin', 'password', ''))
->SetEncrypt($this->Config()->Get('plugin', 'encrypt', ''))
@ -68,6 +71,12 @@ class PostfixAdminChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
->SetDefaultValue(3306),
\RainLoop\Plugins\Property::NewInstance('database')->SetLabel('MySQL Database')
->SetDefaultValue('postfixadmin'),
\RainLoop\Plugins\Property::NewInstance('table')->SetLabel('MySQL table')
->SetDefaultValue('mailbox'),
\RainLoop\Plugins\Property::NewInstance('usercol')->SetLabel('MySQL username column')
->SetDefaultValue('username'),
\RainLoop\Plugins\Property::NewInstance('passcol')->SetLabel('MySQL password column')
->SetDefaultValue('password'),
\RainLoop\Plugins\Property::NewInstance('user')->SetLabel('MySQL User')
->SetDefaultValue('postfixadmin'),
\RainLoop\Plugins\Property::NewInstance('password')->SetLabel('MySQL Password')