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

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