/**
  * Get User Based Cache dir (e.g. /tmp/www-data/your-folder)
  *
  * @param string $folder
  *
  * @return string
  */
 public static function getUserBasedCachedDir($folder = null)
 {
     $path = [sys_get_temp_dir(), SystemUtility::getCurrentUser()];
     if (null !== $folder) {
         $path[] = $folder;
     }
     return implode(DIRECTORY_SEPARATOR, $path);
 }
Exemple #2
0
 private function administration()
 {
     /* Bail out if the user doesn't have SA permissions. */
     if ($this->_realAccessLevel < ACCESS_LEVEL_DEMO && !$_SESSION['CATS']->hasUserCategory('careerportal')) {
         CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
     }
     $systemInfo = new SystemInfo();
     $systemInfoData = $systemInfo->getSystemInfo();
     if (isset($systemInfoData['available_version']) && $systemInfoData['available_version'] > CATSUtility::getVersionAsInteger()) {
         $newVersion = true;
     } else {
         $newVersion = false;
     }
     if (isset($systemInfoData['disable_version_check']) && $systemInfoData['disable_version_check']) {
         $versionCheckPref = false;
     } else {
         $versionCheckPref = true;
     }
     if ($this->_realAccessLevel >= ACCESS_LEVEL_ROOT || $this->_realAccessLevel == ACCESS_LEVEL_DEMO) {
         $systemAdministration = true;
     } else {
         $systemAdministration = false;
     }
     // FIXME: 's' isn't a good variable name.
     if (isset($_GET['s'])) {
         switch ($_GET['s']) {
             case 'siteName':
                 $templateFile = './modules/settings/SiteName.tpl';
                 break;
             case 'newVersionCheck':
                 if (!$systemAdministration) {
                     CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
                     return;
                     //$this->fatal(ERROR_NO_PERMISSION);
                 }
                 $this->_template->assign('versionCheckPref', $versionCheckPref);
                 $this->_template->assign('availableVersion', $systemInfoData['available_version']);
                 $this->_template->assign('newVersion', $newVersion);
                 $this->_template->assign('newVersionNews', NewVersionCheck::getNews());
                 $templateFile = './modules/settings/NewVersionCheck.tpl';
                 break;
             case 'passwords':
                 if (!$systemAdministration) {
                     CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
                     return;
                     //$this->fatal(ERROR_NO_PERMISSION);
                 }
                 $templateFile = './modules/settings/Passwords.tpl';
                 break;
             case 'localization':
                 if ($this->_realAccessLevel < ACCESS_LEVEL_SA) {
                     CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
                     return;
                     //$this->fatal(ERROR_NO_PERMISSION);
                 }
                 $this->_template->assign('timeZone', $_SESSION['CATS']->getTimeZone());
                 $this->_template->assign('isDateDMY', $_SESSION['CATS']->isDateDMY());
                 $templateFile = './modules/settings/Localization.tpl';
                 break;
             case 'systemInformation':
                 if ($this->_realAccessLevel < ACCESS_LEVEL_SA) {
                     CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
                     return;
                     //$this->fatal(ERROR_NO_PERMISSION);
                 }
                 $db = DatabaseConnection::getInstance();
                 $databaseVersion = $db->getRDBMSVersion();
                 $installationDirectory = realpath('./');
                 if (SystemUtility::isWindows()) {
                     $OSType = 'Windows';
                 } else {
                     if (SystemUtility::isMacOSX()) {
                         $OSType = 'Mac OS X';
                     } else {
                         $OSType = 'UNIX';
                     }
                 }
                 $schemaVersions = ModuleUtility::getModuleSchemaVersions();
                 $this->_template->assign('databaseVersion', $databaseVersion);
                 $this->_template->assign('installationDirectory', $installationDirectory);
                 $this->_template->assign('OSType', $OSType);
                 $this->_template->assign('schemaVersions', $schemaVersions);
                 $templateFile = './modules/settings/SystemInformation.tpl';
                 break;
             default:
                 $templateFile = './modules/settings/Administration.tpl';
                 break;
         }
     } else {
         $templateFile = './modules/settings/Administration.tpl';
         /* Load extra settings. */
         $extraSettings = array();
         $modules = ModuleUtility::getModules();
         foreach ($modules as $moduleName => $parameters) {
             $extraSettingsModule = $parameters[MODULE_SETTINGS_ENTRIES];
             if ($extraSettingsModule != false) {
                 foreach ($extraSettingsModule as $extraSettingsModuleData) {
                     if ($extraSettingsModuleData[2] <= $this->_realAccessLevel) {
                         $extraSettings[] = $extraSettingsModuleData;
                     }
                 }
             }
         }
         $this->_template->assign('extraSettings', $extraSettings);
     }
     if (!strcmp($templateFile, './modules/settings/Administration.tpl')) {
         // Highlight certain rows of importance based on criteria
         $candidates = new Candidates($this->_siteID);
         $this->_template->assign('totalCandidates', $candidates->getCount());
     }
     if (!eval(Hooks::get('SETTINGS_DISPLAY_ADMINISTRATION'))) {
         return;
     }
     /* Check if careers website is enabled or can be enabled */
     $careerPortalUnlock = false;
     $careerPortalSettings = new CareerPortalSettings($this->_siteID);
     $cpData = $careerPortalSettings->getAll();
     if (intval($cpData['enabled']) || file_exists('modules/asp') && !$_SESSION['CATS']->isFree() || LicenseUtility::isProfessional()) {
         $careerPortalUnlock = true;
     }
     $this->_template->assign('careerPortalUnlock', $careerPortalUnlock);
     $this->_template->assign('subActive', 'Administration');
     $this->_template->assign('systemAdministration', $systemAdministration);
     $this->_template->assign('active', $this);
     $this->_template->display($templateFile);
 }
