以下功能来自SmartJobBoard脚本,其主要工作是在求职者申请工作时发送电子邮件通知。
我想要的是根据$ application_email是否存在来设置一个运行条件。如果没有$ application_email,则该函数不应该运行。
public static function sendApplyNow($info, $file = '', $data_resume = array(), $current_user_sid = false, $notRegisterUserData = false, $score = false)
{
if ($current_user_sid) {
$user_info = SJB_UserManager::getUserInfoBySID($current_user_sid);
$sender_email_address = $user_info['email'];
} else {
$sender_email_address = $notRegisterUserData['email'];
}
$application_email = SJB_Applications::getApplicationEmailbyListingId($info['listing']['id']);
$email_address = !empty($application_email) ? $application_email : $info['listing']['user']['email'];
$questionnaire = !empty($info['submitted_data']['questionnaire'])?unserialize($info['submitted_data']['questionnaire']):'';
$questionnaireInfo = array();
if ($questionnaire) {
$listingInfo = SJB_ListingManager::getListingInfoBySID($info['listing']['id']);
$questSID = isset($listingInfo['screening_questionnaire'])?$listingInfo['screening_questionnaire']:0;
$questionnaireInfo = SJB_ScreeningQuestionnaires::getInfoBySID($questSID);
$passing_score = 0;
switch ($questionnaireInfo['passing_score']) {
case 'acceptable':
$passing_score = 1;
break;
case 'good':
$passing_score = 2;
break;
case 'very_good':
$passing_score = 3;
break;
case 'excellent':
$passing_score = 4;
break;
}
if ($score >= $passing_score) {
$questionnaireInfo['passing_score'] = 'Passed';
}
else {
$questionnaireInfo['passing_score'] = 'Not passed';
}
}
if (!empty($info['listing']['subuser']['sid'])) {
$subUserInfo = SJB_UserManager::getUserInfoBySID($info['listing']['subuser']['sid']);
if (!empty($subUserInfo)) {
$email_address = $subUserInfo['email'];
}
}
$data = array(
'user' => SJB_Array::getPath($info, 'listing/user'),
'listing' => $info['listing'],
'applicant_request' => $info['submitted_data'],
'data_resume' => $data_resume,
'questionnaire' => $questionnaire,
'score' => $score,
'questionnaire_info' => $questionnaireInfo);
$email = SJB_EmailTemplateEditor::getEmail($email_address, self::SEND_APPLY_NOW_SID, $data);
$email->setReplyTo($sender_email_address);
if ($file != '') {
$email->setFile($file);
}
return $email->send('Apply Now');
}
感谢您的帮助。
感谢。
答案 0 :(得分:0)
<?php
$application_email = SJB_Applications::getApplicationEmailbyListingId($info['listing']['id']);
if(empty($application_email)) return; # New line
$email_address = !empty($application_email) ? $application_email : $info['listing']['user']['email'];