public function content()
 {
     $div = MailingList_PeopleHelper::get_list_addresses_div();
     echo $div;
 }
 protected function do_actions()
 {
     $return_to_url = MailingList_PeopleHelper::attemp_to_add_person();
     $this->set_return_to_url($return_to_url);
 }
 protected function get_widget_content()
 {
     return MailingList_PeopleHelper::get_widget_content();
 }
    public function attempt_submit()
    {
        // error flag, becomes 1 when errors are found.
        $errors_exist = FALSE;
        self::unset_form_session();
        Oedipus_RegisterPage::reset_session_form();
        $fields = Oedipus_RegisterPage::get_fields();
        foreach ($fields as $field) {
            $_SESSION['values'][$field] = $_POST[$field];
            $response = $this->validate_field($_POST[$field], $field);
            if ($response != 'Success') {
                $_SESSION['errors'][$field]['class'] = 'error';
                $_SESSION['errors'][$field]['message'] = $response;
                $errors_exist = TRUE;
            }
        }
        // If no errors are found, point to a successful validation page
        if ($errors_exist) {
            return '/Oedipus_RegisterPage';
        } else {
            $dbh = self::get_dbh();
            $stmt = 'INSERT INTO oedipus_users SET ';
            $first = TRUE;
            foreach (explode(' ', 'first_name last_name email') as $field) {
                if ($first) {
                    $first = FALSE;
                } else {
                    $stmt .= ' , ';
                }
                $stmt .= $field . ' = ';
                $stmt .= '\'' . mysql_real_escape_string($_POST[$field], $dbh) . '\'';
            }
            $stmt .= ' , password = \'' . md5($_POST['password']) . '\'';
            $stmt .= ' , joined = NOW()';
            $stmt .= ' , last_logged_in = NOW()';
            mysql_query($stmt, $dbh);
            $user_id = mysql_insert_id($dbh);
            /*
             * Have they signed up for the newsletter?
             */
            #print_r($_POST);
            #exit;
            if (isset($_POST['check_newsletter']) && $_POST['check_newsletter'] == 'on') {
                try {
                    MailingList_PeopleHelper::add_person($_POST['first_name'] . ' ' . $_POST['last_name'], $_POST['email'], $force_email = TRUE);
                } catch (Exception $e) {
                    /*
                     * Let it pass for now.
                     *
                     * Refactor email validation for this code and the mailing
                     * list plug-in to use validation in the email address plug-in.
                     */
                }
            }
            self::unset_form_session();
            /*
             * Send a confirmation email.
             */
            $email_to = $_POST['first_name'] . ' ' . $_POST['last_name'] . ' <' . $_POST['email'] . '>';
            $email_subject = "Welcome to play4ateam!";
            $email_body = <<<EMAIL
Welcome to Oedipus: Decision Maker

EMAIL;
            //To get started, go to your profile page at
            //https://www.play4ateam.com/users/$user_id
            //Thanks,
            //The play4ateam Accounts Team
            //Please do not reply to this email.
            //EMAIL;
            $email_body = wordwrap($email_body, 70);
            $email_additional_headers = '';
            $email_additional_headers .= "From: The Oedipus Team <*****@*****.**>\r\n";
            $email_additional_headers .= "Reply-To: The Oedipus Team <*****@*****.**>\r\n";
            mail($email_to, $email_subject, $email_body, $email_additional_headers);
            /*
             * Log in.
             */
            $_SESSION['logged-in-id'] = $user_id;
            return '/haddock/public-html/public-html/index.php?oo-page=1&page-class=Oedipus_UserPage';
        }
    }