Skip to content

Commit

Permalink
Plugin: Replaced tab character by 4 spaces in sql's strings, renamed …
Browse files Browse the repository at this point in the history
…export_csv by export, Changed param null to string|null in stardate and endate BT#17648 - refs #3461
  • Loading branch information
carlangas159 committed Sep 7, 2020
1 parent d02eb89 commit c8837dc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 35 deletions.
11 changes: 5 additions & 6 deletions main/inc/lib/extra_field.lib.php
Expand Up @@ -3134,15 +3134,14 @@ public static function getDisplayNameByVariable($variableName = null)
if ($variableName == null) {
return null;
}
$variableName = Security::remove_XSS($variableName);
$variableName = Database::escape_string($variableName);
$tblExtraField = Database::get_main_table(TABLE_EXTRA_FIELD);
$query = "SELECT
display_text
FROM
$tblExtraField
WHERE
variable = '$variableName'";
display_text
FROM
$tblExtraField
WHERE
variable = '$variableName'";
$companyField = Database::fetch_assoc(Database::query($query));

if ($companyField == false or !isset($companyField['display_text'])) {
Expand Down
23 changes: 11 additions & 12 deletions main/inc/lib/myspace.lib.php
Expand Up @@ -1011,8 +1011,8 @@ public static function display_user_overview_export_options()
* Export to cvs a list of users who were enrolled in the lessons.
* It is necessary that in the extra field, a company is defined.
*
* @param null $startDate
* @param null $endDate
* @param string|null $startDate
* @param string|null $endDate
*
* @return array
*/
Expand Down Expand Up @@ -1052,8 +1052,8 @@ public static function exportCompanyResumeCsv($startDate, $endDate)
* Displays a list as a table of users who were enrolled in the lessons.
* It is necessary that in the extra field, a company is defined.
*
* @param null $startDate
* @param null $endDate
* @param string|null $startDate
* @param string|null $endDate
*/
public static function displayResumeCompany(
$startDate = null,
Expand Down Expand Up @@ -1094,7 +1094,7 @@ public static function displayResumeCompany(
//$form->addButtonSave(get_lang('Ok'), 'export');
$form
->addButton(
'export_csv',
'export',
get_lang('ExportAsCSV'),
'check',
'primary',
Expand All @@ -1118,8 +1118,8 @@ public static function displayResumeCompany(
/**
* Displays a list as a table of teachers who are set authors by a extra_field authors.
*
* @param null $startDate
* @param null $endDate
* @param string|null $startDate
* @param string|null $endDate
* @param bool $csv
*/
public static function displayResumeLP(
Expand Down Expand Up @@ -1157,7 +1157,6 @@ public static function displayResumeLP(
$registeredUsers = self::getCompanyLearnpathSubscription($startDate, $endDate, $lp_id);
if (!empty($registeredUsers)) {
$lp_info = [];
$teacherList = [];
$teachersId = explode(',', trim($row['users_id'], ","));
$lp_table = Database::get_course_table(TABLE_LP_MAIN);
$query = "
Expand Down Expand Up @@ -1203,7 +1202,7 @@ public static function displayResumeLP(
$index = 0;
//icons for show and hode
$iconAdd = Display::return_icon('add.png', get_lang('ShowOrHide'), '', ICON_SIZE_SMALL);
$iconRemove = Display::return_icon('error.png', get_lang('howOrHide'), '', ICON_SIZE_SMALL);
$iconRemove = Display::return_icon('error.png', get_lang('ShowOrHide'), '', ICON_SIZE_SMALL);
$teacherNameTemp = '';
foreach ($data as $teacherName => $reportData) {
$lpCount = 0;
Expand Down Expand Up @@ -1264,7 +1263,7 @@ public static function displayResumeLP(
//$form->addButtonSave(get_lang('Ok'), 'export');
$form
->addButton(
'export_csv',
'export',
get_lang('ExportAsCSV'),
'check',
'primary',
Expand Down Expand Up @@ -3615,8 +3614,8 @@ public static function grapher($sql_result, $start_date, $end_date, $type = '')
*
* if lpId is different to 0, this search by lp id too
*
* @param null $startDate
* @param null $endDate
* @param string|null $startDate
* @param string|null $endDate
* @param int $lpId
*
* @return array
Expand Down
2 changes: 0 additions & 2 deletions main/mySpace/admin_view.php
Expand Up @@ -9,8 +9,6 @@
api_block_anonymous_users();

$exportCSV = isset($_GET['export']) && $_GET['export'] === 'csv' ? true : false;
// Catch param export_csv from buttom
$exportCSV = isset($_GET['export_csv']) && $exportCSV == false ? true : false;
$display = isset($_GET['display']) ? Security::remove_XSS($_GET['display']) : null;

$htmlHeadXtra[] = api_get_jqgrid_js();
Expand Down
@@ -1,5 +1,7 @@
<?php

/* For license terms, see /license.txt */

/**
* Class CheckExtraFieldAuthorsCompanyPlugin.
*/
Expand Down Expand Up @@ -254,11 +256,11 @@ public function setCompanyExtrafieldData()
];
$order = 0;
$query = "SELECT
id
FROM
".$this->tblExtraField."
WHERE
variable = 'company'";
id
FROM
".$this->tblExtraField."
WHERE
variable = 'company'";
$companyId = Database::fetch_assoc(Database::query($query));
$companyId = isset($companyId['id']) ? $companyId['id'] : null;
for ($i = 0; $i < count($companys); $i++) {
Expand Down Expand Up @@ -297,11 +299,11 @@ protected function getInfoExtrafield($variableName = null)
$variableName = strtolower(Database::escape_string(Security::remove_XSS($variableName)));
$tblExtraField = $this->tblExtraField;
$query = "SELECT
*
FROM
$tblExtraField
WHERE
variable = '$variableName'";
*
FROM
$tblExtraField
WHERE
variable = '$variableName'";
$data = Database::fetch_assoc(Database::query($query));
if ($data == false or !isset($data['display_text'])) {
return [];
Expand Down Expand Up @@ -333,11 +335,11 @@ protected function deleteQuery($data)
}
if ($validVariable == true && $id != 0 && !empty($extraFieldType)) {
$query = "SELECT
id
FROM
".$this->tblExtraField."
WHERE
id = $id
id
FROM
".$this->tblExtraField."
WHERE
id = $id
AND
variable = '$variable'
AND
Expand Down

0 comments on commit c8837dc

Please sign in to comment.