Esempio n. 1
0
 public static function sendEmail($to, $from, $subject, $content, $cc = NULL, $bcc = NULL)
 {
     $settings = InternSettings::getInstance();
     // Sanity checking
     if (!isset($to) || is_null($to)) {
         return false;
     }
     if (!isset($from) || is_null($from)) {
         $from = $settings->getSystemName() . ' <' . $settings->getEmailFromAddress() . '>';
     }
     if (!isset($subject) || is_null($subject)) {
         return false;
     }
     if (!isset($content) || is_nulL($content)) {
         return false;
     }
     // Create a Mail object and set it up
     PHPWS_Core::initCoreClass('Mail.php');
     $message = new PHPWS_Mail();
     $message->addSendTo($to);
     $message->setFrom($from);
     $message->setSubject($subject);
     $message->setMessageBody($content);
     if (isset($cc)) {
         $message->addCarbonCopy($cc);
     }
     if (isset($bcc)) {
         $message->addBlindCopy($bcc);
     }
     // Send the message
     if (EMAIL_TEST_FLAG) {
         $result = true;
     } else {
         $result = $message->send();
     }
     if (PEAR::isError($result)) {
         PHPWS_Error::log($result);
         return false;
     }
     self::logEmail($message);
     return true;
 }
Esempio n. 2
0
 public static function send_email($to, $from, $subject, $content, $cc = NULL, $bcc = NULL)
 {
     # Sanity checking
     if (!isset($to) || is_null($to)) {
         return false;
     }
     if (!isset($from) || is_null($from)) {
         $from = SYSTEM_NAME . ' <' . FROM_ADDRESS . '>';
     }
     if (!isset($subject) || is_null($subject)) {
         return false;
     }
     if (!isset($content) || is_nulL($content)) {
         return false;
     }
     # Create a Mail object and set it up
     \PHPWS_Core::initCoreClass('Mail.php');
     $message = new PHPWS_Mail();
     $message->addSendTo($to);
     $message->setFrom($from);
     $message->setSubject($subject);
     $message->setMessageBody($content);
     if (isset($cc)) {
         $message->addCarbonCopy($cc);
     }
     if (isset($bcc)) {
         $message->addBlindCopy($bcc);
     }
     # Send the message
     if (EMAIL_TEST_FLAG) {
         HMS_Email::log_email($message);
         $result = true;
     } else {
         $result = $message->send();
     }
     if (PEAR::isError($result)) {
         PHPWS_Error::log($result);
         return false;
     }
     return true;
 }
Esempio n. 3
0
 /**
  * Sends email to Wiki Admin if option enabled
  *
  * @author Greg Meiste <*****@*****.**>
  */
 function sendEmail()
 {
     if (PHPWS_Settings::get('wiki', 'monitor_edits')) {
         $pagetitle = WikiManager::formatTitle(strip_tags($_REQUEST['page']));
         $message = PHPWS_Settings::get('wiki', 'email_text');
         $message = str_replace('[page]', $pagetitle, $message);
         $message = str_replace('[url]', PHPWS_Core::getHomeHttp() . (MOD_REWRITE_ENABLED ? 'wiki/' : 'index.php?module=wiki&page=') . $_REQUEST['page'], $message);
         PHPWS_Core::initCoreClass('Mail.php');
         $mail = new PHPWS_Mail();
         $mail->addSendTo(PHPWS_Settings::get('wiki', 'admin_email'));
         $mail->setSubject(sprintf(dgettext('wiki', '%s updated!'), $pagetitle));
         $mail->setFrom(PHPWS_User::getUserSetting('site_contact'));
         $mail->setMessageBody($message);
         $mail->send();
     }
 }
