Skip to content

Commit

Permalink
Search diagnosis: Fix session list filtered by user - refs BT#18899
Browse files Browse the repository at this point in the history
  • Loading branch information
cfasanando committed Sep 4, 2021
1 parent 5c51efc commit d33df97
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
15 changes: 7 additions & 8 deletions public/main/inc/ajax/model.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -829,11 +829,13 @@ function getWhereClause($col, $oper, $val)
case 'custom':
case 'simple':
$count = SessionManager::getSessionsForAdmin(
api_get_user_id(),
['where' => $whereCondition, 'extra' => $extra_fields],
true,
[],
$extraFieldsToLoad,
$language
$listType,
$extraFieldsToLoad
);
break;
case 'active':
Expand Down Expand Up @@ -1930,10 +1932,6 @@ function getWhereClause($col, $oper, $val)
}
break;
case 'get_sessions':
$listType = isset($_REQUEST['list_type']) ? $_REQUEST['list_type'] : 'simple';
$language = isset($_REQUEST['lang']) ? $_REQUEST['lang'] : '';
$order = isset($_REQUEST['order']) ? $_REQUEST['order'] : '';

$sessionColumns = SessionManager::getGridColumns($listType);
$columns = $sessionColumns['simple_column_name'];

Expand Down Expand Up @@ -1964,6 +1962,7 @@ function getWhereClause($col, $oper, $val)
case 'custom':
case 'simple':
$result = SessionManager::getSessionsForAdmin(
api_get_user_id(),
[
'where' => $whereCondition,
'order' => "$sidx $sord, s.name",
Expand All @@ -1972,8 +1971,8 @@ function getWhereClause($col, $oper, $val)
],
false,
$sessionColumns,
$extraFieldsToLoad,
$language,
$listType,
$extraFieldsToLoad
);
break;
case 'active':
Expand All @@ -1988,7 +1987,7 @@ function getWhereClause($col, $oper, $val)
],
false,
$sessionColumns,
[],
$extraFieldsToLoad,
$listType
);
break;
Expand Down
15 changes: 8 additions & 7 deletions public/main/inc/lib/sessionmanager.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ public static function getSessionsForAdmin(
$options = [],
$getCount = false,
$columns = [],
$listType = 'all'
$listType = 'all',
$extraFieldsToLoad = []
) {
$tblSession = Database::get_main_table(TABLE_MAIN_SESSION);
$sessionCategoryTable = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
Expand All @@ -506,10 +507,8 @@ public static function getSessionsForAdmin(
) {
$where .= " AND s.id_coach = $userId ";
}

$extraFieldModel = new ExtraFieldModel('session');
$conditions = $extraFieldModel->parseConditions($options);

$sqlInjectJoins = $conditions['inject_joins'];
$where .= $conditions['where'];
$sqlInjectWhere = $conditions['inject_where'];
Expand Down Expand Up @@ -544,6 +543,11 @@ public static function getSessionsForAdmin(
s.id
";

// ofaj fix
if (!empty($extraFieldsToLoad)) {
$select = "SELECT DISTINCT s.* ";
}

if ($showCountUsers) {
$select .= ', count(su.user_id) users';
}
Expand Down Expand Up @@ -642,14 +646,12 @@ public static function getSessionsForAdmin(
$query .= $order;
$query .= $limit;
$result = Database::query($query);

$sessions = Database::store_result($result, 'ASSOC');

if ('all' === $listType) {
if ($getCount) {
return $sessions[0]['total_rows'];
}

return $sessions;
}

Expand Down Expand Up @@ -683,9 +685,8 @@ public static function formatSessionsAdminForGrid(
}
}
}

$userId = api_get_user_id();
$sessions = self::getSessionsForAdmin($userId, $options, $getCount, $columns, $listType);
$sessions = self::getSessionsForAdmin($userId, $options, $getCount, $columns, $listType, $extraFieldsToLoad);
if ($getCount) {
return (int) $sessions;
}
Expand Down
6 changes: 3 additions & 3 deletions public/main/search/load_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@
$searchChecked3 = null === $searchChecked3 ? 'checked' : $searchChecked3;
}

$form->addStartPanel('dispo_avant', get_lang('Disponibilite Avant'));
$form->addStartPanel('dispo_avant', '<input type="checkbox" name="search_using_1" '.$searchChecked1.' />&nbsp;'.get_lang('Disponibilite Avant'));
$form->addHtml('<p class="text-info">'.get_lang('Disponibilite Avant Explanation').'</p>');

// Session fields
Expand Down Expand Up @@ -351,7 +351,7 @@

$form->addEndPanel();

$form->addStartPanel('theme_obj', get_lang('Themes Objectifs'));
$form->addStartPanel('theme_obj', '<input type="checkbox" name="search_using_2" '.$searchChecked2.' />&nbsp;'.get_lang('Themes Objectifs'));
$form->addHtml('<p class="text-info">'.get_lang('Themes Objectifs Explanation').'</p>');

$showOnlyThisFields = [
Expand Down Expand Up @@ -409,7 +409,7 @@

$form->addEndPanel();

$form->addStartPanel('niveau_langue', get_lang('Niveau Langue'));
$form->addStartPanel('niveau_langue', '<input type="checkbox" name="search_using_3" '.$searchChecked3.' />&nbsp;'.get_lang('Niveau Langue'));
$form->addHtml('<p class="text-info">'.get_lang('Niveau Langue Explanation').'</p>');

$showOnlyThisFields = [
Expand Down

0 comments on commit d33df97

Please sign in to comment.