Minor: Format code - refs BT#20946

pull/4863/head
Angel Fernando Quiroz Campos 2 years ago
parent 3fbd99d52c
commit ea3be70986
  1. 14
      main/admin/access_url_edit_users_to_url.php
  2. 2
      main/admin/configure_extensions.php
  3. 1
      main/calendar/agenda.php
  4. 21
      main/cron/forum_bulk_notification_to_course_teacher_for_new_post_in_last_X_days.php
  5. 16
      main/exercise/ReadingComprehension.php
  6. 2
      main/glossary/glossary.js.php
  7. 2
      main/inc/ajax/social.ajax.php
  8. 1
      main/inc/lib/ScheduledAnnouncement.php
  9. 275
      main/inc/lib/agenda.lib.php
  10. 100
      main/inc/lib/extra_field.lib.php
  11. 3
      main/inc/lib/formvalidator/FormValidator.class.php
  12. 8
      main/inc/lib/tracking.lib.php
  13. 2
      main/inc/lib/webservices/Rest.php
  14. 2
      main/lp/learnpath.class.php

@ -306,9 +306,8 @@ if (!empty($errorMsg)) {
foreach ($nosessionUsersList as $enreg) {
if ($showAndOrderByOfficialCode) {
$userOfficialCode = $enreg['official_code'].' - ';
}
?>
<option value="<?php echo $enreg['user_id']; ?>"><?php echo $userOfficialCode . $enreg['username'].' - '.api_get_person_name($enreg['firstname'], $enreg['lastname']); ?></option>
} ?>
<option value="<?php echo $enreg['user_id']; ?>"><?php echo $userOfficialCode.$enreg['username'].' - '.api_get_person_name($enreg['firstname'], $enreg['lastname']); ?></option>
<?php
}
unset($nosessionUsersList); ?>
@ -344,14 +343,13 @@ if (!empty($errorMsg)) {
<?php
foreach ($sessionUsersList as $enreg) {
if ($showAndOrderByOfficialCode) {
$userOfficialCode = $enreg['official_code'].' - ';
}
?>
$userOfficialCode = $enreg['official_code'].' - ';
} ?>
<option value="<?php echo $enreg['user_id']; ?>">
<?php echo $userOfficialCode . $enreg['username'].' - '.api_get_person_name($enreg['firstname'], $enreg['lastname']); ?>
<?php echo $userOfficialCode.$enreg['username'].' - '.api_get_person_name($enreg['firstname'], $enreg['lastname']); ?>
</option>
<?php
}
}
unset($sessionUsersList);
?>
</select></td>

@ -162,7 +162,7 @@ Display::display_header($nameTool);
if (api_get_configuration_value('webservice_remote_ppt2png_enable') == true) {
$form->addElement('text', 'host', get_lang('Host'));
} else {
$form->addElement('text', 'host', [get_lang('Host'),'Remote host disabled - set webservice_remote_ppt2png_enable setting to true in configuration.php to enable']);
$form->addElement('text', 'host', [get_lang('Host'), 'Remote host disabled - set webservice_remote_ppt2png_enable setting to true in configuration.php to enable']);
}
//$form -> addElement('html','<br /><br />');
$form->addElement('text', 'port', get_lang('Port'));

