header('Location: newuser.php?msg=existing-user'); } $email = w2PgetParam($_POST, 'contact_email', 0); $contact = new CContact(); $result = $contact->loadAll(null, "contact_email = '{$email}'"); if (count($result)) { header('Location: newuser.php?msg=existing-email'); } if (!$user->bind($_POST)) { $AppUI->setMsg($user->getError(), UI_MSG_ERROR); header('Location: newuser.php?msg=user'); } if (!$contact->bind($_POST)) { $AppUI->setMsg($contact->getError(), UI_MSG_ERROR); header('Location: newuser.php?msg=contact'); } $result = $contact->store(); if (count($contact->getError())) { header('Location: newuser.php?msg=contact'); } else { $user->user_contact = $contact->contact_id; $result = $user->store(null, true); if (count($user->getError())) { header('Location: newuser.php?msg=user'); } else { notifyNewExternalUser($contact->contact_email, $contact->contact_first_name, $user->user_username, $_POST['user_password']); notifyHR(w2PgetConfig('admin_email', '*****@*****.**'), 'w2P System Human Resources', $contact->contact_email, $contact->contact_first_name, $user->user_username, $_POST['user_password'], $user->user_id); $AppUI->setMsg('The User Administrator has been notified to grant you access to the system and an email message was sent to you with your login info. Thank you.', UI_MSG_OK); } } $AppUI->redirect();
public function test_notifyNewExternalUser() { // This is for phpUnit 3.6+ $emailUtility = $this->getMock('w2p_Utilities_Mail', array('Send', 'Body', 'Subject')); $emailUtility->expects($this->once())->method('Subject')->with($this->stringContains('New Account Created')); $emailUtility->expects($this->once())->method('Body')->with($this->stringContains('logname')); $emailUtility->expects($this->once())->method('Send'); notifyNewExternalUser('*****@*****.**', 'username', 'logname', 'logpwd', $emailUtility); }