From 2ceb39f99ed603a6c6c96fcf2cb68888af7f3f65 Mon Sep 17 00:00:00 2001 From: prasad <prasad@vtiger.com> Date: Thu, 18 Feb 2016 14:09:42 +0530 Subject: [PATCH] Added cryptmode flag to portalinfo table. --- modules/Contacts/ContactsHandler.php | 8 ++++---- modules/Migration/schema/640_to_650.php | 13 ++++++------- schema/DatabaseSchema.xml | 1 + 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/Contacts/ContactsHandler.php b/modules/Contacts/ContactsHandler.php index 972f44a2a..54c876936 100644 --- a/modules/Contacts/ContactsHandler.php +++ b/modules/Contacts/ContactsHandler.php @@ -42,13 +42,13 @@ function Contacts_sendCustomerPortalLoginDetails($entityData){ $password = makeRandomPassword(); $md5_password = md5($password); if ($insert == true) { - $sql = "INSERT INTO vtiger_portalinfo(id,user_name,user_password,type,isactive) VALUES(?,?,?,?,?)"; - $params = array($entityId, $email, $md5_password, 'C', 1); + $sql = "INSERT INTO vtiger_portalinfo(id,user_name,user_password,cryptmode,type,isactive) VALUES(?,?,?,?,?)"; + $params = array($entityId, $email, $md5_password, 'MD5', 'C', 1); $adb->pquery($sql, $params); } if ($update == true && $portalChanged == true) { - $sql = "UPDATE vtiger_portalinfo SET user_password=? WHERE id=?"; - $params = array($md5_password, $entityId); + $sql = "UPDATE vtiger_portalinfo SET user_password=?, cryptmode=? WHERE id=?"; + $params = array($md5_password, 'MD5', $entityId); $adb->pquery($sql, $params); } if (($insert == true || ($update = true && $portalChanged == true)) && $entityData->get('emailoptout') == 0) { diff --git a/modules/Migration/schema/640_to_650.php b/modules/Migration/schema/640_to_650.php index 432024594..a62a89bc6 100644 --- a/modules/Migration/schema/640_to_650.php +++ b/modules/Migration/schema/640_to_650.php @@ -11,14 +11,13 @@ if(defined('VTIGER_UPGRADE')) { //Start add new currency - 'CFP Franc or Pacific Franc' -global $db; +global $adb; + +Vtiger_Utils::AddColumn('vtiger_portalinfo', 'cryptmode', 'varchar(20)'); //Updating existing users password to thier md5 hash +$updateQuery = "UPDATE vtiger_portalinfo SET user_password=MD5(user_password),cryptmode='MD5' WHERE cryptmode is null"; +$adb->pquery($updateQuery, array()); -$selectQuery = 'SELECT 1 FROM vtiger_portalinfo'; -$resultSet = $db->pquery($selectQuery, array()); -if ($db->num_rows($resultSet) > 0) { - $updateQuery = 'UPDATE vtiger_portalinfo SET user_password=MD5(user_password)'; - $db->pquery($updateQuery, array()); } -} \ No newline at end of file + diff --git a/schema/DatabaseSchema.xml b/schema/DatabaseSchema.xml index 9a45daf4c..08c0f29bf 100644 --- a/schema/DatabaseSchema.xml +++ b/schema/DatabaseSchema.xml @@ -587,6 +587,7 @@ <field name="user_name" type="C" size="50" /> <field name="user_password" type="C" size="30" /> <field name="type" type="C" size="5" /> + <field name="cryptmode" type="C" size="20" /> <field name="last_login_time" type="T" /> <field name="login_time" type="T" /> <field name="logout_time" type="T" /> -- GitLab