[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /*+*********************************************************************************** 3 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 *************************************************************************************/ 10 11 function Contacts_sendCustomerPortalLoginDetails($entityData){ 12 $adb = PearDatabase::getInstance(); 13 $moduleName = $entityData->getModuleName(); 14 $wsId = $entityData->getId(); 15 $parts = explode('x', $wsId); 16 $entityId = $parts[1]; 17 18 $email = $entityData->get('email'); 19 20 if ($entityData->get('portal') == 'on' || $entityData->get('portal') == '1') { 21 $sql = "SELECT id, user_name, user_password, isactive FROM vtiger_portalinfo WHERE id=?"; 22 $result = $adb->pquery($sql, array($entityId)); 23 $insert = false; 24 if($adb->num_rows($result) == 0){ 25 $insert = true; 26 }else{ 27 $dbusername = $adb->query_result($result,0,'user_name'); 28 $isactive = $adb->query_result($result,0,'isactive'); 29 if($email == $dbusername && $isactive == 1 && !$entityData->isNew()){ 30 $update = false; 31 } else if($entityData->get('portal') == 'on' || $entityData->get('portal') == '1'){ 32 $sql = "UPDATE vtiger_portalinfo SET user_name=?, isactive=1 WHERE id=?"; 33 $adb->pquery($sql, array($email, $entityId)); 34 $password = $adb->query_result($result,0,'user_password'); 35 $update = true; 36 } else { 37 $sql = "UPDATE vtiger_portalinfo SET user_name=?, isactive=? WHERE id=?"; 38 $adb->pquery($sql, array($email, 0, $entityId)); 39 $update = false; 40 } 41 } 42 if($insert == true){ 43 $password = makeRandomPassword(); 44 $sql = "INSERT INTO vtiger_portalinfo(id,user_name,user_password,type,isactive) VALUES(?,?,?,?,?)"; 45 $params = array($entityId, $email, $password, 'C', 1); 46 $adb->pquery($sql, $params); 47 } 48 49 if($insert == true || $update == true) { 50 global $current_user,$HELPDESK_SUPPORT_EMAIL_ID, $HELPDESK_SUPPORT_NAME; 51 require_once ("modules/Emails/mail.php"); 52 $emailData = Contacts::getPortalEmailContents($entityData,$password,'LoginDetails'); 53 $subject = $emailData['subject']; 54 $contents = $emailData['body']; 55 send_mail('Contacts', $entityData->get('email'), $HELPDESK_SUPPORT_NAME, $HELPDESK_SUPPORT_EMAIL_ID, $subject, $contents,'','','','','',true); 56 } 57 } else { 58 $sql = "UPDATE vtiger_portalinfo SET user_name=?,isactive=0 WHERE id=?"; 59 $adb->pquery($sql, array($email, $entityId)); 60 } 61 } 62 63 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |