zen_redirect(zen_href_link(FILENAME_ADMIN_ACCOUNT)); } // act upon any specific action specified switch ($action) { case 'edit': // display populated form for editing existing user $formAction = 'update'; $profilesList = array_merge(array(array('id' => 0, 'text' => 'Choose Profile')), zen_get_profiles()); break; case 'password': // display unpopulated form for resetting existing user's password $formAction = 'reset'; break; case 'update': // update existing user's details in database. Post data is prep'd for db in the first function call $errors = zen_update_user(FALSE, $_POST['email'], $_POST['id'], $_POST['profile']); if (sizeof($errors) > 0) { foreach ($errors as $error) { $messageStack->add($error, 'error'); } $action = 'edit'; $formAction = 'update'; $profilesList = array_merge(array(array('id' => 0, 'text' => 'Choose Profile')), zen_get_profiles()); } else { $action = ''; $messageStack->add(SUCCESS_USER_DETAILS_UPDATED, 'success'); } break; case 'reset': // reset existing user's password in database. Post data is prep'd for db in the first function call $errors = zen_reset_password($_POST['user'], $_POST['password'], $_POST['confirm']);
$errors = zen_insert_user($_POST['name'], $_POST['email'], $_POST['password'], $_POST['confirm'], $_POST['profile']); if (sizeof($errors) > 0) { foreach ($errors as $error) { $messageStack->add($error, 'error'); } $action = 'add'; $formAction = 'insert'; $profilesList = array_merge(array(array('id' => 0, 'text' => 'Choose Profile')), zen_get_profiles()); } else { $action = ''; $messageStack->add(SUCCESS_NEW_USER_ADDED, 'success'); } break; case 'update': // update existing user's details in database. Post data is prep'd for db in the first function call $errors = zen_update_user($_POST['name'], $_POST['email'], $_POST['id'], $_POST['profile']); if (sizeof($errors) > 0) { foreach ($errors as $error) { $messageStack->add($error, 'error'); } $action = 'edit'; $formAction = 'update'; $profilesList = array_merge(array(array('id' => 0, 'text' => 'Choose Profile')), zen_get_profiles()); } else { $action = ''; $messageStack->add(SUCCESS_USER_DETAILS_UPDATED, 'success'); } break; case 'reset': // reset existing user's password in database. Post data is prep'd for db in the first function call $errors = zen_reset_password($_POST['user'], $_POST['password'], $_POST['confirm']);