예제 #1
0
 /**
  * 
  * @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;
 }
예제 #2
0
 /**
  * 
  * @param WOOOF $wo
  * @param array $in
  * @return false | id
  * Returns actually saved $obj 
  */
 public static function saveMainInfo(WOOOF $wo, $in)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     $wo->debug("{$place}:  ");
     if (!$wo->hasContent($in['firstName'])) {
         $wo->logError(self::_ECP . "0012 No value for first name");
         return false;
     }
     if (!$wo->hasContent($in['lastName'])) {
         $wo->logError(self::_ECP . "0014 No value for last name");
         return false;
     }
     $movieRamaUser = $wo->db->getRowByColumn('movierama_users', 'userId', $wo->userData['id']);
     //fernei olo to row
     if ($movieRamaUser === FALSE) {
         return false;
     }
     $movieRamaUserProfile = $wo->db->getRow('person_profiles', $movieRamaUser['personProfileId']);
     //fernei olo to row
     if ($movieRamaUserProfile === FALSE) {
         return false;
     }
     $tblProfile = new VO_TblPersonProfile($movieRamaUserProfile);
     $tblProfile->firstName = $in['firstName'];
     $tblProfile->lastName = $in['lastName'];
     $res = VO_Users::savePersonProfile($wo, $tblProfile);
     if ($res === FALSE) {
         return false;
     }
     return $res;
 }