Esempio n. 4
0
 public static function notifyUser($user, $password)
 {
     PHPWS_Core::initCoreClass('Mail.php');
     $page_title = Layout::getPageTitle(true);
     $body[] = sprintf(dgettext('users', '%s created an user account for you.'), $page_title);
     $body[] = dgettext('users', 'You may log-in using the following information:');
     $body[] = sprintf(dgettext('users', 'Site address: %s'), PHPWS_Core::getHomeHttp());
     $body[] = sprintf(dgettext('users', 'Username: %s'), $user->username);
     $body[] = sprintf(dgettext('users', 'Password: %s'), $password);
     $body[] = dgettext('users', 'Please change your password immediately after logging in.');
     $mail = new PHPWS_Mail();
     $mail->addSendTo($user->email);
     $mail->setSubject(sprintf(dgettext('users', '%s account created'), $page_title));
     $mail->setFrom(PHPWS_User::getUserSetting('site_contact'));
     $mail->setReplyTo(PHPWS_User::getUserSetting('site_contact'));
     $mail->setMessageBody(implode("\n\n", $body));
     $result = $mail->send();
     return $result;
 }
Esempio n. 5
0
 /**
  * Sends everyone (limited by search) in a specific sheet an email
  */
 public function sendEmail()
 {
     PHPWS_Core::initCoreClass('Mail.php');
     if (!isset($_SESSION['Email_Applicants'])) {
         $_SESSION['Email_Applicants']['email'] =& $this->email;
         $_SESSION['Email_Applicants']['sheet_id'] = $this->sheet->id;
         $_SESSION['Email_Applicants']['search'] = @$_REQUEST['search'];
         $vars['aop'] = 'send_email';
         Layout::metaRoute(PHPWS_Text::linkAddress('signup', $vars, true), 1);
         $this->title = dgettext('signup', 'Sending emails');
         $this->content = dgettext('signup', 'Please wait');
         return;
     }
     $email_session =& $_SESSION['Email_Applicants'];
     $mail = new PHPWS_Mail();
     $mail->setSubject($email_session['email']['subject']);
     $mail->setFrom($email_session['email']['from']);
     $mail->setReplyTo($email_session['email']['from']);
     $mail->setMessageBody($email_session['email']['message']);
     $mail->sendIndividually(true);
     $this->loadSheet($email_session['sheet_id']);
     if (!$this->sheet->id) {
         $this->title = dgettext('signup', 'Sorry');
         $this->content = dgettext('signup', 'Unable to send emails. Signup sheet does not exist.');
         PHPWS_Core::killSession('Email_Applicants');
         return;
     }
     $db = new PHPWS_DB('signup_peeps');
     $db->addColumn('email');
     $db->addWhere('sheet_id', $this->sheet->id);
     if (isset($email_session['search'])) {
         $search = explode('+', $email_session['search']);
         foreach ($search as $s) {
             $db->addWhere('first_name', "%{$s}%", 'like', 'or', 1);
             $db->addWhere('last_name', "%{$s}%", 'like', 'or', 1);
         }
     }
     $result = $db->select('col');
     if (empty($result)) {
         $this->title = dgettext('signup', 'Emails not sent');
         $this->content = dgettext('signup', 'Signup sheet did not contain any applicants.');
         return;
     } elseif (PHPWS_Error::logIfError($result)) {
         $this->title = dgettext('signup', 'Emails not sent');
         $this->content = dgettext('signup', 'An error occurred when pulling applicants.');
         return;
     }
     foreach ($result as $address) {
         $mail->addSendTo($address);
     }
     $mail->send();
     $vars['aop'] = 'report';
     $vars['sheet_id'] = $this->sheet->id;
     $link = PHPWS_Text::linkAddress('signup', $vars, true);
     $this->title = dgettext('signup', 'Emails sent');
     $this->content = dgettext('signup', 'Returning to applicant listing.');
     Layout::metaRoute($link, 5);
     PHPWS_Core::killSession('Email_Applicants');
 }