Exemple #3
0
 private function addActivityScheduleEvent()
 {
     /* Bail out if we don't have a valid candidate ID. */
     if (!$this->isRequiredIDValid('contactID', $_GET)) {
         CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid contact ID.');
     }
     $contactID = $_GET['contactID'];
     $contacts = new Contacts($this->_siteID);
     $contactData = $contacts->get($contactID);
     $regardingRS = $contacts->getJobOrdersArray($contactID);
     $calendar = new Calendar($this->_siteID);
     $calendarEventTypes = $calendar->getAllEventTypes();
     /* Are we in "Only Schedule Event" mode? */
     $onlyScheduleEvent = $this->isChecked('onlyScheduleEvent', $_GET);
     if (!eval(Hooks::get('CONTACTS_ADD_ACTIVITY_SCHEDULE_EVENT'))) {
         return;
     }
     if (SystemUtility::isSchedulerEnabled() && !$_SESSION['CATS']->isDemo()) {
         $allowEventReminders = true;
     } else {
         $allowEventReminders = false;
     }
     $this->_template->assign('contactID', $contactID);
     $this->_template->assign('regardingRS', $regardingRS);
     $this->_template->assign('allowEventReminders', $allowEventReminders);
     $this->_template->assign('userEmail', $_SESSION['CATS']->getEmail());
     $this->_template->assign('onlyScheduleEvent', $onlyScheduleEvent);
     $this->_template->assign('calendarEventTypes', $calendarEventTypes);
     $this->_template->assign('isFinishedMode', false);
     $this->_template->display('./modules/contacts/AddActivityScheduleEventModal.tpl');
 }
 /**
  * Executes a shell command in a platform-independent way and returns the
  * results in an array containing the exact system command executed, the
  * raw output of that command, and the command's return code.
  *
  * @param string command to execute
  * @return array command results
  */
 private function _executeCommand($command)
 {
     /* Running on Windows? */
     if (SystemUtility::isWindows()) {
         /* Generate a random temp file name. */
         $tempFile = sprintf('%s/%s.txt', realpath(CATS_TEMP_DIR), FileUtility::makeRandomFilename());
         /* Create a new COM Windows Scripting Host Shell object. */
         $WSHShell = new COM('WScript.Shell');
         /* Build the command to execute. */
         $command = sprintf('cmd.exe /C "%s > "%s""', $command, $tempFile);
         /* Execute the command via the Windows Scripting Host Shell. */
         $returnCode = $WSHShell->Run($command, 0, true);
         /* Grab the contents of the temporary file and remove it. */
         $output = file($tempFile);
         @unlink($tempFile);
     } else {
         @exec($command, $output, $returnCode);
     }
     return array('command' => $command, 'output' => $output, 'returnCode' => $returnCode);
 }
