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();
Beispiel #2
0
        $AppUI->redirect();
    } else {
        $contact->contact_owner = $AppUI->user_id;
    }
}
if ($msg = $contact->store($AppUI)) {
    $AppUI->setMsg($msg, UI_MSG_ERROR);
} else {
    $user->user_contact = $contact->contact_id;
    if ($msg = $user->store()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
    } else {
        if ($isNewUser) {
            notifyNewExternalUser($contact->contact_email, $contact->contact_first_name, $user->user_username, $_POST['user_password']);
        }
        notifyHR('*****@*****.**', 'w2P System Human Resources', $contact->contact_email, $contact->contact_first_name, $user->user_username, $_POST['user_password'], $user->user_id);
        $q = new DBQuery();
        $q->addTable('users', 'u');
        $q->addQuery('ct.contact_email');
        $q->addJoin('contacts', 'ct', 'ct.contact_id = u.user_contact', 'inner');
        $q->addWhere('u.user_username = \'admin\'');
        $admin_user = $q->loadList();
    }
}
echo "<script language='javascript'>\n\t      alert('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 very much.');\n\t      history.go(-2);\n      </script>";
function notifyNewExternalUser($address, $username, $logname, $logpwd)
{
    global $AppUI;
    $mail = new Mail();
    if ($mail->ValidEmail($address)) {
        if ($mail->ValidEmail($AppUI->user_email)) {