} else { $insert = 'false'; } if ($insert == 'true') { $password = makeRandomPassword(); $sql = "insert into vtiger_portalinfo values(?,?,?,?,?,?,?,?)"; $params = array($focus->id, $username, $password, 'C', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1); $adb->pquery($sql, $params); } //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 . '" style="font-family:Arial, Helvetica, sans-serif;font-size:12px; font-weight:bolder;text-decoration:none;color: #4242FD;">' . $mod_strings['Please Login Here'] . '</a>'; $value = getmail_contents_portalUser($data_array, $password, "LoginDetails"); $contents = $value["body"]; $subject = $value["subject"]; $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('Support', $_REQUEST['email'], $current_user->user_name, '', $subject, $contents); } $log->info("After return from the SendMailToCustomer function. Now control will go to the header."); } //END -- Code for Create Customer Portal Users password and Send Mail $log->info("This Page is redirected to : " . $return_module . " / " . $return_action . "& return id =" . $return_id); //code added for returning back to the current view after edit from list view if ($_REQUEST['return_viewname'] == '') { $return_viewname = '0'; } if ($_REQUEST['return_viewname'] != '') {
$sql = "update vtiger_portalinfo set user_name=?, isactive=1 where id=?"; $params = array($email, $modObj->id); $adb->pquery($sql, $params); $result = $adb->pquery("select user_password from vtiger_portalinfo where id=?", array($modObj->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=?"; $adb->pquery($sql, array($modObj->id)); } } } require_once "modules/Emails/mail.php"; global $current_user; $data_array = array(); $data_array['first_name'] = $modObj->column_fields['firstname']; $data_array['last_name'] = $modObj->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 ($modObj->id != "") { echo ":#:SUCCESS"; } else { echo ":#:FAILURE"; } } else { echo ":#:FAILURE"; } } elseif ($ajaxaction == "LOADRELATEDLIST" || $ajaxaction == "DISABLEMODULE") { require_once 'include/ListView/RelatedListViewContents.php'; }
function sendCustomerPortalLoginDetails($module) { global $adb, $log, $PORTAL_URL, $mod_strings; $email = $this->column_fields['email']; if ($this->column_fields['portal'] == 'on' || $this->column_fields['portal'] == '1') { $sql = "SELECT id, user_name, user_password, isactive FROM vtiger_portalinfo WHERE id=?"; $result = $adb->pquery($sql, array($this->id)); $insert = false; if ($adb->num_rows($result) == 0) { $insert = true; } else { $dbusername = $adb->query_result($result, 0, 'user_name'); $isactive = $adb->query_result($result, 0, 'isactive'); if ($email == $dbusername && $isactive == 1 && $this->mode == 'edit') { $update = false; } else { if ($this->column_fields['portal'] == 'on' || $this->column_fields['portal'] == '1') { $sql = "UPDATE vtiger_portalinfo SET user_name=?, isactive=1 WHERE id=?"; $adb->pquery($sql, array($email, $this->id)); $password = $adb->query_result($result, 0, 'user_password'); $update = true; } else { $sql = "UPDATE vtiger_portalinfo SET user_name=?, isactive=? WHERE id=?"; $adb->pquery($sql, array($email, 0, $this->id)); $update = false; } } } if ($insert == true) { $password = makeRandomPassword(); $sql = "INSERT INTO vtiger_portalinfo(id,user_name,user_password,type,isactive) VALUES(?,?,?,?,?)"; $params = array($this->id, $email, $password, 'C', 1); $adb->pquery($sql, $params); } require_once "modules/Emails/mail.php"; global $current_user; $data_array = array(); $data_array['first_name'] = $this->column_fields['firstname']; $data_array['last_name'] = $this->column_fields['lastname']; $data_array['email'] = $this->column_fields['email']; $data_array['portal_url'] = '<a href="' . $PORTAL_URL . '" style="font-family:Arial, Helvetica, sans-serif;font-size:12px; font-weight:bolder;text-decoration:none;color: #4242FD;">' . $mod_strings['Please Login Here'] . '</a>'; $contents = getmail_contents_portalUser($data_array, $password); $subject = $mod_strings['Customer Portal Login Details']; $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', $this->column_fields['email'], $current_user->user_name, "", $subject, $contents); } } else { $sql = "UPDATE vtiger_portalinfo SET user_name=?,isactive=0 WHERE id=?"; $adb->pquery($sql, array($email, $this->id)); } }