Admin: add config setting "disable_user_conditions_sender_id" BT#16345

pull/4101/head
Julio 6 years ago
parent 57b9c224c7
commit ac0516221d
  1. 3
      main/install/configuration.dist.php
  2. 61
      tests/scripts/disable_user_conditions.php

@ -1289,6 +1289,9 @@ requires extension "php-soap" sudo apt-get install php-soap
// ALTER TABLE session ADD COLUMN status INT DEFAULT 0; // ALTER TABLE session ADD COLUMN status INT DEFAULT 0;
// $_configuration['allow_session_status'] = 0; // $_configuration['allow_session_status'] = 0;
// Sets the sender id when using the script tests/scripts/disable_user_conditions.php
// $_configuration['disable_user_conditions_sender_id'] = 0;
// KEEP THIS AT THE END // KEEP THIS AT THE END
// -------- Custom DB changes // -------- Custom DB changes
// Add user activation by confirmation email // Add user activation by confirmation email

@ -11,6 +11,13 @@ $extraFieldValue = new ExtraField('user');
$extraFieldInfo = $extraFieldValue->get_handler_field_info_by_field_variable('termactivated'); $extraFieldInfo = $extraFieldValue->get_handler_field_info_by_field_variable('termactivated');
$fieldId = $extraFieldInfo['id']; $fieldId = $extraFieldInfo['id'];
$senderId = api_get_configuration_value('disable_user_conditions_sender_id');
$senderInfo = api_get_user_info($senderId);
if (empty($senderId) || empty($senderInfo)) {
echo 'Please set the configuraction value: "disable_user_conditions_sender_id" for a valid user.';
}
$statusCondition = ' AND u.status = '.STUDENT; $statusCondition = ' AND u.status = '.STUDENT;
$date = new Datetime(); $date = new Datetime();
@ -58,7 +65,18 @@ foreach ($students as $student) {
if (false === $test) { if (false === $test) {
UserManager::disable($studentId); UserManager::disable($studentId);
MessageManager::send_message($studentId, $subject, $content); MessageManager::send_message(
$studentId,
$subject,
$content,
[],
[],
0,
0,
0,
0,
$senderId
);
} }
} }
} }
@ -103,7 +121,18 @@ foreach ($students as $student) {
if (false === $test) { if (false === $test) {
UserManager::disable($studentId); UserManager::disable($studentId);
MessageManager::send_message($studentId, $subject, $content); MessageManager::send_message(
$studentId,
$subject,
$content,
[],
[],
0,
0,
0,
0,
$senderId
);
} }
} }
} }
@ -158,10 +187,32 @@ foreach ($students as $student) {
if (false === $test) { if (false === $test) {
UserManager::disable($studentId); UserManager::disable($studentId);
MessageManager::send_message($studentId, $subject, $content); MessageManager::send_message(
$studentId,
$subject,
$content,
[],
[],
0,
0,
0,
0,
$senderId
);
if (!empty($bossInfo) && !empty($subjectBoss)) { if (!empty($bossInfo) && !empty($subjectBoss)) {
MessageManager::send_message($studentBoss, $subjectBoss, $contentBoss); MessageManager::send_message(
$studentBoss,
$subjectBoss,
$contentBoss,
[],
[],
0,
0,
0,
0,
$senderId
);
} }
UserManager::removeAllBossFromStudent($studentId); UserManager::removeAllBossFromStudent($studentId);
} }
@ -172,6 +223,8 @@ foreach ($students as $student) {
if ($test) { if ($test) {
echo '<h3>No changes have been made.</h3>'.$newLine; echo '<h3>No changes have been made.</h3>'.$newLine;
echo 'Sender user: '.$senderInfo['complete_name'].$newLine;
echo "Now: $now".$newLine; echo "Now: $now".$newLine;
echo "3 Months old: $date3Months".$newLine; echo "3 Months old: $date3Months".$newLine;
echo "6 Months old: $date6Months".$newLine; echo "6 Months old: $date6Months".$newLine;

Loading…
Cancel
Save