Remove error_logs, remove called to unused code.

pull/2487/head
jmontoyaa 7 years ago
parent 4c08b6b3b5
commit 193a286273
  1. 65
      plugin/openmeetings/lib/openmeetings.class.php
  2. 9
      plugin/openmeetings/lib/openmeetings_gateway.php
  3. 439
      plugin/sepe/src/formative-action-edit.php
  4. 400
      plugin/sepe/src/function.php
  5. 477
      plugin/sepe/src/participant-action-edit.php
  6. 551
      plugin/sepe/src/participant-specialty-edit.php
  7. 469
      plugin/sepe/src/specialty-action-edit.php
  8. 264
      plugin/sepe/src/specialty-classroom-edit.php
  9. 443
      plugin/sepe/src/specialty-tutor-edit.php
  10. 315
      plugin/sepe/src/specialty-tutorial-edit.php
  11. 28
      tests/scripts/delete_old_tasks.php

@ -91,41 +91,6 @@ class OpenMeetings
return api_is_course_admin() || api_is_coach() || api_is_platform_admin();
}
/**
* Login the user with OM Server. This generates a session ID that is
* specific to the current user, but that does not require specific user data
*
* It is similar to opening a PHP session. In fact, the session ID is kept
* inside the $_SESSION['openmeetings_session'] session variable
* @return bool True if the user is correct and false when is incorrect
* @deprecated loginUser now called at object instanciation
*/
/**
function loginUser()
{
try {
//Verifying if there is already an active session
if (empty($_SESSION['openmeetings_session'])) {
// Login user returns either 0 or >0, depending on the results
// Technically, as long as the SOAP user has been configured in OpenMeetings and OpenMeetings is on, this should always succeed.
if ($this->gateway->loginUser()) {
$this->sessionId = $_SESSION['openmeetings_session'] = $this->gateway->session_id;
return true;
} else {
error_log('loginUser did not succeed');
return false;
}
} else {
$this->sessionId = $_SESSION['openmeetings_session'];
return true;
}
} catch (SoapFault $e) {
error_log(__FILE__.'+'.__LINE__.' Warning: We have detected some problems. Fault: '.$e->faultstring);
return false;
}
}
*/
/*
* Creating a Room for the meeting
* @return bool True if the user is correct and false when is incorrect
@ -152,8 +117,6 @@ class OpenMeetings
);
if ($meetingData != false && count($meetingData) > 0) {
//error_log(print_r($meetingData,1));
//error_log('Found previous room reference - reusing');
// There has been a room in the past for this course. It should
// still be on the server, so update (instead of creating a new one)
// This fills the following attributes: status, name, comment, chamiloCourseId, chamiloSessionId
@ -164,12 +127,9 @@ class OpenMeetings
$roomId = $this->gateway->updateRoomWithModeration($room);
if ($roomId != $meetingData['room_id']) {
$msg = 'Something went wrong: the updated room ID ('.$roomId.') is not the same as the one we had ('.$meetingData['room_id'].')';
error_log($msg);
die($msg);
}
} else {
//error_log('Found no previous room - creating');
$room = new Room();
$room->SID = $this->sessionId;
$room->name = $this->roomName;
@ -387,31 +347,8 @@ class OpenMeetings
)
)
);
/*$urlWsdl = $this->url."/services/RoomService?wsdl";
$omServices = new \SoapClient($urlWsdl);*/
$room = new Room();
/*
try {
$rooms = $this->gateway->getRoomsWithCurrentUsersByType();
//$rooms = $omServices->getRoomsPublic(array(
//'SID' => $this->sessionId,
//'start' => 0,
//'max' => 10,
//'orderby' => 'name',
//'asc' => 'true',
//'externalRoomType' => 'chamilo',
//'roomtypes_id' => 'chamilo',
//)
//);
} catch (SoapFault $e) {
error_log(__FILE__.'+'.__LINE__.' '.$e->faultstring);
//error_log($rooms->getDebug());
return false;
}
*/
$room->SID = $this->sessionId;
//error_log(__FILE__.'+'.__LINE__.' Meetings found: '.print_r($room->SID,1));
if (!empty($meetingsList)) {
foreach ($meetingsList as $meetingDb) {
//$room->rooms_id = $meetingDb['room_id'];
@ -593,7 +530,6 @@ class OpenMeetings
array('id = ? ' => $meetingId)
);
}
//error_log(__FILE__.'+'.__LINE__.' Finished closing');
} catch (SoapFault $e) {
error_log(__FILE__.'+'.__LINE__.' Warning: We have detected some problems: Fault: '.$e->faultstring);
exit;
@ -619,7 +555,6 @@ class OpenMeetings
array('id = ? ' => $id)
);
return $id;
//error_log(__FILE__.'+'.__LINE__.' Finished closing');
} catch (SoapFault $e) {
error_log(__FILE__.'+'.__LINE__.' Warning: We have detected some problems: Fault: '.$e->faultstring);
exit;

@ -98,7 +98,6 @@ class OpenMeetingsGateway
if ($err) {
error_log('Error: '.$err);
} else {
//error_log('getSession returned '.$response. ' - Storing as sessionId');
$this->sessionId = $response;
$url = $this->getRestUrl("UserService")
@ -157,7 +156,7 @@ class OpenMeetingsGateway
. "&isDemoRoom=false"
. "&demoTime=0"
. "&isModeratedRoom=".$this->var_to_str($isModeratedRoom));
//error_log($url);
$result = $this->rest->call($url);
if ($result->fault) {
@ -167,8 +166,6 @@ class OpenMeetingsGateway
if ($err) {
error_log('Error: '.$err);
} else {
// echo '<h2>Result</h2><pre>'; print_r($result["return"]); echo '</pre>';
//error_log('Room updated successfully '.print_r($result,1));
return $result;
}
}
@ -366,7 +363,6 @@ class OpenMeetingsGateway
if ($err) {
error_log('Error: '.$err);
} else {
//error_log('Creation of a new room succeeded: ID '.print_r($result,1));
return $result;
}
}
@ -391,11 +387,9 @@ class OpenMeetingsGateway
// . "getRoomTypes?"
// . "SID=" . $this->sessionId;
//$url = $this->getRestUrl('JabberService') . 'getAvailableRooms?SID=' . $this->sessionId;
//error_log(__FILE__.'+'.__LINE__.' Calling WS: '.$url);
$result = $this->rest->call($url, "return");
$rooms = array();
foreach ($result as $room) {
//error_log(__FILE__.'+'.__LINE__.': one room found on remote: '.print_r($room,1));
if ($room['externalRoomType'] == $type && count($room['currentusers']) > 0) {
$rooms[] = $room;
}
@ -420,7 +414,6 @@ class OpenMeetingsGateway
. "getRoomById?"
. "SID=".$this->sessionId
. "&rooms_id=".$roomId;
//error_log(__FILE__.'+'.__LINE__.' Calling WS: '.$url);
$result = $this->rest->call($url, "return");
return $result;
}

