/** * * @param WOOOF $wo * @param array $in // [ 'email', 'password', 'passwordConfirm', 'firstName', 'lastName' ] * @return false | new user id */ public static function registerUser(WOOOF $wo, $in, &$errors) { $place = __CLASS__ . '::' . __FUNCTION__; $wo->debug("{$place}: "); $errors = []; // Check passwords if (!$wo->hasContentArrayEntry($in, 'password') || !$wo->hasContentArrayEntry($in, 'passwordConfirm')) { array_push($errors, "You must provide a password and a password confirmation!"); } else { if ($in['password'] !== $in['passwordConfirm']) { array_push($errors, "The passwords you provided do not match."); } } // Check firstName, lastName if (!$wo->hasContentArrayEntry($in, 'firstName')) { array_push($errors, "Please fill-in your First Name."); } if (!$wo->hasContentArrayEntry($in, 'lastName')) { array_push($errors, "Please fill-in your Last Name."); } if (!empty($errors)) { return false; } // Add to __users // (also makes the final check on password) // $userId = WOOOF_User::createUser($wo, $in['email'], $in['password'], 'Normal User'); if ($userId === FALSE) { $errors = [$wo->getErrorsAsStringAndClear(['WOO9999'])]; return false; } // Add to person_profiles $ppr = new VO_TblPersonProfile(); $ppr->email = $in['email']; $ppr->firstName = $in['firstName']; $ppr->lastName = $in['lastName']; $pprId = VO_Users::savePersonProfile($wo, $ppr); if ($pprId === FALSE) { return FALSE; } // Add to movierama_users $us = new VO_TblUser(); $us->userId = $userId; $us->username = $in['email']; $us->personProfileId = $pprId; $movieramaUserId = VO_Users::save($wo, $us); if ($movieramaUserId === FALSE) { return FALSE; } return $movieramaUserId; }