Exemple #5
0
                 document.getElementById(\'htmlExecutableOrg\').value = \'' . $html2textWithSlashes . '\';
             </script>';
     }
     if (UNRTF_PATH == '') {
         echo '
             <script type="text/javascript">
                 document.getElementById(\'rtfEnabled\').checked = false;
                 document.getElementById(\'rtfExecutable\').disabled = true;
                 document.getElementById(\'rtfExecutable\').value = \'\';
                 document.getElementById(\'rtfExecutableOrg\').value = \'\';
             </script>';
     } else {
         $unrtfWithSlashes = str_replace('\\', '\\\\', UNRTF_PATH);
         include_once 'lib/SystemUtility.php';
         /* Change Windows default command to UNIX default command hack. */
         if (strpos(strtolower($unrtfWithSlashes), "c:\\") === 0 && !SystemUtility::isWindows()) {
             $unrtfWithSlashes = '/usr/bin/unrtf';
         }
         echo '
             <script type="text/javascript">
                 document.getElementById(\'rtfEnabled\').checked = true;
                 document.getElementById(\'rtfExecutable\').disabled = false;
                 document.getElementById(\'rtfExecutable\').value = \'' . $unrtfWithSlashes . '\';
                 document.getElementById(\'rtfExecutableOrg\').value = \'' . $unrtfWithSlashes . '\';
             </script>';
     }
     echo '<script type="text/javascript">showTextBlock(\'resumeParsing\');</script>';
     break;
 case 'testResumeParsing':
     echo '
         <script type="text/javascript">
Exemple #6
0
    public function showCalendar()
    {
        $currentHour     = DateUtility::getAdjustedDate('H');
        $currentDay      = DateUtility::getAdjustedDate('j');
        $currentMonth    = DateUtility::getAdjustedDate('n');
        $currentYear     = DateUtility::getAdjustedDate('Y');
        $currentUnixTime = DateUtility::getAdjustedDate();
        $currentDateMDY  = DateUtility::getAdjustedDate('m-d-y');

        $currentWeek  = DateUtility::getWeekNumber($currentUnixTime) - DateUtility::getWeekNumber(
            mktime(0, 0, 0, $currentMonth, 1, $currentYear)
        );

        /* Do we have a valid date argument? If a month was specified and
         * isn't valid, fatal() out. If none was specified, use the current
         * month.
         */
        if ($this->isRequiredIDValid('month', $_GET) &&
            $this->isRequiredIDValid('year', $_GET))
        {
            $month = $_GET['month'];
            $year  = $_GET['year'];

            if (!checkdate($month, 1, $year))
            {
                CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid date.');
            }

            if ($month == $currentMonth && $year == $currentYear)
            {
                $isCurrentMonth = true;
            }
            else
            {
                $isCurrentMonth = false;
            }
        }
        else
        {
            $month = $currentMonth;
            $year  = $currentYear;
            $isCurrentMonth = true;
        }

        if (isset($_GET['view']))
        {
            $view = $_GET['view'];
        }
        else
        {
            $view = 'DEFAULT_VIEW';
        }

        if (isset($_GET['week']))
        {
            $week = $_GET['week'];
        }
        else
        {
            $week = $currentWeek+1;
        }

        if (isset($_GET['day']))
        {
            $day = $_GET['day'];
        }
        else
        {
            $day = $currentDay;
        }

        if (isset($_GET['showEvent']))
        {
            $showEvent = $_GET['showEvent'];
        }
        else
        {
            $showEvent = null;
        }

        $userIsSuperUser = ($this->_accessLevel < ACCESS_LEVEL_SA ? 0 : 1);
        if ($userIsSuperUser && isset($_GET['superuser']) && $_GET['superuser'] == 1)
        {
            $superUserActive = true;
        }
        else
        {
            $superUserActive = false;
        }

        $startingWeekday = DateUtility::getStartingWeekday($month, $year);
        $daysInMonth     = DateUtility::getDaysInMonth($month, $year);

        $calendar = new Calendar($this->_siteID);

        $monthBefore = $month - 1;
        $monthAfter  = $month + 1;
        $yearBefore  = $year;
        $yearAfter   = $year;

        if ($monthAfter > 12)
        {
            $monthAfter = 1;
            $yearAfter = $year + 1;
        }

        if ($monthBefore < 1)
        {
            $monthBefore = 12;
            $yearBefore = $year - 1;
        }

        $eventsStringNow = $calendar->makeEventString(
            $calendar->getEventArray($month, $year),
            $month,
            $year
        );

        $eventsStringBefore = $calendar->makeEventString(
            $calendar->getEventArray($monthBefore, $yearBefore),
            $monthBefore,
            $yearBefore
        );

        $eventsStringAfter = $calendar->makeEventString(
            $calendar->getEventArray($monthAfter, $yearAfter),
            $monthAfter,
            $yearAfter
        );

        $eventsString = implode(
            '@',
            array($eventsStringNow, $eventsStringBefore, $eventsStringAfter, $userIsSuperUser)
        );

        /* Textual representation of the month and year. */
        $dateString = date(
            'F Y',
            mktime($_SESSION['CATS']->getTimeZoneOffset(), 0, 0, $month, 1, $year)
        );

        /* The offset is the number of days after the first Sunday on a given
         * calendar page on which the 1st of the month falls. We subtract 1
         * because Sunday has a value of 1.
         */
        $startingOffset = $startingWeekday - 1;

        $userEmail = $_SESSION['CATS']->getEmail();

        $calendarEventTypes = $calendar->getAllEventTypes();

        $calendarSettings = new CalendarSettings($this->_siteID);
        $calendarSettingsRS = $calendarSettings->getAll();

        if ($view == 'DEFAULT_VIEW')
        {
            $view = $calendarSettingsRS['calendarView'];
        }

        $summaryHTML = $calendar->getUpcomingEventsHTML(12, UPCOMING_FOR_CALENDAR);

        if (!eval(Hooks::get('CALENDAR_SHOW'))) return;

        if (SystemUtility::isSchedulerEnabled() && !$_SESSION['CATS']->isDemo())
        {
            $allowEventReminders = true;
        }
        else
        {
            $allowEventReminders = false;
        }

        /* FIXME: Configurable */
        $this->_template->assign('dayHourStart', $calendarSettingsRS['dayStart']);
        $this->_template->assign('dayHourEnd', $calendarSettingsRS['dayStop']);
        $this->_template->assign('firstDayMonday', $calendarSettingsRS['firstDayMonday']);
        $this->_template->assign('allowAjax', ($calendarSettingsRS['noAjax'] == 0 ? true : false));
        $this->_template->assign('defaultPublic', ($calendarSettingsRS['defaultPublic'] == 0 ? 'false' : 'true'));
        $this->_template->assign('militaryTime', false);

        $this->_template->assign('active', $this);
        $this->_template->assign('currentDateMDY', $currentDateMDY);
        $this->_template->assign('startingWeekday', $startingWeekday);
        $this->_template->assign('daysInMonth', $daysInMonth);
        $this->_template->assign('currentHour', $currentHour);
        $this->_template->assign('currentDay', $currentDay);
        $this->_template->assign('currentMonth', $currentMonth);
        $this->_template->assign('currentYear', $currentYear);
        $this->_template->assign('startingOffset', $startingOffset);
        $this->_template->assign('userEmail', $userEmail);
        $this->_template->assign('userID', $this->_userID);
        $this->_template->assign('userEmail', $_SESSION['CATS']->getEmail());
        $this->_template->assign('summaryHTML', $summaryHTML);
        $this->_template->assign('userIsSuperUser', $userIsSuperUser);
        $this->_template->assign('superUserActive', $superUserActive);
        $this->_template->assign('calendarEventTypes', $calendarEventTypes);
        $this->_template->assign('view', $view);
        $this->_template->assign('day', $day);
        $this->_template->assign('week', $week);
        $this->_template->assign('month', $month);
        $this->_template->assign('year', $year);
        $this->_template->assign('showEvent', $showEvent);
        $this->_template->assign('dateString', $dateString);
        $this->_template->assign('isCurrentMonth', $isCurrentMonth);
        $this->_template->assign('eventsString', $eventsString);
        $this->_template->assign('allowEventReminders', $allowEventReminders);
        $this->_template->display('./modules/calendar/Calendar.php');
    }
 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');
 }
 /**
  * Attempts to convert a document document to plain text.
  *
  * @param string file name
  * @param flag document type
  * @return boolean True if successful; false otherwise.ful
  */
 public function convert($fileName, $documentType)
 {
     /* (Re?)initialize variables. */
     $this->_linesArray = array();
     $this->_linesString = '';
     $this->_rawOutput = '';
     $this->_fileName = $fileName;
     /* If we are trying to parse a DOC file, is it really a DOC file or is
      * it an RTF file?
      */
     if ($documentType == DOCUMENT_TYPE_DOC) {
         $handle = @fopen(realpath($fileName), 'r');
         if ($handle) {
             $header = fread($handle, 5);
             fclose($handle);
             if ($header == '{\\rtf') {
                 $documentType = DOCUMENT_TYPE_RTF;
             }
         }
     }
     /* Find the absolute path to the filename and escape it for use in a
      * system command.
      */
     //$escapedFilename = escapeshellarg(realpath($fileName));
     $nativeEncoding = "";
     $command = false;
     /* Use different methods to extract text depending on the type of document. */
     switch ($documentType) {
         case DOCUMENT_TYPE_DOC:
             if (ANTIWORD_PATH != '') {
                 $escapedFilename = escapeshellarg(realpath($fileName));
                 $nativeEncoding = 'ISO-8859-1';
                 $command = '"' . ANTIWORD_PATH . '" -m ' . ANTIWORD_MAP . ' ' . $escapedFilename;
             }
             break;
         case DOCUMENT_TYPE_DOCX:
             break;
         case DOCUMENT_TYPE_PDF:
             if (PDFTOTEXT_PATH != '') {
                 $escapedFilename = escapeshellarg(realpath($fileName));
                 $nativeEncoding = 'ISO-8859-1';
                 $convertEncoding = false;
                 $command = '"' . PDFTOTEXT_PATH . '" -layout ' . $escapedFilename . ' -';
             }
             break;
         case DOCUMENT_TYPE_HTML:
             if (HTML2TEXT_PATH != '') {
                 $escapedFilename = escapeshellarg(realpath($fileName));
                 $nativeEncoding = 'ISO-8859-1';
                 $convertEncoding = false;
                 if (SystemUtility::isWindows()) {
                     $command = 'TYPE ' . $escapedFilename . ' | "' . HTML2TEXT_PATH . '" -nobs ';
                 } else {
                     $command = '"' . HTML2TEXT_PATH . '" -nobs ' . $escapedFilename;
                 }
             }
             break;
         case DOCUMENT_TYPE_TEXT:
             return $this->_readTextFile($fileName);
             break;
         case DOCUMENT_TYPE_RTF:
             if (HTML2TEXT_PATH == '') {
                 $this->_setError('The HTML format has not been configured, which is required for the RTF format.');
                 return false;
             }
             if (UNRTF_PATH == '') {
                 $this->_setError('The RTF format has not been configured.');
                 return false;
             }
             $escapedFilename = escapeshellarg(realpath($fileName));
             $nativeEncoding = 'ISO-8859-1';
             $convertEncoding = false;
             $command = '"' . UNRTF_PATH . '" ' . $escapedFilename . ' | "' . HTML2TEXT_PATH . '" -nobs ';
             break;
         case DOCUMENT_TYPE_ODT:
             $this->_setError('The ODT format is not yet supported by CATS.');
             return false;
             break;
         case DOCUMENT_TYPE_UNKNOWN:
         default:
             $this->_setError('This file format is unknown format and is not yet supported by CATS.');
             return false;
             break;
     }
     if ($command === false) {
         $docObj = new DocumentReader($fileName, $documentType);
         if ($text = $docObj->convertToText()) {
             $commandResult = array('command' => "", 'output' => array($text), 'returnCode' => 0);
         } else {
             $commandResult = array('command' => "", 'output' => "", 'returnCode' => 1);
         }
     } else {
         /* Run the text converter. */
         exec($command, $output, $returnCode);
         if ($returnCode !== 0) {
             $docObj = new DocumentReader($fileName, $documentType);
             //$docObj = new Filetotext("test.pdf");
             if ($text = $docObj->convertToText()) {
                 $commandResult = array('command' => "", 'output' => array($text), 'returnCode' => 0);
             } else {
                 $commandResult = array('command' => "", 'output' => "", 'returnCode' => 1);
             }
         } else {
             $commandResult = array('command' => $command, 'output' => $output, 'returnCode' => $returnCode);
         }
     }
     //$commandResult = $this->_executeCommand($command);
     /* Store the return code for getReturnCode(). */
     $this->_returnCode = $commandResult['returnCode'];
     /* Store the raw output for getRawOutput(). */
     $commandResult['output'] = array_map('rtrim', $commandResult['output']);
     $this->_rawOutput = implode("\n", $commandResult['output']);
     /* Fix encoding issues. */
     if ($nativeEncoding == 'ISO-8859-1' && function_exists('iconv')) {
         $this->_rawOutput = iconv($nativeEncoding, 'UTF-8', $this->_rawOutput);
     }
     /* If command returned non-zero or output is not an array, assume
      * failure.
      */
     if ($commandResult['returnCode'] != 0 || !is_array($commandResult['output'])) {
         return false;
     }
     /* Store the output in string and array form. */
     $this->_linesArray = $commandResult['output'];
     $this->_linesString = $this->_rawOutput;
     return true;
 }
 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->isOptionalIDValid('jobOrderID', $_GET)) {
         CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid job order ID.');
     }
     $selectedJobOrderID = $_GET['jobOrderID'];
     $candidateID = $_GET['candidateID'];
     $candidates = new Candidates($this->_siteID);
     $candidateData = $candidates->get($candidateID);
     /* Bail out if we got an empty result set. */
     if (empty($candidateData)) {
         CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this);
         return;
         /*$this->fatalModal(
               'The specified candidate ID could not be found.'
           );*/
     }
     $pipelines = new Pipelines($this->_siteID);
     $pipelineRS = $pipelines->getCandidatePipeline($candidateID);
     $statusRS = $pipelines->getStatusesForPicking();
     if ($selectedJobOrderID != -1) {
         $selectedStatusID = ResultSetUtility::getColumnValueByIDValue($pipelineRS, 'jobOrderID', $selectedJobOrderID, 'statusID');
     } else {
         $selectedStatusID = -1;
     }
     /* 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 = '1';
     } 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'], $candidateData['firstName'], $candidateData['firstName']);
     $statusChangeTemplate = str_replace($stringsToFind, $replacementStrings, $statusChangeTemplate);
     /* Are we in "Only Schedule Event" mode? */
     $onlyScheduleEvent = $this->isChecked('onlyScheduleEvent', $_GET);
     $calendar = new Calendar($this->_siteID);
     $calendarEventTypes = $calendar->getAllEventTypes();
     if (!eval(Hooks::get('CANDIDATE_ADD_ACTIVITY_CHANGE_STATUS'))) {
         return;
     }
     if (SystemUtility::isSchedulerEnabled() && !$_SESSION['CATS']->isDemo()) {
         $allowEventReminders = true;
     } else {
         $allowEventReminders = false;
     }
     $this->_template->assign('candidateID', $candidateID);
     $this->_template->assign('pipelineRS', $pipelineRS);
     $this->_template->assign('statusRS', $statusRS);
     $this->_template->assign('selectedJobOrderID', $selectedJobOrderID);
     $this->_template->assign('selectedStatusID', $selectedStatusID);
     $this->_template->assign('allowEventReminders', $allowEventReminders);
     $this->_template->assign('userEmail', $_SESSION['CATS']->getEmail());
     $this->_template->assign('calendarEventTypes', $calendarEventTypes);
     $this->_template->assign('statusChangeTemplate', $statusChangeTemplate);
     $this->_template->assign('onlyScheduleEvent', $onlyScheduleEvent);
     $this->_template->assign('emailDisabled', $emailDisabled);
     $this->_template->assign('isFinishedMode', false);
     $this->_template->assign('isJobOrdersMode', false);
     $this->_template->display('./modules/candidates/AddActivityChangeStatusModal.tpl');
 }