コード例 #1
0
ファイル: Mailer.php プロジェクト: Hassanj343/candidats
 public function __construct($siteID, $userID = -1)
 {
     $this->_siteID = $siteID;
     $this->_mailer = new PHPMailer();
     $this->_mailer->PluginDir = './lib/phpmailer/';
     /* Load mailer configuration settings. */
     $settings = new MailerSettings($this->_siteID);
     $this->_settings = $settings->getAll();
     /* Configure PHPMailer based on CATS configuration settings. */
     $this->refreshSettings();
     $this->_mailer->SetLanguage('en', './lib/phpmailer/language/');
     /* Stuff for E-Mail logging. */
     // FIXME: Do this in the UserInterface. Session dependencied in
     //        libraries are bad.
     if ($userID != -1) {
         $this->_userID = $userID;
     } else {
         $this->_userID = $_SESSION['CATS']->getUserID();
     }
     $this->_db = DatabaseConnection::getInstance();
 }
コード例 #2
0
ファイル: Users.php プロジェクト: Hassanj343/candidats
    public function sendEMail($subject, $body, $isHTML = false,
        $logMessage = true, $replyTo = array(), $wrapLinesAt = 78,
        $signature = true)
    {
        $arrEmailData=array();
        $arrEmailData["id"]=$this->user_id;

        $arrEmailData["email"][]=array("email"=>$this->email,"name"=>$this->first_name." ".$this->last_name);
        $settings = new MailerSettings($this->_siteID);
        $settings_config = $settings->getAll();
        $mailer = new Mailer($this->_siteID);
        return $mailer->send(
            array($settings_config['fromAddress'], ''),
            $arrEmailData,
            $subject,
            $body,
            $isHTML,
            $logMessage,
            $replyTo,
            $wrapLinesAt,
            $signature,
            "users"
        );
    }
コード例 #3
0
ファイル: SettingsUI.php プロジェクト: rankinp/OpenCATS
 private function newInstallFinished()
 {
     NewVersionCheck::checkForUpdate();
     $accessLevel = $_SESSION['CATS']->getAccessLevel();
     $mailerSettings = new MailerSettings($this->_siteID);
     $mailerSettingsRS = $mailerSettings->getAll();
     $this->_template->assign('inputType', 'conclusion');
     $this->_template->assign('title', 'Settings Saved');
     if ($mailerSettingsRS['configured'] == '0' && $accessLevel >= ACCESS_LEVEL_SA) {
         $this->_template->assign('prompt', 'Your site name has been saved. This concludes the required CATS configuration wizard.<BR><BR><span style="font-weight: bold;">Warning:</span><BR><BR> E-mail features are disabled. In order to enable e-mail features (such as e-mail notifications), please configure your e-mail settings by clicking on the Settings tab and then clicking on Administration.');
     } else {
         $this->_template->assign('prompt', 'Your site name has been saved. This concludes the required CATS configuration wizard.');
     }
     $this->_template->assign('action', $this->getAction());
     $this->_template->assign('home', 'home');
     $this->_template->display('./modules/settings/NewInstallWizard.tpl');
 }
