Actualización
This commit is contained in:
43
plugin/sepe/src/configuration.php
Normal file
43
plugin/sepe/src/configuration.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* This script displays setting api key user.
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$course_plugin = 'sepe';
|
||||
$plugin = SepePlugin::create();
|
||||
$_cid = 0;
|
||||
|
||||
if (api_is_platform_admin()) {
|
||||
$tUser = Database::get_main_table(TABLE_MAIN_USER);
|
||||
$tApi = Database::get_main_table(TABLE_MAIN_USER_API_KEY);
|
||||
$login = 'SEPE';
|
||||
$sql = "SELECT a.api_key AS api
|
||||
FROM $tUser u, $tApi a
|
||||
WHERE u.username='".$login."' and u.user_id = a.user_id AND a.api_service = 'dokeos';";
|
||||
$result = Database::query($sql);
|
||||
if (Database::num_rows($result) > 0) {
|
||||
$tmp = Database::fetch_assoc($result);
|
||||
$info = $tmp['api'];
|
||||
} else {
|
||||
$info = '';
|
||||
}
|
||||
$templateName = $plugin->get_lang('Setting');
|
||||
$interbreadcrumb[] = [
|
||||
"url" => "/plugin/sepe/src/sepe-administration-menu.php",
|
||||
"name" => $plugin->get_lang('MenuSepe'),
|
||||
];
|
||||
$tpl = new Template($templateName);
|
||||
|
||||
$tpl->assign('info', $info);
|
||||
|
||||
$listing_tpl = 'sepe/view/configuration.tpl';
|
||||
$content = $tpl->fetch($listing_tpl);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
} else {
|
||||
header('Location:'.api_get_path(WEB_PATH));
|
||||
exit;
|
||||
}
|
||||
234
plugin/sepe/src/formative-action-edit.php
Normal file
234
plugin/sepe/src/formative-action-edit.php
Normal file
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* This script displays a formative action edit form.
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$course_plugin = 'sepe';
|
||||
$plugin = SepePlugin::create();
|
||||
$_cid = 0;
|
||||
|
||||
if (!empty($_POST)) {
|
||||
$check = Security::check_token('post');
|
||||
if ($check) {
|
||||
$actionOrigin = Database::escape_string(trim($_POST['action_origin']));
|
||||
$actionCode = Database::escape_string(trim($_POST['action_code']));
|
||||
$situation = Database::escape_string(trim($_POST['situation']));
|
||||
$specialtyOrigin = Database::escape_string(trim($_POST['specialty_origin']));
|
||||
$professionalArea = Database::escape_string(trim($_POST['professional_area']));
|
||||
$specialtyCode = Database::escape_string(trim($_POST['specialty_code']));
|
||||
$duration = Database::escape_string(trim($_POST['duration']));
|
||||
$dayStart = Database::escape_string(trim($_POST['day_start']));
|
||||
$monthStart = Database::escape_string(trim($_POST['month_start']));
|
||||
$yearStart = Database::escape_string(trim($_POST['year_start']));
|
||||
$dayEnd = Database::escape_string(trim($_POST['day_end']));
|
||||
$monthEnd = Database::escape_string(trim($_POST['month_end']));
|
||||
$yearEnd = Database::escape_string(trim($_POST['year_end']));
|
||||
$fullItineraryIndicator = Database::escape_string(trim($_POST['full_itinerary_indicator']));
|
||||
$financingType = Database::escape_string(trim($_POST['financing_type']));
|
||||
$attendeesCount = intval($_POST['attendees_count']);
|
||||
$actionName = Database::escape_string(trim($_POST['action_name']));
|
||||
$globalInfo = Database::escape_string(trim($_POST['global_info']));
|
||||
$schedule = Database::escape_string(trim($_POST['schedule']));
|
||||
$requirements = Database::escape_string(trim($_POST['requirements']));
|
||||
$contactAction = Database::escape_string(trim($_POST['contact_action']));
|
||||
$actionId = intval($_POST['action_id']);
|
||||
$courseId = intval($_POST['course_id']);
|
||||
|
||||
$startDate = $yearStart."-".$monthStart."-".$dayStart;
|
||||
$endDate = $yearEnd."-".$monthEnd."-".$dayEnd;
|
||||
|
||||
if (!empty($actionId) && $actionId != '0') {
|
||||
$sql = "UPDATE plugin_sepe_actions SET
|
||||
action_origin='".$actionOrigin."',
|
||||
action_code='".$actionCode."',
|
||||
situation='".$situation."',
|
||||
specialty_origin='".$specialtyOrigin."',
|
||||
professional_area='".$professionalArea."',
|
||||
specialty_code='".$specialtyCode."',
|
||||
duration='".$duration."',
|
||||
start_date='".$startDate."',
|
||||
end_date='".$endDate."',
|
||||
full_itinerary_indicator='".$fullItineraryIndicator."',
|
||||
financing_type='".$financingType."',
|
||||
attendees_count='".$attendeesCount."',
|
||||
action_name='".$actionName."',
|
||||
global_info='".$globalInfo."',
|
||||
schedule='".$schedule."',
|
||||
requirements='".$requirements."',
|
||||
contact_action='".$contactAction."'
|
||||
WHERE id='".$actionId."';";
|
||||
} else {
|
||||
$sql = "INSERT INTO plugin_sepe_actions (
|
||||
action_origin,
|
||||
action_code,
|
||||
situation,
|
||||
specialty_origin,
|
||||
professional_area,
|
||||
specialty_code,
|
||||
duration,
|
||||
start_date,
|
||||
end_date,
|
||||
full_itinerary_indicator,
|
||||
financing_type,
|
||||
attendees_count,
|
||||
action_name,
|
||||
global_info,
|
||||
schedule,
|
||||
requirements,
|
||||
contact_action
|
||||
) VALUES (
|
||||
'".$actionOrigin."',
|
||||
'".$actionCode."',
|
||||
'".$situation."',
|
||||
'".$specialtyOrigin."',
|
||||
'".$professionalArea."',
|
||||
'".$specialtyCode."',
|
||||
'".$duration."',
|
||||
'".$startDate."',
|
||||
'".$endDate."',
|
||||
'".$fullItineraryIndicator."',
|
||||
'".$financingType."',
|
||||
'".$attendeesCount."',
|
||||
'".$actionName."',
|
||||
'".$globalInfo."',
|
||||
'".$schedule."',
|
||||
'".$requirements."',
|
||||
'".$contactAction."'
|
||||
);";
|
||||
}
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange');
|
||||
} else {
|
||||
if ($actionId == '0') {
|
||||
//Sync formative action and course
|
||||
$actionId = Database::insert_id();
|
||||
$sql = "SELECT 1 FROM course WHERE id='".$courseId."';";
|
||||
$rs = Database::query($sql);
|
||||
if (Database::num_rows($rs) == 0) {
|
||||
$sepe_message_error .= $plugin->get_lang('NoExistsCourse');
|
||||
error_log($sepe_message_error);
|
||||
} else {
|
||||
$sql = "INSERT INTO $tableSepeCourseActions (course_id, action_id) VALUES ('".$courseId."','".$actionId."');";
|
||||
$rs = Database::query($sql);
|
||||
if (!$rs) {
|
||||
$sepe_message_error .= $plugin->get_lang('NoSaveSeleccion');
|
||||
error_log($sepe_message_error);
|
||||
} else {
|
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$courseId = getCourse($actionId);
|
||||
header("Location: formative-action.php?cid=".$courseId);
|
||||
} else {
|
||||
Security::clear_token();
|
||||
$token = Security::get_token();
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken');
|
||||
session_write_close();
|
||||
$actionId = intval($_POST['action_id']);
|
||||
if ($actionId == '0') {
|
||||
$courseId = intval($_POST['course_id']);
|
||||
header("Location: formative-action-edit.php?new_action=1&cid=".$courseId);
|
||||
} else {
|
||||
header("Location: formative-action-edit.php?action_id=".$actionId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$token = Security::get_token();
|
||||
}
|
||||
|
||||
if (api_is_platform_admin()) {
|
||||
if (isset($_GET['new_action']) && intval($_GET['new_action']) == 1) {
|
||||
$info = [];
|
||||
$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'),
|
||||
];
|
||||
$templateName = $plugin->get_lang('formativeActionNew');
|
||||
$tpl = new Template($templateName);
|
||||
$yearStart = $yearEnd = date("Y");
|
||||
$tpl->assign('info', $info);
|
||||
$tpl->assign('new_action', '1');
|
||||
$tpl->assign('course_id', intval($_GET['cid']));
|
||||
} else {
|
||||
$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($_GET['action_id']);
|
||||
$templateName = $plugin->get_lang('formativeActionEdit');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('info', $info);
|
||||
if ($info['start_date'] != "0000-00-00" && $info['start_date'] != null) {
|
||||
$tpl->assign('day_start', date("j", strtotime($info['start_date'])));
|
||||
$tpl->assign('month_start', date("n", strtotime($info['start_date'])));
|
||||
$tpl->assign('year_start', date("Y", strtotime($info['start_date'])));
|
||||
$yearStart = date("Y", strtotime($info['start_date']));
|
||||
} elseif (strpos($info['start_date'], '0000') === false) {
|
||||
$yearStart = date("Y", strtotime($info['start_date']));
|
||||
} else {
|
||||
$yearStart = date("Y");
|
||||
}
|
||||
if ($info['end_date'] != "0000-00-00" && $info['end_date'] != null) {
|
||||
$tpl->assign('day_end', date("j", strtotime($info['end_date'])));
|
||||
$tpl->assign('month_end', date("n", strtotime($info['end_date'])));
|
||||
$tpl->assign('year_end', date("Y", strtotime($info['end_date'])));
|
||||
$yearEnd = date("Y", strtotime($info['end_date']));
|
||||
} elseif (strpos($info['end_date'], '0000') === false) {
|
||||
$yearEnd = date("Y", strtotime($info['end_date']));
|
||||
} else {
|
||||
$yearEnd = date("Y");
|
||||
}
|
||||
$tpl->assign('new_action', '0');
|
||||
}
|
||||
|
||||
$yearList = [];
|
||||
if ($yearStart > $yearEnd) {
|
||||
$tmp = $yearStart;
|
||||
$yearStart = $yearEnd;
|
||||
$yearEnd = $tmp;
|
||||
}
|
||||
$yearStart -= 5;
|
||||
$yearEnd += 5;
|
||||
$fin_rango_anio = (($yearStart + 15) < $yearEnd) ? ($yearEnd + 1) : ($yearStart + 15);
|
||||
while ($yearStart <= $fin_rango_anio) {
|
||||
$yearList[] = $yearStart;
|
||||
$yearStart++;
|
||||
}
|
||||
$tpl->assign('list_year', $yearList);
|
||||
if (isset($_SESSION['sepe_message_info'])) {
|
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']);
|
||||
unset($_SESSION['sepe_message_info']);
|
||||
}
|
||||
if (isset($_SESSION['sepe_message_error'])) {
|
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']);
|
||||
unset($_SESSION['sepe_message_error']);
|
||||
}
|
||||
$tpl->assign('sec_token', $token);
|
||||
|
||||
$listing_tpl = 'sepe/view/formative-action-edit.tpl';
|
||||
$content = $tpl->fetch($listing_tpl);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
} else {
|
||||
header('Location:'.api_get_path(WEB_PATH));
|
||||
exit;
|
||||
}
|
||||
54
plugin/sepe/src/formative-action.php
Normal file
54
plugin/sepe/src/formative-action.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* This script displays a basic info of formative action.
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$course_plugin = 'sepe';
|
||||
$plugin = SepePlugin::create();
|
||||
$_cid = 0;
|
||||
|
||||
if (api_is_platform_admin()) {
|
||||
$actionId = getActionId($_GET['cid']);
|
||||
$info = getActionInfo($actionId);
|
||||
if ($info === false) {
|
||||
header("Location: formative-actions-list.php");
|
||||
exit;
|
||||
}
|
||||
$templateName = $plugin->get_lang('FormativeActionData');
|
||||
$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'),
|
||||
];
|
||||
$tpl = new Template($templateName);
|
||||
|
||||
if (isset($_SESSION['sepe_message_info'])) {
|
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']);
|
||||
unset($_SESSION['sepe_message_info']);
|
||||
}
|
||||
if (isset($_SESSION['sepe_message_error'])) {
|
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']);
|
||||
unset($_SESSION['sepe_message_error']);
|
||||
}
|
||||
|
||||
$tpl->assign('info', $info);
|
||||
$tpl->assign('start_date', date("d/m/Y", strtotime($info['start_date'])));
|
||||
$tpl->assign('end_date', date("d/m/Y", strtotime($info['end_date'])));
|
||||
$tpl->assign('action_id', $actionId);
|
||||
$listSpecialty = specialtyList($actionId);
|
||||
$tpl->assign('listSpecialty', $listSpecialty);
|
||||
$listParticipant = participantList($actionId);
|
||||
$tpl->assign('listParticipant', $listParticipant);
|
||||
$listing_tpl = 'sepe/view/formative-action.tpl';
|
||||
$content = $tpl->fetch($listing_tpl);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
} else {
|
||||
header('Location:'.api_get_path(WEB_PATH));
|
||||
}
|
||||
42
plugin/sepe/src/formative-actions-list.php
Normal file
42
plugin/sepe/src/formative-actions-list.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* This script displays a formatives actions list.
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$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'),
|
||||
];
|
||||
$tpl = new Template($templateName);
|
||||
|
||||
if (isset($_SESSION['sepe_message_info'])) {
|
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']);
|
||||
unset($_SESSION['sepe_message_info']);
|
||||
}
|
||||
if (isset($_SESSION['sepe_message_error'])) {
|
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']);
|
||||
unset($_SESSION['sepe_message_error']);
|
||||
}
|
||||
$courseActionList = listCourseAction();
|
||||
$courseFreeList = listCourseFree();
|
||||
$actionFreeList = listActionFree();
|
||||
|
||||
$tpl->assign('course_action_list', $courseActionList);
|
||||
$tpl->assign('course_free_list', $courseFreeList);
|
||||
$tpl->assign('action_free_list', $actionFreeList);
|
||||
|
||||
$listing_tpl = 'sepe/view/formative-actions-list.tpl';
|
||||
$content = $tpl->fetch($listing_tpl);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
} else {
|
||||
header('Location:'.api_get_path(WEB_PATH));
|
||||
exit;
|
||||
}
|
||||
200
plugin/sepe/src/function.php
Normal file
200
plugin/sepe/src/function.php
Normal file
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
/**
|
||||
* Functions for the Sepe plugin.
|
||||
*
|
||||
* @package chamilo.plugin.sepe
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$plugin = SepePlugin::create();
|
||||
|
||||
if ($_REQUEST['tab'] == 'delete_center_data') {
|
||||
$sql = "DELETE FROM $tableSepeCenter;";
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$sql = "DELETE FROM $tableSepeActions;";
|
||||
$res = Database::query($sql);
|
||||
$content = $plugin->get_lang('ProblemToDeleteInfoCenter');
|
||||
echo json_encode(["status" => "false", "content" => $content]);
|
||||
} else {
|
||||
$content = $plugin->get_lang('DeleteOk');
|
||||
echo json_encode(["status" => "true", "content" => $content]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST['tab'] == 'delete_action') {
|
||||
$id = intval($_REQUEST['id']);
|
||||
$sql = "DELETE FROM $tableSepeActions WHERE id = $id;";
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$content = $plugin->get_lang('ProblemToDeleteInfoAction');
|
||||
echo json_encode(["status" => "false", "content" => $content]);
|
||||
} else {
|
||||
$content = $plugin->get_lang('DeleteOk');
|
||||
$_SESSION['sepe_message_info'] = $content;
|
||||
echo json_encode(["status" => "true"]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST['tab'] == 'delete_specialty') {
|
||||
$id = intval(substr($_REQUEST['id'], 9));
|
||||
$sql = "DELETE FROM $tableSepeSpecialty WHERE id = $id;";
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$content = $plugin->get_lang('ProblemToDeleteInfoSpecialty');
|
||||
echo json_encode(["status" => "false", "content" => $content]);
|
||||
} else {
|
||||
$content = $plugin->get_lang('DeleteOk');
|
||||
echo json_encode(["status" => "true", "content" => $content]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST['tab'] == 'delete_specialty_participant') {
|
||||
$id = intval(substr($_REQUEST['id'], 9));
|
||||
$sql = "DELETE FROM $tableSepeParticipantsSpecialty WHERE id = $id;";
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$content = $plugin->get_lang('ProblemToDeleteInfoSpecialty');
|
||||
echo json_encode(["status" => "false", "content" => $content]);
|
||||
} else {
|
||||
$content = $plugin->get_lang('DeleteOk');
|
||||
echo json_encode(["status" => "true", "content" => $content]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST['tab'] == 'delete_classroom') {
|
||||
$id = intval(substr($_REQUEST['id'], 9));
|
||||
$sql = "DELETE FROM $tableSepeSpecialtyClassroom WHERE id = $id;";
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$content = $plugin->get_lang('ProblemToDeleteInfoSpecialtyClassroom');
|
||||
echo json_encode(["status" => "false", "content" => $content]);
|
||||
} else {
|
||||
$content = $plugin->get_lang('DeleteOk');
|
||||
echo json_encode(["status" => "true", "content" => $content]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST['tab'] == 'checkTutorEdit') {
|
||||
$type = Database::escape_string(trim($_REQUEST['type']));
|
||||
$number = Database::escape_string(trim($_REQUEST['number']));
|
||||
$letter = Database::escape_string(trim($_REQUEST['letter']));
|
||||
$platform_user_id = intval($_REQUEST['platform_user_id']);
|
||||
|
||||
$sql = "SELECT platform_user_id
|
||||
FROM $tableSepeTutors
|
||||
WHERE document_type='".$type."' AND document_number='".$number."' AND document_letter='".$letter."';";
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$content = $plugin->get_lang('ProblemDataBase');
|
||||
error_log(print_r($content, 1));
|
||||
exit;
|
||||
} else {
|
||||
$aux = Database::fetch_assoc($res);
|
||||
if ($aux['platform_user_id'] == $platform_user_id || $aux['platform_user_id'] == 0) {
|
||||
echo json_encode(["status" => "true"]);
|
||||
} else {
|
||||
$content = $plugin->get_lang('ModDataTeacher');
|
||||
echo json_encode(["status" => "false", "content" => $content]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST['tab'] == 'delete_tutor') {
|
||||
$id = intval(substr($_REQUEST['id'], 5));
|
||||
$sql = "DELETE FROM $tableSepeSpecialtyTutors WHERE id = $id;";
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$content = $plugin->get_lang('ProblemToDeleteInfoSpecialtyTutor');
|
||||
echo json_encode(["status" => "false", "content" => $content]);
|
||||
} else {
|
||||
$content = $plugin->get_lang('DeleteOk');
|
||||
echo json_encode(["status" => "true", "content" => $content]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST['tab'] == 'delete_participant') {
|
||||
$id = intval(substr($_REQUEST['id'], 11));
|
||||
$sql = "SELECT platform_user_id, action_id FROM $tableSepeParticipants WHERE id = $id;";
|
||||
$res = Database::query($sql);
|
||||
$row = Database::fetch_assoc($res);
|
||||
|
||||
$sql = "UPDATE plugin_sepe_log_participant SET fecha_baja='".date("Y-m-d H:i:s")."' WHERE platform_user_id='".$row['platform_user_id']."' AND action_id='".$row['action_id']."';";
|
||||
$res = Database::query($sql);
|
||||
|
||||
$sql = "DELETE FROM $tableSepeParticipants WHERE id = $id;";
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$content = $plugin->get_lang('ProblemToDeleteInfoParticipant');
|
||||
echo json_encode(["status" => "false", "content" => $content]);
|
||||
} else {
|
||||
$content = $plugin->get_lang('DeleteOk');
|
||||
echo json_encode(["status" => "true", "content" => $content]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST['tab'] == 'unlink_action') {
|
||||
$id = intval(substr($_REQUEST['id'], 16));
|
||||
$sql = "DELETE FROM $tableSepeCourseActions WHERE id = $id;";
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$content = $plugin->get_lang('ProblemToDesvincularInfoAction');
|
||||
echo json_encode(["status" => "false", "content" => $content]);
|
||||
} else {
|
||||
$content = $plugin->get_lang('DeleteOk');
|
||||
echo json_encode(["status" => "true", "content" => $content]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST['tab'] == 'assign_action') {
|
||||
$course_id = intval(substr($_REQUEST['course_id'], 9));
|
||||
$action_id = intval($_REQUEST['action_id']);
|
||||
|
||||
if ($action_id != 0 && $course_id != 0) {
|
||||
$sql = "SELECT * FROM $tableSepeCourseActions WHERE action_id = $action_id;";
|
||||
$rs = Database::query($sql);
|
||||
if (Database::num_rows($rs) > 0) {
|
||||
$content = $plugin->get_lang('FormativeActionInUse');
|
||||
echo json_encode(["status" => "false", "content" => $content]);
|
||||
} else {
|
||||
$sql = "SELECT 1 FROM course WHERE id = $course_id;";
|
||||
$rs = Database::query($sql);
|
||||
if (Database::num_rows($rs) == 0) {
|
||||
$content = $plugin->get_lang('NoExistsCourse');
|
||||
echo json_encode(["status" => "false", "content" => $content]);
|
||||
} else {
|
||||
$sql = "INSERT INTO $tableSepeCourseActions (course_id, action_id) VALUES ($course_id, $action_id);";
|
||||
$rs = Database::query($sql);
|
||||
if (!$rs) {
|
||||
$content = $plugin->get_lang('NoSaveData');
|
||||
echo json_encode(["status" => "false", "content" => utf8_encode($content)]);
|
||||
} else {
|
||||
echo json_encode(["status" => "true"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$content = $plugin->get_lang('ErrorDataIncorrect');
|
||||
echo json_encode(["status" => "false", "content" => $content]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST['tab'] == 'key_sepe_generator') {
|
||||
$tApi = Database::get_main_table(TABLE_MAIN_USER_API_KEY);
|
||||
$info_user = api_get_user_info_from_username('SEPE');
|
||||
|
||||
$array_list_key = [];
|
||||
$user_id = $info_user['user_id'];
|
||||
$api_service = 'dokeos';
|
||||
$num = UserManager::update_api_key($user_id, $api_service);
|
||||
$array_list_key = UserManager::get_api_keys($user_id, $api_service);
|
||||
|
||||
if (trim($array_list_key[$num]) != '') {
|
||||
$content = $array_list_key[$num];
|
||||
echo json_encode(["status" => "true", "content" => $content]);
|
||||
} else {
|
||||
$content = $plugin->get_lang('ProblemGenerateApiKey');
|
||||
echo json_encode(["status" => "false", "content" => $content]);
|
||||
}
|
||||
}
|
||||
95
plugin/sepe/src/identification-data-edit.php
Normal file
95
plugin/sepe/src/identification-data-edit.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* This script displays a data center edit form.
|
||||
*/
|
||||
require_once '../config.php';
|
||||
$plugin = SepePlugin::create();
|
||||
|
||||
if (!empty($_POST)) {
|
||||
$check = Security::check_token('post');
|
||||
if ($check) {
|
||||
$centerOrigin = Database::escape_string(trim($_POST['center_origin']));
|
||||
$centerCode = Database::escape_string(trim($_POST['center_code']));
|
||||
$centerName = Database::escape_string(trim($_POST['center_name']));
|
||||
$url = Database::escape_string(trim($_POST['url']));
|
||||
$trackingUrl = Database::escape_string(trim($_POST['tracking_url']));
|
||||
$phone = Database::escape_string(trim($_POST['phone']));
|
||||
$mail = Database::escape_string(trim($_POST['mail']));
|
||||
$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."'
|
||||
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."'
|
||||
);";
|
||||
}
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange');
|
||||
} else {
|
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange');
|
||||
}
|
||||
header("Location: identification-data.php");
|
||||
} else {
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken');
|
||||
Security::clear_token();
|
||||
$token = Security::get_token();
|
||||
}
|
||||
} else {
|
||||
$token = Security::get_token();
|
||||
}
|
||||
|
||||
if (api_is_platform_admin()) {
|
||||
$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);
|
||||
$info = getInfoIdentificationData();
|
||||
$tpl->assign('info', $info);
|
||||
if (isset($_SESSION['sepe_message_info'])) {
|
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']);
|
||||
unset($_SESSION['sepe_message_info']);
|
||||
}
|
||||
if (isset($_SESSION['sepe_message_error'])) {
|
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']);
|
||||
unset($_SESSION['sepe_message_error']);
|
||||
}
|
||||
$tpl->assign('sec_token', $token);
|
||||
$listing_tpl = 'sepe/view/identification-data-edit.tpl';
|
||||
$content = $tpl->fetch($listing_tpl);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
} else {
|
||||
header('Location:'.api_get_path(WEB_PATH));
|
||||
exit;
|
||||
}
|
||||
36
plugin/sepe/src/identification-data.php
Normal file
36
plugin/sepe/src/identification-data.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* This script displays a basic info about data center.
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$plugin = SepePlugin::create();
|
||||
$_cid = 0;
|
||||
|
||||
if (api_is_platform_admin()) {
|
||||
$info = getInfoIdentificationData();
|
||||
$templateName = $plugin->get_lang('DataCenter');
|
||||
$interbreadcrumb[] = [
|
||||
"url" => "/plugin/sepe/src/sepe-administration-menu.php",
|
||||
"name" => $plugin->get_lang('MenuSepe'),
|
||||
];
|
||||
$tpl = new Template($templateName);
|
||||
|
||||
if (isset($_SESSION['sepe_message_info'])) {
|
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']);
|
||||
unset($_SESSION['sepe_message_info']);
|
||||
}
|
||||
if (isset($_SESSION['sepe_message_error'])) {
|
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']);
|
||||
unset($_SESSION['sepe_message_error']);
|
||||
}
|
||||
$tpl->assign('info', $info);
|
||||
$listing_tpl = 'sepe/view/identification-data.tpl';
|
||||
$content = $tpl->fetch($listing_tpl);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
} else {
|
||||
header('Location:'.api_get_path(WEB_PATH));
|
||||
}
|
||||
1
plugin/sepe/src/index.php
Normal file
1
plugin/sepe/src/index.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php
|
||||
41
plugin/sepe/src/index.sepe.php
Normal file
41
plugin/sepe/src/index.sepe.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Index of the Sepe plugin.
|
||||
*/
|
||||
$plugin = SepePlugin::create();
|
||||
$enable = $plugin->get('sepe_enable') == 'true';
|
||||
$title = $plugin->get_lang('AdministratorSepe');
|
||||
$pluginPath = api_get_path(WEB_PLUGIN_PATH).'sepe/src/';
|
||||
if (api_is_platform_admin() && $enable) {
|
||||
echo '<div class="panel panel-default">';
|
||||
echo '<div class="panel-heading" role="tab">';
|
||||
echo '<h4 class="panel-title">'.$title.'</h4>';
|
||||
echo '</div>';
|
||||
echo '<div class="panel-collapse collapse in" role="tabpanel">';
|
||||
echo '<div class="panel-body">';
|
||||
echo '<ul class="nav nav-pills nav-stacked">';
|
||||
echo '<li>';
|
||||
echo '<a href="'.$pluginPath.'identification-data.php">';
|
||||
echo '<img src="'.api_get_path(WEB_PLUGIN_PATH).'sepe/resources/list.png">';
|
||||
echo $plugin->get_lang('DataCenter');
|
||||
echo '</a>';
|
||||
echo '</li>';
|
||||
echo '<li>';
|
||||
echo '<a href="'.$pluginPath.'formative-actions-list.php">';
|
||||
echo '<img src="'.api_get_path(WEB_PLUGIN_PATH).'sepe/resources/forms.png">';
|
||||
echo $plugin->get_lang('FormativeActionsForm');
|
||||
echo '</a>';
|
||||
echo '</li>';
|
||||
echo '<li>';
|
||||
echo '<a href="'.$pluginPath.'configuration.php">';
|
||||
echo '<img src="'.api_get_path(WEB_PLUGIN_PATH).'sepe/resources/settings.png">';
|
||||
echo $plugin->get_lang('Setting');
|
||||
echo '</a>';
|
||||
echo '</li>';
|
||||
echo '</ul>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
248
plugin/sepe/src/participant-action-edit.php
Normal file
248
plugin/sepe/src/participant-action-edit.php
Normal file
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* This script displays a participant edit form.
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$course_plugin = 'sepe';
|
||||
$plugin = SepePlugin::create();
|
||||
$_cid = 0;
|
||||
|
||||
if (!empty($_POST)) {
|
||||
$check = Security::check_token('post');
|
||||
if ($check) {
|
||||
$companyTutorId = (!empty($_POST['company_tutor_id']) ? intval($_POST['company_tutor_id']) : null);
|
||||
$trainingTutorId = (!empty($_POST['training_tutor_id']) ? intval($_POST['training_tutor_id']) : null);
|
||||
$tutorCompanyDocumentType = Database::escape_string(trim($_POST['tutor_company_document_type']));
|
||||
$tutorCompanyDocumentNumber = Database::escape_string(trim($_POST['tutor_company_document_number']));
|
||||
$tutorCompanyDocumentLetter = Database::escape_string(trim($_POST['tutor_company_document_letter']));
|
||||
$tutorCompanyAlias = Database::escape_string(trim($_POST['tutor_company_alias']));
|
||||
$tutorTrainingDocumentType = Database::escape_string(trim($_POST['tutor_training_document_type']));
|
||||
$tutorTrainingDocumentNumber = Database::escape_string(trim($_POST['tutor_training_document_number']));
|
||||
$tutorTrainingDocumentLetter = Database::escape_string(trim($_POST['tutor_training_document_letter']));
|
||||
$tutorTrainingAlias = Database::escape_string(trim($_POST['tutor_training_alias']));
|
||||
$newParticipant = intval($_POST['new_participant']);
|
||||
$platformUserId = intval($_POST['platform_user_id']);
|
||||
$documentType = Database::escape_string(trim($_POST['document_type']));
|
||||
$documentNumber = Database::escape_string(trim($_POST['document_number']));
|
||||
$documentLetter = Database::escape_string(trim($_POST['document_letter']));
|
||||
$keyCompetence = Database::escape_string(trim($_POST['key_competence']));
|
||||
$contractId = Database::escape_string(trim($_POST['contract_id']));
|
||||
$companyFiscalNumber = Database::escape_string(trim($_POST['company_fiscal_number']));
|
||||
$participantId = intval($_POST['participant_id']);
|
||||
$actionId = intval($_POST['action_id']);
|
||||
|
||||
if (isset($companyTutorId) && $companyTutorId == 0) {
|
||||
$sql = "SELECT * FROM $tableTutorCompany
|
||||
WHERE document_type = '".$tutorCompanyDocumentType."'
|
||||
AND document_number = '".$tutorCompanyDocumentNumber."'
|
||||
AND document_letter = '".$tutorCompanyDocumentLetter."';";
|
||||
$rs = Database::query($sql);
|
||||
if (Database::num_rows($rs) > 0) {
|
||||
$row = Database::fetch_assoc($rs);
|
||||
$companyTutorId = $row['id'];
|
||||
$sql = "UPDATE $tableTutorCompany SET company = 1 WHERE id = $companyTutorId";
|
||||
Database::query($sql);
|
||||
} else {
|
||||
$sql = "INSERT INTO $tableTutorCompany (alias,document_type,document_number,document_letter,company)
|
||||
VALUES ('".$tutorCompanyAlias."','".$tutorCompanyDocumentType."','".$tutorCompanyDocumentNumber."','".$tutorCompanyDocumentLetter."','1');";
|
||||
$rs = Database::query($sql);
|
||||
if (!$rs) {
|
||||
} else {
|
||||
$companyTutorId = Database::insert_id();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($trainingTutorId) && $trainingTutorId == 0) {
|
||||
$sql = "SELECT * FROM $tableTutorCompany
|
||||
WHERE
|
||||
document_type = '".$tutorTrainingDocumentType."' AND
|
||||
document_number = '".$tutorTrainingDocumentNumber."' AND
|
||||
document_letter = '".$tutorTrainingDocumentLetter."';";
|
||||
$rs = Database::query($sql);
|
||||
|
||||
if (Database::num_rows($rs) > 0) {
|
||||
$row = Database::fetch_assoc($rs);
|
||||
$trainingTutorId = $row['id'];
|
||||
$sql = "UPDATE $tableTutorCompany SET training = 1 WHERE id = $trainingTutorId";
|
||||
Database::query($sql);
|
||||
} else {
|
||||
$sql = "INSERT INTO $tableTutorCompany (alias,document_type,document_number,document_letter,training)
|
||||
VALUES ('".$tutorTrainingAlias."','".$tutorTrainingDocumentType."','".$tutorTrainingDocumentNumber."','".$tutorTrainingDocumentLetter."','1');";
|
||||
$rs = Database::query($sql);
|
||||
if (!$rs) {
|
||||
} else {
|
||||
$trainingTutorId = Database::insert_id();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($newParticipant) && $newParticipant != 1) {
|
||||
$sql = "UPDATE $tableSepeParticipants SET
|
||||
platform_user_id = '".$platformUserId."',
|
||||
document_type = '".$documentType."',
|
||||
document_number = '".$documentNumber."',
|
||||
document_letter = '".$documentLetter."',
|
||||
key_competence = '".$keyCompetence."',
|
||||
contract_id = '".$contractId."',
|
||||
company_fiscal_number = '".$companyFiscalNumber."'
|
||||
WHERE id = $participantId";
|
||||
} else {
|
||||
$sql = "INSERT INTO $tableSepeParticipants(
|
||||
action_id,
|
||||
platform_user_id,
|
||||
document_type,
|
||||
document_number,
|
||||
document_letter,
|
||||
key_competence,
|
||||
contract_id,
|
||||
company_fiscal_number
|
||||
) VALUES (
|
||||
'".$actionId."',
|
||||
'".$platformUserId."',
|
||||
'".$documentType."',
|
||||
'".$documentNumber."',
|
||||
'".$documentLetter."',
|
||||
'".$keyCompetence."',
|
||||
'".$contractId."',
|
||||
'".$companyFiscalNumber."'
|
||||
);";
|
||||
}
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange');
|
||||
} else {
|
||||
if ($newParticipant == 1) {
|
||||
$participantId = Database::insert_id();
|
||||
}
|
||||
// Update tutors
|
||||
if (is_null($companyTutorId)) {
|
||||
$sql = "UPDATE $tableSepeParticipants SET company_tutor_id = NULL WHERE id = $participantId";
|
||||
} else {
|
||||
$sql = "UPDATE $tableSepeParticipants SET company_tutor_id = $companyTutorId WHERE id = $participantId";
|
||||
}
|
||||
Database::query($sql);
|
||||
if (is_null($trainingTutorId)) {
|
||||
$sql = "UPDATE $tableSepeParticipants SET training_tutor_id = NULL WHERE id = $participantId";
|
||||
} else {
|
||||
$sql = "UPDATE $tableSepeParticipants SET training_tutor_id = $trainingTutorId WHERE id = $participantId";
|
||||
}
|
||||
Database::query($sql);
|
||||
|
||||
$insertLog = checkInsertNewLog($platformUserId, $actionId);
|
||||
if ($insertLog) {
|
||||
$sql = "INSERT INTO $tableSepeLogParticipant (
|
||||
platform_user_id,
|
||||
action_id,
|
||||
registration_date
|
||||
) VALUES (
|
||||
'".$platformUserId."',
|
||||
'".$actionId."',
|
||||
'".date("Y-m-d H:i:s")."'
|
||||
);";
|
||||
} else {
|
||||
$sql = "INSERT INTO $tableSepeLogChangeParticipant (
|
||||
platform_user_id,
|
||||
action_id,
|
||||
change_date
|
||||
) VALUES (
|
||||
'".$platformUserId."',
|
||||
'".$actionId."',
|
||||
'".date("Y-m-d H:i:s")."'
|
||||
);";
|
||||
}
|
||||
$res = Database::query($sql);
|
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange');
|
||||
}
|
||||
session_write_close();
|
||||
header("Location: participant-action-edit.php?new_participant=0&participant_id=".$participantId."&action_id=".$actionId);
|
||||
exit;
|
||||
} else {
|
||||
$participantId = intval($_POST['participant_id']);
|
||||
$actionId = intval($_POST['action_id']);
|
||||
$newParticipant = intval($_POST['new_participant']);
|
||||
Security::clear_token();
|
||||
$token = Security::get_token();
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken');
|
||||
session_write_close();
|
||||
header("Location: participant-action-edit.php?new_participant=".$newParticipant."&participant_id=".$participantId."&action_id=".$actionId);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$token = Security::get_token();
|
||||
}
|
||||
|
||||
if (api_is_platform_admin()) {
|
||||
$actionId = intval($_GET['action_id']);
|
||||
$courseId = getCourse($actionId);
|
||||
$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'),
|
||||
];
|
||||
if (isset($_GET['new_participant']) && intval($_GET['new_participant']) == 1) {
|
||||
$templateName = $plugin->get_lang('NewParticipantAction');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('action_id', $actionId);
|
||||
$info = [];
|
||||
$tpl->assign('info', $info);
|
||||
$tpl->assign('new_participant', '1');
|
||||
} else {
|
||||
$templateName = $plugin->get_lang('EditParticipantAction');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('action_id', $actionId);
|
||||
$info = getInfoParticipantAction($_GET['participant_id']);
|
||||
$tpl->assign('info', $info);
|
||||
$tpl->assign('new_participant', '0');
|
||||
$tpl->assign('participant_id', (int) $_GET['participant_id']);
|
||||
|
||||
if ($info['platform_user_id'] != 0) {
|
||||
$infoUserPlatform = api_get_user_info($info['platform_user_id']);
|
||||
$tpl->assign('info_user_platform', $infoUserPlatform);
|
||||
}
|
||||
$listParticipantSpecialty = listParticipantSpecialty(intval($_GET['participant_id']));
|
||||
$tpl->assign('listParticipantSpecialty', $listParticipantSpecialty);
|
||||
}
|
||||
$courseCode = getCourseCode($actionId);
|
||||
$listStudentInfo = [];
|
||||
$listStudent = CourseManager::get_student_list_from_course_code($courseCode);
|
||||
|
||||
foreach ($listStudent as $value) {
|
||||
$sql = "SELECT 1 FROM $tableSepeParticipants WHERE platform_user_id = '".$value['user_id']."';";
|
||||
$res = Database::query($sql);
|
||||
if (Database::num_rows($res) == 0) {
|
||||
$listStudentInfo[] = api_get_user_info($value['user_id']);
|
||||
}
|
||||
}
|
||||
$tpl->assign('listStudent', $listStudentInfo);
|
||||
$listTutorCompany = listTutorType("company = '1'");
|
||||
$tpl->assign('list_tutor_company', $listTutorCompany);
|
||||
$listTutorTraining = listTutorType("training = '1'");
|
||||
$tpl->assign('list_tutor_training', $listTutorTraining);
|
||||
if (isset($_SESSION['sepe_message_info'])) {
|
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']);
|
||||
unset($_SESSION['sepe_message_info']);
|
||||
}
|
||||
if (isset($_SESSION['sepe_message_error'])) {
|
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']);
|
||||
unset($_SESSION['sepe_message_error']);
|
||||
}
|
||||
$tpl->assign('sec_token', $token);
|
||||
$listing_tpl = 'sepe/view/participant-action-edit.tpl';
|
||||
$content = $tpl->fetch($listing_tpl);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
} else {
|
||||
header('Location:'.api_get_path(WEB_PATH));
|
||||
exit;
|
||||
}
|
||||
284
plugin/sepe/src/participant-specialty-edit.php
Normal file
284
plugin/sepe/src/participant-specialty-edit.php
Normal file
@@ -0,0 +1,284 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* This script displays a participant specialty edit form.
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$course_plugin = 'sepe';
|
||||
$plugin = SepePlugin::create();
|
||||
$_cid = 0;
|
||||
|
||||
if (!empty($_POST)) {
|
||||
$check = Security::check_token('post');
|
||||
if ($check) {
|
||||
$newSpecialty = intval($_POST['new_specialty']);
|
||||
$specialtyOrigin = Database::escape_string(trim($_POST['specialty_origin']));
|
||||
$professionalArea = Database::escape_string(trim($_POST['professional_area']));
|
||||
$specialtyCode = Database::escape_string(trim($_POST['specialty_code']));
|
||||
$centerOrigin = Database::escape_string(trim($_POST['center_origin']));
|
||||
$centerCode = Database::escape_string(trim($_POST['center_code']));
|
||||
$finalResult = Database::escape_string(trim($_POST['final_result']));
|
||||
$finalQualification = Database::escape_string(trim($_POST['final_qualification']));
|
||||
$finalScore = Database::escape_string(trim($_POST['final_score']));
|
||||
$yearRegistration = Database::escape_string(trim($_POST['year_registration']));
|
||||
$monthRegistration = Database::escape_string(trim($_POST['month_registration']));
|
||||
$dayRegistration = Database::escape_string(trim($_POST['day_registration']));
|
||||
$yearLeaving = Database::escape_string(trim($_POST['year_leaving']));
|
||||
$monthLeaving = Database::escape_string(trim($_POST['month_leaving']));
|
||||
$dayLeaving = Database::escape_string(trim($_POST['day_leaving']));
|
||||
$dayStart = Database::escape_string(trim($_POST['day_start']));
|
||||
$monthStart = Database::escape_string(trim($_POST['month_start']));
|
||||
$yearStart = Database::escape_string(trim($_POST['year_start']));
|
||||
$dayEnd = Database::escape_string(trim($_POST['day_end']));
|
||||
$monthEnd = Database::escape_string(trim($_POST['month_end']));
|
||||
$yearEnd = Database::escape_string(trim($_POST['year_end']));
|
||||
$participantId = intval($_POST['participant_id']);
|
||||
$actionId = intval($_POST['action_id']);
|
||||
$specialtyId = intval($_POST['specialty_id']);
|
||||
|
||||
$registrationDate = $yearRegistration."-".$monthRegistration."-".$dayRegistration;
|
||||
$leavingDate = $yearLeaving."-".$monthLeaving."-".$dayLeaving;
|
||||
$startDate = $yearStart."-".$monthStart."-".$dayStart;
|
||||
$endDate = $yearEnd."-".$monthEnd."-".$dayEnd;
|
||||
|
||||
if (isset($newSpecialty) && $newSpecialty != 1) {
|
||||
$sql = "UPDATE $tableSepeParticipantsSpecialty SET
|
||||
specialty_origin = '".$specialtyOrigin."',
|
||||
professional_area = '".$professionalArea."',
|
||||
specialty_code = '".$specialtyCode."',
|
||||
registration_date = '".$registrationDate."',
|
||||
leaving_date = '".$leavingDate."',
|
||||
center_origin = '".$centerOrigin."',
|
||||
center_code = '".$centerCode."',
|
||||
start_date = '".$startDate."',
|
||||
end_date = '".$endDate."',
|
||||
final_result = '".$finalResult."',
|
||||
final_qualification = '".$finalQualification."',
|
||||
final_score = '".$finalScore."'
|
||||
WHERE id = $specialtyId";
|
||||
} else {
|
||||
$sql = "INSERT INTO $tableSepeParticipantsSpecialty (
|
||||
participant_id,
|
||||
specialty_origin,
|
||||
professional_area,
|
||||
specialty_code,
|
||||
registration_date,
|
||||
leaving_date,
|
||||
center_origin,
|
||||
center_code,
|
||||
start_date,
|
||||
end_date,
|
||||
final_result,
|
||||
final_qualification,
|
||||
final_score
|
||||
) VALUES (
|
||||
$participantId,
|
||||
'".$specialtyOrigin."',
|
||||
'".$professionalArea."',
|
||||
'".$specialtyCode."',
|
||||
'".$registrationDate."',
|
||||
'".$leavingDate."',
|
||||
'".$centerOrigin."',
|
||||
'".$centerCode."',
|
||||
'".$startDate."',
|
||||
'".$endDate."',
|
||||
'".$finalResult."',
|
||||
'".$finalQualification."',
|
||||
'".$finalScore."'
|
||||
);";
|
||||
}
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange');
|
||||
} else {
|
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange');
|
||||
if ($newSpecialty == "1") {
|
||||
$specialtyId = Database::insert_id();
|
||||
}
|
||||
|
||||
$platformUserId = getUserPlatformFromParticipant($participantId);
|
||||
$insertLog = checkInsertNewLog($platformUserId, $actionId);
|
||||
if ($insertLog) {
|
||||
if ($finalResult == "1" || $finalResult == "2") {
|
||||
$leavingDateLog = date("Y-m-d H:i:s");
|
||||
} else {
|
||||
$leavingDateLog = '0000-00-00';
|
||||
}
|
||||
$sql = "INSERT INTO $tableSepeLogParticipant (
|
||||
platform_user_id,
|
||||
action_id,
|
||||
registration_date,
|
||||
leaving_date
|
||||
) VALUES (
|
||||
'".$platformUserId."',
|
||||
'".$actionId."',
|
||||
'".date("Y-m-d H:i:s")."'
|
||||
'".$leavingDateLog."'
|
||||
);";
|
||||
} else {
|
||||
if ($finalResult == "1" || $finalResult == "2") {
|
||||
$sql = "UPDATE $tableSepeLogParticipant
|
||||
SET leaving_date = '".date("Y-m-d H:i:s")."'
|
||||
WHERE platform_user_id = '".$platformUserId."' AND action_id = '".$actionId."';";
|
||||
} else {
|
||||
$sql = "INSERT INTO $tableSepeLogChangeParticipant (
|
||||
platform_user_id,
|
||||
action_id,
|
||||
change_date
|
||||
) VALUES (
|
||||
'".$platformUserId."',
|
||||
'".$actionId."',
|
||||
'".date("Y-m-d H:i:s")."'
|
||||
);";
|
||||
}
|
||||
}
|
||||
$res = Database::query($sql);
|
||||
}
|
||||
session_write_close();
|
||||
header("Location: participant-specialty-edit.php?new_specialty=0&specialty_id=".$specialtyId."&participant_id=".$participantId."&action_id=".$actionId);
|
||||
exit;
|
||||
} else {
|
||||
$newSpecialty = intval($_POST['new_specialty']);
|
||||
$participantId = intval($_POST['participant_id']);
|
||||
$actionId = intval($_POST['action_id']);
|
||||
$specialtyId = intval($_POST['specialty_id']);
|
||||
Security::clear_token();
|
||||
$token = Security::get_token();
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken');
|
||||
session_write_close();
|
||||
header("Location: participant-specialty-edit.php?new_specialty=".$newSpecialty."&specialty_id=".$specialtyId."&participant_id=".$participantId."&action_id=".$actionId);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$token = Security::get_token();
|
||||
}
|
||||
|
||||
if (api_is_platform_admin()) {
|
||||
$actionId = (int) $_GET['action_id'];
|
||||
$courseId = getCourse($actionId);
|
||||
$participantId = (int) $_GET['participant_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'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
"url" => "participant-action-edit.php?new_participant=0&participant_id=".$participantId."&action_id=".$actionId,
|
||||
"name" => $plugin->get_lang('FormativeActionParticipant'),
|
||||
];
|
||||
if (isset($_GET['new_specialty']) && intval($_GET['new_specialty']) == 1) {
|
||||
$templateName = $plugin->get_lang('NewSpecialtyParticipant');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('action_id', $actionId);
|
||||
$tpl->assign('participant_id', $participantId);
|
||||
$info = [];
|
||||
$tpl->assign('info', $info);
|
||||
$tpl->assign('new_specialty', '1');
|
||||
$startYear = $endYear = date("Y");
|
||||
$registrationYear = $leaveYear = date("Y");
|
||||
} else {
|
||||
$templateName = $plugin->get_lang('EditSpecialtyParticipant');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('action_id', $actionId);
|
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id']));
|
||||
$tpl->assign('participant_id', $participantId);
|
||||
$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) {
|
||||
$tpl->assign('day_registration', date("j", strtotime($info['registration_date'])));
|
||||
$tpl->assign('month_registration', date("n", strtotime($info['registration_date'])));
|
||||
$tpl->assign('year_registration', date("Y", strtotime($info['registration_date'])));
|
||||
$registrationYear = date("Y", strtotime($info['registration_date']));
|
||||
} elseif (strpos($info['end_date'], '0000') === false) {
|
||||
$registrationYear = date("Y", strtotime($info['registration_date']));
|
||||
} else {
|
||||
$registrationYear = date("Y");
|
||||
}
|
||||
if ($info['leaving_date'] != '0000-00-00' && $info['leaving_date'] != null) {
|
||||
$tpl->assign('day_leaving', date("j", strtotime($info['leaving_date'])));
|
||||
$tpl->assign('month_leaving', date("n", strtotime($info['leaving_date'])));
|
||||
$tpl->assign('year_leaving', date("Y", strtotime($info['leaving_date'])));
|
||||
$leaveYear = date("Y", strtotime($info['leaving_date']));
|
||||
} elseif (strpos($info['end_date'], '0000') === false) {
|
||||
$leaveYear = date("Y", strtotime($info['leaving_date']));
|
||||
} else {
|
||||
$leaveYear = date("Y");
|
||||
}
|
||||
if ($info['start_date'] != '0000-00-00' && $info['start_date'] != null) {
|
||||
$tpl->assign('day_start', date("j", strtotime($info['start_date'])));
|
||||
$tpl->assign('month_start', date("n", strtotime($info['start_date'])));
|
||||
$tpl->assign('year_start', date("Y", strtotime($info['start_date'])));
|
||||
$startYear = date("Y", strtotime($info['start_date']));
|
||||
} elseif (strpos($info['end_date'], '0000') === false) {
|
||||
$startYear = date("Y", strtotime($info['start_date']));
|
||||
} else {
|
||||
$startYear = date("Y");
|
||||
}
|
||||
if ($info['end_date'] != '0000-00-00' && $info['end_date'] != null) {
|
||||
$tpl->assign('day_end', date("j", strtotime($info['end_date'])));
|
||||
$tpl->assign('month_end', date("n", strtotime($info['end_date'])));
|
||||
$tpl->assign('year_end', date("Y", strtotime($info['end_date'])));
|
||||
$endYear = date("Y", strtotime($info['end_date']));
|
||||
} elseif (strpos($info['end_date'], '0000') === false) {
|
||||
$endYear = date("Y", strtotime($info['end_date']));
|
||||
} else {
|
||||
$endYear = date("Y");
|
||||
}
|
||||
$listSpecialtyTutorials = getListSpecialtyTutorial($_GET['specialty_id']);
|
||||
$tpl->assign('listSpecialtyTutorials', $listSpecialtyTutorials);
|
||||
}
|
||||
|
||||
$listYear = [];
|
||||
if ($registrationYear > $leaveYear) {
|
||||
$tmp = $registrationYear;
|
||||
$registrationYear = $leaveYear;
|
||||
$leaveYear = $tmp;
|
||||
}
|
||||
$registrationYear -= 5;
|
||||
$leaveYear += 5;
|
||||
$endRangeYear = (($registrationYear + 15) < $leaveYear) ? ($leaveYear + 1) : ($registrationYear + 15);
|
||||
while ($registrationYear <= $endRangeYear) {
|
||||
$listYear[] = $registrationYear;
|
||||
$registrationYear++;
|
||||
}
|
||||
$tpl->assign('list_year', $listYear);
|
||||
|
||||
$listYear = [];
|
||||
if ($startYear > $endYear) {
|
||||
$tmp = $startYear;
|
||||
$startYear = $endYear;
|
||||
$endYear = $tmp;
|
||||
}
|
||||
$startYear -= 5;
|
||||
$endYear += 5;
|
||||
$endRangeYear = (($startYear + 15) < $endYear) ? ($endYear + 1) : ($startYear + 15);
|
||||
while ($startYear <= $endRangeYear) {
|
||||
$listYear[] = $startYear;
|
||||
$startYear++;
|
||||
}
|
||||
$tpl->assign('list_year_2', $listYear);
|
||||
|
||||
if (isset($_SESSION['sepe_message_info'])) {
|
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']);
|
||||
unset($_SESSION['sepe_message_info']);
|
||||
}
|
||||
if (isset($_SESSION['sepe_message_error'])) {
|
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']);
|
||||
unset($_SESSION['sepe_message_error']);
|
||||
}
|
||||
$tpl->assign('sec_token', $token);
|
||||
$listing_tpl = 'sepe/view/participant-specialty-edit.tpl';
|
||||
$content = $tpl->fetch($listing_tpl);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
} else {
|
||||
header('Location:'.api_get_path(WEB_PATH));
|
||||
exit;
|
||||
}
|
||||
59
plugin/sepe/src/sepe-administration-menu.php
Normal file
59
plugin/sepe/src/sepe-administration-menu.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* This script displays a administrator menu.
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$plugin = SepePlugin::create();
|
||||
$enable = $plugin->get('sepe_enable') == 'true';
|
||||
|
||||
$title = $plugin->get_lang('AdministratorSepe');
|
||||
$pluginPath = api_get_path(WEB_PLUGIN_PATH).'sepe/src/';
|
||||
|
||||
if (api_is_platform_admin() && $enable) {
|
||||
$htmlText = '';
|
||||
$htmlText .= '<div class="panel panel-default">';
|
||||
$htmlText .= '<div class="panel-heading" role="tab">';
|
||||
$htmlText .= '<h4 class="panel-title">'.$title.'</h4>';
|
||||
$htmlText .= '</div>';
|
||||
$htmlText .= '<div class="panel-collapse collapse in" role="tabpanel">';
|
||||
$htmlText .= '<div class="panel-body">';
|
||||
$htmlText .= '<ul class="nav nav-pills nav-stacked">';
|
||||
$htmlText .= '<li>';
|
||||
$htmlText .= '<a href="'.$pluginPath.'identification-data.php">';
|
||||
$htmlText .= '<img src="'.api_get_path(WEB_PLUGIN_PATH).'sepe/resources/list.png">';
|
||||
$htmlText .= $plugin->get_lang('DataCenter');
|
||||
$htmlText .= '</a>';
|
||||
$htmlText .= '</li>';
|
||||
$htmlText .= '<li>';
|
||||
$htmlText .= '<a href="'.$pluginPath.'formative-actions-list.php">';
|
||||
$htmlText .= '<img src="'.api_get_path(WEB_PLUGIN_PATH).'sepe/resources/forms.png">';
|
||||
$htmlText .= $plugin->get_lang('FormativeActionsForm');
|
||||
$htmlText .= '</a>';
|
||||
$htmlText .= '</li>';
|
||||
$htmlText .= '<li>';
|
||||
$htmlText .= '<a href="'.$pluginPath.'configuration.php">';
|
||||
$htmlText .= '<img src="'.api_get_path(WEB_PLUGIN_PATH).'sepe/resources/settings.png">';
|
||||
$htmlText .= $plugin->get_lang('Setting');
|
||||
$htmlText .= '</a>';
|
||||
$htmlText .= '</li>';
|
||||
$htmlText .= '</ul>';
|
||||
$htmlText .= '</div>';
|
||||
$htmlText .= '</div>';
|
||||
$htmlText .= '</div>';
|
||||
|
||||
$templateName = $plugin->get_lang('MenuSepeAdministrator');
|
||||
$interbreadcrumb[] = ["url" => "/main/admin/index.php", "name" => get_lang('Administration')];
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('html_text', $htmlText);
|
||||
|
||||
$listing_tpl = 'sepe/view/sepe-administration-menu.tpl';
|
||||
$content = $tpl->fetch($listing_tpl);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
} else {
|
||||
header('Location:'.api_get_path(WEB_PATH));
|
||||
exit;
|
||||
}
|
||||
586
plugin/sepe/src/sepe.lib.php
Normal file
586
plugin/sepe/src/sepe.lib.php
Normal file
@@ -0,0 +1,586 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Functions.
|
||||
*
|
||||
* @package chamilo.plugin.sepe
|
||||
*/
|
||||
$tableSepeCenter = Database::get_main_table(SepePlugin::TABLE_SEPE_CENTER);
|
||||
$tableSepeActions = Database::get_main_table(SepePlugin::TABLE_SEPE_ACTIONS);
|
||||
$tableSepeSpecialty = Database::get_main_table(SepePlugin::TABLE_SEPE_SPECIALTY);
|
||||
$tableSepeSpecialtyClassroom = Database::get_main_table(SepePlugin::TABLE_SEPE_SPECIALTY_CLASSROOM);
|
||||
$tableSepeSpecialtyTutors = Database::get_main_table(SepePlugin::TABLE_SEPE_SPECIALTY_TUTORS);
|
||||
$tableSepeTutors = Database::get_main_table(SepePlugin::TABLE_SEPE_TUTORS);
|
||||
$tableSepeParticipants = Database::get_main_table(SepePlugin::TABLE_SEPE_PARTICIPANTS);
|
||||
$tableSepeParticipantsSpecialty = Database::get_main_table(SepePlugin::TABLE_SEPE_PARTICIPANTS_SPECIALTY);
|
||||
$tableSepeParticipantsSpecialtyTutorials = Database::get_main_table(SepePlugin::TABLE_SEPE_PARTICIPANTS_SPECIALTY_TUTORIALS);
|
||||
$tableSepeCourseActions = Database::get_main_table(SepePlugin::TABLE_SEPE_COURSE_ACTIONS);
|
||||
$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
|
||||
$tableCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
|
||||
$tableUser = Database::get_main_table(TABLE_MAIN_USER);
|
||||
$tableCenters = Database::get_main_table(SepePlugin::TABLE_SEPE_CENTERS);
|
||||
$tableTutorCompany = Database::get_main_table(SepePlugin::TABLE_SEPE_TUTORS_COMPANY);
|
||||
$tableSepeCourseActions = Database::get_main_table(SepePlugin::TABLE_SEPE_COURSE_ACTIONS);
|
||||
$tableSepeLogParticipant = Database::get_main_table(SepePlugin::TABLE_SEPE_LOG_PARTICIPANT);
|
||||
$tableSepeLogChangeParticipant = Database::get_main_table(SepePlugin::TABLE_SEPE_LOG_MOD_PARTICIPANT);
|
||||
|
||||
function getInfoIdentificationData()
|
||||
{
|
||||
global $tableSepeCenter;
|
||||
$sql = "SELECT * FROM $tableSepeCenter;";
|
||||
$res = Database::query($sql);
|
||||
if (Database::num_rows($res) > 0) {
|
||||
$row = Database::fetch_assoc($res);
|
||||
$row['center_origin'] = Security::remove_XSS(stripslashes($row['center_origin']));
|
||||
$row['center_code'] = Security::remove_XSS(stripslashes($row['center_code']));
|
||||
$row['center_name'] = Security::remove_XSS(stripslashes($row['center_name']));
|
||||
$row['url'] = Security::remove_XSS(stripslashes($row['url']));
|
||||
$row['tracking_url'] = Security::remove_XSS(stripslashes($row['tracking_url']));
|
||||
$row['phone'] = Security::remove_XSS(stripslashes($row['phone']));
|
||||
$row['mail'] = Security::remove_XSS(stripslashes($row['mail']));
|
||||
} else {
|
||||
$row = false;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function checkIdentificationData()
|
||||
{
|
||||
global $tableSepeCenter;
|
||||
$sql = "SELECT 1 FROM $tableSepeCenter;";
|
||||
$result = Database::query($sql);
|
||||
if (Database::affected_rows($result) > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
return $aux['action_id'];
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
return $aux['course_id'];
|
||||
}
|
||||
function getCourseCode($actionId)
|
||||
{
|
||||
global $tableCourse;
|
||||
$actionId = (int) $actionId;
|
||||
$courseId = getCourse($actionId);
|
||||
$sql = "SELECT code FROM $tableCourse WHERE id = $courseId";
|
||||
$rs = Database::query($sql);
|
||||
$aux = Database::fetch_assoc($rs);
|
||||
|
||||
return $aux['code'];
|
||||
}
|
||||
|
||||
function getActionInfo($id)
|
||||
{
|
||||
global $tableSepeActions;
|
||||
|
||||
$id = (int) $id;
|
||||
$sql = "SELECT * FROM $tableSepeActions WHERE id = $id";
|
||||
$res = Database::query($sql);
|
||||
$row = false;
|
||||
if (Database::num_rows($res) > 0) {
|
||||
$row['action_origin'] = Security::remove_XSS(stripslashes($row['action_origin']));
|
||||
$row['action_code'] = Security::remove_XSS(stripslashes($row['action_code']));
|
||||
$row['situation'] = Security::remove_XSS(stripslashes($row['situation']));
|
||||
$row['specialty_origin'] = Security::remove_XSS(stripslashes($row['specialty_origin']));
|
||||
$row['professional_area'] = Security::remove_XSS(stripslashes($row['professional_area']));
|
||||
$row['specialty_code'] = Security::remove_XSS(stripslashes($row['specialty_code']));
|
||||
$row['full_itinerary_indicator'] = Security::remove_XSS(stripslashes($row['full_itinerary_indicator']));
|
||||
$row['financing_type'] = Security::remove_XSS(stripslashes($row['financing_type']));
|
||||
$row['action_name'] = Security::remove_XSS(stripslashes($row['action_name']));
|
||||
$row['global_info'] = Security::remove_XSS(stripslashes($row['global_info']));
|
||||
$row['schedule'] = Security::remove_XSS(stripslashes($row['schedule']));
|
||||
$row['requirements'] = Security::remove_XSS(stripslashes($row['requirements']));
|
||||
$row['contact_action'] = Security::remove_XSS(stripslashes($row['contact_action']));
|
||||
$row = Database::fetch_assoc($res);
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function getSpecialtActionInfo($specialtyId)
|
||||
{
|
||||
global $tableSepeSpecialty;
|
||||
$specialtyId = (int) $specialtyId;
|
||||
$sql = "SELECT * FROM $tableSepeSpecialty WHERE id = $specialtyId";
|
||||
$res = Database::query($sql);
|
||||
$row = false;
|
||||
if (Database::num_rows($res) > 0) {
|
||||
$row['specialty_origin'] = Security::remove_XSS(stripslashes($row['specialty_origin']));
|
||||
$row['professional_area'] = Security::remove_XSS(stripslashes($row['professional_area']));
|
||||
$row['specialty_code'] = Security::remove_XSS(stripslashes($row['specialty_code']));
|
||||
$row['center_origin'] = Security::remove_XSS(stripslashes($row['center_origin']));
|
||||
$row['center_code'] = Security::remove_XSS(stripslashes($row['center_code']));
|
||||
$row['modality_impartition'] = Security::remove_XSS(stripslashes($row['modality_impartition']));
|
||||
$row = Database::fetch_assoc($res);
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function getInfoSpecialtyClassroom($classroomId)
|
||||
{
|
||||
global $tableSepeSpecialtyClassroom;
|
||||
global $tableCenters;
|
||||
$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;
|
||||
if (Database::num_rows($res) > 0) {
|
||||
$row['center_origin'] = Security::remove_XSS(stripslashes($row['center_origin']));
|
||||
$row['center_code'] = Security::remove_XSS(stripslashes($row['center_code']));
|
||||
$row = Database::fetch_assoc($res);
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function getInfoSpecialtyTutorial($tutorialId)
|
||||
{
|
||||
global $tableSepeParticipantsSpecialtyTutorials;
|
||||
$tutorialId = (int) $tutorialId;
|
||||
$sql = "SELECT * FROM $tableSepeParticipantsSpecialtyTutorials WHERE id = $tutorialId";
|
||||
$res = Database::query($sql);
|
||||
if (Database::num_rows($res) > 0) {
|
||||
$row = Database::fetch_assoc($res);
|
||||
} else {
|
||||
$row = false;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
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) {
|
||||
$row = Database::fetch_assoc($res);
|
||||
} else {
|
||||
$row = false;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function getCentersList()
|
||||
{
|
||||
global $tableCenters;
|
||||
$sql = "SELECT * FROM $tableCenters;";
|
||||
$res = Database::query($sql);
|
||||
$aux = [];
|
||||
while ($row = Database::fetch_assoc($res)) {
|
||||
$aux[] = $row;
|
||||
}
|
||||
|
||||
return $aux;
|
||||
}
|
||||
|
||||
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 = [];
|
||||
while ($row = Database::fetch_assoc($res)) {
|
||||
$tmp = [];
|
||||
$tmp['id'] = $row['id'];
|
||||
if (trim($row['alias']) != '') {
|
||||
$tmp['alias'] = $row['alias'].' - '.$row['document_type'].' '.$row['document_number'].' '.$row['document_letter'];
|
||||
} else {
|
||||
$tmp['alias'] = $row['document_type'].' '.$row['document_number'].' '.$row['document_letter'];
|
||||
}
|
||||
$aux[] = $tmp;
|
||||
}
|
||||
|
||||
return $aux;
|
||||
}
|
||||
|
||||
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;";
|
||||
$res = Database::query($sql);
|
||||
$aux = [];
|
||||
while ($row = Database::fetch_assoc($res)) {
|
||||
if (!in_array($row['id'], $tutorsList)) {
|
||||
$tutor = [];
|
||||
$tutor['id'] = $row['id'];
|
||||
if (trim($row['firstname']) != '' || trim($row['lastname']) != '') {
|
||||
$tutor['data'] = $row['firstname'].' '.$row['lastname'].' ('.$row['document_type'].' '.$row['document_number'].' '.$row['document_letter'].' )';
|
||||
} else {
|
||||
$tutor['data'] = $row['document_type'].' '.$row['document_number'].' '.$row['document_letter'];
|
||||
}
|
||||
$aux[] = $tutor;
|
||||
}
|
||||
}
|
||||
|
||||
return $aux;
|
||||
}
|
||||
|
||||
function getInfoSpecialtyTutor($tutorId)
|
||||
{
|
||||
global $tableSepeSpecialtyTutors;
|
||||
global $tableSepeTutors;
|
||||
$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);
|
||||
if (Database::num_rows($res) > 0) {
|
||||
$row['tutor_accreditation'] = Security::remove_XSS(stripslashes($row['tutor_accreditation']));
|
||||
$row['teaching_competence'] = Security::remove_XSS(stripslashes($row['teaching_competence']));
|
||||
$row['training_teleforming'] = Security::remove_XSS(stripslashes($row['training_teleforming']));
|
||||
$row = Database::fetch_assoc($res);
|
||||
} else {
|
||||
$row = false;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
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) {
|
||||
while ($aux = Database::fetch_assoc($rs)) {
|
||||
$sql = "SELECT platform_user_id FROM $tableSepeTutors WHERE id='".$aux['tutor_id']."';";
|
||||
$res = Database::query($sql);
|
||||
if (Database::num_rows($res) > 0) {
|
||||
$tmp = Database::fetch_assoc($res);
|
||||
if ($tmp['platform_user_id'] != 0 && $tmp['platform_user_id'] != $platform_user_id) {
|
||||
foreach ($teacherList as $key => $value) {
|
||||
if ($value['id'] == $tmp['platform_user_id']) {
|
||||
unset($teacherList[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $teacherList;
|
||||
}
|
||||
|
||||
function getInfoParticipantAction($participantId)
|
||||
{
|
||||
global $tableSepeParticipants;
|
||||
$participantId = (int) $participantId;
|
||||
$sql = "SELECT * FROM $tableSepeParticipants WHERE id = $participantId";
|
||||
$res = Database::query($sql);
|
||||
if (Database::num_rows($res) > 0) {
|
||||
$row = Database::fetch_assoc($res);
|
||||
$result = [];
|
||||
$result['id'] = $row[''];
|
||||
$result['action_id'] = $row['action_id'];
|
||||
$result['company_tutor_id'] = $row['company_tutor_id'];
|
||||
$result['training_tutor_id'] = $row['training_tutor_id'];
|
||||
$result['platform_user_id'] = $row['platform_user_id'];
|
||||
$result['document_type'] = Security::remove_XSS(stripslashes($row['document_type']));
|
||||
$result['document_number'] = Security::remove_XSS(stripslashes($row['document_number']));
|
||||
$result['document_letter'] = Security::remove_XSS(stripslashes($row['document_letter']));
|
||||
$result['key_competence'] = Security::remove_XSS(stripslashes($row['key_competence']));
|
||||
$result['contract_id'] = Security::remove_XSS(stripslashes($row['contract_id']));
|
||||
$result['company_fiscal_number'] = Security::remove_XSS(stripslashes($row['company_fiscal_number']));
|
||||
} else {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
return $aux['participant_id'];
|
||||
}
|
||||
|
||||
function getInfoSpecialtyParticipant($specialtyId)
|
||||
{
|
||||
global $tableSepeParticipantsSpecialty;
|
||||
$specialtyId = (int) $specialtyId;
|
||||
$sql = "SELECT * FROM $tableSepeParticipantsSpecialty WHERE id = $specialtyId";
|
||||
$res = Database::query($sql);
|
||||
if (Database::num_rows($res) > 0) {
|
||||
$row = Database::fetch_assoc($res);
|
||||
$row['specialty_origin'] = Security::remove_XSS(stripslashes($row['specialty_origin']));
|
||||
$row['professional_area'] = Security::remove_XSS(stripslashes($row['professional_area']));
|
||||
$row['specialty_code'] = Security::remove_XSS(stripslashes($row['specialty_code']));
|
||||
$row['center_origin'] = Security::remove_XSS(stripslashes($row['center_origin']));
|
||||
$row['center_code'] = Security::remove_XSS(stripslashes($row['center_code']));
|
||||
$row['final_result'] = Security::remove_XSS(stripslashes($row['final_result']));
|
||||
$row['final_qualification'] = Security::remove_XSS(stripslashes($row['final_qualification']));
|
||||
$row['final_score'] = Security::remove_XSS(stripslashes($row['final_score']));
|
||||
} else {
|
||||
$row = false;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function specialtyList($actionId)
|
||||
{
|
||||
global $tableSepeSpecialty;
|
||||
$actionId = (int) $actionId;
|
||||
$sql = "SELECT id, specialty_origin, professional_area, specialty_code
|
||||
FROM $tableSepeSpecialty
|
||||
WHERE action_id = $actionId";
|
||||
$res = Database::query($sql);
|
||||
$aux = [];
|
||||
while ($row = Database::fetch_assoc($res)) {
|
||||
$aux[] = $row;
|
||||
}
|
||||
|
||||
return $aux;
|
||||
}
|
||||
|
||||
function participantList($actionId)
|
||||
{
|
||||
global $tableSepeParticipants;
|
||||
global $tableUser;
|
||||
$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 = [];
|
||||
while ($row = Database::fetch_assoc($res)) {
|
||||
$aux[] = $row;
|
||||
}
|
||||
|
||||
return $aux;
|
||||
}
|
||||
|
||||
function listParticipantSpecialty($participantId)
|
||||
{
|
||||
global $tableSepeParticipantsSpecialty;
|
||||
|
||||
$participantId = (int) $participantId;
|
||||
$sql = "SELECT * FROM $tableSepeParticipantsSpecialty WHERE participant_id = $participantId";
|
||||
$res = Database::query($sql);
|
||||
$aux = [];
|
||||
while ($row = Database::fetch_assoc($res)) {
|
||||
$row['specialty_origin'] = Security::remove_XSS(stripslashes($row['specialty_origin']));
|
||||
$row['professional_area'] = Security::remove_XSS(stripslashes($row['professional_area']));
|
||||
$row['specialty_code'] = Security::remove_XSS(stripslashes($row['specialty_code']));
|
||||
$row['center_origin'] = Security::remove_XSS(stripslashes($row['center_origin']));
|
||||
$row['center_code'] = Security::remove_XSS(stripslashes($row['center_code']));
|
||||
$row['final_result'] = Security::remove_XSS(stripslashes($row['final_result']));
|
||||
$row['final_qualification'] = Security::remove_XSS(stripslashes($row['final_qualification']));
|
||||
$row['final_score'] = Security::remove_XSS(stripslashes($row['final_score']));
|
||||
$aux[] = $row;
|
||||
}
|
||||
|
||||
return $aux;
|
||||
}
|
||||
|
||||
function classroomList($specialtyId)
|
||||
{
|
||||
global $tableSepeSpecialtyClassroom;
|
||||
global $tableCenters;
|
||||
$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 = [];
|
||||
while ($row = Database::fetch_assoc($res)) {
|
||||
$aux[] = $row;
|
||||
}
|
||||
|
||||
return $aux;
|
||||
}
|
||||
|
||||
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
|
||||
WHERE a.specialty_id = $specialtyId";
|
||||
$res = Database::query($sql);
|
||||
while ($row = Database::fetch_assoc($res)) {
|
||||
$aux[] = $row;
|
||||
}
|
||||
|
||||
return $aux;
|
||||
}
|
||||
|
||||
function getListSpecialtyTutorial($specialtyId)
|
||||
{
|
||||
global $tableSepeParticipantsSpecialtyTutorials;
|
||||
$specialtyId = (int) $specialtyId;
|
||||
$sql = "SELECT * FROM $tableSepeParticipantsSpecialtyTutorials
|
||||
WHERE participant_specialty_id = $specialtyId";
|
||||
$res = Database::query($sql);
|
||||
$aux = [];
|
||||
while ($row = Database::fetch_assoc($res)) {
|
||||
$row['tutor_accreditation'] = Security::remove_XSS(stripslashes($row['tutor_accreditation']));
|
||||
$row['teaching_competence'] = Security::remove_XSS(stripslashes($row['teaching_competence']));
|
||||
$row['training_teleforming'] = Security::remove_XSS(stripslashes($row['training_teleforming']));
|
||||
$aux[] = $row;
|
||||
}
|
||||
|
||||
return $aux;
|
||||
}
|
||||
|
||||
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
|
||||
AND $tableSepeActions.id=$tableSepeCourseActions.action_id";
|
||||
$res = Database::query($sql);
|
||||
$aux = [];
|
||||
while ($row = Database::fetch_assoc($res)) {
|
||||
$aux[] = $row;
|
||||
}
|
||||
|
||||
return $aux;
|
||||
}
|
||||
|
||||
function listCourseFree()
|
||||
{
|
||||
global $tableCourse;
|
||||
global $tableSepeCourseActions;
|
||||
$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)) {
|
||||
$aux[] = $row;
|
||||
}
|
||||
|
||||
return $aux;
|
||||
}
|
||||
|
||||
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)
|
||||
;";
|
||||
$res = Database::query($sql);
|
||||
$aux = [];
|
||||
while ($row = Database::fetch_assoc($res)) {
|
||||
$row['action_origin'] = Security::remove_XSS(stripslashes($row['action_origin']));
|
||||
$row['action_code'] = Security::remove_XSS(stripslashes($row['action_code']));
|
||||
$aux[] = $row;
|
||||
}
|
||||
|
||||
return $aux;
|
||||
}
|
||||
|
||||
function getSpecialtyTutorId($specialtyId, $tutorId)
|
||||
{
|
||||
global $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);
|
||||
|
||||
return $row['id'];
|
||||
}
|
||||
|
||||
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) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function getUserPlatformFromParticipant($participantId)
|
||||
{
|
||||
global $tableSepeParticipants;
|
||||
$participantId = (int) $participantId;
|
||||
|
||||
$sql = "SELECT * FROM $tableSepeParticipants WHERE id = $participantId";
|
||||
$res = Database::query($sql);
|
||||
$row = Database::fetch_assoc($res);
|
||||
if ($row['platform_user_id'] == 0 || $row['platform_user_id'] == '') {
|
||||
return false;
|
||||
} else {
|
||||
return $row['platform_user_id'];
|
||||
}
|
||||
}
|
||||
557
plugin/sepe/src/sepe_plugin.class.php
Normal file
557
plugin/sepe/src/sepe_plugin.class.php
Normal file
@@ -0,0 +1,557 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Plugin class for the SEPE plugin.
|
||||
*
|
||||
* @package chamilo.plugin.sepe
|
||||
*
|
||||
* @author Jose Angel Ruiz <jaruiz@nosolored.com>
|
||||
* @author Julio Montoya <gugli100@gmail.com>
|
||||
*/
|
||||
class SepePlugin extends Plugin
|
||||
{
|
||||
public const TABLE_SEPE_CENTER = 'plugin_sepe_center';
|
||||
public const TABLE_SEPE_ACTIONS = 'plugin_sepe_actions';
|
||||
public const TABLE_SEPE_SPECIALTY = 'plugin_sepe_specialty';
|
||||
public const TABLE_SEPE_SPECIALTY_CLASSROOM = 'plugin_sepe_specialty_classroom';
|
||||
public const TABLE_SEPE_CENTERS = 'plugin_sepe_centers';
|
||||
public const TABLE_SEPE_TUTORS = 'plugin_sepe_tutors';
|
||||
public const TABLE_SEPE_SPECIALTY_TUTORS = 'plugin_sepe_specialty_tutors';
|
||||
public const TABLE_SEPE_PARTICIPANTS = 'plugin_sepe_participants';
|
||||
public const TABLE_SEPE_PARTICIPANTS_SPECIALTY = 'plugin_sepe_participants_specialty';
|
||||
public const TABLE_SEPE_PARTICIPANTS_SPECIALTY_TUTORIALS = 'plugin_sepe_participants_specialty_tutorials';
|
||||
public const TABLE_SEPE_COURSE_ACTIONS = 'plugin_sepe_course_actions';
|
||||
public const TABLE_SEPE_TUTORS_COMPANY = 'plugin_sepe_tutors_company';
|
||||
public const TABLE_SEPE_TEACHING_COMPETENCE = 'plugin_sepe_teaching_competence';
|
||||
public const TABLE_SEPE_LOG_PARTICIPANT = 'plugin_sepe_log_participant';
|
||||
public const TABLE_SEPE_LOG_MOD_PARTICIPANT = 'plugin_sepe_log_mod_participant';
|
||||
public const TABLE_SEPE_LOG = 'plugin_sepe_log';
|
||||
|
||||
public $isAdminPlugin = true;
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'2.1',
|
||||
'
|
||||
Jose Angel Ruiz - NoSoloRed (original author) <br>
|
||||
Julio Montoya (SOAP integration)
|
||||
',
|
||||
['sepe_enable' => 'boolean']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SepePlugin
|
||||
*/
|
||||
public static function create()
|
||||
{
|
||||
static $result = null;
|
||||
|
||||
return $result ? $result : $result = new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates the tables required to this plugin.
|
||||
*/
|
||||
public function install()
|
||||
{
|
||||
$tablesToBeCompared = [
|
||||
self::TABLE_SEPE_CENTER,
|
||||
self::TABLE_SEPE_ACTIONS,
|
||||
self::TABLE_SEPE_SPECIALTY,
|
||||
self::TABLE_SEPE_SPECIALTY_CLASSROOM,
|
||||
self::TABLE_SEPE_CENTERS,
|
||||
self::TABLE_SEPE_TUTORS,
|
||||
self::TABLE_SEPE_SPECIALTY_TUTORS,
|
||||
self::TABLE_SEPE_PARTICIPANTS,
|
||||
self::TABLE_SEPE_PARTICIPANTS_SPECIALTY,
|
||||
self::TABLE_SEPE_PARTICIPANTS_SPECIALTY_TUTORIALS,
|
||||
self::TABLE_SEPE_COURSE_ACTIONS,
|
||||
self::TABLE_SEPE_TUTORS_COMPANY,
|
||||
self::TABLE_SEPE_TEACHING_COMPETENCE,
|
||||
self::TABLE_SEPE_LOG_PARTICIPANT,
|
||||
self::TABLE_SEPE_LOG_MOD_PARTICIPANT,
|
||||
self::TABLE_SEPE_LOG,
|
||||
];
|
||||
$em = Database::getManager();
|
||||
$cn = $em->getConnection();
|
||||
$sm = $cn->getSchemaManager();
|
||||
$tables = $sm->tablesExist($tablesToBeCompared);
|
||||
|
||||
if (empty($tables)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
require_once api_get_path(SYS_PLUGIN_PATH).'sepe/database.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method drops the plugin tables.
|
||||
*/
|
||||
public function uninstall()
|
||||
{
|
||||
$tablesToBeDeleted = [
|
||||
self::TABLE_SEPE_CENTER,
|
||||
self::TABLE_SEPE_SPECIALTY_CLASSROOM,
|
||||
self::TABLE_SEPE_CENTERS,
|
||||
self::TABLE_SEPE_TUTORS,
|
||||
self::TABLE_SEPE_SPECIALTY_TUTORS,
|
||||
self::TABLE_SEPE_PARTICIPANTS_SPECIALTY_TUTORIALS,
|
||||
self::TABLE_SEPE_PARTICIPANTS_SPECIALTY,
|
||||
self::TABLE_SEPE_COURSE_ACTIONS,
|
||||
self::TABLE_SEPE_PARTICIPANTS,
|
||||
self::TABLE_SEPE_TUTORS_COMPANY,
|
||||
self::TABLE_SEPE_SPECIALTY,
|
||||
self::TABLE_SEPE_ACTIONS,
|
||||
self::TABLE_SEPE_TEACHING_COMPETENCE,
|
||||
self::TABLE_SEPE_LOG_PARTICIPANT,
|
||||
self::TABLE_SEPE_LOG_MOD_PARTICIPANT,
|
||||
self::TABLE_SEPE_LOG,
|
||||
];
|
||||
|
||||
foreach ($tablesToBeDeleted as $tableToBeDeleted) {
|
||||
$table = Database::get_main_table($tableToBeDeleted);
|
||||
$sql = "DROP TABLE IF EXISTS $table";
|
||||
Database::query($sql);
|
||||
}
|
||||
$this->manageTab(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update.
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$oldTableCenters = 'plugin_sepe_centros';
|
||||
$oldTableTutorsCompany = 'plugin_sepe_tutors_empresa';
|
||||
$oldTableCompetence = 'plugin_sepe_competencia_docente';
|
||||
$sql = "RENAME TABLE "
|
||||
.$oldTableCenters." TO ".self::TABLE_SEPE_CENTERS.", "
|
||||
.$oldTableTutorsCompany." TO ".self::TABLE_SEPE_TUTORS_COMPANY.", "
|
||||
.$oldTableCompetence." TO ".self::TABLE_SEPE_TEACHING_COMPETENCE.";";
|
||||
Database::query($sql);
|
||||
|
||||
$sepeCourseActionsTable = self::TABLE_SEPE_COURSE_ACTIONS;
|
||||
$sql = "ALTER TABLE ".$sepeCourseActionsTable."
|
||||
CHANGE `cod` `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeCourseActionsTable."
|
||||
CHANGE `cod_action` `action_id` INT( 10 ) UNSIGNED NOT NULL";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeCourseActionsTable."
|
||||
CHANGE `id_course` `course_id` INT( 10 ) UNSIGNED NOT NULL";
|
||||
Database::query($sql);
|
||||
|
||||
$sepeActionsTable = self::TABLE_SEPE_ACTIONS;
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `cod` `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `ORIGEN_ACCION` `action_origin` VARCHAR(2)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `CODIGO_ACCION` `action_code` VARCHAR(30)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `SITUACION` `situation` VARCHAR(2)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `ORIGEN_ESPECIALIDAD` `specialty_origin` VARCHAR(2)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `AREA_PROFESIONAL` `professional_area` VARCHAR(4)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `CODIGO_ESPECIALIDAD` `specialty_code` VARCHAR(14)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `DURACION` `duration` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `FECHA_INICIO` `start_date` DATE NULL";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `FECHA_FIN` `end_date` DATE";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `IND_ITINERARIO_COMPLETO` `full_itinerary_indicator` VARCHAR(2)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `TIPO_FINANCIACION` `financing_type` VARCHAR(2)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `NUMERO_ASISTENTES` `attendees_count` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `DENOMINACION_ACCION` `action_name` VARCHAR(50)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `INFORMACION_GENERAL` `global_info` LONGTEXT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `HORARIOS` `schedule` LONGTEXT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `REQUISITOS` `requirements` LONGTEXT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeActionsTable."
|
||||
CHANGE `CONTACTO_ACCION` `contact_action` LONGTEXT";
|
||||
Database::query($sql);
|
||||
|
||||
$sepeSpecialtyTable = self::TABLE_SEPE_SPECIALTY;
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `cod` `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `cod_action` `action_id` INT( 10 ) UNSIGNED NOT NULL";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `ORIGEN_ESPECIALIDAD` `specialty_origin` VARCHAR(2)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `AREA_PROFESIONAL` `professional_area` VARCHAR(4)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `CODIGO_ESPECIALIDAD` `specialty_code` VARCHAR(14)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `ORIGEN_CENTRO` `center_origin` VARCHAR(2)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `CODIGO_CENTRO` `center_code` VARCHAR(16)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `FECHA_INICIO` `start_date` DATE";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `FECHA_FIN` `end_date` DATE";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `MODALIDAD_IMPARTICION` `modality_impartition` VARCHAR(2)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `HORAS_PRESENCIAL` `classroom_hours` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `HORAS_TELEFORMACION` `distance_hours` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `HM_NUM_PARTICIPANTES` `mornings_participants_number` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `HM_NUMERO_ACCESOS` `mornings_access_number` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `HM_DURACION_TOTAL` `morning_total_duration` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `HT_NUM_PARTICIPANTES` `afternoon_participants_number` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `HT_NUMERO_ACCESOS` `afternoon_access_number` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `HT_DURACION_TOTAL` `afternoon_total_duration` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `HN_NUM_PARTICIPANTES` `night_participants_number` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `HN_NUMERO_ACCESOS` `night_access_number` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `HN_DURACION_TOTAL` `night_total_duration` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `NUM_PARTICIPANTES` `attendees_count` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `NUMERO_ACTIVIDADES_APRENDIZAJE` `learning_activity_count` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `NUMERO_INTENTOS` `attempt_count` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTable."
|
||||
CHANGE `NUMERO_ACTIVIDADES_EVALUACION` `evaluation_activity_count` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
|
||||
$sepeParticipantTable = self::TABLE_SEPE_PARTICIPANTS;
|
||||
$sql = "ALTER TABLE ".$sepeParticipantTable."
|
||||
CHANGE `cod` `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantTable."
|
||||
CHANGE `cod_action` `action_id` INT( 10 ) UNSIGNED NOT NULL";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantTable."
|
||||
CHANGE `cod_tutor_empresa` `company_tutor_id` INT( 10 ) UNSIGNED NULL";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantTable."
|
||||
CHANGE `cod_tutor_formacion` `training_tutor_id` INT( 10 ) UNSIGNED NULL";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantTable."
|
||||
CHANGE `cod_user_chamilo` `platform_user_id` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantTable."
|
||||
CHANGE `TIPO_DOCUMENTO` `document_type` VARCHAR( 1 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantTable."
|
||||
CHANGE `NUM_DOCUMENTO` `document_number` VARCHAR( 10 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantTable."
|
||||
CHANGE `LETRA_NIF` `document_letter` VARCHAR( 1 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantTable."
|
||||
CHANGE `INDICADOR_COMPETENCIAS_CLAVE` `key_competence` VARCHAR( 2 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantTable."
|
||||
CHANGE `ID_CONTRATO_CFA` `contract_id` VARCHAR( 14 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantTable."
|
||||
CHANGE `CIF_EMPRESA` `company_fiscal_number` VARCHAR( 9 )";
|
||||
Database::query($sql);
|
||||
|
||||
$sepeCenterTable = self::TABLE_SEPE_CENTERS;
|
||||
$sql = "ALTER TABLE ".$sepeCenterTable."
|
||||
CHANGE `cod` `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeCenterTable."
|
||||
CHANGE `ORIGEN_CENTRO` `center_origin` VARCHAR(2)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeCenterTable."
|
||||
CHANGE `CODIGO_CENTRO` `center_code` VARCHAR(16)";
|
||||
Database::query($sql);
|
||||
|
||||
$sepeSpecialtyClassroomTable = self::TABLE_SEPE_SPECIALTY_CLASSROOM;
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyClassroomTable."
|
||||
CHANGE `cod` `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyClassroomTable."
|
||||
CHANGE `cod_specialty` `specialty_id` INT( 10 ) UNSIGNED NOT NULL";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyClassroomTable."
|
||||
CHANGE `cod_centro` `center_id` INT( 10 ) UNSIGNED NOT NULL";
|
||||
Database::query($sql);
|
||||
|
||||
$sepeSpecialtyTutorsTable = self::TABLE_SEPE_SPECIALTY_TUTORS;
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTutorsTable."
|
||||
CHANGE `cod` `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTutorsTable."
|
||||
CHANGE `cod_specialty` `specialty_id` INT( 10 ) UNSIGNED NOT NULL";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTutorsTable."
|
||||
CHANGE `cod_tutor` `tutor_id` INT( 10 ) UNSIGNED NOT NULL";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTutorsTable."
|
||||
CHANGE `ACREDITACION_TUTOR` `tutor_accreditation` VARCHAR(200)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTutorsTable."
|
||||
CHANGE `EXPERIENCIA_PROFESIONAL` `professional_experience` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTutorsTable."
|
||||
CHANGE `COMPETENCIA_DOCENTE` `teaching_competence` VARCHAR(2)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTutorsTable."
|
||||
CHANGE `EXPERIENCIA_MODALIDAD_TELEFORMACION` `experience_teleforming` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeSpecialtyTutorsTable."
|
||||
CHANGE `FORMACION_MODALIDAD_TELEFORMACION` `training_teleforming` VARCHAR(2)";
|
||||
Database::query($sql);
|
||||
|
||||
$sepeTutorsTable = self::TABLE_SEPE_TUTORS;
|
||||
$sql = "ALTER TABLE ".$sepeTutorsTable."
|
||||
CHANGE `cod` `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeTutorsTable."
|
||||
CHANGE `cod_user_chamilo` `platform_user_id` INT( 10 ) UNSIGNED NOT NULL";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeTutorsTable."
|
||||
CHANGE `TIPO_DOCUMENTO` `document_type` VARCHAR( 1 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeTutorsTable."
|
||||
CHANGE `NUM_DOCUMENTO` `document_number` VARCHAR( 10 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeTutorsTable."
|
||||
CHANGE `LETRA_NIF` `document_letter` VARCHAR( 1 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeTutorsTable."
|
||||
CHANGE `ACREDITACION_TUTOR` `tutor_accreditation` VARCHAR(200)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeTutorsTable."
|
||||
CHANGE `EXPERIENCIA_PROFESIONAL` `professional_experience` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeTutorsTable."
|
||||
CHANGE `COMPETENCIA_DOCENTE` `teaching_competence` VARCHAR(2)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeTutorsTable."
|
||||
CHANGE `EXPERIENCIA_MODALIDAD_TELEFORMACION` `experience_teleforming` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeTutorsTable."
|
||||
CHANGE `FORMACION_MODALIDAD_TELEFORMACION` `training_teleforming` VARCHAR(2)";
|
||||
Database::query($sql);
|
||||
|
||||
$sepeParticipantSpecialtyTable = self::TABLE_SEPE_PARTICIPANTS_SPECIALTY;
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTable."
|
||||
CHANGE `cod` `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTable."
|
||||
CHANGE `cod_participant` `participant_id` INT( 10 ) UNSIGNED NOT NULL";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTable."
|
||||
CHANGE `ORIGEN_ESPECIALIDAD` `specialty_origin` VARCHAR(2)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTable."
|
||||
CHANGE `AREA_PROFESIONAL` `professional_area` VARCHAR(4)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTable."
|
||||
CHANGE `CODIGO_ESPECIALIDAD` `specialty_code` VARCHAR(14)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTable."
|
||||
CHANGE `FECHA_ALTA` `registration_date` DATE";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTable."
|
||||
CHANGE `FECHA_BAJA` `leaving_date` DATE";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTable."
|
||||
CHANGE `ORIGEN_CENTRO` `center_origin` VARCHAR(2)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTable."
|
||||
CHANGE `CODIGO_CENTRO` `center_code` VARCHAR(16)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTable."
|
||||
CHANGE `FECHA_INICIO` `start_date` DATE";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTable."
|
||||
CHANGE `FECHA_FIN` `end_date` DATE";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTable."
|
||||
CHANGE `RESULTADO_FINAL` `final_result` VARCHAR(1)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTable."
|
||||
CHANGE `CALIFICACION_FINAL` `final_qualification` VARCHAR(4)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTable."
|
||||
CHANGE `PUNTUACION_FINAL` `final_score` VARCHAR(4)";
|
||||
Database::query($sql);
|
||||
|
||||
$sepeParticipantSpecialtyTutorialsTable = self::TABLE_SEPE_PARTICIPANTS_SPECIALTY_TUTORIALS;
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTutorialsTable."
|
||||
CHANGE `cod` `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTutorialsTable."
|
||||
CHANGE `cod_participant_specialty` `participant_specialty_id` INT( 10 ) UNSIGNED NOT NULL";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTutorialsTable."
|
||||
CHANGE `ORIGEN_CENTRO` `center_origin` VARCHAR(2)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTutorialsTable."
|
||||
CHANGE `CODIGO_CENTRO` `center_code` VARCHAR(16)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTutorialsTable."
|
||||
CHANGE `FECHA_INICIO` `start_date` DATE";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeParticipantSpecialtyTutorialsTable."
|
||||
CHANGE `FECHA_FIN` `end_date` DATE";
|
||||
Database::query($sql);
|
||||
|
||||
$sepeTutorsCompanyTable = self::TABLE_SEPE_TUTORS_COMPANY;
|
||||
|
||||
$sql = "UPDATE ".$sepeTutorsCompanyTable." SET empresa='1' WHERE empresa='SI'";
|
||||
Database::query($sql);
|
||||
$sql = "UPDATE ".$sepeTutorsCompanyTable." SET empresa='0' WHERE empresa='NO'";
|
||||
Database::query($sql);
|
||||
$sql = "UPDATE ".$sepeTutorsCompanyTable." SET formacion='1' WHERE formacion='SI'";
|
||||
Database::query($sql);
|
||||
$sql = "UPDATE ".$sepeTutorsCompanyTable." SET formacion='0' WHERE formacion='NO'";
|
||||
Database::query($sql);
|
||||
|
||||
$sql = "ALTER TABLE ".$sepeTutorsCompanyTable."
|
||||
CHANGE `cod` `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeTutorsCompanyTable."
|
||||
CHANGE `alias` `alias` VARCHAR(255)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeTutorsCompanyTable."
|
||||
CHANGE `TIPO_DOCUMENTO` `document_type` VARCHAR( 1 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeTutorsCompanyTable."
|
||||
CHANGE `NUM_DOCUMENTO` `document_number` VARCHAR( 10 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeTutorsCompanyTable."
|
||||
CHANGE `LETRA_NIF` `document_letter` VARCHAR( 1 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeTutorsCompanyTable."
|
||||
CHANGE `empresa` `company` VARCHAR(1)";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeTutorsCompanyTable."
|
||||
CHANGE `formacion` `training` VARCHAR(1)";
|
||||
Database::query($sql);
|
||||
|
||||
$sepeCompetenceTable = self::TABLE_SEPE_TEACHING_COMPETENCE;
|
||||
$sql = "ALTER TABLE ".$sepeCompetenceTable."
|
||||
CHANGE `cod` `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeCompetenceTable."
|
||||
CHANGE `valor` `value` LONGTEXT";
|
||||
Database::query($sql);
|
||||
|
||||
$sepeLogParticipantTable = self::TABLE_SEPE_LOG_PARTICIPANT;
|
||||
$sql = "ALTER TABLE ".$sepeLogParticipantTable."
|
||||
CHANGE `cod` `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeLogParticipantTable."
|
||||
CHANGE `cod_user_chamilo` `platform_user_id` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeLogParticipantTable."
|
||||
CHANGE `cod_action` `action_id` INT( 10 ) UNSIGNED";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeLogParticipantTable."
|
||||
CHANGE `fecha_alta` `registration_date` DATE";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeLogParticipantTable."
|
||||
CHANGE `fecha_baja` `leaving_date` DATE";
|
||||
Database::query($sql);
|
||||
|
||||
$sepeLogModParticipantTable = self::TABLE_SEPE_LOG_MOD_PARTICIPANT;
|
||||
$sql = "ALTER TABLE ".$sepeLogModParticipantTable."
|
||||
CHANGE `cod` `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeLogModParticipantTable."
|
||||
CHANGE `cod_user_chamilo` `platform_user_id` INT( 10 ) UNSIGNED NOT NULL";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeLogModParticipantTable."
|
||||
CHANGE `cod_action` `action_id` INT( 10 ) UNSIGNED NOT NULL";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeLogModParticipantTable."
|
||||
CHANGE `fecha_mod` `change_date` DATE";
|
||||
Database::query($sql);
|
||||
|
||||
$sepeCenterTable = self::TABLE_SEPE_CENTER;
|
||||
$sql = "ALTER TABLE ".$sepeCenterTable."
|
||||
CHANGE `cod` `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeCenterTable."
|
||||
CHANGE `origen_centro` `center_origin` VARCHAR( 255 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeCenterTable."
|
||||
CHANGE `codigo_centro` `center_code` VARCHAR( 255 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeCenterTable."
|
||||
CHANGE `nombre_centro` `center_name` VARCHAR( 255 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeCenterTable."
|
||||
CHANGE `url` `url` VARCHAR( 255 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeCenterTable."
|
||||
CHANGE `url_seguimiento` `tracking_url` VARCHAR( 255 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeCenterTable."
|
||||
CHANGE `telefono` `phone` VARCHAR( 255 )";
|
||||
Database::query($sql);
|
||||
$sql = "ALTER TABLE ".$sepeCenterTable."
|
||||
CHANGE `email` `mail` VARCHAR( 255 )";
|
||||
Database::query($sql);
|
||||
}
|
||||
}
|
||||
241
plugin/sepe/src/specialty-action-edit.php
Normal file
241
plugin/sepe/src/specialty-action-edit.php
Normal file
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* This script displays a specialty action edit form.
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$course_plugin = 'sepe';
|
||||
$plugin = SepePlugin::create();
|
||||
$_cid = 0;
|
||||
|
||||
if (!empty($_POST)) {
|
||||
$check = Security::check_token('post');
|
||||
if ($check) {
|
||||
$specialtyOrigin = Database::escape_string(trim($_POST['specialty_origin']));
|
||||
$professionalArea = Database::escape_string(trim($_POST['professional_area']));
|
||||
$specialtyCode = Database::escape_string(trim($_POST['specialty_code']));
|
||||
$centerOrigin = Database::escape_string(trim($_POST['center_origin']));
|
||||
$centerCode = Database::escape_string(trim($_POST['center_code']));
|
||||
$dayStart = Database::escape_string(trim($_POST['day_start']));
|
||||
$monthStart = Database::escape_string(trim($_POST['month_start']));
|
||||
$yearStart = Database::escape_string(trim($_POST['year_start']));
|
||||
$dayEnd = Database::escape_string(trim($_POST['day_end']));
|
||||
$monthEnd = Database::escape_string(trim($_POST['month_end']));
|
||||
$yearEnd = Database::escape_string(trim($_POST['year_end']));
|
||||
$modality_impartition = Database::escape_string(trim($_POST['modality_impartition']));
|
||||
$classroomHours = Database::escape_string(trim($_POST['classroom_hours']));
|
||||
$distanceHours = intval($_POST['distance_hours']);
|
||||
$morningsParticipantsNumber = intval($_POST['mornings_participants_number']);
|
||||
$morningsAccessNumber = intval($_POST['mornings_access_number']);
|
||||
$morningTotalDuration = intval($_POST['morning_total_duration']);
|
||||
$afternoonParticipantsNumber = intval($_POST['afternoon_participants_number']);
|
||||
$afternoonAccessNumber = intval($_POST['afternoon_access_number']);
|
||||
$afternoonTotalDuration = intval($_POST['afternoon_total_duration']);
|
||||
$nightParticipantsNumber = intval($_POST['night_participants_number']);
|
||||
$nightAccessNumber = intval($_POST['night_access_number']);
|
||||
$nightTotalDuration = intval($_POST['night_total_duration']);
|
||||
$attendeesCount = intval($_POST['attendees_count']);
|
||||
$learningActivityCount = intval($_POST['learning_activity_count']);
|
||||
$attemptCount = intval($_POST['attempt_count']);
|
||||
$evaluationActivityCount = intval($_POST['evaluation_activity_count']);
|
||||
$actionId = intval($_POST['action_id']);
|
||||
$specialtyId = intval($_POST['specialty_id']);
|
||||
$newSpecialty = intval($_POST['new_specialty']);
|
||||
|
||||
$startDate = $yearStart."-".$monthStart."-".$dayStart;
|
||||
$endDate = $yearEnd."-".$monthEnd."-".$dayEnd;
|
||||
|
||||
if (isset($newSpecialty) && $newSpecialty != 1) {
|
||||
$sql = "UPDATE plugin_sepe_specialty SET
|
||||
specialty_origin='".$specialtyOrigin."',
|
||||
professional_area='".$professionalArea."',
|
||||
specialty_code='".$specialtyCode."',
|
||||
center_origin='".$centerOrigin."',
|
||||
center_code='".$centerCode."',
|
||||
start_date='".$startDate."',
|
||||
end_date='".$endDate."',
|
||||
modality_impartition='".$modalityImpartition."',
|
||||
classroom_hours = $classroomHours,
|
||||
distance_hours = $distanceHours,
|
||||
mornings_participants_number = $morningsParticipantsNumber,
|
||||
mornings_access_number = $morningsAccessNumber,
|
||||
morning_total_duration = $morningTotalDuration,
|
||||
afternoon_participants_number = $afternoonParticipantsNumber,
|
||||
afternoon_access_number = $afternoonAccessNumber,
|
||||
afternoon_total_duration = $afternoonTotalDuration,
|
||||
night_participants_number = $nightParticipantsNumber,
|
||||
night_access_number = $nightAccessNumber,
|
||||
night_total_duration = $nightTotalDuration,
|
||||
attendees_count = $attendeesCount,
|
||||
learning_activity_count = $learningActivityCount,
|
||||
attempt_count = $attemptCount,
|
||||
evaluation_activity_count = $evaluationActivityCount
|
||||
WHERE id = $specialtyId;";
|
||||
} else {
|
||||
$sql = "INSERT INTO plugin_sepe_specialty (
|
||||
action_id,
|
||||
specialty_origin,
|
||||
professional_area,
|
||||
specialty_code,
|
||||
center_origin,
|
||||
center_code,
|
||||
start_date,
|
||||
end_date,
|
||||
modality_impartition,
|
||||
classroom_hours,
|
||||
distance_hours,
|
||||
mornings_participants_number,
|
||||
mornings_access_number,
|
||||
morning_total_duration,
|
||||
afternoon_participants_number,
|
||||
afternoon_access_number,
|
||||
afternoon_total_duration,
|
||||
night_participants_number,
|
||||
night_access_number,
|
||||
night_total_duration,
|
||||
attendees_count,
|
||||
learning_activity_count,
|
||||
attempt_count,
|
||||
evaluation_activity_count
|
||||
) VALUES (
|
||||
$actionId,
|
||||
'".$specialtyOrigin."',
|
||||
'".$professionalArea."',
|
||||
'".$specialtyCode."',
|
||||
'".$centerOrigin."',
|
||||
'".$centerCode."',
|
||||
'".$startDate."',
|
||||
'".$endDate."',
|
||||
'".$modalityImpartition."',
|
||||
$classroomHours,
|
||||
$distanceHours,
|
||||
$morningsParticipantsNumber,
|
||||
$morningsAccessNumber,
|
||||
$morningTotalDuration,
|
||||
$afternoonParticipantsNumber,
|
||||
$afternoonAccessNumber,
|
||||
$afternoonTotalDuration,
|
||||
$nightParticipantsNumber,
|
||||
$nightAccessNumber,
|
||||
$nightTotalDuration,
|
||||
$attendeesCount,
|
||||
$learningActivityCount,
|
||||
$attemptCount,
|
||||
$evaluationActivityCount
|
||||
);";
|
||||
}
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange');
|
||||
} else {
|
||||
if ($newSpecialty == 1) {
|
||||
$specialtyId = Database::insert_id();
|
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange');
|
||||
}
|
||||
}
|
||||
session_write_close();
|
||||
header("Location: specialty-action-edit.php?new_specialty=0&specialty_id=".$specialtyId."&action_id=".$actionId);
|
||||
} else {
|
||||
$actionId = intval($_POST['action_id']);
|
||||
$specialtyId = intval($_POST['specialty_id']);
|
||||
$newSpecialty = intval($_POST['new_specialty']);
|
||||
Security::clear_token();
|
||||
$token = Security::get_token();
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken');
|
||||
session_write_close();
|
||||
header("Location: specialty-action-edit.php?new_specialty=".$newSpecialty."&specialty_id=".$specialtyId."&action_id=".$actionId);
|
||||
}
|
||||
} else {
|
||||
$token = Security::get_token();
|
||||
}
|
||||
|
||||
if (api_is_platform_admin()) {
|
||||
$id_course = getCourse(intval($_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=".$id_course,
|
||||
"name" => $plugin->get_lang('FormativeAction'),
|
||||
];
|
||||
if (isset($_GET['new_specialty']) && intval($_GET['new_specialty']) == 1) {
|
||||
$templateName = $plugin->get_lang('NewSpecialtyAccion');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('action_id', intval($_GET['action_id']));
|
||||
$info = [];
|
||||
$tpl->assign('info', $info);
|
||||
$tpl->assign('new_action', '1');
|
||||
$yearStart = $yearEnd = date("Y");
|
||||
} else {
|
||||
$templateName = $plugin->get_lang('EditSpecialtyAccion');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('action_id', intval($_GET['action_id']));
|
||||
$info = getSpecialtActionInfo(intval($_GET['specialty_id']));
|
||||
$tpl->assign('info', $info);
|
||||
if ($info['start_date'] != '0000-00-00' && $info['start_date'] != null) {
|
||||
$tpl->assign('day_start', date("j", strtotime($info['start_date'])));
|
||||
$tpl->assign('month_start', date("n", strtotime($info['start_date'])));
|
||||
$tpl->assign('year_start', date("Y", strtotime($info['start_date'])));
|
||||
$yearStart = date("Y", strtotime($info['start_date']));
|
||||
} elseif (strpos($info['start_date'], '0000') === false) {
|
||||
$yearStart = date("Y", strtotime($info['start_date']));
|
||||
} else {
|
||||
$yearStart = date("Y");
|
||||
}
|
||||
if ($info['end_date'] != '0000-00-00' && $info['end_date'] != null) {
|
||||
$tpl->assign('day_end', date("j", strtotime($info['end_date'])));
|
||||
$tpl->assign('month_end', date("n", strtotime($info['end_date'])));
|
||||
$tpl->assign('year_end', date("Y", strtotime($info['end_date'])));
|
||||
$yearEnd = date("Y", strtotime($info['end_date']));
|
||||
} elseif (strpos($info['end_date'], '0000') === false) {
|
||||
$yearEnd = date("Y", strtotime($info['end_date']));
|
||||
} else {
|
||||
$yearEnd = date("Y");
|
||||
}
|
||||
$tpl->assign('new_action', '0');
|
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id']));
|
||||
|
||||
$listClassroom = classroomList(intval($_GET['specialty_id']));
|
||||
$tpl->assign('listClassroom', $listClassroom);
|
||||
$listTutors = tutorsList(intval($_GET['specialty_id']));
|
||||
$tpl->assign('listTutors', $listTutors);
|
||||
}
|
||||
|
||||
$yearList = [];
|
||||
if ($yearStart > $yearEnd) {
|
||||
$tmp = $yearStart;
|
||||
$yearStart = $yearEnd;
|
||||
$yearEnd = $tmp;
|
||||
}
|
||||
$yearStart -= 5;
|
||||
$yearEnd += 5;
|
||||
$fin_rango_anio = (($yearStart + 15) < $yearEnd) ? ($yearEnd + 1) : ($yearStart + 15);
|
||||
while ($yearStart <= $fin_rango_anio) {
|
||||
$yearList[] = $yearStart;
|
||||
$yearStart++;
|
||||
}
|
||||
$tpl->assign('list_year', $yearList);
|
||||
if (isset($_SESSION['sepe_message_info'])) {
|
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']);
|
||||
unset($_SESSION['sepe_message_info']);
|
||||
}
|
||||
if (isset($_SESSION['sepe_message_error'])) {
|
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']);
|
||||
unset($_SESSION['sepe_message_error']);
|
||||
}
|
||||
$tpl->assign('sec_token', $token);
|
||||
$listing_tpl = 'sepe/view/specialty-action-edit.tpl';
|
||||
$content = $tpl->fetch($listing_tpl);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
} else {
|
||||
header('Location:'.api_get_path(WEB_PATH));
|
||||
exit;
|
||||
}
|
||||
131
plugin/sepe/src/specialty-classroom-edit.php
Normal file
131
plugin/sepe/src/specialty-classroom-edit.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* This script displays a specialty classroom edit form.
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$course_plugin = 'sepe';
|
||||
$plugin = SepePlugin::create();
|
||||
$_cid = 0;
|
||||
|
||||
if (!empty($_POST)) {
|
||||
$check = Security::check_token('post');
|
||||
if ($check) {
|
||||
$sltCentersExists = intval($_POST['slt_centers_exists']);
|
||||
$specialtyId = intval($_POST['specialty_id']);
|
||||
$existsCenterId = intval($_POST['exists_center_id']);
|
||||
$centerOrigin = Database::escape_string(trim($_POST['center_origin']));
|
||||
$centerCode = Database::escape_string(trim($_POST['center_code']));
|
||||
$newClassroom = intval($_POST['new_classroom']);
|
||||
$actionId = intval($_POST['action_id']);
|
||||
$classroomId = intval($_POST['classroom_id']);
|
||||
|
||||
if ($sltCentersExists == 1) {
|
||||
$sql = "INSERT INTO $tableSepeSpecialtyClassroom (specialty_id, center_id)
|
||||
VALUES ($specialtyId, $existsCenterId);";
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange');
|
||||
} else {
|
||||
if ($newClassroom == 1) {
|
||||
$classroomId = Database::insert_id();
|
||||
}
|
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange');
|
||||
}
|
||||
} else {
|
||||
//Checker exists centers
|
||||
$sql = "SELECT * FROM $tableCenters
|
||||
WHERE center_origin='".$centerOrigin."' AND center_code='".$centerCode."'";
|
||||
$rs_tmp = Database::query($sql);
|
||||
if (Database::num_rows($rs_tmp) > 0) {
|
||||
$aux = Database::fetch_assoc($rs_tmp);
|
||||
$centerId = $aux['id'];
|
||||
} else {
|
||||
$params = [
|
||||
'center_origin' => $centerOrigin,
|
||||
'center_code' => $centerCode,
|
||||
];
|
||||
$centerId = Database::insert($tableCenters, $params);
|
||||
}
|
||||
|
||||
if (isset($newClassroom) && $newClassroom != 1) {
|
||||
$sql = "UPDATE $tableSepeSpecialtyClassroom SET center_id = $centerId WHERE id = $classroomId;";
|
||||
} else {
|
||||
$sql = "INSERT INTO $tableSepeSpecialtyClassroom (specialty_id, center_id) VALUES ($specialtyId, $centerId);";
|
||||
}
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange');
|
||||
} else {
|
||||
if ($newClassroom == 1) {
|
||||
$classroomId = Database::insert_id();
|
||||
}
|
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange');
|
||||
}
|
||||
}
|
||||
session_write_close();
|
||||
header("Location: specialty-action-edit.php?new_specialty=0&specialty_id=".$specialtyId."&action_id=".$actionId);
|
||||
exit;
|
||||
} else {
|
||||
$newClassroom = intval($_POST['new_classroom']);
|
||||
$actionId = intval($_POST['action_id']);
|
||||
$classroomId = intval($_POST['classroom_id']);
|
||||
$specialtyId = intval($_POST['specialty_id']);
|
||||
Security::clear_token();
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken');
|
||||
$token = Security::get_token();
|
||||
session_write_close();
|
||||
header("Location:specialty-classroom-edit.php?new_classroom=".$newClassroom."&specialty_id=".$specialtyId."&classroom_id=".$classroomId."&action_id=".$actionId);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$token = Security::get_token();
|
||||
}
|
||||
|
||||
if (api_is_platform_admin()) {
|
||||
$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')];
|
||||
$interbreadcrumb[] = ["url" => "specialty-action-edit.php?new_specialty=0&specialty_id=".intval($_GET['specialty_id'])."&action_id=".intval($_GET['action_id']), "name" => $plugin->get_lang('SpecialtyFormativeAction')];
|
||||
if (isset($_GET['new_classroom']) && intval($_GET['new_classroom']) == 1) {
|
||||
$templateName = $plugin->get_lang('NewSpecialtyClassroom');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('action_id', intval($_GET['action_id']));
|
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id']));
|
||||
$info = [];
|
||||
$tpl->assign('info', $info);
|
||||
$tpl->assign('new_classroom', '1');
|
||||
} else {
|
||||
$templateName = $plugin->get_lang('EditSpecialtyClassroom');
|
||||
$tpl = new Template($templateName);
|
||||
$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($_GET['classroom_id']);
|
||||
$tpl->assign('info', $info);
|
||||
$tpl->assign('new_classroom', '0');
|
||||
}
|
||||
$centerList = getCentersList();
|
||||
$tpl->assign('listExistsCenters', $centerList);
|
||||
|
||||
if (isset($_SESSION['sepe_message_info'])) {
|
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']);
|
||||
unset($_SESSION['sepe_message_info']);
|
||||
}
|
||||
if (isset($_SESSION['sepe_message_error'])) {
|
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']);
|
||||
unset($_SESSION['sepe_message_error']);
|
||||
}
|
||||
$tpl->assign('sec_token', $token);
|
||||
|
||||
$listing_tpl = 'sepe/view/specialty-classroom-edit.tpl';
|
||||
$content = $tpl->fetch($listing_tpl);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
} else {
|
||||
header('Location:'.api_get_path(WEB_PATH));
|
||||
exit;
|
||||
}
|
||||
232
plugin/sepe/src/specialty-tutor-edit.php
Normal file
232
plugin/sepe/src/specialty-tutor-edit.php
Normal file
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* This script displays a specialty tutors edit form.
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$course_plugin = 'sepe';
|
||||
$plugin = SepePlugin::create();
|
||||
$_cid = 0;
|
||||
|
||||
if (!empty($_POST)) {
|
||||
$check = Security::check_token('post');
|
||||
if ($check) {
|
||||
$sltUserExists = intval($_POST['slt_user_exists']);
|
||||
$existingTutor = intval($_POST['existingTutor']);
|
||||
$specialtyId = intval($_POST['specialty_id']);
|
||||
$tutorAccreditation = Database::escape_string(trim($_POST['tutor_accreditation']));
|
||||
$professionalExperience = intval($_POST['professional_experience']);
|
||||
$teachingCompetence = Database::escape_string(trim($_POST['teaching_competence']));
|
||||
$experienceTeleforming = intval($_POST['experience_teleforming']);
|
||||
$trainingTeleforming = Database::escape_string(trim($_POST['training_teleforming']));
|
||||
$specialtyTutorId = intval($_POST['specialtyTutorId']);
|
||||
$documentType = Database::escape_string(trim($_POST['document_type']));
|
||||
$documentNumber = Database::escape_string(trim($_POST['document_number']));
|
||||
$documentLetter = Database::escape_string(trim($_POST['document_letter']));
|
||||
$actionId = intval($_POST['action_id']);
|
||||
$newTutor = intval($_POST['new_tutor']);
|
||||
$platformUserId = intval($_POST['platform_user_id']);
|
||||
|
||||
if ($sltUserExists == 1) {
|
||||
$sql = "SELECT * FROM $tableSepeTutors WHERE id = $existingTutor;";
|
||||
$rs = Database::query($sql);
|
||||
$tmp = Database::fetch_assoc($rs);
|
||||
|
||||
$sql = "INSERT INTO $tableSepeSpecialtyTutors (
|
||||
specialty_id,
|
||||
tutor_id,
|
||||
tutor_accreditation,
|
||||
professional_experience,
|
||||
teaching_competence,
|
||||
experience_teleforming ,
|
||||
training_teleforming
|
||||
) VALUES (
|
||||
$specialtyId,
|
||||
$existingTutor,
|
||||
'".$tmp['tutor_accreditation']."',
|
||||
'".$tmp['professional_experience']."',
|
||||
'".$tmp['teaching_competence']."',
|
||||
'".$tmp['experience_teleforming ']."',
|
||||
'".$tmp['training_teleforming']."'
|
||||
);";
|
||||
$res = Database::query($sql);
|
||||
} else {
|
||||
$sql = "SELECT id
|
||||
FROM $tableSepeTutors
|
||||
WHERE
|
||||
document_type = '".$documentType."'
|
||||
AND document_number = '".$documentNumber."'
|
||||
AND document_letter = '".$documentLetter."';";
|
||||
$rs = Database::query($sql);
|
||||
if (Database::num_rows($rs) > 0) {
|
||||
$aux = Database::fetch_assoc($rs);
|
||||
$sql = "UPDATE $tableSepeTutors SET
|
||||
platform_user_id = $platformUserId,
|
||||
tutor_accreditation = '".$tutorAccreditation."',
|
||||
professional_experience = $professionalExperience,
|
||||
teaching_competence = '".$teachingCompetence."',
|
||||
experience_teleforming = $experienceTeleforming,
|
||||
training_teleforming = '".$trainingTeleforming."'
|
||||
WHERE id = '".$aux['id']."';";
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange');
|
||||
}
|
||||
$newTutor = 0; //Reset variable, no create new tutor, exists tutor
|
||||
$tutorId = $aux['id'];
|
||||
$specialtyTutorId = getSpecialtyTutorId($specialtyId, $tutorId);
|
||||
} else {
|
||||
$sql = "UPDATE $tableSepeTutors
|
||||
SET platform_user_id=''
|
||||
WHERE platform_user_id='".$platformUserId."'";
|
||||
Database::query($sql);
|
||||
$sql = "INSERT INTO $tableSepeTutors (
|
||||
platform_user_id,
|
||||
document_type,
|
||||
document_number,
|
||||
document_letter,
|
||||
tutor_accreditation,
|
||||
professional_experience,
|
||||
teaching_competence,
|
||||
experience_teleforming,
|
||||
training_teleforming
|
||||
) VALUES (
|
||||
$platformUserId,
|
||||
'".$documentType."',
|
||||
'".$documentNumber."',
|
||||
'".$documentLetter."',
|
||||
'".$tutorAccreditation."',
|
||||
$professionalExperience,
|
||||
'".$teachingCompetence."',
|
||||
$experienceTeleforming,
|
||||
'".$trainingTeleforming."'
|
||||
);";
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange');
|
||||
} else {
|
||||
$tutorId = Database::insert_id();
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($newTutor) && $newTutor != 1) {
|
||||
$sql = "UPDATE $tableSepeSpecialtyTutors SET
|
||||
tutor_id = $tutorId,
|
||||
tutor_accreditation = '".$tutorAccreditation."',
|
||||
professional_experience = $professionalExperience,
|
||||
teaching_competence = '".$teachingCompetence."',
|
||||
experience_teleforming = $experienceTeleforming,
|
||||
training_teleforming='".$trainingTeleforming."'
|
||||
WHERE id = $specialtyTutorId;";
|
||||
} else {
|
||||
$sql = "INSERT INTO $tableSepeSpecialtyTutors (
|
||||
specialty_id,
|
||||
tutor_id,
|
||||
tutor_accreditation,
|
||||
professional_experience,
|
||||
teaching_competence,
|
||||
experience_teleforming,
|
||||
training_teleforming
|
||||
) VALUES (
|
||||
$specialtyId,
|
||||
$tutorId,
|
||||
'".$tutorAccreditation."',
|
||||
$professionalExperience,
|
||||
'".$teachingCompetence."',
|
||||
$experienceTeleforming,
|
||||
'".$trainingTeleforming."'
|
||||
);";
|
||||
}
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange');
|
||||
} else {
|
||||
if ($newTutor == 1) {
|
||||
$tutorId = Database::insert_id();
|
||||
}
|
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange');
|
||||
}
|
||||
}
|
||||
session_write_close();
|
||||
header("Location: specialty-action-edit.php?new_specialty=0&specialty_id=".$specialtyId."&action_id=".$actionId);
|
||||
exit;
|
||||
} else {
|
||||
$actionId = intval($_POST['action_id']);
|
||||
$newTutor = intval($_POST['new_tutor']);
|
||||
$specialtyId = intval($_POST['specialty_id']);
|
||||
$specialtyTutorId = intval($_POST['specialtyTutorId']);
|
||||
Security::clear_token();
|
||||
$token = Security::get_token();
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken');
|
||||
session_write_close();
|
||||
header("Location: specialty-tutor-edit.php?new_tutor=".$newTutor."&specialty_id=".$specialtyId."&tutor_id=".$specialtyTutorId."&action_id=".$actionId);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$token = Security::get_token();
|
||||
}
|
||||
|
||||
if (api_is_platform_admin()) {
|
||||
$actionId = (int) $_GET['action_id'];
|
||||
$specialtyId = (int) $_GET['specialty_id'];
|
||||
|
||||
$courseId = getCourse($actionId);
|
||||
$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'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
"url" => "specialty-action-edit.php?new_specialty=0&specialty_id=".$specialtyId."&action_id=".$actionId,
|
||||
"name" => $plugin->get_lang('SpecialtyFormativeAction'),
|
||||
];
|
||||
if (isset($_GET['new_tutor']) && intval($_GET['new_tutor']) == 1) {
|
||||
$templateName = $plugin->get_lang('NewSpecialtyTutor');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('action_id', $actionId);
|
||||
$tpl->assign('specialty_id', $specialtyId);
|
||||
$info = [];
|
||||
$tpl->assign('info', $info);
|
||||
$tpl->assign('new_tutor', '1');
|
||||
$platformUserId = '';
|
||||
} else {
|
||||
$templateName = $plugin->get_lang('EditSpecialtyTutor');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('action_id', $actionId);
|
||||
$tpl->assign('specialty_id', $specialtyId);
|
||||
$tpl->assign('tutor_id', 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($_GET['specialty_id']);
|
||||
$tpl->assign('ExistingTutorsList', $tutorsList);
|
||||
|
||||
$listTeachers = CourseManager::getTeachersFromCourse($courseId);
|
||||
$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']);
|
||||
unset($_SESSION['sepe_message_info']);
|
||||
}
|
||||
if (isset($_SESSION['sepe_message_error'])) {
|
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']);
|
||||
unset($_SESSION['sepe_message_error']);
|
||||
}
|
||||
$tpl->assign('sec_token', $token);
|
||||
|
||||
$listing_tpl = 'sepe/view/specialty-tutor-edit.tpl';
|
||||
$content = $tpl->fetch($listing_tpl);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
} else {
|
||||
header('Location:'.api_get_path(WEB_PATH));
|
||||
exit;
|
||||
}
|
||||
158
plugin/sepe/src/specialty-tutorial-edit.php
Normal file
158
plugin/sepe/src/specialty-tutorial-edit.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* This script displays a specialty tutorial edit form.
|
||||
*/
|
||||
require_once '../config.php';
|
||||
|
||||
$course_plugin = 'sepe';
|
||||
$plugin = SepePlugin::create();
|
||||
$_cid = 0;
|
||||
|
||||
if (!empty($_POST)) {
|
||||
$check = Security::check_token('post');
|
||||
if ($check) {
|
||||
$centerOrigin = Database::escape_string(trim($_POST['center_origin']));
|
||||
$centerCode = Database::escape_string(trim($_POST['center_code']));
|
||||
$dayStart = Database::escape_string(trim($_POST['day_start']));
|
||||
$monthStart = Database::escape_string(trim($_POST['month_start']));
|
||||
$yearStart = Database::escape_string(trim($_POST['year_start']));
|
||||
$dayEnd = Database::escape_string(trim($_POST['day_end']));
|
||||
$monthEnd = Database::escape_string(trim($_POST['month_end']));
|
||||
$yearEnd = Database::escape_string(trim($_POST['year_end']));
|
||||
$tutorialId = intval($_POST['tutorial_id']);
|
||||
$actionId = intval($_POST['action_id']);
|
||||
$specialtyId = intval($_POST['specialty_id']);
|
||||
$newTutorial = intval($_POST['new_tutorial']);
|
||||
$starDate = $yearStart."-".$monthStart."-".$dayStart;
|
||||
$endDate = $yearEnd."-".$monthEnd."-".$dayEnd;
|
||||
|
||||
if (isset($newTutorial) && $newTutorial != 1) {
|
||||
$sql = "UPDATE $tableSepeParticipantsSpecialtyTutorials SET
|
||||
center_origin='".$centerOrigin."',
|
||||
center_code='".$centerCode."',
|
||||
start_date='".$starDate."',
|
||||
end_date='".$endDate."'
|
||||
WHERE id = $tutorialId;";
|
||||
} else {
|
||||
$sql = "INSERT INTO $tableSepeParticipantsSpecialtyTutorials (
|
||||
participant_specialty_id,
|
||||
center_origin,
|
||||
center_code,
|
||||
start_date,
|
||||
end_date
|
||||
) VALUES (
|
||||
$specialtyId,
|
||||
'".$centerOrigin."',
|
||||
'".$centerCode."',
|
||||
'".$starDate."',
|
||||
'".$endDate."'
|
||||
);";
|
||||
}
|
||||
$res = Database::query($sql);
|
||||
if (!$res) {
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange');
|
||||
} else {
|
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange');
|
||||
}
|
||||
|
||||
session_write_close();
|
||||
$participantId = getParticipantId($specialtyId);
|
||||
header("Location: participant-specialty-edit.php?new_specialty=0&participant_id=".$participantId."&specialty_id=".$specialtyId."&action_id=".$actionId);
|
||||
exit;
|
||||
} else {
|
||||
$tutorialId = intval($_POST['tutorial_id']);
|
||||
$actionId = intval($_POST['action_id']);
|
||||
$specialtyId = intval($_POST['specialty_id']);
|
||||
$newTutorial = intval($_POST['new_tutorial']);
|
||||
Security::clear_token();
|
||||
$token = Security::get_token();
|
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken');
|
||||
session_write_close();
|
||||
header("Location: specialty-tutorial-edit.php?new_tutorial=".$newTutorial."&specialty_id=".$specialtyId."&tutorial_id=".$tutorialId."&action_id=".$actionId);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$token = Security::get_token();
|
||||
}
|
||||
|
||||
if (api_is_platform_admin()) {
|
||||
$courseId = getCourse(intval($_GET['action_id']));
|
||||
$participantId = getParticipantId(intval($_GET['specialty_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')];
|
||||
$interbreadcrumb[] = ["url" => "participant-specialty-edit.php?new_specialty=0&participant_id=".$participantId."&specialty_id=".intval($_GET['specialty_id'])."&action_id=".intval($_GET['action_id']), "name" => $plugin->get_lang('SpecialtyFormativeParcipant')];
|
||||
if (isset($_GET['new_tutorial']) && intval($_GET['new_tutorial']) == 1) {
|
||||
$templateName = $plugin->get_lang('new_tutorial');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('action_id', intval($_GET['action_id']));
|
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id']));
|
||||
$info = [];
|
||||
$tpl->assign('info', $info);
|
||||
$tpl->assign('new_tutorial', '1');
|
||||
$startYear = $endYear = date("Y");
|
||||
} else {
|
||||
$templateName = $plugin->get_lang('edit_tutorial');
|
||||
$tpl = new Template($templateName);
|
||||
$tpl->assign('action_id', intval($_GET['action_id']));
|
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id']));
|
||||
$tpl->assign('tutorial_id', intval($_GET['tutorial_id']));
|
||||
$info = getInfoSpecialtyTutorial(intval($_GET['tutorial_id']));
|
||||
$tpl->assign('info', $info);
|
||||
$tpl->assign('new_tutorial', '0');
|
||||
if ($info['start_date'] != '0000-00-00' && $info['start_date'] != null) {
|
||||
$tpl->assign('day_start', date("j", strtotime($info['start_date'])));
|
||||
$tpl->assign('month_start', date("n", strtotime($info['start_date'])));
|
||||
$tpl->assign('year_start', date("Y", strtotime($info['start_date'])));
|
||||
$startYear = date("Y", strtotime($info['start_date']));
|
||||
} elseif (strpos($info['end_date'], '0000') === false) {
|
||||
$startYear = date("Y", strtotime($info['start_date']));
|
||||
} else {
|
||||
$startYear = date("Y");
|
||||
}
|
||||
if ($info['end_date'] != '0000-00-00' && $info['end_date'] != null) {
|
||||
$tpl->assign('day_end', date("j", strtotime($info['end_date'])));
|
||||
$tpl->assign('month_end', date("n", strtotime($info['end_date'])));
|
||||
$tpl->assign('year_end', date("Y", strtotime($info['end_date'])));
|
||||
$endYear = date("Y", strtotime($info['end_date']));
|
||||
} elseif (strpos($info['end_date'], '0000') === false) {
|
||||
$endYear = date("Y", strtotime($info['end_date']));
|
||||
} else {
|
||||
$endYear = date("Y");
|
||||
}
|
||||
}
|
||||
$listYears = [];
|
||||
if ($startYear > $endYear) {
|
||||
$tmp = $startYear;
|
||||
$startYear = $endYear;
|
||||
$endYear = $tmp;
|
||||
}
|
||||
$startYear -= 5;
|
||||
$endYear += 5;
|
||||
$endRangeYear = (($startYear + 15) < $endYear) ? ($endYear + 1) : ($startYear + 15);
|
||||
while ($startYear <= $endRangeYear) {
|
||||
$listYears[] = $startYear;
|
||||
$startYear++;
|
||||
}
|
||||
$tpl->assign('list_year', $listYears);
|
||||
|
||||
if (isset($_SESSION['sepe_message_info'])) {
|
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']);
|
||||
unset($_SESSION['sepe_message_info']);
|
||||
}
|
||||
if (isset($_SESSION['sepe_message_error'])) {
|
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']);
|
||||
unset($_SESSION['sepe_message_error']);
|
||||
}
|
||||
$tpl->assign('sec_token', $token);
|
||||
|
||||
$listing_tpl = 'sepe/view/specialty-tutorial-edit.tpl';
|
||||
$content = $tpl->fetch($listing_tpl);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
} else {
|
||||
header('Location:'.api_get_path(WEB_PATH));
|
||||
exit;
|
||||
}
|
||||
204
plugin/sepe/src/wsse/soap-server-wsse.php
Normal file
204
plugin/sepe/src/wsse/soap-server-wsse.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
/**
|
||||
* soap-server-wsse.php
|
||||
*
|
||||
* Copyright (c) 2007, Robert Richards <rrichards@ctindustries.net>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Robert Richards nor the names of his
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @author Robert Richards <rrichards@ctindustries.net>
|
||||
* @copyright 2007 Robert Richards <rrichards@ctindustries.net>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
use RobRichards\XMLSecLibs\XMLSecurityDSig;
|
||||
use RobRichards\XMLSecLibs\XMLSecurityKey;
|
||||
|
||||
/**
|
||||
* Class WSSESoapServer
|
||||
*/
|
||||
class WSSESoapServer
|
||||
{
|
||||
const WSSENS = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
|
||||
const WSSENS_2003 = 'http://schemas.xmlsoap.org/ws/2003/06/secext';
|
||||
const WSUNS = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd';
|
||||
const WSSEPFX = 'wsse';
|
||||
const WSUPFX = 'wsu';
|
||||
private $soapNS, $soapPFX;
|
||||
private $soapDoc = null;
|
||||
private $envelope = null;
|
||||
private $SOAPXPath = null;
|
||||
private $secNode = null;
|
||||
public $signAllHeaders = false;
|
||||
|
||||
private function locateSecurityHeader($setActor = null)
|
||||
{
|
||||
$wsNamespace = null;
|
||||
if ($this->secNode == null) {
|
||||
$secnode = null;
|
||||
$headers = $this->SOAPXPath->query('//wssoap:Envelope/wssoap:Header');
|
||||
if ($header = $headers->item(0)) {
|
||||
$secnodes = $this->SOAPXPath->query('./*[local-name()="Security"]', $header);
|
||||
|
||||
foreach ($secnodes as $node) {
|
||||
$nsURI = $node->namespaceURI;
|
||||
if (($nsURI == self::WSSENS) || ($nsURI == self::WSSENS_2003)) {
|
||||
$actor = $node->getAttributeNS($this->soapNS, 'actor');
|
||||
if (empty($actor) || ($actor == $setActor)) {
|
||||
$secnode = $node;
|
||||
$wsNamespace = $nsURI;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->secNode = $secnode;
|
||||
}
|
||||
|
||||
return $wsNamespace;
|
||||
}
|
||||
|
||||
public function __construct($doc)
|
||||
{
|
||||
$this->soapDoc = $doc;
|
||||
$this->envelope = $doc->documentElement;
|
||||
|
||||
$this->soapNS = $this->envelope->namespaceURI;
|
||||
$this->soapPFX = $this->envelope->prefix;
|
||||
|
||||
$this->SOAPXPath = new DOMXPath($doc);
|
||||
$this->SOAPXPath->registerNamespace('wssoap', $this->soapNS);
|
||||
$this->SOAPXPath->registerNamespace('wswsu', self::WSUNS);
|
||||
$wsNamespace = $this->locateSecurityHeader();
|
||||
if (!empty($wsNamespace)) {
|
||||
$this->SOAPXPath->registerNamespace('wswsse', $wsNamespace);
|
||||
}
|
||||
}
|
||||
|
||||
public function processSignature($refNode)
|
||||
{
|
||||
$objXMLSecDSig = new XMLSecurityDSig();
|
||||
$objXMLSecDSig->idKeys[] = 'wswsu:Id';
|
||||
$objXMLSecDSig->idNS['wswsu'] = self::WSUNS;
|
||||
$objXMLSecDSig->sigNode = $refNode;
|
||||
|
||||
/* Canonicalize the signed info */
|
||||
$objXMLSecDSig->canonicalizeSignedInfo();
|
||||
$retVal = $objXMLSecDSig->validateReference();
|
||||
|
||||
if (!$retVal) {
|
||||
throw new Exception("Validation Failed");
|
||||
}
|
||||
|
||||
$key = null;
|
||||
$objKey = $objXMLSecDSig->locateKey();
|
||||
|
||||
if ($objKey) {
|
||||
if ($objKeyInfo = XMLSecEnc::staticLocateKeyInfo($objKey, $refNode)) {
|
||||
/* Handle any additional key processing such as encrypted keys here */
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($objKey)) {
|
||||
throw new Exception("Error loading key to handle Signature");
|
||||
}
|
||||
do {
|
||||
if (empty($objKey->key)) {
|
||||
$this->SOAPXPath->registerNamespace('xmlsecdsig', XMLSecurityDSig::XMLDSIGNS);
|
||||
$query = "./xmlsecdsig:KeyInfo/wswsse:SecurityTokenReference/wswsse:Reference";
|
||||
$nodeset = $this->SOAPXPath->query($query, $refNode);
|
||||
if ($encmeth = $nodeset->item(0)) {
|
||||
if ($uri = $encmeth->getAttribute("URI")) {
|
||||
$arUrl = parse_url($uri);
|
||||
|
||||
if (empty($arUrl['path']) && ($identifier = $arUrl['fragment'])) {
|
||||
$query = '//wswsse:BinarySecurityToken[@wswsu:Id="'.$identifier.'"]';
|
||||
$nodeset = $this->SOAPXPath->query($query);
|
||||
if ($encmeth = $nodeset->item(0)) {
|
||||
$x509cert = $encmeth->textContent;
|
||||
$x509cert = str_replace(array("\r", "\n"), "", $x509cert);
|
||||
$x509cert = "-----BEGIN CERTIFICATE-----\n".chunk_split($x509cert, 64, "\n")."-----END CERTIFICATE-----\n";
|
||||
|
||||
$objKey->loadKey($x509cert);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Exception("Error loading key to handle Signature");
|
||||
}
|
||||
} while(0);
|
||||
|
||||
if (! $objXMLSecDSig->verify($objKey)) {
|
||||
throw new Exception("Unable to validate Signature");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
if (empty($this->secNode)) {
|
||||
return;
|
||||
}
|
||||
$node = $this->secNode->firstChild;
|
||||
while ($node) {
|
||||
$nextNode = $node->nextSibling;
|
||||
switch ($node->localName) {
|
||||
case "Signature":
|
||||
if ($this->processSignature($node)) {
|
||||
if ($node->parentNode) {
|
||||
$node->parentNode->removeChild($node);
|
||||
}
|
||||
} else {
|
||||
/* throw fault */
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$node = $nextNode;
|
||||
}
|
||||
$this->secNode->parentNode->removeChild($this->secNode);
|
||||
$this->secNode = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function saveXML()
|
||||
{
|
||||
return $this->soapDoc->saveXML();
|
||||
}
|
||||
|
||||
public function save($file)
|
||||
{
|
||||
return $this->soapDoc->save($file);
|
||||
}
|
||||
}
|
||||
168
plugin/sepe/src/wsse/soap-wsa.php
Normal file
168
plugin/sepe/src/wsse/soap-wsa.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/**
|
||||
* soap-wsa.php
|
||||
*
|
||||
* Copyright (c) 2007, Robert Richards <rrichards@ctindustries.net>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Robert Richards nor the names of his
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @author Robert Richards <rrichards@ctindustries.net>
|
||||
* @copyright 2007 Robert Richards <rrichards@ctindustries.net>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class WSASoap
|
||||
*/
|
||||
class WSASoap
|
||||
{
|
||||
const WSANS = 'http://schemas.xmlsoap.org/ws/2004/08/addressing';
|
||||
const WSAPFX = 'wsa';
|
||||
private $soapNS, $soapPFX;
|
||||
private $soapDoc = null;
|
||||
private $envelope = null;
|
||||
private $SOAPXPath = null;
|
||||
private $header = null;
|
||||
private $messageID = null;
|
||||
|
||||
private function locateHeader()
|
||||
{
|
||||
if ($this->header == null) {
|
||||
$headers = $this->SOAPXPath->query('//wssoap:Envelope/wssoap:Header');
|
||||
$header = $headers->item(0);
|
||||
if (!$header) {
|
||||
$header = $this->soapDoc->createElementNS($this->soapNS, $this->soapPFX.':Header');
|
||||
$this->envelope->insertBefore($header, $this->envelope->firstChild);
|
||||
}
|
||||
$this->header = $header;
|
||||
}
|
||||
|
||||
return $this->header;
|
||||
}
|
||||
|
||||
public function __construct($doc)
|
||||
{
|
||||
$this->soapDoc = $doc;
|
||||
$this->envelope = $doc->documentElement;
|
||||
$this->soapNS = $this->envelope->namespaceURI;
|
||||
$this->soapPFX = $this->envelope->prefix;
|
||||
$this->SOAPXPath = new DOMXPath($doc);
|
||||
$this->SOAPXPath->registerNamespace('wssoap', $this->soapNS);
|
||||
$this->SOAPXPath->registerNamespace('wswsa', self::WSANS);
|
||||
|
||||
$this->envelope->setAttributeNS("http://www.w3.org/2000/xmlns/", 'xmlns:'.self::WSAPFX, self::WSANS);
|
||||
$this->locateHeader();
|
||||
}
|
||||
|
||||
public function addAction($action)
|
||||
{
|
||||
/* Add the WSA Action */
|
||||
$header = $this->locateHeader();
|
||||
|
||||
$nodeAction = $this->soapDoc->createElementNS(self::WSANS, self::SAPFX.':Action', $action);
|
||||
$header->appendChild($nodeAction);
|
||||
}
|
||||
|
||||
public function addTo($location)
|
||||
{
|
||||
/* Add the WSA To */
|
||||
$header = $this->locateHeader();
|
||||
|
||||
$nodeTo = $this->soapDoc->createElementNS(WSASoap::WSANS, WSASoap::WSAPFX.':To', $location);
|
||||
$header->appendChild($nodeTo);
|
||||
}
|
||||
|
||||
private function createID()
|
||||
{
|
||||
$uuid = md5(uniqid(rand(), true));
|
||||
$guid = 'uudi:'.substr($uuid, 0, 8)."-".
|
||||
substr($uuid, 8, 4)."-".
|
||||
substr($uuid, 12, 4)."-".
|
||||
substr($uuid, 16, 4)."-".
|
||||
substr($uuid, 20, 12);
|
||||
|
||||
return $guid;
|
||||
}
|
||||
|
||||
public function addMessageID($id = null)
|
||||
{
|
||||
/* Add the WSA MessageID or return existing ID */
|
||||
if (!is_null($this->messageID)) {
|
||||
return $this->messageID;
|
||||
}
|
||||
|
||||
if (empty($id)) {
|
||||
$id = $this->createID();
|
||||
}
|
||||
|
||||
$header = $this->locateHeader();
|
||||
|
||||
$nodeID = $this->soapDoc->createElementNS(self::WSANS, self::WSAPFX.':MessageID', $id);
|
||||
$header->appendChild($nodeID);
|
||||
$this->messageID = $id;
|
||||
}
|
||||
|
||||
public function addReplyTo($address = null)
|
||||
{
|
||||
/* Create Message ID is not already added - required for ReplyTo */
|
||||
if (is_null($this->messageID)) {
|
||||
$this->addMessageID();
|
||||
}
|
||||
/* Add the WSA ReplyTo */
|
||||
$header = $this->locateHeader();
|
||||
|
||||
$nodeReply = $this->soapDoc->createElementNS(self::WSANS, self::WSAPFX.':ReplyTo');
|
||||
$header->appendChild($nodeReply);
|
||||
|
||||
if (empty($address)) {
|
||||
$address = 'http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous';
|
||||
}
|
||||
$nodeAddress = $this->soapDoc->createElementNS(self::WSANS, self::WSAPFX.':Address', $address);
|
||||
$nodeReply->appendChild($nodeAddress);
|
||||
}
|
||||
|
||||
public function getDoc()
|
||||
{
|
||||
return $this->soapDoc;
|
||||
}
|
||||
|
||||
public function saveXML()
|
||||
{
|
||||
return $this->soapDoc->saveXML();
|
||||
}
|
||||
|
||||
public function save($file)
|
||||
{
|
||||
return $this->soapDoc->save($file);
|
||||
}
|
||||
}
|
||||
|
||||
540
plugin/sepe/src/wsse/soap-wsse.php
Normal file
540
plugin/sepe/src/wsse/soap-wsse.php
Normal file
@@ -0,0 +1,540 @@
|
||||
<?php
|
||||
/**
|
||||
* soap-wsse.php
|
||||
*
|
||||
* Copyright (c) 2010, Robert Richards <rrichards@ctindustries.net>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Robert Richards nor the names of his
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @author Robert Richards <rrichards@ctindustries.net>
|
||||
* @copyright 2007-2010 Robert Richards <rrichards@ctindustries.net>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version 1.1.0-dev
|
||||
*/
|
||||
|
||||
use RobRichards\XMLSecLibs\XMLSecurityDSig;
|
||||
use RobRichards\XMLSecLibs\XMLSecurityKey;
|
||||
|
||||
/**
|
||||
* Class WSSESoap
|
||||
*/
|
||||
class WSSESoap
|
||||
{
|
||||
const WSSENS = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
|
||||
const WSUNS = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd';
|
||||
const WSUNAME = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0';
|
||||
const WSSEPFX = 'wsse';
|
||||
const WSUPFX = 'wsu';
|
||||
private $soapNS, $soapPFX;
|
||||
private $soapDoc = null;
|
||||
private $envelope = null;
|
||||
private $SOAPXPath = null;
|
||||
private $secNode = null;
|
||||
public $signAllHeaders = false;
|
||||
|
||||
private function locateSecurityHeader($bMustUnderstand = true, $setActor = null)
|
||||
{
|
||||
if ($this->secNode == null) {
|
||||
$headers = $this->SOAPXPath->query('//wssoap:Envelope/wssoap:Header');
|
||||
$header = $headers->item(0);
|
||||
if (!$header) {
|
||||
$header = $this->soapDoc->createElementNS($this->soapNS, $this->soapPFX.':Header');
|
||||
$this->envelope->insertBefore($header, $this->envelope->firstChild);
|
||||
}
|
||||
$secnodes = $this->SOAPXPath->query('./wswsse:Security', $header);
|
||||
$secnode = null;
|
||||
foreach ($secnodes as $node) {
|
||||
$actor = $node->getAttributeNS($this->soapNS, 'actor');
|
||||
if ($actor == $setActor) {
|
||||
$secnode = $node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$secnode) {
|
||||
$secnode = $this->soapDoc->createElementNS(self::WSSENS, self::WSSEPFX.':Security');
|
||||
///if (isset($secnode) && !empty($secnode)) {
|
||||
$header->appendChild($secnode);
|
||||
//}
|
||||
if ($bMustUnderstand) {
|
||||
$secnode->setAttributeNS($this->soapNS, $this->soapPFX.':mustUnderstand', '1');
|
||||
}
|
||||
if (! empty($setActor)) {
|
||||
$ename = 'actor';
|
||||
if ($this->soapNS == 'http://www.w3.org/2003/05/soap-envelope') {
|
||||
$ename = 'role';
|
||||
}
|
||||
$secnode->setAttributeNS($this->soapNS, $this->soapPFX.':'.$ename, $setActor);
|
||||
}
|
||||
}
|
||||
$this->secNode = $secnode;
|
||||
}
|
||||
return $this->secNode;
|
||||
}
|
||||
|
||||
public function __construct($doc, $bMustUnderstand = true, $setActor = null)
|
||||
{
|
||||
$this->soapDoc = $doc;
|
||||
$this->envelope = $doc->documentElement;
|
||||
$this->soapNS = $this->envelope->namespaceURI;
|
||||
$this->soapPFX = $this->envelope->prefix;
|
||||
$this->SOAPXPath = new DOMXPath($doc);
|
||||
$this->SOAPXPath->registerNamespace('wssoap', $this->soapNS);
|
||||
$this->SOAPXPath->registerNamespace('wswsse', self::WSSENS);
|
||||
$this->locateSecurityHeader($bMustUnderstand, $setActor);
|
||||
}
|
||||
|
||||
public function addTimestamp($secondsToExpire = 3600)
|
||||
{
|
||||
/* Add the WSU timestamps */
|
||||
$security = $this->locateSecurityHeader();
|
||||
|
||||
$timestamp = $this->soapDoc->createElementNS(self::WSUNS, self::WSUPFX.':Timestamp');
|
||||
$security->insertBefore($timestamp, $security->firstChild);
|
||||
$currentTime = time();
|
||||
$created = $this->soapDoc->createElementNS(
|
||||
self::WSUNS,
|
||||
self::WSUPFX.':Created',
|
||||
gmdate("Y-m-d\TH:i:s", $currentTime).'Z'
|
||||
);
|
||||
$timestamp->appendChild($created);
|
||||
if (!is_null($secondsToExpire)) {
|
||||
$expire = $this->soapDoc->createElementNS(
|
||||
self::WSUNS,
|
||||
self::WSUPFX.':Expires',
|
||||
gmdate("Y-m-d\TH:i:s", $currentTime + $secondsToExpire).'Z'
|
||||
);
|
||||
$timestamp->appendChild($expire);
|
||||
}
|
||||
}
|
||||
|
||||
public function addUserToken($userName, $password = null, $passwordDigest = false)
|
||||
{
|
||||
if ($passwordDigest && empty($password)) {
|
||||
throw new Exception("Cannot calculate the digest without a password");
|
||||
}
|
||||
|
||||
$security = $this->locateSecurityHeader();
|
||||
|
||||
$token = $this->soapDoc->createElementNS(self::WSSENS, self::WSSEPFX.':UsernameToken');
|
||||
$security->insertBefore($token, $security->firstChild);
|
||||
|
||||
$username = $this->soapDoc->createElementNS(self::WSSENS, self::WSSEPFX.':Username', $userName);
|
||||
$token->appendChild($username);
|
||||
|
||||
/* Generate nonce - create a 256 bit session key to be used */
|
||||
$objKey = new XMLSecurityKey(XMLSecurityKey::AES256_CBC);
|
||||
$nonce = $objKey->generateSessionKey();
|
||||
unset($objKey);
|
||||
$createdate = gmdate("Y-m-d\TH:i:s").'Z';
|
||||
|
||||
if ($password) {
|
||||
$passType = self::WSUNAME.'#PasswordText';
|
||||
if ($passwordDigest) {
|
||||
$password = base64_encode(sha1($nonce.$createdate.$password, true));
|
||||
$passType = self::WSUNAME.'#PasswordDigest';
|
||||
}
|
||||
$passwordNode = $this->soapDoc->createElementNS(self::WSSENS, self::WSSEPFX.':Password', $password);
|
||||
$token->appendChild($passwordNode);
|
||||
$passwordNode->setAttribute('Type', $passType);
|
||||
}
|
||||
|
||||
$nonceNode = $this->soapDoc->createElementNS(self::WSSENS, self::WSSEPFX.':Nonce', base64_encode($nonce));
|
||||
$token->appendChild($nonceNode);
|
||||
|
||||
$created = $this->soapDoc->createElementNS(self::WSUNS, self::WSUPFX.':Created', $createdate);
|
||||
$token->appendChild($created);
|
||||
}
|
||||
|
||||
public function addBinaryToken($cert, $isPEMFormat = true, $isDSig = true)
|
||||
{
|
||||
$security = $this->locateSecurityHeader();
|
||||
$data = XMLSecurityDSig::get509XCert($cert, $isPEMFormat);
|
||||
|
||||
$token = $this->soapDoc->createElementNS(self::WSSENS, self::WSSEPFX.':BinarySecurityToken', $data);
|
||||
$security->insertBefore($token, $security->firstChild);
|
||||
|
||||
$token->setAttribute(
|
||||
'EncodingType',
|
||||
'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'
|
||||
);
|
||||
$token->setAttributeNS(self::WSUNS, self::WSUPFX.':Id', XMLSecurityDSig::generate_GUID());
|
||||
$token->setAttribute(
|
||||
'ValueType',
|
||||
'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3'
|
||||
);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function attachTokentoSig($token)
|
||||
{
|
||||
if (!($token instanceof DOMElement)) {
|
||||
throw new Exception('Invalid parameter: BinarySecurityToken element expected');
|
||||
}
|
||||
$objXMLSecDSig = new XMLSecurityDSig();
|
||||
if ($objDSig = $objXMLSecDSig->locateSignature($this->soapDoc)) {
|
||||
$tokenURI = '#'.$token->getAttributeNS(self::WSUNS, "Id");
|
||||
$this->SOAPXPath->registerNamespace('secdsig', XMLSecurityDSig::XMLDSIGNS);
|
||||
$query = "./secdsig:KeyInfo";
|
||||
$nodeset = $this->SOAPXPath->query($query, $objDSig);
|
||||
$keyInfo = $nodeset->item(0);
|
||||
if (!$keyInfo) {
|
||||
$keyInfo = $objXMLSecDSig->createNewSignNode('KeyInfo');
|
||||
$objDSig->appendChild($keyInfo);
|
||||
}
|
||||
|
||||
$tokenRef = $this->soapDoc->createElementNS(self::WSSENS, self::WSSEPFX.':SecurityTokenReference');
|
||||
$keyInfo->appendChild($tokenRef);
|
||||
$reference = $this->soapDoc->createElementNS(self::WSSENS, self::WSSEPFX.':Reference');
|
||||
$reference->setAttribute("URI", $tokenURI);
|
||||
$tokenRef->appendChild($reference);
|
||||
} else {
|
||||
throw new Exception('Unable to locate digital signature');
|
||||
}
|
||||
}
|
||||
|
||||
public function signSoapDoc($objKey, $options = null)
|
||||
{
|
||||
$objDSig = new XMLSecurityDSig();
|
||||
$objDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N);
|
||||
$arNodes = array();
|
||||
foreach ($this->secNode->childNodes as $node) {
|
||||
if ($node->nodeType == XML_ELEMENT_NODE) {
|
||||
$arNodes[] = $node;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->signAllHeaders) {
|
||||
foreach ($this->secNode->parentNode->childNodes as $node) {
|
||||
if (($node->nodeType == XML_ELEMENT_NODE) &&
|
||||
($node->namespaceURI != self::WSSENS)) {
|
||||
$arNodes[] = $node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->envelope->childNodes as $node) {
|
||||
if ($node->namespaceURI == $this->soapNS && $node->localName == 'Body') {
|
||||
$arNodes[] = $node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$algorithm = XMLSecurityDSig::SHA1;
|
||||
if (is_array($options) && isset($options["algorithm"])) {
|
||||
$algorithm = $options["algorithm"];
|
||||
}
|
||||
|
||||
$arOptions = array('prefix' => self::WSUPFX, 'prefix_ns' => self::WSUNS);
|
||||
$objDSig->addReferenceList($arNodes, $algorithm, null, $arOptions);
|
||||
|
||||
$objDSig->sign($objKey);
|
||||
|
||||
$insertTop = true;
|
||||
if (is_array($options) && isset($options["insertBefore"])) {
|
||||
$insertTop = (bool)$options["insertBefore"];
|
||||
}
|
||||
$objDSig->appendSignature($this->secNode, $insertTop);
|
||||
|
||||
/* New suff */
|
||||
|
||||
if (is_array($options)) {
|
||||
if (!empty($options["KeyInfo"])) {
|
||||
if (!empty($options["KeyInfo"]["X509SubjectKeyIdentifier"])) {
|
||||
$sigNode = $this->secNode->firstChild->nextSibling;
|
||||
$objDoc = $sigNode->ownerDocument;
|
||||
$keyInfo = $sigNode->ownerDocument->createElementNS(XMLSecurityDSig::XMLDSIGNS, 'ds:KeyInfo');
|
||||
$sigNode->appendChild($keyInfo);
|
||||
$tokenRef = $objDoc->createElementNS(self::WSSENS, self::WSSEPFX.':SecurityTokenReference');
|
||||
$keyInfo->appendChild($tokenRef);
|
||||
$reference = $objDoc->createElementNS(self::WSSENS, self::WSSEPFX.':KeyIdentifier');
|
||||
$reference->setAttribute(
|
||||
"ValueType",
|
||||
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509SubjectKeyIdentifier"
|
||||
);
|
||||
$reference->setAttribute(
|
||||
"EncodingType",
|
||||
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"
|
||||
);
|
||||
$tokenRef->appendChild($reference);
|
||||
$x509 = openssl_x509_parse($objKey->getX509Certificate());
|
||||
$keyid = $x509["extensions"]["subjectKeyIdentifier"];
|
||||
$arkeyid = split(":", $keyid);
|
||||
|
||||
$data = "";
|
||||
foreach ($arkeyid as $hexchar) {
|
||||
$data .= chr(hexdec($hexchar));
|
||||
}
|
||||
$dataNode = new DOMText(base64_encode($data));
|
||||
$reference->appendChild($dataNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addEncryptedKey($node, $key, $token, $options = null)
|
||||
{
|
||||
if (!$key->encKey) {
|
||||
return false;
|
||||
}
|
||||
$encKey = $key->encKey;
|
||||
$security = $this->locateSecurityHeader();
|
||||
$doc = $security->ownerDocument;
|
||||
if (!$doc->isSameNode($encKey->ownerDocument)) {
|
||||
$key->encKey = $security->ownerDocument->importNode($encKey, true);
|
||||
$encKey = $key->encKey;
|
||||
}
|
||||
if (!empty($key->guid)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$lastToken = null;
|
||||
$findTokens = $security->firstChild;
|
||||
while ($findTokens) {
|
||||
if ($findTokens->localName == 'BinarySecurityToken') {
|
||||
$lastToken = $findTokens;
|
||||
}
|
||||
$findTokens = $findTokens->nextSibling;
|
||||
}
|
||||
if ($lastToken) {
|
||||
$lastToken = $lastToken->nextSibling;
|
||||
}
|
||||
|
||||
$security->insertBefore($encKey, $lastToken);
|
||||
$key->guid = XMLSecurityDSig::generate_GUID();
|
||||
$encKey->setAttribute('Id', $key->guid);
|
||||
$encMethod = $encKey->firstChild;
|
||||
while ($encMethod && $encMethod->localName != 'EncryptionMethod') {
|
||||
$encMethod = $encMethod->nextChild;
|
||||
}
|
||||
if ($encMethod) {
|
||||
$encMethod = $encMethod->nextSibling;
|
||||
}
|
||||
$objDoc = $encKey->ownerDocument;
|
||||
$keyInfo = $objDoc->createElementNS('http://www.w3.org/2000/09/xmldsig#', 'dsig:KeyInfo');
|
||||
$encKey->insertBefore($keyInfo, $encMethod);
|
||||
$tokenRef = $objDoc->createElementNS(self::WSSENS, self::WSSEPFX.':SecurityTokenReference');
|
||||
$keyInfo->appendChild($tokenRef);
|
||||
/* New suff */
|
||||
if (is_array($options)) {
|
||||
if (!empty($options["KeyInfo"])) {
|
||||
if (!empty($options["KeyInfo"]["X509SubjectKeyIdentifier"])) {
|
||||
$reference = $objDoc->createElementNS(self::WSSENS, self::WSSEPFX.':KeyIdentifier');
|
||||
$reference->setAttribute(
|
||||
"ValueType",
|
||||
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509SubjectKeyIdentifier"
|
||||
);
|
||||
$reference->setAttribute(
|
||||
"EncodingType",
|
||||
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"
|
||||
);
|
||||
$tokenRef->appendChild($reference);
|
||||
$x509 = openssl_x509_parse($token->getX509Certificate());
|
||||
$keyid = $x509["extensions"]["subjectKeyIdentifier"];
|
||||
$arkeyid = split(":", $keyid);
|
||||
$data = "";
|
||||
foreach ($arkeyid as $hexchar) {
|
||||
$data .= chr(hexdec($hexchar));
|
||||
}
|
||||
$dataNode = new DOMText(base64_encode($data));
|
||||
$reference->appendChild($dataNode);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tokenURI = '#'.$token->getAttributeNS(self::WSUNS, "Id");
|
||||
$reference = $objDoc->createElementNS(self::WSSENS, self::WSSEPFX.':Reference');
|
||||
$reference->setAttribute("URI", $tokenURI);
|
||||
$tokenRef->appendChild($reference);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function AddReference($baseNode, $guid)
|
||||
{
|
||||
$refList = null;
|
||||
$child = $baseNode->firstChild;
|
||||
while ($child) {
|
||||
if (($child->namespaceURI == XMLSecEnc::XMLENCNS) && ($child->localName == 'ReferenceList')) {
|
||||
$refList = $child;
|
||||
break;
|
||||
}
|
||||
$child = $child->nextSibling;
|
||||
}
|
||||
$doc = $baseNode->ownerDocument;
|
||||
if (is_null($refList)) {
|
||||
$refList = $doc->createElementNS(XMLSecEnc::XMLENCNS, 'xenc:ReferenceList');
|
||||
$baseNode->appendChild($refList);
|
||||
}
|
||||
$dataref = $doc->createElementNS(XMLSecEnc::XMLENCNS, 'xenc:DataReference');
|
||||
$refList->appendChild($dataref);
|
||||
$dataref->setAttribute('URI', '#'.$guid);
|
||||
}
|
||||
|
||||
public function EncryptBody($siteKey, $objKey, $token)
|
||||
{
|
||||
$enc = new XMLSecEnc();
|
||||
$node = false;
|
||||
foreach ($this->envelope->childNodes as $node) {
|
||||
if ($node->namespaceURI == $this->soapNS && $node->localName == 'Body') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$enc->setNode($node);
|
||||
/* encrypt the symmetric key */
|
||||
$enc->encryptKey($siteKey, $objKey, false);
|
||||
|
||||
$enc->type = XMLSecEnc::Content;
|
||||
/* Using the symmetric key to actually encrypt the data */
|
||||
$encNode = $enc->encryptNode($objKey);
|
||||
|
||||
$guid = XMLSecurityDSig::generate_GUID();
|
||||
$encNode->setAttribute('Id', $guid);
|
||||
|
||||
$refNode = $encNode->firstChild;
|
||||
while ($refNode && $refNode->nodeType != XML_ELEMENT_NODE) {
|
||||
$refNode = $refNode->nextSibling;
|
||||
}
|
||||
if ($refNode) {
|
||||
$refNode = $refNode->nextSibling;
|
||||
}
|
||||
if ($this->addEncryptedKey($encNode, $enc, $token)) {
|
||||
$this->AddReference($enc->encKey, $guid);
|
||||
}
|
||||
}
|
||||
|
||||
public function encryptSoapDoc($siteKey, $objKey, $options = null, $encryptSignature = true)
|
||||
{
|
||||
$enc = new XMLSecEnc();
|
||||
|
||||
$xpath = new DOMXPath($this->envelope->ownerDocument);
|
||||
if ($encryptSignature == false) {
|
||||
$nodes = $xpath->query('//*[local-name()="Body"]');
|
||||
} else {
|
||||
$nodes = $xpath->query('//*[local-name()="Signature"] | //*[local-name()="Body"]');
|
||||
}
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
$type = XMLSecEnc::Element;
|
||||
$name = $node->localName;
|
||||
if ($name == "Body") {
|
||||
$type = XMLSecEnc::Content;
|
||||
}
|
||||
$enc->addReference($name, $node, $type);
|
||||
}
|
||||
|
||||
$enc->encryptReferences($objKey);
|
||||
|
||||
$enc->encryptKey($siteKey, $objKey, false);
|
||||
|
||||
$nodes = $xpath->query('//*[local-name()="Security"]');
|
||||
$signode = $nodes->item(0);
|
||||
$this->addEncryptedKey($signode, $enc, $siteKey, $options);
|
||||
}
|
||||
|
||||
public function decryptSoapDoc($doc, $options)
|
||||
{
|
||||
|
||||
$privKey = null;
|
||||
$privKey_isFile = false;
|
||||
$privKey_isCert = false;
|
||||
|
||||
if (is_array($options)) {
|
||||
$privKey = (!empty($options["keys"]["private"]["key"]) ? $options["keys"]["private"]["key"] : null);
|
||||
$privKey_isFile = (!empty($options["keys"]["private"]["isFile"]) ? true : false);
|
||||
$privKey_isCert = (!empty($options["keys"]["private"]["isCert"]) ? true : false);
|
||||
}
|
||||
|
||||
$objenc = new XMLSecEnc();
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
$envns = $doc->documentElement->namespaceURI;
|
||||
$xpath->registerNamespace("soapns", $envns);
|
||||
$xpath->registerNamespace("soapenc", "http://www.w3.org/2001/04/xmlenc#");
|
||||
|
||||
$nodes = $xpath->query('/soapns:Envelope/soapns:Header/*[local-name()="Security"]/soapenc:EncryptedKey');
|
||||
|
||||
$references = array();
|
||||
if ($node = $nodes->item(0)) {
|
||||
$objenc = new XMLSecEnc();
|
||||
$objenc->setNode($node);
|
||||
if (!$objKey = $objenc->locateKey()) {
|
||||
throw new Exception("Unable to locate algorithm for this Encrypted Key");
|
||||
}
|
||||
$objKey->isEncrypted = true;
|
||||
$objKey->encryptedCtx = $objenc;
|
||||
XMLSecEnc::staticLocateKeyInfo($objKey, $node);
|
||||
if ($objKey && $objKey->isEncrypted) {
|
||||
$objencKey = $objKey->encryptedCtx;
|
||||
$objKey->loadKey($privKey, $privKey_isFile, $privKey_isCert);
|
||||
$key = $objencKey->decryptKey($objKey);
|
||||
$objKey->loadKey($key);
|
||||
}
|
||||
|
||||
$refnodes = $xpath->query('./soapenc:ReferenceList/soapenc:DataReference/@URI', $node);
|
||||
foreach ($refnodes as $reference) {
|
||||
$references[] = $reference->nodeValue;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($references as $reference) {
|
||||
$arUrl = parse_url($reference);
|
||||
$reference = $arUrl['fragment'];
|
||||
$query = '//*[@Id="'.$reference.'"]';
|
||||
$nodes = $xpath->query($query);
|
||||
$encData = $nodes->item(0);
|
||||
|
||||
if ($algo = $xpath->evaluate("string(./soapenc:EncryptionMethod/@Algorithm)", $encData)) {
|
||||
$objKey = new XMLSecurityKey($algo);
|
||||
$objKey->loadKey($key);
|
||||
}
|
||||
|
||||
$objenc->setNode($encData);
|
||||
$objenc->type = $encData->getAttribute("Type");
|
||||
$decrypt = $objenc->decryptNode($objKey, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function saveXML()
|
||||
{
|
||||
return $this->soapDoc->saveXML();
|
||||
}
|
||||
|
||||
public function save($file)
|
||||
{
|
||||
return $this->soapDoc->save($file);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user