Example #1
0
 function perform($edit = array())
 {
     $fields = array();
     if (validate_nonblank($edit['username'])) {
         $fields['username'] = $edit['username'];
     }
     if (validate_nonblank($edit['email'])) {
         $fields['email'] = $edit['email'];
     }
     if (count($fields) < 1) {
         error_exit("You must supply at least one of username or email address");
     }
     /* Now, try and find the user */
     $user = Person::load($fields);
     /* Now, we either have one or zero users.  Regardless, we'll present
      * the user with the same output; that prevents them from using this
      * to guess valid usernames.
      */
     if ($user) {
         /* Generate a password */
         $pass = generate_password();
         $user->set_password($pass);
         if (!$user->save()) {
             error_exit("Error setting password");
         }
         /* And fire off an email */
         $rc = send_mail($user, false, false, _person_mail_text('password_reset_subject', array('%site' => variable_get('app_name', 'Leaguerunner'))), _person_mail_text('password_reset_body', array('%fullname' => "{$user->firstname} {$user->lastname}", '%username' => $user->username, '%password' => $pass, '%site' => variable_get('app_name', 'Leaguerunner'))));
         if ($rc == false) {
             error_exit("System was unable to send email to that user.  Please contact system administrator.");
         }
     }
 }
Example #2
0
 function send_membership_letter()
 {
     global $dbh;
     // Send the email
     $variables = array('%fullname' => $this->fullname, '%firstname' => $this->firstname, '%lastname' => $this->lastname, '%adminname' => variable_get('app_admin_name', 'Leaguerunner Admin'), '%site' => variable_get('app_org_name', 'league'), '%year' => date('Y'));
     $message = _person_mail_text('member_letter_body', $variables);
     return send_mail($this, false, false, _person_mail_text('member_letter_subject', $variables), $message);
 }
