Plugin: Tracking: Changed sql to chamilo's type / Translate authors and company BT#17648 - refs #3461

pull/3462/head
carlos alvarado 5 years ago
parent 4a0ec8928f
commit 005e105c02
  1. 16
      main/inc/lib/myspace.lib.php
  2. 2
      main/mySpace/admin_view.php
  3. 100
      plugin/check_extra_field_author_company/CheckExtraFieldAuthorsCompanyPlugin.php

@ -1016,13 +1016,13 @@ class MySpace
*
* @return array
*/
public static function export_company_resume_csv($startDate, $endDate)
public static function exportCompanyResumeCsv($startDate, $endDate)
{
$companys = self::getCompanyLearnpathSubscription($startDate, $endDate);
$csv_content = [];
// Printing table
$total = 0;
$displayText = ExtraField::getDisplayNameByVariable('company');
$displayText = get_lang('Company');
// the first line of the csv file with the column headers
$csv_row = [];
$csv_row[] = $displayText;
@ -1065,7 +1065,7 @@ class MySpace
$total = 0;
$table = '<div class="table-responsive"><table class="table table-bordered data_table">';
$displayText = ExtraField::getDisplayNameByVariable('company');
$displayText = get_lang('Company');
$table .= "<thead><tr><th class=\"th-header\">$displayText</th><th class=\"th-header\"> ".get_lang('CountOfSubscribedUsers')." </th></tr></thead><tbody>";
foreach ($companys as $entity => $student) {
@ -1147,7 +1147,7 @@ class MySpace
WHERE
variable = 'authors'
)
AND sf.extra_field_type = 6
AND sf.extra_field_type = " . ExtraField::FIELD_TYPE_DATE . "
AND (s.value != '' OR s.value IS NOT NULL)
";
$queryResult = Database::query($query);
@ -1193,7 +1193,7 @@ class MySpace
"<table class='table table-bordered data_table'>".
"<thead>".
"<tr>".
"<th class=\"th-header\">".get_lang('CourseTeachers')."</th>".
"<th class=\"th-header\">".get_lang('Author')."</th>".
"<th class=\"th-header\">".get_lang('LearningPathList')."</th>".
"<th class=\"th-header\">".get_lang('CountOfSubscribedUsers')."</th>".
"<th class=\"th-header\">".get_lang('StudentList')."</th>".
@ -1283,7 +1283,7 @@ class MySpace
} else {
$csv_content = [];
$csv_row = [];
$csv_row[] = get_lang('CourseTeachers');
$csv_row[] = get_lang('Author');
$csv_row[] = get_lang('LearningPathList');
$csv_row[] = get_lang('CountOfSubscribedUsers');
$csv_row[] = get_lang('StudentList');
@ -3648,13 +3648,13 @@ class MySpace
// Settings condition and parametter GET to right date
if (!empty($startDate)) {
$startDate = $startDate->format('Y-m-d');
$startDate = api_get_utc_datetime($startDate->format('Y-m-d'));
$_GET['startDate'] = $startDate;
$whereCondition .= "
AND $tblItemProperty.lastedit_date >= '$startDate' ";
}
if (!empty($endDate)) {
$endDate = $endDate->format('Y-m-d');
$endDate = api_get_utc_datetime($endDate->format('Y-m-d'));
$_GET['endDate'] = $endDate;
$whereCondition .= "
AND $tblItemProperty.lastedit_date <= '$endDate' ";

@ -57,7 +57,7 @@ if ($exportCSV) {
// Getting dates
$startDate = isset($_GET['startDate']) ? $_GET['startDate'] : null;
$endDate = isset($_GET['endDate']) ? $_GET['endDate'] : null;
MySpace::export_company_resume_csv($startDate, $endDate);
MySpace::exportCompanyResumeCsv($startDate, $endDate);
exit;
} elseif ('learningPath' === $display) {
// Getting dates

@ -52,10 +52,10 @@ class CheckExtraFieldAuthorsCompanyPlugin extends Plugin
$this->authorsExist = false;
}
$this->authorsField = [
'extra_field_type' => 6,
'field_type' => 5,
'extra_field_type' => ExtraField::FIELD_TYPE_DATE,
'field_type' => ExtraField::FIELD_TYPE_SELECT_MULTIPLE,
'variable' => 'authors',
'display_text' => 'Authors',
'display_text' => get_lang('Authors'),
'default_value' => '',
'field_order' => 0,
'visible_to_self' => 1,
@ -64,10 +64,10 @@ class CheckExtraFieldAuthorsCompanyPlugin extends Plugin
'filter' => 1,
];
$this->companyField = [
'extra_field_type' => 1,
'field_type' => 3,
'extra_field_type' => ExtraField::FIELD_TYPE_TEXT,
'field_type' => ExtraField::FIELD_TYPE_RADIO,
'variable' => 'company',
'display_text' => 'Company',
'display_text' => get_lang('Company'),
'default_value' => '',
'field_order' => 0,
'visible_to_self' => 0,
@ -151,8 +151,10 @@ class CheckExtraFieldAuthorsCompanyPlugin extends Plugin
$data['filter'] = (int) $data['filter'];
$data['default_value'] = '';
$data['variable'] = 'company';
$data['display_text'] = strtolower(Database::escape_string(Security::remove_XSS($data['display_text'])));
$this->queryInsertUpdate($data);
$data['visible'] = 1;
$data['display_text'] = strtoupper(strtolower(Database::escape_string(Security::remove_XSS($data['display_text']))));
$schedule = new ExtraField('user');
$schedule->save($data);
}
/**
@ -201,8 +203,10 @@ class CheckExtraFieldAuthorsCompanyPlugin extends Plugin
$data['filter'] = (int) $data['filter'];
$data['default_value'] = null;
$data['variable'] = 'authors';
$data['display_text'] = strtolower(Database::escape_string(Security::remove_XSS($data['display_text'])));
$this->queryInsertUpdate($data);
$data['visible'] = 1;
$data['display_text'] = strtoupper(strtolower(Database::escape_string(Security::remove_XSS($data['display_text']))));
$schedule = new ExtraField('lp');
$schedule->save($data);
}
/**
@ -306,82 +310,6 @@ class CheckExtraFieldAuthorsCompanyPlugin extends Plugin
return $data;
}
/**
* Executes the insertion or update of the queries in the database for the extra_field table.
*
* @param $data
*/
protected function queryInsertUpdate($data)
{
$data['extra_field_type'] = (int) $data['extra_field_type'];
$data['field_type'] = (int) $data['field_type'];
$data['field_order'] = (int) $data['field_order'];
$data['visible_to_self'] = (int) $data['visible_to_self'];
$data['visible_to_others'] = (int) $data['visible_to_others'];
$data['changeable'] = (int) $data['changeable'];
$data['filter'] = (int) $data['filter'];
$data['default_value'] = '';
// $data['variable'] = $variable;
$data['display_text'] = strtolower(Database::escape_string(Security::remove_XSS($data['display_text'])));
$exist = null;
$validVariable = false;
$variable = $data['variable'];
if ($variable == 'company') {
$exist = $this->CompanyFieldExist();
$validVariable = true;
} elseif ($variable == 'authors') {
$exist = $this->AuthorsFieldExist();
$validVariable = true;
}
if ($exist == true) {
$query = "
UPDATE ".$this->tblExtraField."
SET
`extra_field_type` = ".$data['extra_field_type'].",
`field_type` = ".$data['field_type'].",
`variable` = '".$data['variable']."',
`default_value` = '".$data['default_value']."',
`field_order` = ".$data['field_order'].",
`visible_to_self` = ".$data['visible_to_self'].",
`visible_to_others` = ".$data['visible_to_others'].",
`changeable` = ".$data['changeable'].",
`filter` = ".$data['filter']."
WHERE
(`id` = ".$data['id'].");
";
} else {
$query = " INSERT INTO ".$this->tblExtraField." (
`extra_field_type`,
`field_type`,
`variable`,
`display_text`,
`default_value`,
`field_order`,
`visible_to_self`,
`visible_to_others`,
`changeable`,
`filter`
)
VALUES
(
".$data['extra_field_type'].",
".$data['field_type'].",
'".$data['variable']."',
'".$data['display_text']."',
'".$data['default_value']."',
".$data['field_order'].",
".$data['visible_to_self'].",
".$data['visible_to_others'].",
".$data['changeable'].",
".$data['filter']."
);
";
}
if ($validVariable == true) {
Database::query($query);
}
}
/**
* Executes fix removal for authors or company.
*

Loading…
Cancel
Save