Skip to content
Permalink
Browse files

Add option "SendAnnouncementCopyToMyself" in announcement see BT#14824

  • Loading branch information...
jmontoyaa committed Sep 13, 2018
1 parent 71c5ed5 commit 260549e93c21ee2af5c6b4017e246c9a6be981e4
@@ -545,13 +545,16 @@
$form->addCheckBox('send_to_hrm_users', null, get_lang('SendAnnouncementCopyToDRH'));
}
$form->addCheckBox('send_me_a_copy_by_email', null, get_lang('SendAnnouncementCopyToMyself'));
$defaults['send_me_a_copy_by_email'] = true;
$form->addButtonSave(get_lang('ButtonPublishAnnouncement'));
$form->setDefaults($defaults);
if ($form->validate()) {
$data = $form->getSubmitValues();
$data['users'] = isset($data['users']) ? $data['users'] : [];
$sendToUsersInSession = isset($data['send_to_users_in_session']) ? true : false;
$sendMeCopy = isset($data['send_me_a_copy_by_email']) ? true : false;
if (isset($id) && $id) {
// there is an Id => the announcement already exists => update mode
@@ -576,10 +579,17 @@
api_get_session_id(),
$id,
$sendToUsersInSession,
isset($data['send_to_hrm_users'])
isset($data['send_to_hrm_users']),
null,
$sendMeCopy
);
}
if ($sendMeCopy) {
$email = new AnnouncementEmail(api_get_course_info(), api_get_session_id(), $id);
$email->sendAnnouncementEmailToMySelf();
}
Display::addFlash(
Display::return_message(
get_lang('AnnouncementModified'),
@@ -274,6 +274,25 @@ public function attachment()
return $result;
}
/**
* Send announcement by email to myself
*/
public function sendAnnouncementEmailToMySelf()
{
$userId = api_get_user_id();
$subject = $this->subject();
$message = $this->message($userId);
MessageManager::send_message_simple(
$userId,
$subject,
$message,
api_get_user_id(),
false,
true
);
}
/**
* Send emails to users.
*
@@ -113,7 +113,7 @@ public static function parseContent(
$extraFields = $extraField->get_all(['filter = ?' => 1]);
if (!empty($extraFields)) {
foreach ($extraFields as $extra) {
$data["extra_".$extra['variable']] = '';
$data['extra_'.$extra['variable']] = '';
}
}
$SkillUserList = "Skills and users list";
$CourseId = "Course ID";
$CareDetailView = "Student care detail view";
$MoreDataAvailableInTheDatabaseButTrunkedForEfficiencyReasons = "More data available in the database but trunked for efficiency reasons.";
$SendAnnouncementCopyToMyself = "Send a copy by email to myself.";
?>

0 comments on commit 260549e

Please sign in to comment.
You can’t perform that action at this time.