$contact->contact_owner = $AppUI->user_id; } else { if (!getPermission('admin', 'edit') || !getPermission('users', 'edit', $user_id_aed)) { $AppUI->redirect('m=public&a=access_denied'); } } } if ($msg = $contact->store()) { $AppUI->setMsg($msg, UI_MSG_ERROR); } else { $obj->user_contact = $contact->contact_id; if ($msg = $obj->store()) { $AppUI->setMsg($msg, UI_MSG_ERROR); } else { if ($isNewUser && $_POST['send_user_mail']) { notifyNewUser($contact->contact_email, $contact->contact_first_name, $obj->user_username, $_POST['user_password']); } if (isset($_POST['user_role']) && $_POST['user_role']) { $perms =& $AppUI->acl(); if ($perms->insertUserRole($_POST['user_role'], $obj->user_id)) { $AppUI->setMsg('', UI_MSG_ALERT, true); } else { $AppUI->setMsg('failed to add role', UI_MSG_ERROR); } } $AppUI->setMsg($isNewUser ? 'added' : 'updated', UI_MSG_OK, true); } $AppUI->redirect($isNewUser ? 'm=admin&a=viewuser&user_id=' . $obj->user_id . '&tab=3' : ''); } function notifyNewUser($address, $username, $logname, $logpwd) {
} // prepare (and translate) the module name ready for the suffix $AppUI->setMsg('Roles'); if ($_REQUEST['user_id']) { $user = new CUser(); $user->load($_REQUEST['user_id']); $contact = new CContact(); $contact->load($user->user_contact); } if ($del) { if ($perms->deleteUserRole(w2PgetParam($_REQUEST, 'role_id', 0), w2PgetParam($_REQUEST, 'user_id', 0))) { $AppUI->setMsg('deleted', UI_MSG_ALERT, true); $AppUI->redirect(); } else { $AppUI->setMsg('failed to delete role', UI_MSG_ERROR); $AppUI->redirect(); } return; } if (isset($_REQUEST['user_role']) && $_REQUEST['user_role']) { if ($perms->insertUserRole($_REQUEST['user_role'], $_REQUEST['user_id'])) { if ($notify_new_user) { notifyNewUser($contact->contact_email, $contact->contact_first_name); } $AppUI->setMsg('added', UI_MSG_ALERT, true); $AppUI->redirect(); } else { $AppUI->setMsg('failed to add role', UI_MSG_ERROR); $AppUI->redirect(); } }
public function test_notifyNewUser() { // 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('username')); $emailUtility->expects($this->once())->method('Send'); notifyNewUser('*****@*****.**', 'username', $emailUtility); }