/** * * @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; }
/** * * @param string $from * @param string $emailAddress * @param string $subject * @param string $message * @param string $replyTo * @return boolean */ public function sendMail($from, $emailAddress, $subject, $message, $replyTo = '', $ccEmailAddresses = '', $htmlMessage = '', $files = null) { $conf = $this->getConfigurationFor('', 'email_smtp'); if ($conf === NULL) { $this->log(WOOOF_loggingLevels::WOOOF_ERROR, self::_ECP . "0200 " . 'email_smtp custom config was not found'); return false; } if (!WOOOF::hasContent($from)) { $from = $this->getConfigurationFor('from_general', 'email_addresses'); if ($from === NULL) { $this->log(WOOOF_loggingLevels::WOOOF_ERROR, self::_ECP . "0210 " . 'No config for from_general in email_addresses'); return false; } } $options = array('FROM' => $from, 'REPLY_TO' => $replyTo, 'SMTP_HOST' => $conf['SMTP_HOST'], 'SMTP_AUTH' => $conf['SMTP_AUTH'], 'SMTP_USERNAME' => $conf['SMTP_USERNAME'], 'SMTP_PASSWORD' => $conf['SMTP_PASSWORD'], 'SMTP_DEBUG' => $this->getFromArray($conf, 'SMTP_DEBUG', false)); if (WOOOF::hasContent($replyTo)) { $options['REPLY_TO'] = $replyTo; } if (WOOOF::hasContentArrayEntry($conf, 'SMTP_SECURE')) { $options['SMTP_SECURE'] = $conf['SMTP_SECURE']; } if (WOOOF::hasContentArrayEntry($conf, 'WORD_WRAP')) { $options['WORD_WRAP'] = $conf['WORD_WRAP']; } /* $p_options_array, // Associative array with the following keys: // FROM (mandatory), REPLY_TO, SMTP_HOST, SMTP_AUTH (bool), // SMTP_USERNAME, SMTP_PASSWORD, SMTP_SECURE (absent or 'tls' or 'ssl'), // WORD_WRAP (word wrap after that many chars), SMTP_DEBUG $p_addresses_array, // Associative array: // TO (mandatory) => <e-mail> or array( <e-mail>, <display_name> ) // CC => as TO, BCC as TO $p_subject, $p_html_message, $p_text_message, $p_attachments, // array of filenames to send as attachments: <filename> or array( filename, display_name ) &$po_error_message */ $errorMessage = ''; if (is_array($emailAddress)) { $emailAddressesArray = $emailAddress; } else { $emailAddressesArray = explode(',', $emailAddress); } if (is_array($ccEmailAddresses)) { $ccEmailAddressesArray = $ccEmailAddresses; } else { $ccEmailAddressesArray = explode(',', $ccEmailAddresses); } $this->debug(__CLASS__ . '.' . __FUNCTION__ . ": send to [" . implode(',', $emailAddressesArray) . ']'); $res = $this->sendPHPMailerMail($options, array('TO' => $emailAddressesArray, 'CC' => $ccEmailAddressesArray), $subject, $htmlMessage, $message, null, $errorMessage); if ($res === FALSE) { $this->log(WOOOF_loggingLevels::WOOOF_ERROR, self::_ECP . "0220 Failed to send e-mail to [" . implode(',', $emailAddressesArray) . "]: {$errorMessage}"); return false; } return true; }