|
|
|
@ -70,11 +70,37 @@ if ($formValidator->validate() && isset($_FILES)) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$userJustifications = $plugin->getUserJustificationList(api_get_user_id()); |
|
|
|
|
|
|
|
|
|
if (!empty($userJustifications)) { |
|
|
|
|
if (count($fields) <= count($userJustifications) && $_REQUEST['a'] != 'notification_sent') { |
|
|
|
|
$formValidator->addHtml('<div class="alert alert-warning"><a href="'.api_get_self().'?a=notify_justification" >'.$plugin->get_lang('SendNotificationToAllAdmins').'</a></div>'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$userJustificationList = ''; |
|
|
|
|
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : ''; |
|
|
|
|
|
|
|
|
|
$justificationContent = ''; |
|
|
|
|
switch ($action) { |
|
|
|
|
case 'notify_justification': |
|
|
|
|
// notification to all admins action |
|
|
|
|
$userInfo = api_get_user_info(); |
|
|
|
|
// get_all_administrators |
|
|
|
|
$adminList = UserManager::get_all_administrators(); |
|
|
|
|
$link = api_get_path(WEB_PATH) . 'plugin/justification/justification_by_user.php?user_id=' . api_get_user_id(); |
|
|
|
|
$emailToAdminSubject = $plugin->get_lang('JustificationsCompleted').': '.$userInfo['complete_name']; |
|
|
|
|
$emailToAdminContent = $emailToAdminSubject . ' <br /><br />' . '<a href="'. $link . '">' . $link . '</a>'; |
|
|
|
|
foreach ($adminList as $adminId => $data) { |
|
|
|
|
MessageManager::send_message_simple( |
|
|
|
|
$adminId, |
|
|
|
|
$emailToAdminSubject, |
|
|
|
|
$emailToAdminContent, |
|
|
|
|
api_get_user_id()); |
|
|
|
|
} |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('MessageSent'))); |
|
|
|
|
header('Location: '.api_get_self().'?a=notification_sent'); |
|
|
|
|
exit; |
|
|
|
|
break; |
|
|
|
|
case 'edit_justification': |
|
|
|
|
$justificationId = isset($_REQUEST['justification_id']) ? (int) $_REQUEST['justification_id'] : ''; |
|
|
|
|
$userJustification = $plugin->getUserJustification($justificationId); |
|
|
|
|