PHPMaker generates the login page by optimizing the powerful ValidateUser function. Unfortunately, when you are using the “Activated” field in your users table in order to signify whether a user's Activated status is “Yes” (enabled = 1 = "Y") or “No” (disabled = 0 = "N"), and when the user status disabled so that the user cannot logged in (this is fine), the message that being displayed does not represent that real condition. The message is: “Incorrect user ID or password”. This is a stupid message I think!
The following modifications will overcome the problem above. It will display the related message that corresponding to the condition where the user Activated status is currently disabled. So, that stupid message above would be replaced with something more accurate like this: “This user is currently being deactivated now”. We will customize PHPMaker template files for this purpose; not the generated web pages, so we can re-use this template for the other projects.
Warning and Important: In order to make this functionality running properly, then make sure you have done the following steps:
- Define the value for Activated field value from: Security -> Advanced -> User Login Options -> User Table Fields.
- Still from the Advanced Security dialog window above, give a checked mark at the Requires activation item under the User Registration Page section.
Updated on May 30, 2012: This customization has been implemented in PHPMaker version 9.0.2, it matches to each other, and as a result, it works properly.
Updated on July 21, 2012: This customization has been implemented in PHPMaker version 9.0.3, it matches to each other, and as a result, it works properly.
Updated on September 4, 2012: This customization has been implemented in PHPMaker version 9.0.4, it matches to each other, and as a result, it works properly.
Updated on November 28, 2012: This customization has been implemented in PHPMaker version 9.1.0, it matches to each other, and as a result, it works properly.
Updated on February 9, 2013: This customization has been implemented in PHPMaker version 9.2.0, it matches to each other, and as a result, it works properly.
[hidepost]
-
Open your \Script\ewcfg.php file, and find this code:
define("EW_USER_ACTIVATE_FILTER", "<!--##=ew_Quote(sFilter)##-->", TRUE);before that line, please insert the following code:
// Begin of modification This User is Currently Being Deactivated Now, by Masino Sinaga, May 5, 2012 define("MS_USER_ACTIVATE_FIELD", "<!--##=ew_Quote(PROJ.SecRegisterActivateFld)##-->", TRUE); // End of modification This User is Currently Being Deactivated Now, by Masino Sinaga, May 5, 2012 -
Open your \Script\phpfn.php file, and find this code:
// Validate user
before that line of that code, please insert the following code:
// Begin of modification This User is Currently Being Deactivated Now, by Masino Sinaga, May 5, 2012 function IsDeactivated($usr) { global $conn, $Language; <!--## if (bUserTable) { ##--> global $<!--##=sSecTblVar##-->; <!--## } ##--> <!--## if (bUserProfile) { ##--> global $UserProfile; <!--## } ##--> $IsDeactivated = FALSE; $sFilter = str_replace("%u", ew_AdjustSql($usr), EW_USER_NAME_FILTER); <!--## if (PROJ.SecRegisterActivate && ew_IsNotEmpty(PROJ.SecRegisterActivateFld)) { FIELD = SECTABLE.Fields(PROJ.SecRegisterActivateFld); sFld = ew_FieldSqlName(FIELD); sFldQuoteS = FIELD.FldQuoteS; sFldQuoteE = FIELD.FldQuoteE; sFldValue = ActivateFieldValue(FIELD); sFilter = "(" + sFld + " <> " + sFldQuoteS + sFldValue + sFldQuoteE + ")"; } else { sFilter = ""; } ##--> $sFilter .= " AND <!--##=ew_Quote(sFilter)##--> "; $sSql = $<!--##=sSecTblVar##-->->GetSQL($sFilter, ""); if ($rs = $conn->Execute($sSql)) { if ($rs->RecordCount()>0) { $IsDeactivated = TRUE; } else { $IsDeactivated = FALSE; } $rs->Close(); } if (!$IsDeactivated) $_SESSION[EW_SESSION_STATUS] = ""; // Clear login status return $IsDeactivated; } // End of modification This User is Currently Being Deactivated Now, by Masino Sinaga, May 5, 2012 -
Open your \Script\login.php file, and find this code:
if ($bValidate) { $bValidPwd = $Security->ValidateUser($this->Username, $sPassword, FALSE); // Manual login if (!$bValidPwd) { <!--## if (bCheckPasswordExpiry) { ##--> // Password expired, force change password if (IsPasswordExpired()) { $this->setFailureMessage($Language->Phrase("PasswordExpired")); $this->Page_Terminate("<!--##=sFnChangePwd##-->"); } <!--## } ##-->after the last line of that code, please insert the following code:
// Begin of modification This User is Currently Being Deactivated Now, by Masino Sinaga, May 5, 2012 <!--## if (PROJ.SecRegisterActivate && ew_IsNotEmpty(PROJ.SecRegisterActivateFld)) { ##--> $IsUserDeactivated = $Security->IsDeactivated($this->Username); if ($IsUserDeactivated) { $this->setFailureMessage($Language->Phrase("UserDeactivated")); // If user still deactivated } <!--## } ##--> // End of modification This User is Currently Being Deactivated Now, by Masino Sinaga, May 5, 2012 -
Open your C:\Program Files\PHPMaker 9\languages\english.xml file, and find this code:
</global>
before that line, please insert the following code:
<phrase id="UserDeactivated" value="This user is currently being deactivated now."/>
do the same way to another language .xml file you have, for example, I am also using Indonesian, so I open my C:\Program Files\PHPMaker 9\languages\indonesian.xml file, and find this code:
</global>
and before that line, I insert the following code:
<phrase id="UserDeactivated" value="Status akun Pengguna ini sedang tidak aktif."/>
- Finally, re-generate your script files using PHPMaker as always.
[/hidepost]
Leave a Reply
You must be logged in to post a comment.