[Vtigercrm-commits] [vtiger-commits] r10407 - in /vtigercrm/branches/5.0.3: include/js/dtlviewajax.js include/utils/CommonUtils.php modules/Contacts/DetailViewAjax.php modules/Contacts/Save.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Mon Mar 12 03:18:54 EDT 2007
Author: saraj
Date: Mon Mar 12 01:18:45 2007
New Revision: 10407
Log:
fix for Ajax Edit doesn't work on Contacts. Fixes #3193 --Minnie
Modified:
vtigercrm/branches/5.0.3/include/js/dtlviewajax.js
vtigercrm/branches/5.0.3/include/utils/CommonUtils.php
vtigercrm/branches/5.0.3/modules/Contacts/DetailViewAjax.php
vtigercrm/branches/5.0.3/modules/Contacts/Save.php
Modified: vtigercrm/branches/5.0.3/include/js/dtlviewajax.js
==============================================================================
--- vtigercrm/branches/5.0.3/include/js/dtlviewajax.js (original)
+++ vtigercrm/branches/5.0.3/include/js/dtlviewajax.js Mon Mar 12 01:18:45 2007
@@ -192,6 +192,15 @@
}else
{
tagValue = trim(document.getElementById(txtBox).value);
+ if(module == "Contacts")
+ {
+ var port_obj = getObj('portal').checked;
+ if(fieldName == "email" && tagValue == '' && port_obj == true)
+ {
+ alert('Portal user should provide email id for portal login');
+ return false;
+ }
+ }
}
@@ -265,7 +274,21 @@
{
if(tagValue == '1')
{
- getObj(dtlView).innerHTML = "yes";
+ if(module == "Contacts")
+ {
+ var obj = getObj("email");
+ if((fieldName == "portal") && (obj.value == ''))
+ {
+ alert("Portal user should provide email Id for portal login");
+ return false;
+
+ }
+ else
+ getObj(dtlView).innerHTML = "yes";
+
+ }
+ else
+ getObj(dtlView).innerHTML = "yes";
}else
{
getObj(dtlView).innerHTML = "no";
Modified: vtigercrm/branches/5.0.3/include/utils/CommonUtils.php
==============================================================================
--- vtigercrm/branches/5.0.3/include/utils/CommonUtils.php (original)
+++ vtigercrm/branches/5.0.3/include/utils/CommonUtils.php Mon Mar 12 01:18:45 2007
@@ -2782,6 +2782,7 @@
return $desc;
}
+
function getPortalInfo_Ticket($id,$title,$contactname,$portal_url)
{
global $mod_strings;
@@ -2793,5 +2794,44 @@
return $bodydetails;
}
+/**
+ * This function is used to get a random password.
+ * @return a random password with alpha numeric chanreters of length 8
+ */
+function makeRandomPassword()
+{
+ global $log;
+ $log->debug("Entering makeRandomPassword() method ...");
+ $salt = "abcdefghijklmnopqrstuvwxyz0123456789";
+ srand((double)microtime()*1000000);
+ $i = 0;
+ while ($i <= 7)
+ {
+ $num = rand() % 33;
+ $tmp = substr($salt, $num, 1);
+ $pass = $pass . $tmp;
+ $i++;
+ }
+ $log->debug("Exiting makeRandomPassword method ...");
+ return $pass;
+}
+
+//added to get mail info for portal user
+function getmail_contents_portalUser($request_array,$password)
+{
+ global $mod_strings;
+ $subject = $mod_strings['Customer Portal Login Details'];
+ $contents = $mod_strings['Dear']." ".$request_array['first_name']." ".$request_array['last_name'].",<br><br>";
+ $contents .= $mod_strings['Your Customer Portal Login details are given below:'];
+ $contents .= "<br><br>".$mod_strings['User Id :']." ".$request_array['email'];
+ $contents .= "<br>".$mod_strings['Password :']." ".$password;
+ $contents .= "<br><br>".$request_array['portal_url'];
+
+ $contents .= "<br><br><b>".$mod_strings['Note :']." </b>".$mod_strings['We suggest you to change your password after logging in first time'];
+ $contents .= "<br><br>".$mod_strings['Support Team'];
+ return $contents;
+
+}
+
?>
Modified: vtigercrm/branches/5.0.3/modules/Contacts/DetailViewAjax.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Contacts/DetailViewAjax.php (original)
+++ vtigercrm/branches/5.0.3/modules/Contacts/DetailViewAjax.php Mon Mar 12 01:18:45 2007
@@ -31,11 +31,67 @@
$cntObj->id = $crmid;
$cntObj->mode = "edit";
$cntObj->save("Contacts");
+
+ $email_res = $adb->query("select email from vtiger_contactdetails where contactid=".$cntObj->id);
+ $email = $adb->query_result($email_res,0,'email');
+
+ $check_available = $adb->query("select * from vtiger_portalinfo where id=".$cntObj->id);
+ $update = '';
if($fieldname =='email')
{
- $sql = "update vtiger_portalinfo set user_name='".$fieldvalue."' where id=".$crmid;
- $adb->query($sql);
+ $active = $adb->query_result($check_available,0,'isactive');
+ $update = false;
+ if($active != '' && $active == 1)
+ {
+ $sql = "update vtiger_portalinfo set user_name='".$fieldvalue."',isactive='".$active."' where id=".$crmid;
+ $adb->query($sql);
+ $email = $fieldvalue;
+ $result = $adb->query("select user_password from vtiger_portalinfo where id=".$cntObj->id);
+ $password = $adb->query_result($result,0,'user_password');
+ $update = true;
+ }
}
+
+ if($fieldname == "portal")
+ {
+ if($email != '')
+ {
+ $confirm = $adb->query_result($check_available,0,'isactive');
+ if($confirm == '' && $fieldvalue == 1)
+ {
+ $password = makeRandomPassword();
+ $sql = "insert into vtiger_portalinfo (id,user_name,user_password,type,isactive) values(".$cntObj->id.",'".$email."','".$password."','C',1)";
+ $adb->query($sql);
+ $insert = true;
+
+ }
+ elseif($confirm == 0 && $fieldvalue == 1)
+ {
+ $sql = "update vtiger_portalinfo set user_name='".$email."', isactive=1 where id=".$cntObj->id;
+ $adb->query($sql);
+ $result = $adb->query("select user_password from vtiger_portalinfo where id=".$cntObj->id);
+ $password = $adb->query_result($result,0,'user_password');
+ $update = true;
+
+ }
+ elseif($confirm == 1 && $fieldvalue == 0)
+ {
+ $sql = "update vtiger_portalinfo set isactive=0 where id=".$cntObj->id;
+ $adb->query($sql);
+ }
+ }
+ }
+ require_once("modules/Emails/mail.php");
+ global $current_user;
+ $data_array = Array();
+ $data_array['first_name'] = $cntObj->column_fields['firstname'];
+ $data_array['last_name'] = $cntObj->column_fields['lastname'];
+ $data_array['email'] = $email;
+ $data_array['portal_url'] = "<a href=".$PORTAL_URL."/login.php>".$mod_strings['Please Login Here']."</a>";
+ $contents = getmail_contents_portalUser($data_array,$password);
+ if($insert == true || $update == true)
+ send_mail('Contacts',$cntObj->column_fields['email'],$current_user->user_name,'',$mod_strings['Customer Portal Login Details'],$contents);
+
if($cntObj->id != "")
{
echo ":#:SUCCESS";
Modified: vtigercrm/branches/5.0.3/modules/Contacts/Save.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Contacts/Save.php (original)
+++ vtigercrm/branches/5.0.3/modules/Contacts/Save.php Mon Mar 12 01:18:45 2007
@@ -25,29 +25,6 @@
require_once('include/database/PearDatabase.php');
require_once("modules/Emails/mail.php");
-
-/**
- * This function is used to get a random password.
- * @return a random password with alpha numeric chanreters of length 8
- */
-function makeRandomPassword()
-{
- global $log;
- $log->debug("Entering makeRandomPassword() method ...");
- $salt = "abcdefghijklmnopqrstuvwxyz0123456789";
- srand((double)microtime()*1000000);
- $i = 0;
- while ($i <= 7)
- {
- $num = rand() % 33;
- $tmp = substr($salt, $num, 1);
- $pass = $pass . $tmp;
- $i++;
- }
-$log->debug("Exiting makeRandomPassword method ...");
- return $pass;
-}
-
$local_log =& LoggerManager::getLogger('index');
global $log,$adb;
@@ -193,20 +170,18 @@
$adb->query($sql);
}
- $subject = $mod_strings['Customer Portal Login Details'];
- $contents = $mod_strings['Dear']." ".$_REQUEST['firstname']." ".$_REQUEST['lastname'].",<br><br>";
- $contents .= $mod_strings['Your Customer Portal Login details are given below:'];
- $contents .= "<br><br>".$mod_strings['User Id :']." ".$_REQUEST['email'];
- $contents .= "<br>".$mod_strings['Password :']." ".$password;
- $contents .= "<br><br><a href=''.$PORTAL_URL.'/login.php'>".$mod_strings['Please Login Here']."</a>";
-
- $contents .= "<br><br><b>".$mod_strings['Note :']." </b>".$mod_strings['We suggest you to change your password after logging in first time'];
- $contents .= "<br><br>".$mod_strings['Support Team'];
+ //changes made to send mail to portal user when we use ajax edit
+ $data_array = Array();
+ $data_array['first_name'] = $_REQUEST['firstname'];
+ $data_array['last_name'] = $_REQUEST['lastname'];
+ $data_array['email'] = $_REQUEST['email'];
+ $data_array['portal_url'] = "<a href=".$PORTAL_URL."/login.php>".$mod_strings['Please Login Here']."</a>";
+ $contents = getmail_contents_portalUser($data_array,$password);
$log->info("Customer Portal Information Updated in database and details are going to send => '".$_REQUEST['email']."'");
if($insert == 'true' || $update == 'true')
{
- $mail_status = send_mail('Contacts',$_REQUEST['email'],$current_user->user_name,'',$subject,$contents);
+ $mail_status = send_mail('Contacts',$_REQUEST['email'],$current_user->user_name,'',$mod_strings['Customer Portal Login Details'],$contents);
}
$log->info("After return from the SendMailToCustomer function. Now control will go to the header.");
}
More information about the vtigercrm-commits
mailing list