Minor - format code, add int casting

pull/2926/head
Julio Montoya 7 years ago
parent 030527eb4e
commit 92475187fa
  1. 5
      main/inc/lib/fileUpload.lib.php
  2. 9
      plugin/azure_active_directory/src/callback.php
  3. 4
      plugin/sepe/src/formative-action-edit.php
  4. 2
      plugin/sepe/src/formative-action.php
  5. 5
      plugin/sepe/src/formative-actions-list.php
  6. 57
      plugin/sepe/src/identification-data-edit.php
  7. 6
      plugin/sepe/src/participant-action-edit.php
  8. 4
      plugin/sepe/src/participant-specialty-edit.php
  9. 100
      plugin/sepe/src/sepe.lib.php
  10. 4
      plugin/sepe/src/specialty-classroom-edit.php
  11. 6
      plugin/sepe/src/specialty-tutor-edit.php

@ -1222,7 +1222,7 @@ function clean_up_files_in_zip($p_event, &$p_header)
}
/**
* Allow .htaccess file
* Allow .htaccess file.
*
* @param $p_event
* @param $p_header
@ -1243,7 +1243,7 @@ function cleanZipFilesAllowHtaccess($p_event, &$p_header)
$skipFiles = [
'__MACOSX',
'.Thumbs.db',
'Thumbs.db'
'Thumbs.db',
];
if (in_array($baseName, $skipFiles)) {
@ -1255,7 +1255,6 @@ function cleanZipFilesAllowHtaccess($p_event, &$p_header)
return 1;
}
/**
* This function cleans up a given path
* by eliminating dangerous file names and cleaning them.

@ -11,13 +11,8 @@ if (isset($_POST['error']) || empty($_REQUEST)) {
list($jwtHeader, $jwtPayload, $jwtSignature) = explode('.', $_REQUEST['id_token']);
$jwtHeader = json_decode(
base64_decode($jwtHeader)
);
$jwtPayload = json_decode(
base64_decode($jwtPayload)
);
$jwtHeader = json_decode(base64_decode($jwtHeader));
$jwtPayload = json_decode(base64_decode($jwtPayload));
$u = [
'firstname' => $jwtPayload->given_name,

@ -154,11 +154,11 @@ if (api_is_platform_admin()) {
$tpl->assign('new_action', '1');
$tpl->assign('course_id', intval($_GET['cid']));
} else {
$courseId = getCourse(intval($_GET['action_id']));
$courseId = getCourse($_GET['action_id']);
$interbreadcrumb[] = ["url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')];
$interbreadcrumb[] = ["url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')];
$interbreadcrumb[] = ["url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction')];
$info = getActionInfo(intval($_GET['action_id']));
$info = getActionInfo($_GET['action_id']);
$templateName = $plugin->get_lang('formativeActionEdit');
$tpl = new Template($templateName);
$tpl->assign('info', $info);

@ -11,7 +11,7 @@ $plugin = SepePlugin::create();
$_cid = 0;
if (api_is_platform_admin()) {
$actionId = getActionId(intval($_GET['cid']));
$actionId = getActionId($_GET['cid']);
$info = getActionInfo($actionId);
if ($info === false) {
header("Location: formative-actions-list.php");

@ -10,7 +10,10 @@ $plugin = SepePlugin::create();
if (api_is_platform_admin()) {
$templateName = $plugin->get_lang('FormativesActionsList');
$interbreadcrumb[] = ["url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')];
$interbreadcrumb[] = [
"url" => "/plugin/sepe/src/sepe-administration-menu.php",
"name" => $plugin->get_lang('MenuSepe'),
];
$tpl = new Template($templateName);
if (isset($_SESSION['sepe_message_info'])) {

@ -20,34 +20,34 @@ if (!empty($_POST)) {
$id = intval($_POST['id']);
if (checkIdentificationData()) {
$sql = "UPDATE $tableSepeCenter SET
center_origin = '".$centerOrigin."',
center_code = '".$centerCode."',
center_name = '".$centerName."',
url = '".$url."',
tracking_url = '".$trackingUrl."',
phone = '".$phone."',
mail = '".$mail."'
$sql = "UPDATE $tableSepeCenter SET
center_origin = '".$centerOrigin."',
center_code = '".$centerCode."',
center_name = '".$centerName."',
url = '".$url."',
tracking_url = '".$trackingUrl."',
phone = '".$phone."',
mail = '".$mail."'
WHERE id = $id";
} else {
$sql = "INSERT INTO $tableSepeCenter (
id,
center_origin,
center_code,
center_name,
url,
tracking_url,
phone,
mail
) VALUES (
1,
'".$centerOrigin."',
'".$centerCode."',
'".$centerName."',
'".$url."',
'".$trackingUrl."',
'".$phone."',
'".$mail."'
$sql = "INSERT INTO $tableSepeCenter (
id,
center_origin,
center_code,
center_name,
url,
tracking_url,
phone,
mail
) VALUES (
1,
'".$centerOrigin."',
'".$centerCode."',
'".$centerName."',
'".$url."',
'".$trackingUrl."',
'".$phone."',
'".$mail."'
);";
}
$res = Database::query($sql);
@ -67,7 +67,10 @@ if (!empty($_POST)) {
}
if (api_is_platform_admin()) {
$interbreadcrumb[] = ["url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')];
$interbreadcrumb[] = [
"url" => "/plugin/sepe/src/sepe-administration-menu.php",
"name" => $plugin->get_lang('MenuSepe'),
];
$interbreadcrumb[] = ["url" => "identification-data.php", "name" => $plugin->get_lang('DataCenter')];
$templateName = $plugin->get_lang('DataCenterEdit');
$tpl = new Template($templateName);

@ -201,10 +201,10 @@ if (api_is_platform_admin()) {
$templateName = $plugin->get_lang('EditParticipantAction');
$tpl = new Template($templateName);
$tpl->assign('action_id', $actionId);
$info = getInfoParticipantAction(intval($_GET['participant_id']));
$info = getInfoParticipantAction($_GET['participant_id']);
$tpl->assign('info', $info);
$tpl->assign('new_participant', '0');
$tpl->assign('participant_id', intval($_GET['participant_id']));
$tpl->assign('participant_id', (int) $_GET['participant_id']);
if ($info['platform_user_id'] != 0) {
$infoUserPlatform = api_get_user_info($info['platform_user_id']);
@ -225,10 +225,8 @@ if (api_is_platform_admin()) {
}
}
$tpl->assign('listStudent', $listStudentInfo);
$listTutorCompany = [];
$listTutorCompany = listTutorType("company = '1'");
$tpl->assign('list_tutor_company', $listTutorCompany);
$listTutorTraining = [];
$listTutorTraining = listTutorType("training = '1'");
$tpl->assign('list_tutor_training', $listTutorTraining);
if (isset($_SESSION['sepe_message_info'])) {

@ -178,7 +178,7 @@ if (api_is_platform_admin()) {
$tpl->assign('action_id', $actionId);
$tpl->assign('specialty_id', intval($_GET['specialty_id']));
$tpl->assign('participant_id', intval($_GET['participant_id']));
$info = getInfoSpecialtyParticipant(intval($_GET['specialty_id']));
$info = getInfoSpecialtyParticipant($_GET['specialty_id']);
$tpl->assign('info', $info);
$tpl->assign('new_specialty', '0');
if ($info['registration_date'] != '0000-00-00' && $info['registration_date'] != null) {
@ -221,7 +221,7 @@ if (api_is_platform_admin()) {
} else {
$endYear = date("Y");
}
$listSpecialtyTutorials = getListSpecialtyTutorial(intval($_GET['specialty_id']));
$listSpecialtyTutorials = getListSpecialtyTutorial($_GET['specialty_id']);
$tpl->assign('listSpecialtyTutorials', $listSpecialtyTutorials);
}

@ -59,6 +59,7 @@ function checkIdentificationData()
function getActionId($courseId)
{
global $tableSepeCourseActions;
$courseId = (int) $courseId;
$sql = "SELECT action_id FROM $tableSepeCourseActions WHERE course_id = $courseId";
$rs = Database::query($sql);
$aux = Database::fetch_assoc($rs);
@ -69,6 +70,7 @@ function getActionId($courseId)
function getCourse($actionId)
{
global $tableSepeCourseActions;
$actionId = (int) $actionId;
$sql = "SELECT course_id FROM $tableSepeCourseActions WHERE action_id = $actionId";
$rs = Database::query($sql);
$aux = Database::fetch_assoc($rs);
@ -78,6 +80,7 @@ function getCourse($actionId)
function getCourseCode($actionId)
{
global $tableCourse;
$actionId = (int) $actionId;
$courseId = getCourse($actionId);
$sql = "SELECT code FROM $tableCourse WHERE id = $courseId";
$rs = Database::query($sql);
@ -89,6 +92,8 @@ function getCourseCode($actionId)
function getActionInfo($id)
{
global $tableSepeActions;
$id = (int) $id;
$sql = "SELECT * FROM $tableSepeActions WHERE id = $id";
$res = Database::query($sql);
$row = false;
@ -115,6 +120,7 @@ function getActionInfo($id)
function getSpecialtActionInfo($specialtyId)
{
global $tableSepeSpecialty;
$specialtyId = (int) $specialtyId;
$sql = "SELECT * FROM $tableSepeSpecialty WHERE id = $specialtyId";
$res = Database::query($sql);
$row = false;
@ -135,8 +141,10 @@ function getInfoSpecialtyClassroom($classroomId)
{
global $tableSepeSpecialtyClassroom;
global $tableCenters;
$sql = "SELECT a.*, center_origin, center_code
FROM $tableSepeSpecialtyClassroom a LEFT JOIN $tableCenters b ON a.center_id = b.id
$classroomId = (int) $classroomId;
$sql = "SELECT a.*, center_origin, center_code
FROM $tableSepeSpecialtyClassroom a
LEFT JOIN $tableCenters b ON a.center_id = b.id
WHERE a.id = $classroomId";
$res = Database::query($sql);
$row = false;
@ -152,6 +160,7 @@ function getInfoSpecialtyClassroom($classroomId)
function getInfoSpecialtyTutorial($tutorialId)
{
global $tableSepeParticipantsSpecialtyTutorials;
$tutorialId = (int) $tutorialId;
$sql = "SELECT * FROM $tableSepeParticipantsSpecialtyTutorials WHERE id = $tutorialId";
$res = Database::query($sql);
$aux = [];
@ -167,6 +176,7 @@ function getInfoSpecialtyTutorial($tutorialId)
function list_tutor($specialtyId)
{
global $tableSepeSpecialtyTutors;
$specialtyId = (int) $specialtyId;
$sql = "SELECT * FROM $tableSepeSpecialtyTutors WHERE specialty_id = $specialtyId";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
@ -194,6 +204,7 @@ function getCentersList()
function listTutorType($condition)
{
global $tableTutorCompany;
$condition = Database::escape_string($condition);
$sql = "SELECT * FROM $tableTutorCompany WHERE ".$condition." ORDER BY alias ASC, document_number ASC;";
$res = Database::query($sql);
$aux = [];
@ -216,14 +227,17 @@ function getTutorsSpecialty($specialtyId)
global $tableSepeSpecialtyTutors;
global $tableSepeTutors;
global $tableUser;
$specialtyId = (int) $specialtyId;
$sql = "SELECT tutor_id FROM $tableSepeSpecialtyTutors WHERE specialty_id = $specialtyId";
$rs = Database::query($sql);
$tutorsList = [];
while ($tmp = Database::fetch_assoc($rs)) {
$tutorsList[] = $tmp['tutor_id'];
}
$sql = "SELECT a.*, b.firstname AS firstname, b.lastname AS lastname
FROM $tableSepeTutors AS a LEFT JOIN $tableUser AS b ON a.platform_user_id=b.user_id;";
$sql = "SELECT a.*, b.firstname AS firstname, b.lastname AS lastname
FROM $tableSepeTutors AS a
LEFT JOIN $tableUser AS b ON a.platform_user_id=b.user_id;";
$res = Database::query($sql);
$aux = [];
while ($row = Database::fetch_assoc($res)) {
@ -246,9 +260,10 @@ function getInfoSpecialtyTutor($tutorId)
{
global $tableSepeSpecialtyTutors;
global $tableSepeTutors;
$sql = "SELECT a.*,platform_user_id,document_type, document_number,document_letter
FROM $tableSepeSpecialtyTutors a
INNER JOIN $tableSepeTutors b ON a.tutor_id=b.id
$tutorId = (int) $tutorId;
$sql = "SELECT a.*,platform_user_id,document_type, document_number,document_letter
FROM $tableSepeSpecialtyTutors a
INNER JOIN $tableSepeTutors b ON a.tutor_id=b.id
WHERE a.id = $tutorId;";
$res = Database::query($sql);
$aux = [];
@ -268,6 +283,10 @@ function freeTeacherList($teacherList, $specialtyId, $platform_user_id)
{
global $tableSepeSpecialtyTutors;
global $tableSepeTutors;
$specialtyId = (int) $specialtyId;
$platform_user_id = (int) $platform_user_id;
$sql = "SELECT tutor_id FROM $tableSepeSpecialtyTutors WHERE specialty_id = $specialtyId";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
@ -294,9 +313,9 @@ function freeTeacherList($teacherList, $specialtyId, $platform_user_id)
function getInfoParticipantAction($participantId)
{
global $tableSepeParticipants;
$participantId = (int) $participantId;
$sql = "SELECT * FROM $tableSepeParticipants WHERE id = $participantId";
$res = Database::query($sql);
$aux = [];
if (Database::num_rows($res) > 0) {
$row = Database::fetch_assoc($res);
$result = [];
@ -321,6 +340,7 @@ function getInfoParticipantAction($participantId)
function getParticipantId($id)
{
global $tableSepeParticipantsSpecialty;
$id = (int) $id;
$sql = "SELECT participant_id FROM $tableSepeParticipantsSpecialty WHERE id = $id";
$rs = Database::query($sql);
$aux = Database::fetch_assoc($rs);
@ -331,9 +351,9 @@ function getParticipantId($id)
function getInfoSpecialtyParticipant($specialtyId)
{
global $tableSepeParticipantsSpecialty;
$specialtyId = (int) $specialtyId;
$sql = "SELECT * FROM $tableSepeParticipantsSpecialty WHERE id = $specialtyId";
$res = Database::query($sql);
$aux = [];
if (Database::num_rows($res) > 0) {
$row = Database::fetch_assoc($res);
$row['specialty_origin'] = Security::remove_XSS(stripslashes($row['specialty_origin']));
@ -354,8 +374,9 @@ function getInfoSpecialtyParticipant($specialtyId)
function specialtyList($actionId)
{
global $tableSepeSpecialty;
$sql = "SELECT id, specialty_origin, professional_area, specialty_code
FROM $tableSepeSpecialty
$actionId = (int) $actionId;
$sql = "SELECT id, specialty_origin, professional_area, specialty_code
FROM $tableSepeSpecialty
WHERE action_id = $actionId";
$res = Database::query($sql);
$aux = [];
@ -370,8 +391,10 @@ function participantList($actionId)
{
global $tableSepeParticipants;
global $tableUser;
$sql = "SELECT $tableSepeParticipants.id AS id, document_type, document_number, document_letter, firstname, lastname
FROM $tableSepeParticipants LEFT JOIN $tableUser ON $tableSepeParticipants.platform_user_id=$tableUser.user_id
$actionId = (int) $actionId;
$sql = "SELECT $tableSepeParticipants.id AS id, document_type, document_number, document_letter, firstname, lastname
FROM $tableSepeParticipants
LEFT JOIN $tableUser ON $tableSepeParticipants.platform_user_id=$tableUser.user_id
WHERE action_id = $actionId";
$res = Database::query($sql);
$aux = [];
@ -385,6 +408,8 @@ function participantList($actionId)
function listParticipantSpecialty($participantId)
{
global $tableSepeParticipantsSpecialty;
$participantId = (int) $participantId;
$sql = "SELECT * FROM $tableSepeParticipantsSpecialty WHERE participant_id = $participantId";
$res = Database::query($sql);
$aux = [];
@ -407,8 +432,10 @@ function classroomList($specialtyId)
{
global $tableSepeSpecialtyClassroom;
global $tableCenters;
$sql = "SELECT a.*, center_origin, center_code
FROM $tableSepeSpecialtyClassroom a LEFT JOIN $tableCenters b ON a.center_id=b.id
$specialtyId = (int) $specialtyId;
$sql = "SELECT a.*, center_origin, center_code
FROM $tableSepeSpecialtyClassroom a
LEFT JOIN $tableCenters b ON a.center_id=b.id
WHERE specialty_id = $specialtyId";
$res = Database::query($sql);
$aux = [];
@ -424,10 +451,12 @@ function tutorsList($specialtyId)
global $tableSepeSpecialtyTutors;
global $tableSepeTutors;
global $tableUser;
$specialtyId = (int) $specialtyId;
$aux = [];
$sql = "SELECT a.*,document_type,document_number,document_letter, firstname, lastname FROM $tableSepeSpecialtyTutors a
INNER JOIN $tableSepeTutors b ON a.tutor_id=b.id
LEFT JOIN $tableUser c ON b.platform_user_id=c.user_id
$sql = "SELECT a.*,document_type,document_number,document_letter, firstname, lastname
FROM $tableSepeSpecialtyTutors a
INNER JOIN $tableSepeTutors b ON a.tutor_id=b.id
LEFT JOIN $tableUser c ON b.platform_user_id=c.user_id
WHERE a.specialty_id = $specialtyId";
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) {
@ -440,7 +469,9 @@ function tutorsList($specialtyId)
function getListSpecialtyTutorial($specialtyId)
{
global $tableSepeParticipantsSpecialtyTutorials;
$sql = "SELECT * FROM $tableSepeParticipantsSpecialtyTutorials WHERE participant_specialty_id = $specialtyId";
$specialtyId = (int) $specialtyId;
$sql = "SELECT * FROM $tableSepeParticipantsSpecialtyTutorials
WHERE participant_specialty_id = $specialtyId";
$res = Database::query($sql);
$aux = [];
while ($row = Database::fetch_assoc($res)) {
@ -457,9 +488,10 @@ function listCourseAction()
{
global $tableSepeActions;
global $tableSepeCourseActions;
$sql = "SELECT $tableSepeCourseActions.*, course.title AS title, $tableSepeActions.action_origin AS action_origin, $tableSepeActions.action_code AS action_code
FROM $tableSepeCourseActions, course, $tableSepeActions
WHERE $tableSepeCourseActions.course_id=course.id
$sql = "SELECT $tableSepeCourseActions.*, course.title AS title, $tableSepeActions.action_origin AS action_origin, $tableSepeActions.action_code AS action_code
FROM $tableSepeCourseActions, course, $tableSepeActions
WHERE $tableSepeCourseActions.course_id=course.id
AND $tableSepeActions.id=$tableSepeCourseActions.action_id";
$res = Database::query($sql);
$aux = [];
@ -474,9 +506,10 @@ function listCourseFree()
{
global $tableCourse;
global $tableSepeCourseActions;
$sql = "SELECT id, title FROM $tableCourse
WHERE NOT EXISTS (
SELECT * FROM $tableSepeCourseActions WHERE $tableCourse.id = $tableSepeCourseActions.course_id)
$sql = "SELECT id, title FROM $tableCourse
WHERE NOT EXISTS (
SELECT * FROM $tableSepeCourseActions
WHERE $tableCourse.id = $tableSepeCourseActions.course_id)
;";
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) {
@ -490,9 +523,9 @@ function listActionFree()
{
global $tableSepeActions;
global $tableSepeCourseActions;
$sql = "SELECT id, action_origin, action_code FROM $tableSepeActions
WHERE NOT EXISTS (
SELECT * FROM $tableSepeCourseActions WHERE $tableSepeActions.id = $tableSepeCourseActions.action_id)
$sql = "SELECT id, action_origin, action_code FROM $tableSepeActions
WHERE NOT EXISTS (
SELECT * FROM $tableSepeCourseActions WHERE $tableSepeActions.id = $tableSepeCourseActions.action_id)
;";
$res = Database::query($sql);
$aux = [];
@ -508,8 +541,11 @@ function listActionFree()
function getSpecialtyTutorId($specialtyId, $tutorId)
{
global $tableSepeSpecialtyTutors;
$sql = "SELECT id
FROM $tableSepeSpecialtyTutors
$specialtyId = (int) $specialtyId;
$tutorId = (int) $tutorId;
$sql = "SELECT id
FROM $tableSepeSpecialtyTutors
WHERE specialty_id = $specialtyId AND tutor_id = $tutorId";
$res = Database::query($sql);
$row = Database::fetch_assoc($res);
@ -520,6 +556,8 @@ function getSpecialtyTutorId($specialtyId, $tutorId)
function checkInsertNewLog($platformUserId, $actionId)
{
global $tableSepeLogParticipant;
$platformUserId = (int) $platformUserId;
$actionId = (int) $actionId;
$sql = "SELECT * FROM $tableSepeLogParticipant WHERE platform_user_id = $platformUserId AND action_id = $actionId";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
@ -532,6 +570,8 @@ function checkInsertNewLog($platformUserId, $actionId)
function getUserPlatformFromParticipant($participantId)
{
global $tableSepeParticipants;
$participantId = (int) $participantId;
$sql = "SELECT * FROM $tableSepeParticipants WHERE id = $participantId";
$res = Database::query($sql);
$row = Database::fetch_assoc($res);

@ -85,7 +85,7 @@ if (!empty($_POST)) {
}
if (api_is_platform_admin()) {
$courseId = getCourse(intval($_GET['action_id']));
$courseId = getCourse($_GET['action_id']);
$interbreadcrumb[] = ["url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')];
$interbreadcrumb[] = ["url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')];
$interbreadcrumb[] = ["url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction')];
@ -104,7 +104,7 @@ if (api_is_platform_admin()) {
$tpl->assign('action_id', intval($_GET['action_id']));
$tpl->assign('specialty_id', intval($_GET['specialty_id']));
$tpl->assign('classroom_id', intval($_GET['classroom_id']));
$info = getInfoSpecialtyClassroom(intval($_GET['classroom_id']));
$info = getInfoSpecialtyClassroom($_GET['classroom_id']);
$tpl->assign('info', $info);
$tpl->assign('new_classroom', '0');
}

@ -189,16 +189,16 @@ if (api_is_platform_admin()) {
$tpl->assign('action_id', intval($_GET['action_id']));
$tpl->assign('specialty_id', intval($_GET['specialty_id']));
$tpl->assign('tutor_id', intval($_GET['tutor_id']));
$info = getInfoSpecialtyTutor(intval($_GET['tutor_id']));
$info = getInfoSpecialtyTutor($_GET['tutor_id']);
$tpl->assign('info', $info);
$tpl->assign('new_tutor', '0');
$platformUserId = $info['platform_user_id'];
}
$tutorsList = getTutorsSpecialty(intval($_GET['specialty_id']));
$tutorsList = getTutorsSpecialty($_GET['specialty_id']);
$tpl->assign('ExistingTutorsList', $tutorsList);
$listTeachers = CourseManager::getTeachersFromCourse($courseId);
$listTeachers = freeTeacherList($listTeachers, intval($_GET['specialty_id']), $platformUserId);
$listTeachers = freeTeacherList($listTeachers, $_GET['specialty_id'], $platformUserId);
$tpl->assign('listTeachers', $listTeachers);
if (isset($_SESSION['sepe_message_info'])) {
$tpl->assign('message_info', $_SESSION['sepe_message_info']);

Loading…
Cancel
Save