function _buildBody($reminder) { return translate_email('Reminder Body', $reminder->resource_name, Time::formatDate($reminder->start_date), Time::formatTime($reminder->start_time), Time::formatDate($reminder->end_date), Time::formatTime($reminder->end_time)); }
/** * Send an email informing the users they have been dropped from the reservation * @param array $emails array of email addresses * @param array $dates that have been dropped */ function remove_users_email($emails, $dates) { global $conf; $mailer = new PHPMailer(); $mailer->From = $this->user->get_email(); $mailer->FromName = $this->user->get_name(); $mailer->Subject = $conf['app']['title'] . ' ' . translate('Reservation Participation Change'); $mailer->IsHTML(false); $url = CmnFns::getScriptURL(); // Format dates $start_date = Time::formatDate($this->start_date); $end_date = Time::formatDate($this->end_date); $start = Time::formatTime($this->get_start()); $end = Time::formatTime($this->get_end()); $dates_text = ''; for ($d = 1; $d < count($dates); $d++) { $dates_text .= Time::formatDate($dates) . ","; } foreach ($emails as $email) { $mailer->ClearAllRecipients(); $mailer->AddAddress($email); $mailer->Body = translate_email('reservation_removal', $this->resource->properties['name'], $start_date, $start, $end_date, $end, $this->summary, $dates_text); $mailer->Send(); } }
/** * Send a notification email that the password has been reset * @param string $memberid id of member * @param string $password new password for user */ function send_pwdreset_email($memberid, $password) { global $conf; $adminemail = $conf['app']['adminEmail']; $appTitle = $conf['app']['title']; $user = new User($memberid); $subject = $appTitle . ' ' . translate('Password Reset'); $msg = $user->get_fname() . ",\r\n" . translate_email('password_reset', $appTitle, $password, $appTitle, CmnFns::getScriptURL(), $adminemail); $mailer = new PHPMailer(); $mailer->AddAddress($user->get_email(), $user->get_name()); $mailer->From = $adminemail; $mailer->FromName = $conf['app']['title']; $mailer->Subject = $subject; $mailer->Body = $msg; $mailer->Send(); }
/** * Change user password * This function creates a new random 8 character password, * sets it in the database and emails it to the user * @return boolean true or false on success of function * @see make_seed() */ function changePassword() { global $conf; $adminemail = $conf['app']['adminEmail']; $title = $conf['app']['title']; $use_logon_name = (bool) $conf['app']['useLogonName']; // Check if user exists $email = stripslashes(trim($_POST['email_address'])); // Connect to database $AuthDB = new AuthDB(); $id = $AuthDB->userExists($email); if (empty($id)) { CmnFns::do_error_box(translate('Sorry, we could not find that user in the database.'), '', false); return false; } else { $user = new User($id); $result = $user->get_user_data(); } // Generate new 8 character password by choosing random // ASCII characters between 48 and 122 // (valid password characters) $pwd = ''; $num = 0; for ($i = 0; $i < 8; $i++) { // Seed random for older versions of PHP mt_srand(make_seed()); if ($i % 2 == 0) { $num = mt_rand(97, 122); } else { if ($i % 3 == 0) { $num = mt_rand(48, 58); } else { $num = mt_rand(63, 90); } } // Uppercase letters and '@ ?' // Put password together $pwd .= chr($num); } // Set password in database $user->set_password($pwd); // Send email to user $sub = translate('Your New Password', array($title)); $msg = translate_email('new_password', $result['fname'], $conf['app']['title'], $pwd, CmnFns::getScriptURL(), $adminemail); $msg .= $use_logon_name ? "\r\n" . translate('Your logon name is', array($result['logon_name'])) : ''; // Send email $mailer = new PHPMailer(); $mailer->AddAddress($result['email'], $result['fname']); $mailer->FromName = $conf['app']['title']; $mailer->From = $adminemail; $mailer->Subject = $sub; $mailer->Body = $msg; $mailer->Send(); return true; }
/** * Register a new user * This function will allow a new user to register. * It checks to make sure the email does not already * exist and then stores all user data in the login table. * It will also set a cookie if the user wants * @param array $data array of user data * @param bool $adminCreated if the user was created by an admin */ function do_register_user($data, $adminCreated) { global $conf; // Verify user data $msg = $this->check_all_values($data, false); if (!empty($msg)) { return $msg; } $adminemail = strtolower($conf['app']['adminEmail']); $techEmail = empty($conf['app']['techEmail']) ? translate('N/A') : $conf['app']['techEmail']; $url = CmnFns::getScriptURL(); // Register the new member $id = $this->db->insertMember($data); $this->db->autoassign($id); // Give permission on auto-assigned resources $mailer = new PHPMailer(); $mailer->IsHTML(false); // Email user informing about successful registration $subject = $conf['ui']['welcome']; $msg = translate_email('register', $data['fname'], $conf['ui']['welcome'], isset($data['logon_name']) ? $data['logon_name'] : $data['emailaddress'], $data['fname'], $data['lname'], $data['phone'], $data['institution'], $data['position'], $url, $adminemail); $mailer->AddAddress($data['emailaddress'], $data['fname'] . ' ' . $data['lname']); $mailer->From = $adminemail; $mailer->FromName = $conf['app']['title']; $mailer->Subject = $subject; $mailer->Body = $msg; $mailer->Send(); // Email the admin informing about new user if ($conf['app']['emailAdmin']) { $subject = translate('A new user has been added'); $msg = translate_email('register_admin', $data['emailaddress'], $data['fname'], $data['lname'], $data['phone'], $data['institution'], $data['position']); $mailer->ClearAllRecipients(); $mailer->AddAddress($adminemail); $mailer->Subject = $subject; $mailer->Body = $msg; $mailer->Send(); } if (!$adminCreated) { // If the user wants to set a cookie, set it // for their ID and fname. Expires in 30 days (2592000 seconds) if (isset($data['setCookie'])) { setcookie('ID', $id, time() + 2592000, '/'); } // If it is the admin, set session variable if ($data['emailaddress'] == $adminemail) { $_SESSION['sessionAdmin'] = $adminemail; } // Set other session variables $_SESSION['sessionID'] = $id; $_SESSION['sessionName'] = $data['fname']; $_SESSION['hourOffset'] = $data['timezone'] - $conf['app']['timezone']; } // Write log file CmnFns::write_log('New user registered. Data provided: fname- ' . $data['fname'] . ' lname- ' . $data['lname'] . ' email- ' . $data['emailaddress'] . ' phone- ' . $data['phone'] . ' institution- ' . $data['institution'] . ' position- ' . $data['position'], $id); if (!$conf['ldap']['authentication'] && !$conf['app']['wrlc']) { $url = 'ctrlpnl.php'; if ($adminCreated) { $url = 'admin.php?tool=users'; } CmnFns::redirect($url, 1, false); $link = CmnFns::getNewLink(); $this->success = translate('You have successfully registered') . '<br/>' . $link->getLink($url, translate('Continue')); } else { // return DB id from entry created if using LDAP return $id; } }