コード例 #4
0
}
$testEmailAddress = $_REQUEST['testEmailAddress'];
$fromAddress = $_REQUEST['fromAddress'];
/* Is the test e-mail address specified valid? */
// FIXME: Validate properly.
if (strpos($testEmailAddress, '@') === false) {
    $interface->outputXMLErrorPage(-2, 'Invalid test e-mail address.');
    die;
}
/* Is the from e-mail address specified valid? */
// FIXME: Validate properly.
if (strpos($fromAddress, '@') === false) {
    $interface->outputXMLErrorPage(-2, 'Invalid from e-mail address.');
    die;
}
$mailerSettings = new MailerSettings($siteID);
$mailerSettingsRS = $mailerSettings->getAll();
$mailer = new Mailer($siteID);
$mailer->overrideSetting('fromAddress', $fromAddress);
$mailerStatus = $mailer->sendToOne(array($testEmailAddress, ''), 'CATS Test E-Mail', 'This is a CATS test e-mail in HTML format.', true);
if (!$mailerStatus) {
    $interface->outputXMLErrorPage(-2, $mailer->getError());
    die;
}
$errorMessage = $mailer->getError();
if (!empty($errorMessage)) {
    $interface->outputXMLErrorPage(-2, $errorMessage);
    die;
}
/* Send back the XML data. */
$interface->outputXMLSuccessPage();
コード例 #5
0
 /**
  * Returns all relevent template data for a given e-mail template title.
  *
  * @param string e-mail template Title
  * @return array e-mail template data
  */
 public function getByTag($emailTemplateTag)
 {
     $sql = sprintf("SELECT\n                email_template.email_template_id AS emailTemplateID,\n                email_template.title AS emailTemplateTitle,\n                email_template.tag AS emailTemplateTag,\n                email_template.text AS text,\n                email_template.possible_variables AS possibleVariables,\n                email_template.allow_substitution AS allowSubstitution,\n                email_template.disabled AS disabled\n            FROM\n                email_template\n            WHERE\n                email_template.tag = %s\n            AND\n                email_template.site_id = %s", $this->_db->makeQueryStringOrNULL($emailTemplateTag), $this->_siteID);
     $rs = $this->_db->getAssoc($sql);
     if (!empty($rs)) {
         $mailerSettings = new MailerSettings($this->_siteID);
         $mailerSettingsRS = $mailerSettings->getAll();
         if ($mailerSettingsRS['configured'] == '0' || MAIL_MAILER == 0 || isset($rs['disabled']) && $rs['disabled'] == '1') {
             $rs['disabled'] = '1';
         } else {
             $rs['disabled'] = '0';
         }
         $rs['textReplaced'] = $this->replaceVariables($rs['text']);
     }
     return $rs;
 }
