From 193a28627306bac9c910e2882368dd2551231536 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 9 Aug 2017 08:52:54 +0200 Subject: [PATCH] Remove error_logs, remove called to unused code. --- .../openmeetings/lib/openmeetings.class.php | 65 --- .../openmeetings/lib/openmeetings_gateway.php | 9 +- plugin/sepe/src/formative-action-edit.php | 439 +++++++------- plugin/sepe/src/function.php | 400 ++++++------- plugin/sepe/src/participant-action-edit.php | 477 ++++++++------- .../sepe/src/participant-specialty-edit.php | 551 +++++++++--------- plugin/sepe/src/specialty-action-edit.php | 469 ++++++++------- plugin/sepe/src/specialty-classroom-edit.php | 264 +++++---- plugin/sepe/src/specialty-tutor-edit.php | 443 +++++++------- plugin/sepe/src/specialty-tutorial-edit.php | 315 +++++----- tests/scripts/delete_old_tasks.php | 28 +- 11 files changed, 1687 insertions(+), 1773 deletions(-) diff --git a/plugin/openmeetings/lib/openmeetings.class.php b/plugin/openmeetings/lib/openmeetings.class.php index 42448715c0..b79616aa66 100755 --- a/plugin/openmeetings/lib/openmeetings.class.php +++ b/plugin/openmeetings/lib/openmeetings.class.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; diff --git a/plugin/openmeetings/lib/openmeetings_gateway.php b/plugin/openmeetings/lib/openmeetings_gateway.php index c48ffbf826..5846b0e158 100755 --- a/plugin/openmeetings/lib/openmeetings_gateway.php +++ b/plugin/openmeetings/lib/openmeetings_gateway.php @@ -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 '

Result

'; print_r($result["return"]); echo '
'; - //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; } diff --git a/plugin/sepe/src/formative-action-edit.php b/plugin/sepe/src/formative-action-edit.php index 6d1829fba8..f5c265e762 100644 --- a/plugin/sepe/src/formative-action-edit.php +++ b/plugin/sepe/src/formative-action-edit.php @@ -1,220 +1,219 @@ -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)); -} +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)); +} diff --git a/plugin/sepe/src/function.php b/plugin/sepe/src/function.php index 437321edde..d84b8c01bd 100644 --- a/plugin/sepe/src/function.php +++ b/plugin/sepe/src/function.php @@ -1,200 +1,200 @@ -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)); - } -} +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)); + } +} diff --git a/plugin/sepe/src/participant-action-edit.php b/plugin/sepe/src/participant-action-edit.php index bcc680364f..2912ff47ee 100644 --- a/plugin/sepe/src/participant-action-edit.php +++ b/plugin/sepe/src/participant-action-edit.php @@ -1,240 +1,237 @@ - 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)); -} + 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)); +} diff --git a/plugin/sepe/src/participant-specialty-edit.php b/plugin/sepe/src/participant-specialty-edit.php index 420617c136..a54b932d3c 100644 --- a/plugin/sepe/src/participant-specialty-edit.php +++ b/plugin/sepe/src/participant-specialty-edit.php @@ -1,276 +1,275 @@ -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)); -} +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)); +} diff --git a/plugin/sepe/src/specialty-action-edit.php b/plugin/sepe/src/specialty-action-edit.php index 8555996a08..f8c4469c82 100644 --- a/plugin/sepe/src/specialty-action-edit.php +++ b/plugin/sepe/src/specialty-action-edit.php @@ -1,235 +1,234 @@ -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)); -} +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)); +} diff --git a/plugin/sepe/src/specialty-classroom-edit.php b/plugin/sepe/src/specialty-classroom-edit.php index 8bcfc6f94e..d173ce45f7 100644 --- a/plugin/sepe/src/specialty-classroom-edit.php +++ b/plugin/sepe/src/specialty-classroom-edit.php @@ -1,133 +1,131 @@ -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)); -} +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)); +} diff --git a/plugin/sepe/src/specialty-tutor-edit.php b/plugin/sepe/src/specialty-tutor-edit.php index 29a7f0b275..52312f15ca 100644 --- a/plugin/sepe/src/specialty-tutor-edit.php +++ b/plugin/sepe/src/specialty-tutor-edit.php @@ -1,223 +1,220 @@ - 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)); -} + 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)); +} diff --git a/plugin/sepe/src/specialty-tutorial-edit.php b/plugin/sepe/src/specialty-tutorial-edit.php index a9a4d0e0f3..22533239c6 100644 --- a/plugin/sepe/src/specialty-tutorial-edit.php +++ b/plugin/sepe/src/specialty-tutorial-edit.php @@ -1,158 +1,157 @@ -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)); -} +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)); +} diff --git a/tests/scripts/delete_old_tasks.php b/tests/scripts/delete_old_tasks.php index 459e365476..e41cd962b8 100644 --- a/tests/scripts/delete_old_tasks.php +++ b/tests/scripts/delete_old_tasks.php @@ -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 @@ -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";