private function onDeleteAttachment() { if ($this->_accessLevel < ACCESS_LEVEL_DELETE) { $this->listByView('Invalid user level for action.'); return; } /* Bail out if we don't have a valid attachment ID. */ if (!$this->isRequiredIDValid('attachmentID', $_GET)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid attachment ID.'); } /* Bail out if we don't have a valid joborder ID. */ if (!$this->isRequiredIDValid('companyID', $_GET)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid company ID.'); } $companyID = $_GET['companyID']; $attachmentID = $_GET['attachmentID']; if (!eval(Hooks::get('CLIENTS_ON_DELETE_ATTACHMENT_PRE'))) { return; } $attachments = new Attachments($this->_siteID); $attachments->delete($attachmentID); if (!eval(Hooks::get('CLIENTS_ON_DELETE_ATTACHMENT_POST'))) { return; } CATSUtility::transferRelativeURI('m=companies&a=show&companyID=' . $companyID); }
public function emailContacts() { Logger::getLogger("AuieoATS")->info("emailContacts:start"); if ($this->_accessLevel == ACCESS_LEVEL_DEMO) { CommonErrors::fatal(COMMONERROR_PERMISSION, $this, 'Sorry, but demo accounts are not allowed to send e-mails.'); } if(isset($_REQUEST["idlist"])) { $db = DatabaseConnection::getInstance(); $idlist=trim($_REQUEST["idlist"]); $rs = $db->getAllAssoc(sprintf( 'SELECT contact_id, email1, email2 ' . 'FROM contact ' . 'WHERE contact_id IN (%s)', $idlist )); $emailTemplates = new EmailTemplates($this->_siteID); $emailTemplatesRS = $emailTemplates->getAll(); $this->_template->assign('emailTemplatesRS', $emailTemplatesRS); $this->_template->assign('active', $this); $this->_template->assign('success', false); $this->_template->assign('recipients', $rs); $this->_template->display('./modules/contacts/emailContacts.php'); } else { $dataGrid = DataGrid::getFromRequest(); $contactIDs = $dataGrid->getExportIDs(); /* Validate each ID */ foreach ($contactIDs as $index => $contactID) { if (!$this->isRequiredIDValid($index, $contactIDs)) { Logger::getLogger("AuieoATS")->error("Invalid contact ID."); CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid contact ID.'); return; } } $db_str = implode(", ", $contactIDs); $db = DatabaseConnection::getInstance(); $rs = $db->getAllAssoc(sprintf( 'SELECT contact_id, email1, email2 ' . 'FROM contact ' . 'WHERE contact_id IN (%s)', $db_str )); //$this->_template->assign('privledgedUser', $privledgedUser); $emailTemplates = new EmailTemplates($this->_siteID); $emailTemplatesRS = $emailTemplates->getAll(); $this->_template->assign('emailTemplatesRS', $emailTemplatesRS); $this->_template->assign('active', $this); $this->_template->assign('success', false); $this->_template->assign('recipients', $rs); $this->_template->display('./modules/contacts/emailContacts.php'); } Logger::getLogger("AuieoATS")->info("emailContacts:end"); }
/** * Processes an Add Activity / Schedule Event form and displays * contacts/AddActivityScheduleEventModal.tpl. This is factored out * for code clarity. * * @param boolean from joborders module perspective * @param integer "regarding" job order ID or -1 * @param string module directory * @return void */ private function _addActivityScheduleEvent($regardingID, $directoryOverride = '') { /* Module directory override for fatal() calls. */ if ($directoryOverride != '') { $moduleDirectory = $directoryOverride; } else { $moduleDirectory = $this->_moduleDirectory; } /* Bail out if we don't have a valid candidate ID. */ if (!$this->isRequiredIDValid('contactID', $_POST)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid contact ID.'); } $contactID = $_POST['contactID']; //if (!eval(Hooks::get('CONTACT_ON_ADD_ACTIVITY_SCHEDULE_EVENT_PRE'))) return; if ($this->isChecked('addActivity', $_POST)) { /* Bail out if we don't have a valid job order ID. */ if (!$this->isOptionalIDValid('activityTypeID', $_POST)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid activity type ID.'); } $activityTypeID = $_POST['activityTypeID']; $activityNote = $this->getTrimmedInput('activityNote', $_POST); $activityNote = htmlspecialchars($activityNote); /* Add the activity entry. */ $activityEntries = new ActivityEntries($this->_siteID); $activityID = $activityEntries->add($contactID, DATA_ITEM_CONTACT, $activityTypeID, $activityNote, $this->_userID, $regardingID); $activityTypes = $activityEntries->getTypes(); $activityTypeDescription = ResultSetUtility::getColumnValueByIDValue($activityTypes, 'typeID', $activityTypeID, 'type'); $activityAdded = true; } else { $activityAdded = false; $activityNote = ''; $activityTypeDescription = ''; } if ($this->isChecked('scheduleEvent', $_POST)) { /* Bail out if we received an invalid date. */ $trimmedDate = $this->getTrimmedInput('dateAdd', $_POST); if (empty($trimmedDate) || !DateUtility::validate('-', $trimmedDate, DATE_FORMAT_MMDDYY)) { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid date.'); } /* Bail out if we don't have a valid event type. */ if (!$this->isRequiredIDValid('eventTypeID', $_POST)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid event type ID.'); } /* Bail out if we don't have a valid time format ID. */ if (!isset($_POST['allDay']) || $_POST['allDay'] != '0' && $_POST['allDay'] != '1') { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid time format ID.'); } $eventTypeID = $_POST['eventTypeID']; if ($_POST['allDay'] == 1) { $allDay = true; } else { $allDay = false; } $publicEntry = $this->isChecked('publicEntry', $_POST); $reminderEnabled = $this->isChecked('reminderToggle', $_POST); $reminderEmail = $this->getTrimmedInput('sendEmail', $_POST); $reminderTime = $this->getTrimmedInput('reminderTime', $_POST); $duration = -1; /* Is this a scheduled event or an all day event? */ if ($allDay) { $date = DateUtility::convert('-', $trimmedDate, DATE_FORMAT_MMDDYY, DATE_FORMAT_YYYYMMDD); $hour = 12; $minute = 0; $meridiem = 'AM'; } else { /* Bail out if we don't have a valid hour. */ if (!isset($_POST['hour'])) { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid hour.'); } /* Bail out if we don't have a valid minute. */ if (!isset($_POST['minute'])) { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid minute.'); } /* Bail out if we don't have a valid meridiem value. */ if (!isset($_POST['meridiem']) || $_POST['meridiem'] != 'AM' && $_POST['meridiem'] != 'PM') { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid meridiem value.'); } $hour = $_POST['hour']; $minute = $_POST['minute']; $meridiem = $_POST['meridiem']; /* Convert formatted time to UNIX timestamp. */ $time = strtotime(sprintf('%s:%s %s', $hour, $minute, $meridiem)); /* Create MySQL date string w/ 24hr time (YYYY-MM-DD HH:MM:SS). */ $date = sprintf('%s %s', DateUtility::convert('-', $trimmedDate, DATE_FORMAT_MMDDYY, DATE_FORMAT_YYYYMMDD), date('H:i:00', $time)); } $description = $this->getTrimmedInput('description', $_POST); $title = $this->getTrimmedInput('title', $_POST); /* Bail out if any of the required fields are empty. */ if (empty($title)) { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Required fields are missing.'); } if ($regardingID > 0) { $eventJobOrderID = $regardingID; } else { $eventJobOrderID = -1; } $calendar = new Calendar($this->_siteID); $eventID = $calendar->addEvent($eventTypeID, $date, $description, $allDay, $this->_userID, $contactID, DATA_ITEM_CONTACT, $eventJobOrderID, $title, $duration, $reminderEnabled, $reminderEmail, $reminderTime, $publicEntry, $_SESSION['CATS']->getTimeZoneOffset()); if ($eventID <= 0) { CommonErrors::fatalModal(COMMONERROR_RECORDERROR, $this, 'Failed to add calendar event.'); } /* Extract the date parts from the specified date. */ $parsedDate = strtotime($date); $formattedDate = date('l, F jS, Y', $parsedDate); $calendar = new Calendar($this->_siteID); $calendarEventTypes = $calendar->getAllEventTypes(); $eventTypeDescription = ResultSetUtility::getColumnValueByIDValue($calendarEventTypes, 'typeID', $eventTypeID, 'description'); $eventHTML = sprintf('<p>An event of type <span class="bold">%s</span> has been scheduled on <span class="bold">%s</span>.</p>', htmlspecialchars($eventTypeDescription), htmlspecialchars($formattedDate)); $eventScheduled = true; } else { $eventHTML = '<p>No event has been scheduled.</p>'; $eventScheduled = false; } if (isset($_GET['onlyScheduleEvent'])) { $onlyScheduleEvent = true; } else { $onlyScheduleEvent = false; } if (!$activityAdded && !$eventScheduled) { $changesMade = false; } else { $changesMade = true; } if (!eval(Hooks::get('CANDIDATE_ON_ADD_ACTIVITY_CHANGE_STATUS_POST'))) { return; } $this->_template->assign('contactID', $contactID); $this->_template->assign('regardingID', $regardingID); $this->_template->assign('activityAdded', $activityAdded); $this->_template->assign('activityDescription', $activityNote); $this->_template->assign('activityType', $activityTypeDescription); $this->_template->assign('eventScheduled', $eventScheduled); $this->_template->assign('onlyScheduleEvent', $onlyScheduleEvent); $this->_template->assign('eventHTML', $eventHTML); $this->_template->assign('changesMade', $changesMade); $this->_template->assign('isFinishedMode', true); $this->_template->display('./modules/contacts/AddActivityScheduleEventModal.tpl'); }
public function onDeleteStaticList() { /* Bail out if we don't have a valid type. */ if (!$this->isRequiredIDValid('savedListID', $_GET)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this); return; } $savedListID = $_GET['savedListID']; $savedLists = new SavedLists($this->_siteID); /* Write changes. */ $savedLists->delete($savedListID); CATSUtility::transferRelativeURI('m=lists'); }
$AUIEO_MODULE = "contacts"; $record=$dataItem->get($dataItemID); /* Bail out if record not found. */ if(empty($record)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid data item ID for the Site '.$siteID); return; } $AUIEO_NAME = $record["firstName"]." ".$record["lastName"]; break; default: /* Bail out if record not found. */ if(empty($record)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid data item type.'); return; } } ob_start(); if (!empty($this->rs)) { foreach ($this->rs as $rowNumber => $data) { ?> <tr class="<?php TemplateUtility::printAlternatingRowClass($rowNumber); ?>"> <td valign="top" align="left"> <?php $this->_($data['name']); ?> </td> <td valign="top" align="left"> <a href="<?php echo(CATSUtility::getIndexName()); ?>?m=<?php echo $AUIEO_MODULE; ?>&a=transferto&dataItemType=<?php echo $dataItemType; ?>&dataItemID=<?php echo $dataItemID; ?>&siteID=<?php $this->_($data['siteID']); ?>"> <?php echo "Transfer"; ?>
public function copyAttachment($dataItemType, $dataItemID, $attachmentID) { $sql = "select * from attachment where attachment_id ={$attachmentID}"; $row = $this->_db->getAssoc($sql); $filePath = "attachments/" . $row["directory_name"] . $row["stored_filename"]; $destination = "attachments/" . $row["directory_name"] . $row["stored_filename"] . "_copy"; if (!file_exists($destination)) { return $this->add($dataItemType, $dataItemID, $row["title"], $row["original_filename"], $row["stored_filename"], $row["content_type"], $row["resume"], $row["text"], $row["profile_image"], $row["directory_name"]); } else { copy($filePath, $destination); } $filePath = $destination; $title = $row["title"]; $contentType = $row["content_type"]; $attachmentCreator = new AttachmentCreator($this->_siteID); $attachmentCreator->createFromFile($dataItemType, $dataItemID, $filePath, $title, $contentType, $extractText, $fileExists); if ($attachmentCreator->isError()) { CommonErrors::fatalModal(COMMONERROR_FILEERROR, $this, $attachmentCreator->getError()); return; //$this->fatalModal($attachmentCreator->getError()); } }
public function onDeleteAttachment() { if ($this->_accessLevel < ACCESS_LEVEL_DELETE) { CommonErrors::fatal(COMMONERROR_PERMISSION, $this, 'Invalid user level for action.'); } /* Bail out if we don't have a valid attachment ID. */ if (!$this->isRequiredIDValid('attachmentID', $_GET)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid attachment ID.'); } /* Bail out if we don't have a valid joborder ID. */ if (!$this->isRequiredIDValid('jobOrderID', $_GET)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid Job Order ID.'); } $jobOrderID = $_GET['jobOrderID']; $attachmentID = $_GET['attachmentID']; if (!eval(Hooks::get('JO_ON_DELETE_ATTACHMENT_PRE'))) return; $attachments = new Attachments($this->_siteID); $attachments->delete($attachmentID); if (!eval(Hooks::get('JO_ON_DELETE_ATTACHMENT_POST'))) return; CATSUtility::transferRelativeURI( 'm=joborders&a=show&jobOrderID=' . $jobOrderID ); }
private function onEmailCandidates() { if ($this->_accessLevel == ACCESS_LEVEL_DEMO) { CommonErrors::fatal(COMMONERROR_PERMISSION, $this, 'Sorry, but demo accounts are not allowed to send e-mails.'); } if (isset($_POST['postback'])) { $emailTo = $_POST['emailTo']; $emailSubject = $_POST['emailSubject']; $emailBody = $_POST['emailBody']; $tmpDestination = explode(', ', $emailTo); $destination = array(); foreach ($tmpDestination as $emailDest) { $destination[] = array($emailDest, $emailDest); } $mailer = new Mailer(CATS_ADMIN_SITE); // FIXME: Use sendToOne()? $mailerStatus = $mailer->send(array($_SESSION['CATS']->getEmail(), $_SESSION['CATS']->getEmail()), $destination, $emailSubject, $emailBody, true, true); $this->_template->assign('active', $this); $this->_template->assign('success', true); $this->_template->assign('success_to', $emailTo); $this->_template->display('./modules/candidates/SendEmail.tpl'); } else { $dataGrid = DataGrid::getFromRequest(); $candidateIDs = $dataGrid->getExportIDs(); /* Validate each ID */ foreach ($candidateIDs as $index => $candidateID) { if (!$this->isRequiredIDValid($index, $candidateIDs)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid candidate ID.'); return; } } $db_str = implode(", ", $candidateIDs); $db = DatabaseConnection::getInstance(); $rs = $db->getAllAssoc(sprintf('SELECT candidate_id, email1, email2 ' . 'FROM candidate ' . 'WHERE candidate_id IN (%s)', $db_str)); //$this->_template->assign('privledgedUser', $privledgedUser); $this->_template->assign('active', $this); $this->_template->assign('success', false); $this->_template->assign('recipients', $rs); $this->_template->display('./modules/candidates/SendEmail.tpl'); } }
public function onEmailCandidates() { if ($this->_accessLevel == ACCESS_LEVEL_DEMO) { CommonErrors::fatal(COMMONERROR_PERMISSION, $this, 'Sorry, but demo accounts are not allowed to send e-mails.'); } Logger::getLogger("AuieoATS")->info("inside onEmailCandidates"); if (isset($_POST['postback'])) { $templateid = $_POST['titleSelect']; $emailTo = $_POST['emailTo']; $emailSubject = $_POST['emailSubject']; $idlist=$_POST["idlist"]; $obj=json_decode(urldecode($idlist),true); foreach($obj as $candid=>$details) { $emailBody = $_POST['emailBody']; $emailData=array(); $emailData["id"]=$candid; $emailData["email"]=array(); foreach($details["email"] as $emailind=>$data) { //$objTemplate=new EmailTemplates($this->_siteID); //$rowTemplate=$objTemplate->get($templateid); $emailBody=$this->renderTemplateVars($emailBody, $candid); $tmpDestination = $data["email"]; $emailData["email"][]=array("email"=>$tmpDestination,"name"=>$tmpDestination); $mailer = new Mailer($this->_siteID); // FIXME: Use sendToOne()? $mailerStatus = $mailer->send( array($_SESSION['CATS']->getEmail(), $_SESSION['CATS']->getEmail()), $emailData, $emailSubject, $emailBody, true, true ); } } $this->_template->assign('active', $this); $this->_template->assign('success_to', $emailTo); if($mailer->getError()) { $this->_template->assign('error', $mailer->getError()); $this->_template->display('./modules/candidates/emailFail.php'); } else { $this->_template->assign('success', true); $this->_template->display('./modules/candidates/emailSuccess.php'); } return; } else { if(isset($_REQUEST["idlist"])) { $db = DatabaseConnection::getInstance(); $idlist=trim($_REQUEST["idlist"]); $rs = $db->getAllAssoc(sprintf( 'SELECT candidate_id, email1, email2, last_name, first_name ' . 'FROM candidate ' . 'WHERE candidate_id IN (%s)', $idlist )); $emailTemplates = new EmailTemplates($this->_siteID); $emailTemplatesRS = $emailTemplates->getAll(); $this->_template->assign('emailTemplatesRS', $emailTemplatesRS); $this->_template->assign('active', $this); $this->_template->assign('success', true); $this->_template->assign('recipients', $rs); $this->_template->display('./modules/candidates/emailCandidates.php'); return; } else { $dataGrid = DataGrid::getFromRequest(); $candidateIDs = $dataGrid->getExportIDs(); /* Validate each ID */ foreach ($candidateIDs as $index => $candidateID) { if (!$this->isRequiredIDValid($index, $candidateIDs)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid candidate ID.'); return; } } $db_str = implode(", ", $candidateIDs); $db = DatabaseConnection::getInstance(); $rs = $db->getAllAssoc(sprintf( 'SELECT candidate_id, email1, email2, last_name, first_name ' . 'FROM candidate ' . 'WHERE candidate_id IN (%s)', $db_str )); if(!$mailerStatus) { CommonErrors::fatal(COMMONERROR_EMAILFAILED, NULL, $mailer->getError()); } $this->_template->assign('active', $this); $this->_template->assign('success', true); $this->_template->assign('success_to', $emailTo); $this->_template->display('./modules/candidates/emailSuccess.php'); //$arrTpl["privledgedUser"]=$privledgedUser; /*$emailTemplates = new EmailTemplates($this->_siteID); $emailTemplatesRS = $emailTemplates->getAll(); $arrTpl["emailTemplatesRS"]=$emailTemplatesRS; $arrTpl["active"]=$this; $arrTpl["success"]=false; $arrTpl["recipients"]=$rs; return $arrTpl;*/ } } }
public function copyto() { if ($this->_accessLevel < ACCESS_LEVEL_EDIT) { CommonErrors::fatal(COMMONERROR_PERMISSION, $this); return; //$this->fatal(ERROR_NO_PERMISSION); } if($this->_moduleName=="candidates") { $module = new Candidates($this->_siteID); } else if($this->_moduleName=="companies") { $module = new Companies($this->_siteID); } else if($this->_moduleName=="joborders") { $module = new JobOrders($this->_siteID); } /* Bail out if we don't have a valid candidate ID. */ if (!isset($module)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, "Invalid Module: {$this->_moduleName}."); return; } /* Bail out if we don't have a valid candidate ID. */ if (!$this->isRequiredIDValid('dataItemID', $_GET)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, "Invalid {$this->_moduleName} ID."); return; } /* Update the candidate record. */ $updateSuccess = $module->copyRecord( $_GET['dataItemID'], $_GET["siteID"] ); if (!$updateSuccess) { CommonErrors::fatal(COMMONERROR_RECORDERROR, $this, "Failed to update {$this->_moduleName}."); } $this->_template->assign('active', $this); $this->_template->display('./modules/Settings/copystatus.php'); }