コード例 #6
0
ファイル: LoginUI.php プロジェクト: PublicityPort/OpenCATS
    private function attemptLogin()
    {
        //FIXME: getTrimmedInput()!
        if (isset($_POST['siteName'])) {
            $siteName = $_POST['siteName'];
        } else {
            $siteName = '';
        }
        if (!isset($_POST['username']) || !isset($_POST['password'])) {
            $message = 'Invalid username or password.';
            if (isset($_GET['reloginVars'])) {
                $this->_template->assign('reloginVars', urlencode($_GET['reloginVars']));
            } else {
                $this->_template->assign('reloginVars', '');
            }
            $site = new Site(-1);
            $rs = $site->getSiteByUnixName($siteName);
            if (isset($rs['name'])) {
                $siteNameFull = $rs['name'];
            } else {
                $siteNameFull = $siteName;
            }
            $this->_template->assign('aspMode', false);
            if (!eval(Hooks::get('LOGIN_NO_CREDENTIALS'))) {
                return;
            }
            $this->_template->assign('message', $message);
            $this->_template->assign('messageSuccess', false);
            $this->_template->assign('siteName', $siteName);
            $this->_template->assign('siteNameFull', $siteNameFull);
            $this->_template->assign('dateString', date('l, F jS, Y'));
            if (ModuleUtility::moduleExists("asp")) {
                $this->_template->display('./modules/asp/AspLogin.tpl');
            } else {
                $this->_template->display('./modules/login/Login.tpl');
            }
            return;
        }
        $username = $this->getTrimmedInput('username', $_POST);
        $password = $this->getTrimmedInput('password', $_POST);
        if (strpos($username, '@') !== false) {
            $siteName = '';
        }
        if ($siteName != '') {
            $site = new Site(-1);
            $rs = $site->getSiteByUnixName($siteName);
            if (isset($rs['siteID'])) {
                $username .= '@' . $rs['siteID'];
            }
        }
        /* Make a blind attempt at logging the user in. */
        $_SESSION['CATS']->processLogin($username, $password);
        /* If unsuccessful, take the user back to the login page. */
        if (!$_SESSION['CATS']->isLoggedIn()) {
            $message = $_SESSION['CATS']->getLoginError();
            if (isset($_GET['reloginVars'])) {
                $this->_template->assign('reloginVars', urlencode($_GET['reloginVars']));
            } else {
                $this->_template->assign('reloginVars', '');
            }
            $site = new Site(-1);
            $rs = $site->getSiteByUnixName($siteName);
            if (isset($rs['name'])) {
                $siteNameFull = $rs['name'];
            } else {
                $siteNameFull = $siteName;
            }
            $this->_template->assign('aspMode', false);
            if (!eval(Hooks::get('LOGIN_UNSUCCESSFUL'))) {
                return;
            }
            $this->_template->assign('message', $message);
            $this->_template->assign('messageSuccess', false);
            $this->_template->assign('siteName', $siteName);
            $this->_template->assign('siteNameFull', $siteNameFull);
            $this->_template->assign('dateString', date('l, F jS, Y'));
            if (ModuleUtility::moduleExists("asp")) {
                $this->_template->display('./modules/asp/AspLogin.tpl');
            } else {
                $this->_template->display('./modules/login/Login.tpl');
            }
            return;
        }
        $systemInfoDb = new SystemInfo();
        $accessLevel = $_SESSION['CATS']->getAccessLevel();
        $mailerSettings = new MailerSettings($_SESSION['CATS']->getSiteID());
        $mailerSettingsRS = $mailerSettings->getAll();
        /***************************** BEGIN NEW WIZARD *****************************************/
        /**
         * Improved setup wizard using the Wizard library. If the user succeeds,
         * all old-style wizards will no longer be shown.
         */
        $wizard = new Wizard(CATSUtility::getIndexName() . '?m=home', './js/wizardIntro.js');
        if ($_SESSION['CATS']->isFirstTimeSetup()) {
            $wizard->addPage('Welcome!', './modules/login/wizard/Intro.tpl', '', false, true);
        }
        if (!$_SESSION['CATS']->isAgreedToLicense()) {
            $phpeval = '';
            if (!eval(Hooks::get('LICENSE_TERMS'))) {
                return;
            }
            $wizard->addPage('License', './modules/login/wizard/License.tpl', $phpeval, true, true);
        }
        if (!file_exists('modules/asp') || defined('CATS_TEST_MODE') && CATS_TEST_MODE) {
            // On-site wizard pages
            if (!LicenseUtility::isLicenseValid()) {
                if (defined('LICENSE_KEY') && LICENSE_KEY == '') {
                    $template = 'Register.tpl';
                    $templateName = 'Register';
                } else {
                    $template = 'Reregister.tpl';
                    $templateName = 'License Expired';
                }
                $wizard->addPage($templateName, './modules/login/wizard/' . $template, '', false, true);
            }
        }
        // if logged in for the first time, change password
        if (strtolower($username) == 'admin' && $password === DEFAULT_ADMIN_PASSWORD) {
            $wizard->addPage('Password', './modules/login/wizard/Password.tpl', '', false, true);
        }
        // make user set an e-mail address
        if (trim($_SESSION['CATS']->getEmail()) == '') {
            $wizard->addPage('E-mail', './modules/login/wizard/Email.tpl', '', false, true);
        }
        // if no site name set, make user set site name
        if ($accessLevel >= ACCESS_LEVEL_SA && $_SESSION['CATS']->getSiteName() === 'default_site') {
            $wizard->addPage('Site', './modules/login/wizard/SiteName.tpl', '', false, true);
        }
        // CATS Hosted Wizard Pages
        if (!eval(Hooks::get('ASP_WIZARD_PAGES'))) {
            return;
        }
        if ($_SESSION['CATS']->isFirstTimeSetup()) {
            $wizard->addPage('Setup Users', './modules/login/wizard/Users.tpl', '
                $users = new Users($siteID);
                $mp = $users->getAll();
                $data = $users->getLicenseData();

                $this->_template->assign(\'users\', $mp);
                $this->_template->assign(\'totalUsers\', $data[\'totalUsers\']);
                $this->_template->assign(\'userLicenses\', $data[\'userLicenses\']);
                $this->_template->assign(\'accessLevels\', $users->getAccessLevels());
            ');
            if (!eval(Hooks::get('ASP_WIZARD_IMPORT'))) {
                return;
            }
        }
        // The wizard will not display if no pages have been added.
        $wizard->doModal();
        /******************************* END NEW WIZARD *******************************************/
        /* Session is logged in, do we need to send the user to the wizard?
         * This should be done only on the first use, indicated by the
         * admin user's password still being set to the default.
         */
        /* If we have a specific page to go to, go there. */
        /* These hooks are for important things, like disabling the site based on criteria. */
        if (!eval(Hooks::get('LOGGED_IN'))) {
            return;
        }
        if (isset($_GET['reloginVars'])) {
            CATSUtility::transferRelativeURI($_GET['reloginVars']);
        }
        /* LOGGED_IN_MESSAGES hooks are only for messages which show up on initial login (warnings, etc) */
        if (!eval(Hooks::get('LOGGED_IN_MESSAGES'))) {
            return;
        } else {
            if ($accessLevel >= ACCESS_LEVEL_SA && $mailerSettingsRS['configured'] == '0') {
                NewVersionCheck::checkForUpdate();
                $this->_template->assign('inputType', 'conclusion');
                $this->_template->assign('title', 'E-Mail Disabled');
                $this->_template->assign('prompt', 'E-mail features are disabled. In order to enable e-mail features (such as e-mail notifications), please configure your e-mail settings by clicking on the Settings tab and then clicking on Administration.');
                $this->_template->assign('action', $this->getAction());
                $this->_template->assign('home', 'home');
                $this->_template->display('./modules/settings/NewInstallWizard.tpl');
            } else {
                if (!eval(Hooks::get('LOGGED_IN_HOME_PAGE'))) {
                    return;
                }
                CATSUtility::transferRelativeURI('m=home');
            }
        }
    }
コード例 #7
0
 private function addActivityChangeStatus()
 {
     /* Bail out if we don't have a valid candidate ID. */
     if (!$this->isRequiredIDValid('candidateID', $_GET)) {
         CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid candidate ID.');
     }
     /* Bail out if we don't have a valid job order ID. */
     if (!$this->isRequiredIDValid('jobOrderID', $_GET)) {
         CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid job order ID.');
     }
     $candidateID = $_GET['candidateID'];
     $jobOrderID = $_GET['jobOrderID'];
     $candidates = new Candidates($this->_siteID);
     $candidateData = $candidates->get($candidateID);
     /* Bail out if we got an empty result set. */
     if (empty($candidateData)) {
         CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'The specified candidate ID could not be found.');
     }
     $pipelines = new Pipelines($this->_siteID);
     $pipelineData = $pipelines->get($candidateID, $jobOrderID);
     /* Bail out if we got an empty result set. */
     if (empty($pipelineData)) {
         CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'The specified pipeline entry could not be found.');
     }
     $statusRS = $pipelines->getStatusesForPicking();
     $selectedStatusID = $pipelineData['statusID'];
     /* Override default send email behavior with site specific send email behavior. */
     $mailerSettings = new MailerSettings($this->_siteID);
     $mailerSettingsRS = $mailerSettings->getAll();
     $candidateJoborderStatusSendsMessage = unserialize($mailerSettingsRS['candidateJoborderStatusSendsMessage']);
     foreach ($statusRS as $index => $status) {
         $statusRS[$index]['triggersEmail'] = $candidateJoborderStatusSendsMessage[$status['statusID']];
     }
     /* Get the change status email template. */
     $emailTemplates = new EmailTemplates($this->_siteID);
     $statusChangeTemplateRS = $emailTemplates->getByTag('EMAIL_TEMPLATE_STATUSCHANGE');
     if (empty($statusChangeTemplateRS) || empty($statusChangeTemplateRS['textReplaced'])) {
         $statusChangeTemplate = '';
         $emailDisabled = $statusChangeTemplateRS['disabled'];
     } else {
         $statusChangeTemplate = $statusChangeTemplateRS['textReplaced'];
         $emailDisabled = $statusChangeTemplateRS['disabled'];
     }
     /* Replace e-mail template variables. '%CANDSTATUS%', '%JBODTITLE%',
      * '%JBODCLIENT%' are replaced by JavaScript.
      */
     $stringsToFind = array('%CANDOWNER%', '%CANDFIRSTNAME%', '%CANDFULLNAME%');
     $replacementStrings = array($candidateData['ownerFullName'], $candidateData['firstName'], $candidateData['firstName'] . ' ' . $candidateData['lastName']);
     $statusChangeTemplate = str_replace($stringsToFind, $replacementStrings, $statusChangeTemplate);
     $calendar = new Calendar($this->_siteID);
     $calendarEventTypes = $calendar->getAllEventTypes();
     if (SystemUtility::isSchedulerEnabled() && !$_SESSION['CATS']->isDemo()) {
         $allowEventReminders = true;
     } else {
         $allowEventReminders = false;
     }
     $this->_template->assign('candidateID', $candidateID);
     $this->_template->assign('pipelineData', $pipelineData);
     $this->_template->assign('statusRS', $statusRS);
     $this->_template->assign('selectedJobOrderID', $jobOrderID);
     $this->_template->assign('selectedStatusID', $selectedStatusID);
     $this->_template->assign('calendarEventTypes', $calendarEventTypes);
     $this->_template->assign('allowEventReminders', $allowEventReminders);
     $this->_template->assign('userEmail', $_SESSION['CATS']->getEmail());
     $this->_template->assign('onlyScheduleEvent', false);
     $this->_template->assign('statusChangeTemplate', $statusChangeTemplate);
     $this->_template->assign('emailDisabled', $emailDisabled);
     $this->_template->assign('isFinishedMode', false);
     $this->_template->assign('isJobOrdersMode', true);
     if (!eval(Hooks::get('JO_ADD_ACTIVITY_CHANGE_STATUS'))) {
         return;
     }
     $this->_template->display('./modules/candidates/AddActivityChangeStatusModal.tpl');
 }
コード例 #8
0
ファイル: Modules.php プロジェクト: Hassanj343/candidats
 public function sendEMail($userID, $destination, $subject, $body, $isHTML = false, $logMessage = true, $replyTo = array(), $wrapLinesAt = 78, $signature = true)
 {
     $arrEmailData = array();
     $arrEmailData["id"] = $this->getModuleID();
     if ($this->module == "candidates") {
         $arrEmailData["email"][] = array("email" => $destination, "name" => $this->first_name . " " . $this->last_name);
     } else {
         if ($this->module == "contact") {
             $arrEmailData["email"][] = array("email" => $destination, "name" => $this->first_name . " " . $this->last_name);
         } else {
             $arrEmailData["email"][] = array("email" => $destination, "name" => $destination);
         }
     }
     $settings = new MailerSettings($this->_siteID);
     $settings_config = $settings->getAll();
     $mailer = new Mailer($this->_siteID, $userID);
     return $mailer->send(array($settings_config['fromAddress'], ''), $arrEmailData, $subject, $body, $isHTML, $logMessage, $replyTo, $wrapLinesAt, $signature, $this->module);
 }