@ -1,220 +1,219 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script displays a formative action edit form.
*/
use \ChamiloSession as Session;
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) {
echo Database::error();
$_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 = array();
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe'));
$interbreadcrumb[] = array("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(intval($_GET['action_id']));
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe'));
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList'));
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction'));
$info = getActionInfo(intval($_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 = array();
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));
}
<?php
/* For licensing terms, see /license.txt */
/**
* This script displays a formative action edit form.
*/
use \ChamiloSession as Session;
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 = array();
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe'));
$interbreadcrumb[] = array("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(intval($_GET['action_id']));
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe'));
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList'));
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction'));
$info = getActionInfo(intval($_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 = array();
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));
}

@ -1,200 +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').Database::error();
echo json_encode(array("status" => "false", "content" => $content));
} else {
$content = $plugin->get_lang('DeleteOk');
echo json_encode(array("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').Database::error();
echo json_encode(array("status" => "false", "content" => $content));
} else {
$content = $plugin->get_lang('DeleteOk');
$_SESSION['sepe_message_info'] = $content;
echo json_encode(array("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').Database::error();
echo json_encode(array("status" => "false", "content" => $content));
} else {
$content = $plugin->get_lang('DeleteOk');
echo json_encode(array("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').Database::error();
echo json_encode(array("status" => "false", "content" => $content));
} else {
$content = $plugin->get_lang('DeleteOk');
echo json_encode(array("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').Database::error();
echo json_encode(array("status" => "false", "content" => $content));
} else {
$content = $plugin->get_lang('DeleteOk');
echo json_encode(array("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').Database::error();
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(array("status" => "true"));
} else {
$content = $plugin->get_lang('ModDataTeacher');
echo json_encode(array("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').Database::error();
echo json_encode(array("status" => "false", "content" => $content));
} else {
$content = $plugin->get_lang('DeleteOk');
echo json_encode(array("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').Database::error();
echo json_encode(array("status" => "false", "content" => $content));
} else {
$content = $plugin->get_lang('DeleteOk');
echo json_encode(array("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').Database::error();
echo json_encode(array("status" => "false", "content" => $content));
} else {
$content = $plugin->get_lang('DeleteOk');
echo json_encode(array("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(array("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(array("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(array("status" => "false", "content" => utf8_encode($content)));
} else {
echo json_encode(array("status" => "true"));
}
}
}
} else {
$content = $plugin->get_lang('ErrorDataIncorrect');
echo json_encode(array("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 = array();
$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(array("status" => "true", "content" => $content));
} else {
$content = $plugin->get_lang('ProblemGenerateApiKey');
echo json_encode(array("status" => "false", "content" => $content));
}
}
<?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(array("status" => "false", "content" => $content));
} else {
$content = $plugin->get_lang('DeleteOk');
echo json_encode(array("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(array("status" => "false", "content" => $content));
} else {
$content = $plugin->get_lang('DeleteOk');
$_SESSION['sepe_message_info'] = $content;
echo json_encode(array("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(array("status" => "false", "content" => $content));
} else {
$content = $plugin->get_lang('DeleteOk');
echo json_encode(array("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(array("status" => "false", "content" => $content));
} else {
$content = $plugin->get_lang('DeleteOk');
echo json_encode(array("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(array("status" => "false", "content" => $content));
} else {
$content = $plugin->get_lang('DeleteOk');
echo json_encode(array("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(array("status" => "true"));
} else {
$content = $plugin->get_lang('ModDataTeacher');
echo json_encode(array("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(array("status" => "false", "content" => $content));
} else {
$content = $plugin->get_lang('DeleteOk');
echo json_encode(array("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(array("status" => "false", "content" => $content));
} else {
$content = $plugin->get_lang('DeleteOk');
echo json_encode(array("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(array("status" => "false", "content" => $content));
} else {
$content = $plugin->get_lang('DeleteOk');
echo json_encode(array("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(array("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(array("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(array("status" => "false", "content" => utf8_encode($content)));
} else {
echo json_encode(array("status" => "true"));
}
}
}
} else {
$content = $plugin->get_lang('ErrorDataIncorrect');
echo json_encode(array("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 = array();
$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(array("status" => "true", "content" => $content));
} else {
$content = $plugin->get_lang('ProblemGenerateApiKey');
echo json_encode(array("status" => "false", "content" => $content));
}
}

@ -1,240 +1,237 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script displays a participant edit form.
*/
use \ChamiloSession as Session;
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) {
echo Database::error();
} 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) {
echo Database::error();
} 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) {
error_log(Database::error());
$_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);
} 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);
}
} else {
$token = Security::get_token();
}
if (api_is_platform_admin()) {
$actionId = intval($_GET['action_id']);
$courseId = getCourse($actionId);
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe'));
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList'));
$interbreadcrumb[] = array("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 = array();
$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(intval($_GET['participant_id']));
$tpl->assign('info', $info);
$tpl->assign('new_participant', '0');
$tpl->assign('participant_id', intval($_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 = array();
$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 = array();
$listTutorCompany = listTutorType("company = '1'");
$tpl->assign('list_tutor_company', $listTutorCompany);
$listTutorTraining = array();
$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));
}
<?php
/* For licensing terms, see /license.txt */
/**
* This script displays a participant edit form.
*/
use \ChamiloSession as Session;
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);
} 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);
}
} else {
$token = Security::get_token();
}
if (api_is_platform_admin()) {
$actionId = intval($_GET['action_id']);
$courseId = getCourse($actionId);
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe'));
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList'));
$interbreadcrumb[] = array("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 = array();
$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(intval($_GET['participant_id']));
$tpl->assign('info', $info);
$tpl->assign('new_participant', '0');
$tpl->assign('participant_id', intval($_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 = array();
$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 = array();
$listTutorCompany = listTutorType("company = '1'");
$tpl->assign('list_tutor_company', $listTutorCompany);
$listTutorTraining = array();
$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));
}

@ -1,276 +1,275 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script displays a participant specialty edit form.
*/
use \ChamiloSession as Session;
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) {
echo Database::error();
$_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);
} 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);
}
} else {
$token = Security::get_token();
}
if (api_is_platform_admin()) {
$actionId = intval($_GET['action_id']);
$courseId = getCourse($actionId);
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe'));
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList'));
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction'));
$interbreadcrumb[] = array("url" => "participant-action-edit.php?new_participant=0&participant_id=".intval($_GET['participant_id'])."&action_id=".$_GET['action_id'], "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', intval($_GET['participant_id']));
$info = array();
$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', intval($_GET['participant_id']));
$info = getInfoSpecialtyParticipant(intval($_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(intval($_GET['specialty_id']));
$tpl->assign('listSpecialtyTutorials', $listSpecialtyTutorials);
}
$listYear = array();
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 = array();
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));
}
<?php
/* For licensing terms, see /license.txt */
/**
* This script displays a participant specialty edit form.
*/
use \ChamiloSession as Session;
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);
} 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);
}
} else {
$token = Security::get_token();
}
if (api_is_platform_admin()) {
$actionId = intval($_GET['action_id']);
$courseId = getCourse($actionId);
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe'));
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList'));
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction'));
$interbreadcrumb[] = array("url" => "participant-action-edit.php?new_participant=0&participant_id=".intval($_GET['participant_id'])."&action_id=".$_GET['action_id'], "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', intval($_GET['participant_id']));
$info = array();
$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', intval($_GET['participant_id']));
$info = getInfoSpecialtyParticipant(intval($_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(intval($_GET['specialty_id']));
$tpl->assign('listSpecialtyTutorials', $listSpecialtyTutorials);
}
$listYear = array();
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 = array();
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));
}

@ -1,235 +1,234 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script displays a specialty action edit form.
*/
use \ChamiloSession as Session;
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) {
echo Database::error();
$_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[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe'));
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList'));
$interbreadcrumb[] = array("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 = array();
$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 = array();
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));
}
<?php
/* For licensing terms, see /license.txt */
/**
* This script displays a specialty action edit form.
*/
use \ChamiloSession as Session;
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[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe'));
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList'));
$interbreadcrumb[] = array("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 = array();
$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 = array();
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));
}

@ -1,133 +1,131 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script displays a specialty classroom edit form.
*/
use \ChamiloSession as Session;
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) {
echo Database::error();
$_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 = array(
'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) {
echo Database::error();
$_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);
} 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);
}
} else {
$token = Security::get_token();
}
if (api_is_platform_admin()) {
$courseId = getCourse(intval($_GET['action_id']));
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe'));
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList'));
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction'));
$interbreadcrumb[] = array("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 = array();
$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(intval($_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));
}
<?php
/* For licensing terms, see /license.txt */
/**
* This script displays a specialty classroom edit form.
*/
use \ChamiloSession as Session;
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 = array(
'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);
} 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);
}
} else {
$token = Security::get_token();
}
if (api_is_platform_admin()) {
$courseId = getCourse(intval($_GET['action_id']));
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe'));
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList'));
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction'));
$interbreadcrumb[] = array("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 = array();
$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(intval($_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));
}

@ -1,223 +1,220 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script displays a specialty tutors edit form.
*/
use \ChamiloSession as Session;
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) {
error_log(Database::error());
$_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) {
error_log(Database::error());
$_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) {
error_log(Database::error());
$_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);
} 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);
}
} else {
$token = Security::get_token();
}
if (api_is_platform_admin()) {
$courseId = getCourse(intval($_GET['action_id']));
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe'));
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList'));
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction'));
$interbreadcrumb[] = array("url" => "specialty-action-edit.php?new_specialty=0&specialty_id=".intval($_GET['specialty_id'])."&action_id=".$_GET['action_id'], "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', intval($_GET['action_id']));
$tpl->assign('specialty_id', intval($_GET['specialty_id']));
$info = array();
$tpl->assign('info', $info);
$tpl->assign('new_tutor', '1');
$platformUserId = '';
} else {
$templateName = $plugin->get_lang('EditSpecialtyTutor');
$tpl = new Template($templateName);
$tpl->assign('action_id', intval($_GET['action_id']));
$tpl->assign('specialty_id', intval($_GET['specialty_id']));
$tpl->assign('tutor_id', intval($_GET['tutor_id']));
$info = getInfoSpecialtyTutor(intval($_GET['tutor_id']));
$tpl->assign('info', $info);
$tpl->assign('new_tutor', '0');
$platformUserId = $info['platform_user_id'];
}
$tutorsList = getTutorsSpecialty(intval($_GET['specialty_id']));
$tpl->assign('ExistingTutorsList', $tutorsList);
$listTeachers = CourseManager::getTeachersFromCourse($courseId);
$listTeachers = freeTeacherList($listTeachers, intval($_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));
}
<?php
/* For licensing terms, see /license.txt */
/**
* This script displays a specialty tutors edit form.
*/
use \ChamiloSession as Session;
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);
} 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);
}
} else {
$token = Security::get_token();
}
if (api_is_platform_admin()) {
$courseId = getCourse(intval($_GET['action_id']));
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe'));
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList'));
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction'));
$interbreadcrumb[] = array("url" => "specialty-action-edit.php?new_specialty=0&specialty_id=".intval($_GET['specialty_id'])."&action_id=".$_GET['action_id'], "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', intval($_GET['action_id']));
$tpl->assign('specialty_id', intval($_GET['specialty_id']));
$info = array();
$tpl->assign('info', $info);
$tpl->assign('new_tutor', '1');
$platformUserId = '';
} else {
$templateName = $plugin->get_lang('EditSpecialtyTutor');
$tpl = new Template($templateName);
$tpl->assign('action_id', intval($_GET['action_id']));
$tpl->assign('specialty_id', intval($_GET['specialty_id']));
$tpl->assign('tutor_id', intval($_GET['tutor_id']));
$info = getInfoSpecialtyTutor(intval($_GET['tutor_id']));
$tpl->assign('info', $info);
$tpl->assign('new_tutor', '0');
$platformUserId = $info['platform_user_id'];
}
$tutorsList = getTutorsSpecialty(intval($_GET['specialty_id']));
$tpl->assign('ExistingTutorsList', $tutorsList);
$listTeachers = CourseManager::getTeachersFromCourse($courseId);
$listTeachers = freeTeacherList($listTeachers, intval($_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));
}