Example #3
0
 function perform($edit)
 {
     global $lr_session;
     $disposition = $edit['disposition'];
     if ($disposition == '---') {
         error_exit("You must select a disposition for this account");
     }
     list($disposition, $dup_id) = explode(':', $disposition);
     switch ($disposition) {
         case 'approve_player':
             $this->person->set('class', 'player');
             $this->person->set('status', 'inactive');
             if (!$this->person->generate_member_id()) {
                 error_exit("Couldn't get member ID allocation");
             }
             if (!$this->person->save()) {
                 error_exit("Couldn't save new member activation");
             }
             $message = _person_mail_text('approved_body_player', array('%fullname' => $this->person->fullname, '%username' => $this->person->username, '%memberid' => $this->person->member_id, '%url' => url(""), '%adminname' => variable_get('app_admin_name', 'Leaguerunner Admin'), '%site' => variable_get('app_name', 'Leaguerunner')));
             $rc = send_mail($this->person, false, false, _person_mail_text('approved_subject', array('%username' => $this->person->username, '%site' => variable_get('app_name', 'Leaguerunner'))), $message);
             if ($rc == false) {
                 error_exit("Error sending email to " . $this->person->email);
             }
             return true;
         case 'approve_visitor':
             $this->person->set('class', 'visitor');
             $this->person->set('status', 'inactive');
             if (!$this->person->save()) {
                 error_exit("Couldn't save new member activation");
             }
             $message = _person_mail_text('approved_body_visitor', array('%fullname' => $this->person->fullname, '%username' => $this->person->username, '%url' => url(""), '%adminname' => variable_get('app_admin_name', 'Leaguerunner Admin'), '%site' => variable_get('app_name', 'Leaguerunner')));
             $rc = send_mail($this->person, false, false, _person_mail_text('approved_subject', array('%username' => $this->person->username, '%site' => variable_get('app_name', 'Leaguerunner'))), $message);
             if ($rc == false) {
                 error_exit("Error sending email to " . $this->person->email);
             }
             return true;
         case 'delete':
             if (!$this->person->delete()) {
                 error_exit("Delete of user " . $this->person->fullname . " failed.");
             }
             return true;
         case 'delete_duplicate':
             $existing = Person::load(array('user_id' => $dup_id));
             $message = _person_mail_text('dup_delete_body', array('%fullname' => $this->person->fullname, '%username' => $this->person->username, '%existingusername' => $existing->username, '%existingemail' => $existing->email, '%passwordurl' => variable_get('password_reset', url('person/forgotpassword')), '%adminname' => $lr_session->user->fullname, '%site' => variable_get('app_name', 'Leaguerunner')));
             $to_list = array($this->person);
             if ($this->person->email != $existing->email) {
                 $to_list[] = $existing;
             }
             if (!$this->person->delete()) {
                 error_exit("Delete of user " . $this->person->fullname . " failed.");
             }
             $rc = send_mail($to_list, false, false, _person_mail_text('dup_delete_subject', array('%site' => variable_get('app_name', 'Leaguerunner'))), $message);
             if ($rc == false) {
                 error_exit("Error sending email to " . $this->person->email);
             }
             return true;
             // This is basically the same as the delete duplicate, except
             // that some old information (e.g. user ID) is preserved
         // This is basically the same as the delete duplicate, except
         // that some old information (e.g. user ID) is preserved
         case 'merge_duplicate':
             $existing = Person::load(array('user_id' => $dup_id));
             $message = _person_mail_text('dup_merge_body', array('%fullname' => $this->person->fullname, '%username' => $this->person->username, '%existingusername' => $existing->username, '%existingemail' => $existing->email, '%passwordurl' => variable_get('password_reset', url('person/forgotpassword')), '%adminname' => variable_get('app_admin_name', 'Leaguerunner Admin'), '%site' => variable_get('app_name', 'Leaguerunner')));
             $to_list = array($this->person);
             if ($this->person->email != $existing->email) {
                 $to_list[] = $existing;
             }
             // Copy over almost all of the new data; there must be a better way
             $existing->set('status', 'active');
             $existing->set('username', $this->person->username);
             $existing->set('password', $this->person->password);
             $existing->set('firstname', $this->person->firstname);
             $existing->set('lastname', $this->person->lastname);
             $existing->set('email', $this->person->email);
             $existing->set('allow_publish_email', $this->person->allow_publish_email);
             $existing->set('home_phone', $this->person->home_phone);
             $existing->set('publish_home_phone', $this->person->publish_home_phone);
             $existing->set('work_phone', $this->person->work_phone);
             $existing->set('publish_work_phone', $this->person->publish_work_phone);
             $existing->set('mobile_phone', $this->person->mobile_phone);
             $existing->set('publish_mobile_phone', $this->person->publish_mobile_phone);
             $existing->set('addr_street', $this->person->addr_street);
             $existing->set('addr_city', $this->person->addr_city);
             $existing->set('addr_prov', $this->person->addr_prov);
             $existing->set('addr_country', $this->person->addr_country);
             $existing->set('addr_postalcode', $this->person->addr_postalcode);
             $existing->set('gender', $this->person->gender);
             $existing->set('birthdate', $this->person->birthdate);
             $existing->set('height', $this->person->height);
             $existing->set('skill_level', $this->person->skill_level);
             $existing->set('year_started', $this->person->year_started);
             $existing->set('shirtsize', $this->person->shirtsize);
             $existing->set('session_cookie', $this->person->session_cookie);
             $existing->set('has_dog', $this->person->has_dog);
             $existing->set('survey_completed', $this->person->survey_completed);
             $existing->set('willing_to_volunteer', $this->person->willing_to_volunteer);
             $existing->set('contact_for_feedback', $this->person->contact_for_feedback);
             $existing->set('last_login', $this->person->last_login);
             $existing->set('client_ip', $this->person->client_ip);
             if (!$existing->member_id) {
                 $existing->generate_member_id();
             }
             if (!$this->person->delete()) {
                 error_exit("Delete of user " . $this->person->fullname . " failed.");
             }
             if (!$existing->save()) {
                 error_exit("Couldn't save new member information");
             }
             $rc = send_mail($to_list, false, false, _person_mail_text('dup_merge_subject', array('%site' => variable_get('app_name', 'Leaguerunner'))), $message);
             if ($rc == false) {
                 error_exit("Error sending email to " . $this->person->email);
             }
             return true;
         default:
             error_exit("You must select a disposition for this account");
     }
 }