@ -183,7 +183,6 @@ if ($allowToEdit) {
$subscriptionItemId = isset($_REQUEST['subscription_item']) ? (int) $_REQUEST['subscription_item'] : null;
$maxSubscriptions = (int) ($_REQUEST['max_subscriptions'] ?? 0);
$reminders = $notificationCount ? array_map(null, $notificationCount, $notificationPeriod) : [];
$eventId = $agenda->addEvent(

@ -31,17 +31,16 @@ $UpdatedThreads = [];
$sql = "SELECT * FROM $tableThread WHERE thread_date > '".$startDate."'";
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
$courseInfo = api_get_course_info_by_id($row['c_id']);
$updatedThreads[$row['c_id']]['courseName'] = $courseInfo['name'];
$sqlNbPost = "SELECT count(*) as nbPost FROM $tablePost WHERE thread_id = '".$row['iid']."' and post_date > '".$startDate."'";
$resultNbPost = Database::query($sqlNbPost);
$rowNbPost = Database::fetch_array($resultNbPost);
$updatedThreads[$row['c_id']][$row['session_id']][$row['iid']] = [
$courseInfo = api_get_course_info_by_id($row['c_id']);
$updatedThreads[$row['c_id']]['courseName'] = $courseInfo['name'];
$sqlNbPost = "SELECT count(*) as nbPost FROM $tablePost WHERE thread_id = '".$row['iid']."' and post_date > '".$startDate."'";
$resultNbPost = Database::query($sqlNbPost);
$rowNbPost = Database::fetch_array($resultNbPost);
$updatedThreads[$row['c_id']][$row['session_id']][$row['iid']] = [
'threadTitle' => $row['thread_title'],
'threadNbPost' => $rowNbPost['nbPost'],
'threadLink' => api_get_path(WEB_PATH) . 'main/forum/viewthread.php?cidReq=' . $courseInfo['code'] . '&id_session=' . $row['session_id'] . '&gidReq=0&gradebook=0&origin=&forum=' . $row['forum_id'] . '&thread=' . $row['iid']
'threadLink' => api_get_path(WEB_PATH).'main/forum/viewthread.php?cidReq='.$courseInfo['code'].'&id_session='.$row['session_id'].'&gidReq=0&gradebook=0&origin=&forum='.$row['forum_id'].'&thread='.$row['iid'],
];
}
foreach ($updatedThreads as $courseId => $sessions) {
foreach ($sessions as $sessionId => $threads) {
@ -65,11 +64,9 @@ foreach ($updatedThreads as $courseId => $sessions) {
}
}
foreach ($usersToNotify as $userId => $notifyInfo) {
sendMessage ($userId, $notifyInfo);
sendMessage($userId, $notifyInfo);
}
/**
* Send the message to notify the specific user for all its courses and threads that have been updated,
* manage the corresponding template and send through MessageManager::send_message_simple.
@ -83,7 +80,6 @@ function sendMessage(
$toUserId,
$notifyInfo
) {
$userInfo = api_get_user_info($toUserId);
$language = $userInfo['language'];
$subject = getUserLang('ForumBulkNotificationMailSubject', $language);
@ -142,4 +138,3 @@ function getUserLang($variable, $language)
}
exit();

@ -50,6 +50,12 @@ class ReadingComprehension extends UniqueAnswer
* @var int
*/
public $refreshTime = 3;
/**
* All speeds (static $speeds + extra speeds defined in configuration.php as 'exercise_question_reading_comprehension_extra_speeds'.
*
* @var array
*/
public $allSpeeds = [];
/**
* Indicates how show the question list.
@ -58,12 +64,6 @@ class ReadingComprehension extends UniqueAnswer
* @var int
*/
private $exerciseType = 2;
/**
* All speeds (static $speeds + extra speeds defined in configuration.php as 'exercise_question_reading_comprehension_extra_speeds'
*
* @var array
*/
public $allSpeeds = [];
/**
* Constructor.
@ -194,7 +194,6 @@ class ReadingComprehension extends UniqueAnswer
*/
public static function get_default_levels()
{
return [
1 => sprintf(get_lang('ReadingComprehensionLevelX'), self::$speeds[1]),
2 => sprintf(get_lang('ReadingComprehensionLevelX'), self::$speeds[2]),
@ -205,8 +204,7 @@ class ReadingComprehension extends UniqueAnswer
}
/**
* Return the augmented speeds (using, if defined, the 'exercise_question_reading_comprehension_extra_speeds' setting
* @return array
* Return the augmented speeds (using, if defined, the 'exercise_question_reading_comprehension_extra_speeds' setting.
*/
public function getReadingSpeeds(): array
{

@ -16,7 +16,7 @@ $glossaryExtraTools = api_get_setting('show_glossary_in_extra_tools');
$showGlossary = false;
if ('learnpath' == $origin) {
$showGlossary = in_array($glossaryExtraTools, ['lp', 'exercise_and_lp']);
} elseif (isset($glossaryInDocs) && 'none' != $glossaryInDocs) {
} elseif (isset($glossaryInDocs) && 'none' != $glossaryInDocs) {
$showGlossary = true;
}

@ -258,7 +258,7 @@ switch ($action) {
SocialManager::deleteMessage($messageId);
echo json_encode([
'message' => Display::return_message(get_lang('MessageDeleted')),
'secToken' => Security::get_token('social')
'secToken' => Security::get_token('social'),
]);
break;
}

@ -305,7 +305,6 @@ class ScheduledAnnouncement extends Model
$extraField = new ExtraField('user');
$extraFields = $extraField->get_all(['filter = ? AND visible_to_self = ?' => [1, 1]]);
foreach ($result as $result) {
if (empty($result['sent'])) {
if (!empty($result['date']) && $result['date'] < $now) {

@ -506,13 +506,12 @@ class Agenda
}
/**
* Checks if an event exists and delete it (right before inserting a modified version in addEvent())
* @param string $start datetime format: 2012-06-14 09:00:00 in local time
* @param string $end datetime format: 2012-06-14 09:00:00 in local time
* @param int $allDay (true = 1, false = 0)
* @param string $title
* Checks if an event exists and delete it (right before inserting a modified version in addEvent()).
*
* @param string $start datetime format: 2012-06-14 09:00:00 in local time
* @param string $end datetime format: 2012-06-14 09:00:00 in local time
* @param int $allDay (true = 1, false = 0)
*
* @return bool
* @throws Exception
*/
public function deleteEventIfAlreadyExists(
@ -3200,138 +3199,6 @@ class Agenda
return $form;
}
private function addCollectiveInvitationsFields(FormValidator $form, ?PersonalAgenda $personalEvent)
{
$invitees = [];
$isCollective = false;
$withInvitation = false;
if ($personalEvent) {
$eventInvitation = $personalEvent->getInvitation();
$withInvitation = !($eventInvitation instanceof AgendaEventSubscription);
if ($withInvitation) {
foreach ($eventInvitation->getInvitees() as $invitee) {
$inviteeUser = $invitee->getUser();
$invitees[$inviteeUser->getId()] = $inviteeUser->getCompleteNameWithUsername();
}
}
$isCollective = $personalEvent->isCollective();
}
$form->addHtml(
'<div id="invitations-block" style="display: '.($withInvitation ? 'block;' : 'none;').'">'
);
$form->addHeader(get_lang('Invitations'));
$form->addSelectAjax(
'invitees',
get_lang('Invitees'),
$invitees,
[
'multiple' => 'multiple',
'url' => api_get_path(WEB_AJAX_PATH).'message.ajax.php?a=find_users',
]
);
$form->addCheckBox('collective', '', get_lang('IsItEditableByTheInvitees'));
$form->addHtml('<hr>');
$form->addHtml('</div>');
$form->setDefaults([
'invitees' => array_keys($invitees),
'collective' => $isCollective
]);
}
private function addSubscriptionFields(FormValidator $form, ?PersonalAgenda $personalEvent)
{
$subscribers = [];
$withSubscription = false;
$maxSubscriptions = 0;
$groupId = null;
if ($personalEvent) {
$eventInvitation = $personalEvent->getInvitation();
$withSubscription = $eventInvitation instanceof AgendaEventSubscription;
$maxSubscriptions = $withSubscription ? $eventInvitation->getMaxAttendees() : 0;
$groupId = $personalEvent->getSubscriptionItemId();
$subscribers = self::getInviteesForPersonalEvent($personalEvent->getId(), AgendaEventSubscriber::class);
$subscribers = array_combine(
array_column($subscribers, 'id'),
array_column($subscribers, 'name')
);
}
$form->addHtml(
'<div id="subscriptions-block" style="display: '.($withSubscription ? 'block;' : 'none;').'">'
);
$form->addHeader(get_lang('Subscriptions'));
$form->addSelect(
'subscription_visibility',
get_lang('AllowSubscriptions'),
[
AgendaEventSubscription::SUBSCRIPTION_NO => get_lang('No'),
AgendaEventSubscription::SUBSCRIPTION_ALL => get_lang('AllUsersOfThePlatform'),
AgendaEventSubscription::SUBSCRIPTION_CLASS => get_lang('UsersInsideClass'),
]
);
$slctItem = $form->addSelectAjax(
'subscription_item',
get_lang('SocialGroup').' / '.get_lang('Class'),
[],
[
'url' => api_get_path(WEB_AJAX_PATH).'usergroup.ajax.php?a=get_class_by_keyword',
'disabled' => 'disabled',
]
);
$form->addNumeric(
'max_subscriptions',
['', get_lang('MaxSubscriptionsLeaveEmptyToNotLimit')],
[
'disabled' => 'disabled',
'step' => 1,
'min' => 0,
'value' => 0,
]
);
$form->addHtml("<script>
$(function () {
$('#add_event_subscription_visibility')
.on('change', function () {
$('#max_subscriptions').prop('disabled', this.value == 0);
$('#add_event_subscription_item').prop('disabled', this.value != 2);
})
.trigger('change');
})
</script>
");
$form->addSelect(
'subscribers',
get_lang('Subscribers'),
$subscribers,
['multiple' => 'multiple']
);
$form->setDefaults([
'subscribers' => array_keys($subscribers),
'max_subscriptions' => $maxSubscriptions,
]);
if ($groupId) {
$objUserGroup = new UserGroup();
$groupInfo = $objUserGroup->get($groupId);
$slctItem->addOption($groupInfo['name'], $groupId);
}
$form->addHtml('</div>');
}
public function addFieldsForRemindersToForm(int $eventId, FormValidator $form)
{
$remindersList = $this->parseEventReminders(
@ -5091,6 +4958,138 @@ class Agenda
];
}
private function addCollectiveInvitationsFields(FormValidator $form, ?PersonalAgenda $personalEvent)
{
$invitees = [];
$isCollective = false;
$withInvitation = false;
if ($personalEvent) {
$eventInvitation = $personalEvent->getInvitation();
$withInvitation = !($eventInvitation instanceof AgendaEventSubscription);
if ($withInvitation) {
foreach ($eventInvitation->getInvitees() as $invitee) {
$inviteeUser = $invitee->getUser();
$invitees[$inviteeUser->getId()] = $inviteeUser->getCompleteNameWithUsername();
}
}
$isCollective = $personalEvent->isCollective();
}
$form->addHtml(
'<div id="invitations-block" style="display: '.($withInvitation ? 'block;' : 'none;').'">'
);
$form->addHeader(get_lang('Invitations'));
$form->addSelectAjax(
'invitees',
get_lang('Invitees'),
$invitees,
[
'multiple' => 'multiple',
'url' => api_get_path(WEB_AJAX_PATH).'message.ajax.php?a=find_users',
]
);
$form->addCheckBox('collective', '', get_lang('IsItEditableByTheInvitees'));
$form->addHtml('<hr>');
$form->addHtml('</div>');
$form->setDefaults([
'invitees' => array_keys($invitees),
'collective' => $isCollective,
]);
}
private function addSubscriptionFields(FormValidator $form, ?PersonalAgenda $personalEvent)
{
$subscribers = [];
$withSubscription = false;
$maxSubscriptions = 0;
$groupId = null;
if ($personalEvent) {
$eventInvitation = $personalEvent->getInvitation();
$withSubscription = $eventInvitation instanceof AgendaEventSubscription;
$maxSubscriptions = $withSubscription ? $eventInvitation->getMaxAttendees() : 0;
$groupId = $personalEvent->getSubscriptionItemId();
$subscribers = self::getInviteesForPersonalEvent($personalEvent->getId(), AgendaEventSubscriber::class);
$subscribers = array_combine(
array_column($subscribers, 'id'),
array_column($subscribers, 'name')
);
}
$form->addHtml(
'<div id="subscriptions-block" style="display: '.($withSubscription ? 'block;' : 'none;').'">'
);
$form->addHeader(get_lang('Subscriptions'));
$form->addSelect(
'subscription_visibility',
get_lang('AllowSubscriptions'),
[
AgendaEventSubscription::SUBSCRIPTION_NO => get_lang('No'),
AgendaEventSubscription::SUBSCRIPTION_ALL => get_lang('AllUsersOfThePlatform'),
AgendaEventSubscription::SUBSCRIPTION_CLASS => get_lang('UsersInsideClass'),
]
);
$slctItem = $form->addSelectAjax(
'subscription_item',
get_lang('SocialGroup').' / '.get_lang('Class'),
[],
[
'url' => api_get_path(WEB_AJAX_PATH).'usergroup.ajax.php?a=get_class_by_keyword',
'disabled' => 'disabled',
]
);
$form->addNumeric(
'max_subscriptions',
['', get_lang('MaxSubscriptionsLeaveEmptyToNotLimit')],
[
'disabled' => 'disabled',
'step' => 1,
'min' => 0,
'value' => 0,
]
);
$form->addHtml("<script>
$(function () {
$('#add_event_subscription_visibility')
.on('change', function () {
$('#max_subscriptions').prop('disabled', this.value == 0);
$('#add_event_subscription_item').prop('disabled', this.value != 2);
})
.trigger('change');
})
</script>
");
$form->addSelect(
'subscribers',
get_lang('Subscribers'),
$subscribers,
['multiple' => 'multiple']
);
$form->setDefaults([
'subscribers' => array_keys($subscribers),
'max_subscriptions' => $maxSubscriptions,
]);
if ($groupId) {
$objUserGroup = new UserGroup();
$groupInfo = $objUserGroup->get($groupId);
$slctItem->addOption($groupInfo['name'], $groupId);
}
$form->addHtml('</div>');
}
private function editReminders(int $eventId, array $reminderList = [])
{
if (false === api_get_configuration_value('agenda_reminders')) {

@ -3192,6 +3192,55 @@ JAVASCRIPT;
return $result;
}
/**
* For one given field ID, get all the item_id + value.
*
* @return array
*/
public function getAllValuesByFieldId(int $fieldId)
{
$type = $this->get_field_type_by_id($fieldId);
$sql = "SELECT item_id, value FROM ".$this->table_field_values." WHERE field_id = $fieldId";
$res = Database::query($sql);
$values = [];
if (Database::num_rows($res) > 0) {
while ($row = Database::fetch_array($res)) {
if (is_null($row['value'])) {
// If the entry exists but is NULL, consider it an empty string (to reproduce the behaviour of UserManager::get_extra_user_data()
$values[$row['item_id']] = '';
} else {
if ($type == UserManager::USER_FIELD_TYPE_SELECT_MULTIPLE) {
$values[$row['item_id']] = explode(';', $row['value']);
} else {
$values[$row['item_id']] = $row['value'];
}
}
}
}
return $values;
}
/**
* Gets the default value for one specific field.
*
* @param int $fieldId Field ID
*
* @return mixed Default value for the field (could be null, or usually a string)
*/
public function getDefaultValueByFieldId(int $fieldId)
{
$sql = "SELECT default_value FROM $this->table WHERE id = $fieldId";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$row = Database::fetch_array($res);
return $row['default_value'];
}
return null;
}
/**
* @param \FormValidator $form
* @param int $defaultValueId
@ -3619,55 +3668,4 @@ JAVASCRIPT;
}
);
}
/**
* For one given field ID, get all the item_id + value
*
* @param int $fieldId
*
* @return array
*/
public function getAllValuesByFieldId(int $fieldId)
{
$type = $this->get_field_type_by_id($fieldId);
$sql = "SELECT item_id, value FROM ".$this->table_field_values." WHERE field_id = $fieldId";
$res = Database::query($sql);
$values = [];
if (Database::num_rows($res) > 0) {
while ($row = Database::fetch_array($res)) {
if (is_null($row['value'])) {
// If the entry exists but is NULL, consider it an empty string (to reproduce the behaviour of UserManager::get_extra_user_data()
$values[$row['item_id']] = '';
} else {
if ($type == UserManager::USER_FIELD_TYPE_SELECT_MULTIPLE) {
$values[$row['item_id']] = explode(';', $row['value']);
} else {
$values[$row['item_id']] = $row['value'];
}
}
}
}
return $values;
}
/**
* Gets the default value for one specific field
*
* @param int $fieldId Field ID
*
* @return mixed Default value for the field (could be null, or usually a string)
*/
public function getDefaultValueByFieldId(int $fieldId)
{
$sql = "SELECT default_value FROM $this->table WHERE id = $fieldId";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$row = Database::fetch_array($res);
return $row['default_value'];
}
return null;
}
}

@ -2094,5 +2094,6 @@ function plain_url_filter($html, $mode = NO_HTML)
$html = kses_no_null($html);
$html = kses_js_entities($html);
$allowed_html_fixed = kses_array_lc($allowed_tags);
return kses_split($html, $allowed_html_fixed, array('http', 'https'));
return kses_split($html, $allowed_html_fixed, ['http', 'https']);
}

@ -2046,8 +2046,7 @@ class Tracking
$n++;
}
}
}
elseif (
} elseif (
'h5p' === $row['item_type']
&& 'true' === $h5pImportEnable
) {
@ -2134,8 +2133,7 @@ class Tracking
$n++;
}
}
}
else {
} else {
$output .= '<tr><td colspan="12">&nbsp;</td></tr>';
}
}
@ -8522,7 +8520,7 @@ class Tracking
if ($resLogoutDate < time() - $lifeTime) {
// it isn't, we should create a fresh entry
Event::eventLogin($userId);
// now that it's created, we can get its ID and carry on
// now that it's created, we can get its ID and carry on
} else {
$sql = "UPDATE $tblTrackLogin SET logout_date = '$now'
WHERE login_id = '$iIdLastConnection'";

@ -1605,7 +1605,7 @@ class Rest extends WebService
$conditions = [];
} else {
$conditions = [
'status' => $params['status']
'status' => $params['status'],
];
}
$idCampus = !empty($params['id_campus']) ?? 1;

@ -13954,7 +13954,7 @@ EOD;
.('cmi5' === $toolLaunch->getActivityType() ? 'cmi5/view.php' : 'tincan/view.php')
."?id=$id&$extraParams";
case TOOL_H5P:
if ('true' === api_get_plugin_setting('h5pimport', 'tool_enable')){
if ('true' === api_get_plugin_setting('h5pimport', 'tool_enable')) {
$toolLaunch = $em->find(H5pImport::class, $id);
if (empty($toolLaunch)) {

Loading…
Cancel
Save