@ -1,158 +1,157 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script displays a specialty tutorial edit form.
*/
use \ChamiloSession as Session;
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) {
error_log(Database::error());
$_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);
} 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);
}
} else {
$token = Security::get_token();
}
if (api_is_platform_admin()) {
$courseId = getCourse(intval($_GET['action_id']));
$participantId = getParticipantId(intval($_GET['specialty_id']));
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe'));
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList'));
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction'));
$interbreadcrumb[] = array("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 = array();
$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 = array();
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));
}
<?php
/* For licensing terms, see /license.txt */
/**
* This script displays a specialty tutorial edit form.
*/
use \ChamiloSession as Session;
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);
} 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);
}
} else {
$token = Security::get_token();
}
if (api_is_platform_admin()) {
$courseId = getCourse(intval($_GET['action_id']));
$participantId = getParticipantId(intval($_GET['specialty_id']));
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe'));
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList'));
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction'));
$interbreadcrumb[] = array("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 = array();
$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 = array();
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));
}

@ -2,9 +2,9 @@
/* For licensing terms, see /license.txt */
/**
* This script removes previous tasks from disk to clear space.
* Configure the date on lines 22-23 to change the dates after/before which
* Configure the date on lines 22-23 to change the dates after/before which
* to delete.
* This works based on sessions dates (it will not delete tasks from
* This works based on sessions dates (it will not delete tasks from
* base courses).
* This script should be located inside the tests/scripts/ folder to work
* @author Paul Patrocinio <ppatrocino@icpna.edu.pe>
@ -39,14 +39,12 @@ $sql = "SELECT id FROM session where access_start_date < '$expiryDate' AND acces
$res = mysql_query($sql, $conexion);
if ($res === false) {
//die("Error querying sessions: ".Database::error($res)."\n");
}
$countSessions = mysql_num_rows($res);
$sql = "SELECT count(*) FROM session";
$resc = mysql_query($sql, $conexion);
if ($resc === false) {
//die("Error querying sessions: ".Database::error($res)."\n");
}
$countAllSessions = mysql_result($resc, 0, 0);
echo "[".time()."] Found $countSessions sessions between $fromDate and $expiryDate on a total of $countAllSessions sessions."."\n";
@ -57,7 +55,7 @@ while ($session = mysql_fetch_assoc($res)) {
WHERE s.id_session = ".$session['id']."
AND s.course_code = c.code";
$res2 = mysql_query($sql2, $conexion); //Database::query($sql2);
if ($res2 === false) {
die("Error querying courses for session ".$session['id'].": ".mysql_error($res2)."\n");
}
@ -66,7 +64,7 @@ while ($session = mysql_fetch_assoc($res)) {
while ($course = mysql_fetch_assoc($res2)) {
$sessionCourses[$session['id']] = $course['cid'];
//$_SESSION['session_course'] = $sessionCourses;
if (empty($coursesCodes[$course['cid']])) {
$coursesCodes[$course['cid']] = $course['ccode'];
}
@ -74,19 +72,19 @@ while ($session = mysql_fetch_assoc($res)) {
$coursesDirs[$course['cid']] = $course['cdir'];
}
}
}
}
}
echo "[".time()."] Filled courses arrays. Now checking tasks...\n";
/**
* Locate and destroy the expired tasks
*/
*/
//$sessionCourse = $_SESSION['session_course'];
$totalSize = 0;
foreach ($sessionCourses as $sid => $cid) {
// Check if a folder already exists in this session
// Folders are exclusive to sessions. If a folder already exists in
// another session, you will not be allowed to create the same folder in
// Folders are exclusive to sessions. If a folder already exists in
// another session, you will not be allowed to create the same folder in
// another session. As such, folders belong to one and only one session.
$sql = "SELECT id, url FROM c_student_publication
WHERE filetype = 'folder'
@ -94,30 +92,30 @@ foreach ($sessionCourses as $sid => $cid) {
AND session_id = $sid
AND active = 1
AND url LIKE '%ALP%'";
$resCarpetas = mysql_query($sql, $conexion); //Database::query($sql);
if (mysql_num_rows($resCarpetas) > 0) {
while ($rowDemo = mysql_fetch_assoc($resCarpetas)) {
$carpetaAlpElimina = $_configuration['root_sys'].'courses/'.$coursesDirs[$cid].'/work'.$rowDemo['url'];
//echo "rm -rf ".$carpetaAlpElimina."\n";
$size = folderSize($carpetaAlpElimina);
$totalSize += $size;
echo "Freeing $size of a total $totalSize bytes in $carpetaAlpElimina\n";
exec('rm -rf '.$carpetaAlpElimina);
}
$sqldel = "DELETE FROM c_student_publication
WHERE
c_id = $cid
AND session_id = $sid AND active = 1;";
$resdel = mysql_query($sqldel);
if ($resdel === false) {
echo "Error querying sessions: ".Database::error($resdel)."\n";
echo "Error querying sessions";
}
}
}
}
echo "[".time()."] Deleted tasks from $countSessions sessions between $fromDate and $expiryDate on a total of $countAllSessions sessions."."\n";

Loading…
Cancel
Save