mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-19 16:02:15 +00:00
- jobs/OneTimeMessages->sendMessageToApplicantsStillWaiting now accept
new message senderId to specify the sender for all the messages - jobs/OneTimeMessages->sendMessageToApplicantsStillWaiting adapted code to make use of the new method CLMessagesModel->sendExplicitTemplateSenderId - jobs/OneTimeMessages->sendMessageToApplicantsStillWaiting now logs the number of prestudents retrieved from database - Renamed CLMessagesModel->sendExplicitTemplate as CLMessagesModel->sendExplicitTemplateSenderId - Added new parameter sender_id to CLMessagesModel->sendExplicitTemplateSenderId to specify the sender person id - Added new public method sendExplicitTemplate to CLMessagesModel as wrapper method for sendExplicitTemplateSenderId - CLMessagesModel->sendExplicitTemplate tries to retrieve the sender id from the authentication session
This commit is contained in:
@@ -29,8 +29,9 @@ class OneTimeMessages extends JOB_Controller
|
||||
* - The given semester (ex WS2020)
|
||||
* - How long since applicant (months)
|
||||
* - The given template id to be used as message subject and body (vorlage_kurzbz)
|
||||
* The sender of all the messages is specified by the parameter senderId (sender person_id)
|
||||
*/
|
||||
public function sendMessageToApplicantsStillWaiting($studyCourseType, $semester, $months, $messageTemplate)
|
||||
public function sendMessageToApplicantsStillWaiting($senderId, $studyCourseType, $semester, $months, $messageTemplate)
|
||||
{
|
||||
$this->logInfo('Send message to applicants still waiting start');
|
||||
|
||||
@@ -94,11 +95,12 @@ class OneTimeMessages extends JOB_Controller
|
||||
$prestudentIdsArray[] = $dbPrestudent->prestudent_id;
|
||||
}
|
||||
|
||||
$sendMessage = $this->CLMessagesModel->sendExplicitTemplate(
|
||||
$prestudentIdsArray, // prestudents id
|
||||
null, // organization unit
|
||||
$messageTemplate, // template id
|
||||
null // extra variables
|
||||
$sendMessage = $this->CLMessagesModel->sendExplicitTemplateSenderId(
|
||||
$senderId, // sender person id
|
||||
$prestudentIdsArray, // prestudents id
|
||||
null, // organization unit
|
||||
$messageTemplate, // template id
|
||||
null // extra variables
|
||||
);
|
||||
|
||||
if (isError($sendMessage))
|
||||
@@ -111,6 +113,8 @@ class OneTimeMessages extends JOB_Controller
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->logInfo('Total amount of prestudents: '.count($prestudentIdsArray));
|
||||
}
|
||||
|
||||
$this->logInfo('Send message to applicants still waiting end');
|
||||
|
||||
@@ -422,17 +422,26 @@ class Messages_model extends CI_Model
|
||||
|
||||
return success('Messages sent successfully');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sends a new message using the given template and information present in parameter prestudents
|
||||
* Extra variables can be added using parameter $msgVars
|
||||
* Wrapper method for sendExplicitTemplateSenderId
|
||||
* The sender id is retrieved from the authentication session, if not present an error would be raised
|
||||
*/
|
||||
public function sendExplicitTemplate($prestudents, $oe_kurzbz, $vorlage_kurzbz, $msgVars)
|
||||
{
|
||||
// Retrieves the sender id
|
||||
$sender_id = isLogged() ? getAuthPersonId() : null;
|
||||
if (!is_numeric($sender_id)) $sender_id = $this->config->item(MessageLib::CFG_SYSTEM_PERSON_ID);
|
||||
$sender_id = getAuthPersonId();
|
||||
if (!is_numeric($sender_id)) show_error('The current logged user person_id is not defined');
|
||||
|
||||
return $this->sendExplicitTemplateSenderId($sender_id, $prestudents, $oe_kurzbz, $vorlage_kurzbz, $msgVars);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a new message using the given template and information present in parameter prestudents
|
||||
* Extra variables can be added using parameter $msgVars
|
||||
*/
|
||||
public function sendExplicitTemplateSenderId($sender_id, $prestudents, $oe_kurzbz, $vorlage_kurzbz, $msgVars)
|
||||
{
|
||||
// Retrieves message vars data for the given user/s
|
||||
$msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents);
|
||||
if (isError($msgVarsData)) show_error(getError($msgVarsData));
|
||||
|
||||
Reference in New Issue
Block a user