summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/contact.pm13
-rw-r--r--httemplate/edit/cust_main-contacts.html7
-rw-r--r--httemplate/edit/elements/edit.html2
-rw-r--r--httemplate/edit/process/elements/process.html2
-rw-r--r--httemplate/elements/contact.html37
5 files changed, 39 insertions, 22 deletions
diff --git a/FS/FS/contact.pm b/FS/FS/contact.pm
index fa047f59d..81dfdbc01 100644
--- a/FS/FS/contact.pm
+++ b/FS/FS/contact.pm
@@ -199,8 +199,6 @@ sub insert {
}
- $error ||= $self->insert_password_history;
-
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;
@@ -302,6 +300,15 @@ sub insert {
}
}
+ if ( $self->get('password') ) {
+ my $error = $self->is_password_allowed($self->get('password'))
+ || $self->change_password($self->get('password'));
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
'';
@@ -811,7 +818,7 @@ sub authenticate_password {
$hash eq $check_hash;
- } else {
+ } else {
return 0 if $self->_password eq '';
diff --git a/httemplate/edit/cust_main-contacts.html b/httemplate/edit/cust_main-contacts.html
index 7c5a78209..abef7505d 100644
--- a/httemplate/edit/cust_main-contacts.html
+++ b/httemplate/edit/cust_main-contacts.html
@@ -60,6 +60,13 @@ this one isn't being maintained well. :/
my $curuser = $FS::CurrentUser::CurrentUser;
my $conf = new FS::Conf;
+if ( $cgi->param('redirect') ) {
+ my $session = $cgi->param('redirect');
+ my $pref = $curuser->option("redirect$session");
+ die "unknown redirect session $session\n" unless length($pref);
+ $cgi = new CGI($pref);
+}
+
my $custnum;
if ( $cgi->param('error') ) {
$custnum = scalar($cgi->param('custnum'));
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 8ba703a2f..b7f2e7adb 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -669,7 +669,7 @@ Example:
var newrow = <% include(@layer_opt, html_only=>1) |js_string %>;
% #until the rest have html/js_only
-% if ( ($type eq 'selectlayers') || ($type eq 'selectlayersx') || ($type =~ /^select-cgp_rule_/) ) {
+% if ( ($type eq 'selectlayers') || ($type eq 'selectlayersx') || ($type =~ /^select-cgp_rule_/) || ($type eq 'contact') ) {
var newfunc = <% include(@layer_opt, js_only=>1) |js_string %>;
% } else {
var newfunc = '';
diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html
index d2b037053..a3ea7ee59 100644
--- a/httemplate/edit/process/elements/process.html
+++ b/httemplate/edit/process/elements/process.html
@@ -127,7 +127,7 @@ Example:
% " attempting to set redirect$session to ". $cgi->query_string."\n";
% }
%
-<% $cgi->redirect("$error_redirect?redirect=$session") %>
+<% $cgi->redirect("$error_redirect"."redirect=$session") %>
%
% } else {
%
diff --git a/httemplate/elements/contact.html b/httemplate/elements/contact.html
index 5588890c8..5fa8ae485 100644
--- a/httemplate/elements/contact.html
+++ b/httemplate/elements/contact.html
@@ -1,4 +1,6 @@
-% unless ( $opt{'js_only'} ) {
+% if ( $opt{'js_only'} ) {
+<% $js %>
+% } else {
<INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">
@@ -75,23 +77,8 @@
VALUE = ""
placeholder = "<% $value |h %>"
>
-% my $contactnum = $curr_value ? $curr_value : '0';
-
<SCRIPT>
- add_password_validation('<% "changepw".$id."_password" %>', 'submit', '', '<% $contactnum %>');
- </SCRIPT>
-
- <SCRIPT TYPE="text/javascript">
- var selfService = document.getElementById("<%$id%>_selfservice_access").value;
-
- if (selfService !== "Y") { document.getElementById("changepw<%$id%>_password").disabled = 'true'; }
- document.getElementById("<%$id%>_selfservice_access").onchange = function() {
- if (this.value == "P" || this.value == "E" || this.value =="Y") {
- document.getElementById("changepw<%$id%>_password").disabled = '';
- }
- else { document.getElementById("changepw<%$id%>_password").disabled = 'true'; }
- return false;
- }
+ <% $js %>
</SCRIPT>
% } elsif ( $field eq 'invoice_dest' || $field eq 'message_dest' ) {
% my $curr_value = $cgi->param($name . '_' . $field);
@@ -136,6 +123,7 @@ my $name = $opt{'element_name'} || $opt{'field'} || 'contactnum';
my $id = $opt{'id'} || 'contactnum';
my $curr_value = $opt{'curr_value'} || $opt{'value'};
+my $contactnum = $curr_value ? $curr_value : '0';
my $onchange = '';
if ( $opt{'onchange'} ) {
@@ -203,4 +191,19 @@ $label{'comment'} = 'Comment';
my @fields = $opt{'name_only'} ? qw( first last ) : keys %label;
+my $js = qq(
+ add_password_validation('changepw$id\_password', 'submit', '', '$contactnum');
+
+ var selfService = document.getElementById("$id\_selfservice_access").value;
+
+ if (selfService !== "Y") { document.getElementById("changepw$id\_password").disabled = 'true'; }
+ document.getElementById("$id\_selfservice_access").onchange = function() {
+ if (this.value == "P" || this.value == "E" || this.value =="Y") {
+ document.getElementById("changepw$id\_password").disabled = '';
+ }
+ else { document.getElementById("changepw$id\_password").disabled = 'true'; }
+ return false;
+ }
+);
+
</%init>