Portal details updated when customer record is updated. See #32
Portal details updated when customer record is updated. See #32

--- a/conf/notifications.php
+++ b/conf/notifications.php
@@ -14,6 +14,8 @@
 $notifs->HomePageTextLoggedIn->className = 'HomePgText';
 $notifs->HomePageTextLoggedIn->text = 'Welcome to PHPCredLocker, please use the menus to proceed';
 
+$notifs->CustPortalFail->className = 'alert alert-info';
+$notifs->CustPortalFail->text = "The customer has been successfully updated, but the customer portal record could not be updated. The customer will need to continue to use their old details";
 
 
 $notifs->addCustSuccess->className = 'alert alert-success';

--- a/lib/customer.class.php
+++ b/lib/customer.class.php
@@ -40,14 +40,47 @@
 
     if (BTMain::getConf()->custPortalEnabled){
     global $notifications;
-    $notifications->setNotification("<div class='alert alert-success'>The customer has been successfully added to the customer portal and can use the password <i>$password</i> to manage their credentials</div>");
+    $not->className = 'alert alert-success';
+    $not->text = "The customer has been successfully added to the customer portal and can use the password <i>$password</i> to manage their credentials";
+
+    $notifications->setNotification($not);
     }
+
+
+
 }
 
 return $id;
 
 }
 
+
+
+
+
+
+function edit($id,$name,$group,$firstname,$surname,$email){
+
+$db = new CustDB;
+
+if (!$db->editCustomer($id,$name,$group,$firstname,$surname,$email)){
+return false;
+}
+
+$db = new AuthDB;
+if ($db->editPortalCustDetails($id,$email)){
+  return true;
+  }else{
+  global $notifications;
+  $notifications->setNotification('CustPortalFail');
+
+  }
+
+
+
+
+
+}
 
 
 

--- a/lib/db/authdb.class.php
+++ b/lib/db/authdb.class.php
@@ -53,6 +53,23 @@
 $this->setQuery($sql);
 return $this->runQuery();
 
+}
+
+
+/** Edit the Portal login details for the specified customer - Passwords done seperately
+*
+* @arg id - Customer ID
+* @arg email - Customers login email address
+*
+*/
+function editPortalCustDetails($id,$email){
+$crypt = new Crypto;
+$id = $this->stringEscape($id);
+$email = $this->stringEscape($crypt->encrypt($email,'auth'));
+
+$sql = "UPDATE #__CustPortal SET `email`='$email' WHERE `id`='$id'";
+$this->setQuery($sql);
+return $this->runQuery();
 }
 
 

--- a/lib/output.php
+++ b/lib/output.php
@@ -474,7 +474,7 @@
 $this->customJS[] = "$js";
 }
 
-
+/** TODO add support for custom notifications passed as an argument **/
 }
 
 

--- a/views/Customer/edit.php
+++ b/views/Customer/edit.php
@@ -15,10 +15,11 @@
 $notifications->setPageTitle("Edit ".Lang::_('Customer'));
 
 if (BTMain::getVar('EditCustSubmitted')){
+$cust = new CredLockCust;
 
 
 
-if ($db->editCustomer(BTMain::getVar('id'),htmlspecialchars(BTMain::getVar('FrmName')),BTMain::getVar('frmGroup'),htmlspecialchars(BTMain::getVar('FrmconName')),htmlspecialchars(BTMain::getVar('FrmSurname')),htmlspecialchars(BTMain::getVar('FrmEmail')))){
+if ($cust->edit(BTMain::getVar('id'),htmlspecialchars(BTMain::getVar('FrmName')),BTMain::getVar('frmGroup'),htmlspecialchars(BTMain::getVar('FrmconName')),htmlspecialchars(BTMain::getVar('FrmSurname')),htmlspecialchars(BTMain::getVar('FrmEmail')))){
 
 
 $notifications->setNotification("EditCustSuccess");