Example #4
0
function person_settings()
{
    $group = form_textfield('Subject of account approval e-mail', 'edit[person_mail_approved_subject]', _person_mail_text('approved_subject'), 70, 180, 'Customize the subject of your approval e-mail, which is sent after account is approved. Available variables are: %username, %site, %url.');
    $group .= form_textarea('Body of account approval e-mail (player)', 'edit[person_mail_approved_body_player]', _person_mail_text('approved_body_player'), 70, 10, 'Customize the body of your approval e-mail, to be sent to players after accounts are approved. Available variables are: %fullname, %memberid, %adminname, %username, %site, %url.');
    $group .= form_textarea('Body of account approval e-mail (visitor)', 'edit[person_mail_approved_body_visitor]', _person_mail_text('approved_body_visitor'), 70, 10, 'Customize the body of your approval e-mail, to be sent to a non-player visitor after account is approved. Available variables are: %fullname, %adminname, %username, %site, %url.');
    $group .= form_textfield('Subject of membership letter e-mail', 'edit[person_mail_member_letter_subject]', _person_mail_text('member_letter_subject'), 70, 180, 'Customize the subject of your membership letter e-mail, which is sent annually after membership is paid for. Available variables are: %fullname, %firstname, %lastname, %site, %year.');
    $group .= form_textarea('Body of membership letter e-mail (player)', 'edit[person_mail_member_letter_body]', _person_mail_text('member_letter_body'), 70, 10, 'Customize the body of your membership letter e-mail, which is sent annually after membership is paid for. If registrations are disabled, or this field is empty, no letters will be sent. Available variables are: %fullname, %firstname, %lastname, %adminname, %site, %year.');
    $group .= form_textfield('Subject of password reset e-mail', 'edit[person_mail_password_reset_subject]', _person_mail_text('password_reset_subject'), 70, 180, 'Customize the subject of your password reset e-mail, which is sent when a user requests a password reset. Available variables are: %site.');
    $group .= form_textarea('Body of password reset e-mail', 'edit[person_mail_password_reset_body]', _person_mail_text('password_reset_body'), 70, 10, 'Customize the body of your password reset e-mail, which is sent when a user requests a password reset. Available variables are: %fullname, %adminname, %username, %password, %site, %url.');
    $group .= form_textfield('Subject of duplicate account deletion e-mail', 'edit[person_mail_dup_delete_subject]', _person_mail_text('dup_delete_subject'), 70, 180, 'Customize the subject of your account deletion mail, sent to a user who has created a duplicate account. Available variables are: %site.');
    $group .= form_textarea('Body of duplicate account deletion e-mail', 'edit[person_mail_dup_delete_body]', _person_mail_text('dup_delete_body'), 70, 10, 'Customize the body of your account deletion e-mail, sent to a user who has created a duplicate account. Available variables are: %fullname, %adminname, %existingusername, %existingemail, %site, %passwordurl.');
    $group .= form_textfield('Subject of duplicate account merge e-mail', 'edit[person_mail_dup_merge_subject]', _person_mail_text('dup_merge_subject'), 70, 180, 'Customize the subject of your account merge mail, sent to a user who has created a duplicate account. Available variables are: %site.');
    $group .= form_textarea('Body of duplicate account merge e-mail', 'edit[person_mail_dup_merge_body]', _person_mail_text('dup_merge_body'), 70, 10, 'Customize the body of your account merge e-mail, sent to a user who has created a duplicate account. Available variables are: %fullname, %adminname, %existingusername, %existingemail, %site, %passwordurl.');
    $group .= form_textfield('Subject of captain request e-mail', 'edit[person_mail_captain_request_subject]', _person_mail_text('captain_request_subject'), 70, 180, 'Customize the subject of your captain request mail, sent to a user who has been invited to join a team. Available variables are: %site, %fullname, %captain, %team, %league, %day, %adminname.');
    $group .= form_textarea('Body of captain request e-mail', 'edit[person_mail_captain_request_body]', _person_mail_text('captain_request_body'), 70, 10, 'Customize the body of your captain request e-mail, sent to a user who has been invited to join a team. Available variables are: %site, %fullname, %captain, %team, %teamurl, %league, %day, %adminname.');
    $group .= form_textfield('Subject of player request e-mail', 'edit[person_mail_player_request_subject]', _person_mail_text('player_request_subject'), 70, 180, 'Customize the subject of your player request mail, sent to captains when a player asks to join their team. Available variables are: %site, %fullname, %team, %league, %day, %adminname.');
    $group .= form_textarea('Body of player request e-mail', 'edit[person_mail_player_request_body]', _person_mail_text('player_request_body'), 70, 10, 'Customize the body of your player request e-mail, sent to captains when a player asks to join their team. Available variables are: %site, %fullname, %captains, %team, %teamurl, %league, %day, %adminname.');
    $output = form_group('User email settings', $group);
    return $output;
}