Esempio n. 6
0
 /**
  * Save new settings
  *
  * @author Greg Meiste <*****@*****.**>
  */
 function save()
 {
     PHPWS_Settings::set('wiki', 'show_on_home', (int) isset($_POST['show_on_home']));
     PHPWS_Settings::set('wiki', 'allow_anon_view', (int) isset($_POST['allow_anon_view']));
     PHPWS_Settings::set('wiki', 'allow_page_edit', (int) isset($_POST['allow_page_edit']));
     PHPWS_Settings::set('wiki', 'allow_image_upload', (int) isset($_POST['allow_image_upload']));
     PHPWS_Settings::set('wiki', 'allow_bbcode', (int) isset($_POST['allow_bbcode']));
     PHPWS_Settings::set('wiki', 'ext_chars_support', (int) isset($_POST['ext_chars_support']));
     PHPWS_Settings::set('wiki', 'add_to_title', (int) isset($_POST['add_to_title']));
     PHPWS_Settings::set('wiki', 'format_title', (int) isset($_POST['format_title']));
     PHPWS_Settings::set('wiki', 'show_modified_info', (int) isset($_POST['show_modified_info']));
     PHPWS_Settings::set('wiki', 'monitor_edits', (int) isset($_POST['monitor_edits']));
     if (isset($_POST['diff_type'])) {
         PHPWS_Settings::set('wiki', 'diff_type', 'one_col');
     } else {
         PHPWS_Settings::set('wiki', 'diff_type', 'two_col');
     }
     PHPWS_Core::initCoreClass('Mail.php');
     if (isset($_POST['admin_email']) && PHPWS_Mail::checkAddress($_POST['admin_email'])) {
         PHPWS_Settings::set('wiki', 'admin_email', PHPWS_Text::parseInput($_POST['admin_email']));
     }
     if (isset($_POST['email_text'])) {
         PHPWS_Settings::set('wiki', 'email_text', PHPWS_Text::parseInput($_POST['email_text']));
     }
     if (isset($_POST['default_page']) && strlen($_POST['default_page']) > 0) {
         PHPWS_Settings::set('wiki', 'default_page', PHPWS_Text::parseInput($_POST['default_page']));
     }
     if (isset($_POST['ext_page_target'])) {
         PHPWS_Settings::set('wiki', 'ext_page_target', PHPWS_Text::parseInput($_POST['ext_page_target']));
     }
     PHPWS_Settings::set('wiki', 'immutable_page', (int) isset($_POST['immutable_page']));
     PHPWS_Settings::set('wiki', 'raw_text', (int) isset($_POST['raw_text']));
     PHPWS_Settings::set('wiki', 'print_view', (int) isset($_POST['print_view']));
     PHPWS_Settings::set('wiki', 'what_links_here', (int) isset($_POST['what_links_here']));
     PHPWS_Settings::set('wiki', 'recent_changes', (int) isset($_POST['recent_changes']));
     PHPWS_Settings::set('wiki', 'random_page', (int) isset($_POST['random_page']));
     PHPWS_Settings::set('wiki', 'discussion', (int) isset($_POST['discussion']));
     if (isset($_POST['discussion_anon'])) {
         PHPWS_Settings::set('wiki', 'discussion', 1);
         PHPWS_Settings::set('wiki', 'discussion_anon', 1);
     } else {
         PHPWS_Settings::set('wiki', 'discussion_anon', 0);
     }
     if (PHPWS_Error::logIfError(PHPWS_Settings::save('wiki'))) {
         return dgettext('wiki', 'There was an error saving the settings.');
     }
     return dgettext('wiki', 'Your settings have been successfully saved.');
 }
Esempio n. 7
0
 /**
  * Reports 'this' application to Banner
  */
 public function reportToBanner()
 {
     PHPWS_Core::initModClass('hms', 'SOAP.php');
     try {
         $soap = SOAP::getInstance(UserStatus::getUsername(), UserStatus::isAdmin() ? SOAP::ADMIN_USER : SOAP::STUDENT_USER);
         $soap->createHousingApp($this->getBannerId(), $this->getTerm());
     } catch (Exception $e) {
         // Send an email notification
         PHPWS_Core::initCoreClass('Mail.php');
         $send_to = array();
         $send_to[] = '*****@*****.**';
         $mail = new PHPWS_Mail();
         $mail->addSendTo($send_to);
         $mail->setFrom(FROM_ADDRESS);
         $mail->setSubject('HMS Application Error!');
         $body = "Username: {$this->getUsername()}\n";
         $mail->setMessageBody($body);
         $mail->send();
         throw $e;
         // rethrow the exception it
     }
     // Log the fact that the application was sent to banner
     PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
     HMS_Activity_Log::log_activity($this->getUsername(), ACTIVITY_APPLICATION_REPORTED, UserStatus::getUsername());
 }