Minor - format code.

1.9.x
Julio Montoya 11 years ago
parent 14d4fca65b
commit 9c8ddf56a9
  1. 37
      main/course_info/legal.php
  2. 8
      main/coursecopy/import_backup.php
  3. 10
      main/inc/lib/course.lib.php
  4. 1
      main/inc/lib/course_home.lib.php
  5. 82
      main/inc/lib/legal.lib.php
  6. 3
      main/inc/lib/plugin.class.php
  7. 2
      main/inc/local.inc.php

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use \ChamiloSession as Session;
@ -10,9 +11,9 @@ $cidReset = true;
require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;
$course_code = isset($_REQUEST['course_code']) ? $_REQUEST['course_code'] : null;
$session_id = isset($_REQUEST['session_id']) ? intval($_REQUEST['session_id']) : null;
$user_id = api_get_user_id();
$course_code = isset($_REQUEST['course_code']) ? $_REQUEST['course_code'] : null;
$session_id = isset($_REQUEST['session_id']) ? intval($_REQUEST['session_id']) : null;
$user_id = api_get_user_id();
if (empty($course_code)) {
api_not_allowed();
@ -34,9 +35,9 @@ $variable = 'accept_legal_'.$user_id.'_'.$course_info['real_id'].'_'.$session_id
if ($form->validate()) {
$accept_legal = $form->exportValue('accept_legal');
if ($accept_legal == 1) {
CourseManager::save_user_legal($user_id, $course_code, $session_id);
CourseManager::save_user_legal($user_id, $course_code, $session_id);
if (api_check_user_access_to_legal($course_info['visibility'])) {
Session::write($variable, true);
}
@ -51,36 +52,36 @@ if (api_check_user_access_to_legal($course_info['visibility']) && Session::read(
$url = api_get_course_url($course_code, $session_id);
if (empty($session_id)) {
if (CourseManager::is_user_subscribed_in_course($user_id, $course_code) || api_check_user_access_to_legal($course_info['visibility'])) {
if (CourseManager::is_user_subscribed_in_course($user_id, $course_code) || api_check_user_access_to_legal($course_info['visibility'])) {
$user_accepted_legal = CourseManager::is_user_accepted_legal($user_id, $course_code);
if ($user_accepted_legal || $user_pass_open_course) {
//Redirect to course home
header('Location: '.$url);
exit;
}
} else {
api_not_allowed();
}
}
} else {
api_not_allowed();
}
} else {
if (api_is_platform_admin()) {
header('Location: '.$url);
}
$user_session_status = SessionManager::get_user_status_in_session($user_id, $course_code, $session_id);
if (isset($user_session_status) || api_check_user_access_to_legal($course_info['visibility'])) {
$user_accepted_legal = CourseManager::is_user_accepted_legal($user_id, $course_code, $session_id);
if (isset($user_session_status) || api_check_user_access_to_legal($course_info['visibility'])) {
$user_accepted_legal = CourseManager::is_user_accepted_legal($user_id, $course_code, $session_id);
if ($user_accepted_legal || $user_pass_open_course) {
//Redirect to course session home
header('Location: '.$url);
exit;
}
}
} else {
api_not_allowed();
}
}
}
Display :: display_header($nameTools);
$form->display();
Display :: display_footer();
Display :: display_footer();

@ -6,10 +6,6 @@
* @author Bart Mollet <bart.mollet@hogent.be>
* @package chamilo.backup
*/
/**
* Code
*/
/* INIT SECTION */
// Language files that need to be included
$language_file = array('exercice', 'coursebackup', 'admin');
@ -131,7 +127,9 @@ if ((isset($_POST['action']) &&
}
} else {
$user = api_get_user_info();
$backups = CourseArchiver::get_available_backups($is_platformAdmin ?null:$user['user_id']);
$backups = CourseArchiver::get_available_backups(
$is_platformAdmin ? null : $user['user_id']
);
$backups_available = count($backups) > 0;
$form = new FormValidator('import_backup_form', 'post', api_get_path(WEB_CODE_PATH).'coursecopy/import_backup.php?'.api_get_cidreq(), '', 'multipart/form-data');

@ -3972,16 +3972,16 @@ class CourseManager
return $wanted_code;
}
/**
* Gets the status of the users agreement in a course course-session
*
* @param int user id
* @param string course code
* @param int session id
* @param int $user_id
* @param string $course_code
* @param int $session_id
* @return boolean
*/
public static function is_user_accepted_legal($user_id, $course_code, $session_id = null) {
public static function is_user_accepted_legal($user_id, $course_code, $session_id = null)
{
$user_id = intval($user_id);
$course_code = Database::escape_string($course_code);
$session_id = intval($session_id);

@ -751,7 +751,6 @@ class CourseHome
// Including Courses Plugins
// Creating title and the link
if (isset($tool['category']) && $tool['category'] == 'plugin') {
$plugin_info = $app_plugin->get_plugin_info($tool['name']);
if (isset($plugin_info) && isset($plugin_info['title'])) {

@ -1,29 +1,28 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Legal class
*
* @version 1.0
* @package chamilo.legal
* Class LegalManager
*
*/
/**
* Class
* @package chamilo.legal
*/
class LegalManager {
private function __construct () {
//void
class LegalManager
{
private function __construct ()
{
}
/**
* Add a new Term and Condition
* @param int language id
* @param string the content
* @param int term and condition type (0 or 1)
* @param string explain changes
* @return boolean sucess
* @param int $language language id
* @param string $content content
* @param int $type term and condition type (0 or 1)
* @param string $changes explain changes
* @return boolean success
*/
public static function add ($language, $content, $type, $changes) {
public static function add($language, $content, $type, $changes)
{
$legal_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$last = self::get_last_condition($language);
$language = Database::escape_string($language);
@ -59,7 +58,8 @@ class LegalManager {
}
}
public static function delete ($id) {
public static function delete($id)
{
/*
$legal_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$id = intval($id);
@ -69,41 +69,52 @@ class LegalManager {
/**
* Gets the last version of a Term and condition by language
* @param int the language id
* @param int $language language id
* @return array all the info of a Term and condition
*/
public static function get_last_condition_version ($language) {
public static function get_last_condition_version ($language)
{
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$language= Database::escape_string($language);
$sql = "SELECT version FROM $legal_conditions_table WHERE language_id = '".$language."' ORDER BY legal_id DESC LIMIT 1 ";
$sql = "SELECT version FROM $legal_conditions_table
WHERE language_id = '".$language."'
ORDER BY legal_id DESC LIMIT 1 ";
$result = Database::query($sql);
$row = Database::fetch_array($result);
if (Database::num_rows($result)>0) {
if (Database::num_rows($result) > 0) {
return $row['version'];
} else {
return 0;
}
}
/**
* Gets the data of a Term and condition by language
* @param int the language id
* @param int $language language id
* @return array all the info of a Term and condition
*/
public static function get_last_condition ($language) {
public static function get_last_condition ($language)
{
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$language= Database::escape_string($language);
$sql = "SELECT * FROM $legal_conditions_table WHERE language_id = '".$language."' ORDER BY version DESC LIMIT 1 ";
$sql = "SELECT * FROM $legal_conditions_table
WHERE language_id = '".$language."'
ORDER BY version DESC LIMIT 1 ";
$result = Database::query($sql);
return Database::fetch_array($result);
}
/**
* Gets the last version of a Term and condition by language
* @param int the language id
* @param int $language language id
* @return boolean | int the version or false if does not exist
*/
public static function get_last_version ($language) {
public static function get_last_version ($language)
{
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$language= Database::escape_string($language);
$sql = "SELECT version FROM $legal_conditions_table WHERE language_id = '".$language."' ORDER BY version DESC LIMIT 1 ";
@ -122,7 +133,8 @@ class LegalManager {
* @param array with type and content i.e array('type'=>'1', 'content'=>'hola');
* @return string html preview
*/
public static function show_last_condition($term_preview) {
public static function show_last_condition($term_preview)
{
$preview = '';
switch ($term_preview['type']) {
/*// scroll box
@ -175,7 +187,6 @@ class LegalManager {
return $preview;
}
/**
* Get the terms and condition table (only for maintenance)
* @param int offset
@ -183,7 +194,8 @@ class LegalManager {
* @param int column
* @return array
*/
public static function get_legal_data ($from, $number_of_items, $column) {
public static function get_legal_data($from, $number_of_items, $column)
{
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
$from = intval($from);
@ -218,12 +230,14 @@ class LegalManager {
* Gets the number of terms and conditions available
* @return int
*/
public static function count() {
public static function count()
{
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$sql = "SELECT count(*) as count_result FROM $legal_conditions_table ORDER BY legal_id DESC ";
$result = Database::query($sql);
$url = Database::fetch_array($result,'ASSOC');
$result = $url['count_result'];
return $result;
}
@ -233,12 +247,14 @@ class LegalManager {
* @param int The language id
* @return int The current type of terms and conditions
*/
public static function get_type_of_terms_and_conditions ($legal_id,$language_id) {
public static function get_type_of_terms_and_conditions ($legal_id,$language_id)
{
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$legal_id=Database::escape_string($legal_id);
$language_id=Database::escape_string($language_id);
$sql='SELECT type FROM '.$legal_conditions_table.' WHERE legal_id="'.$legal_id.'" AND language_id="'.$language_id.'"';
$rs=Database::query($sql);
$sql = 'SELECT type FROM '.$legal_conditions_table.' WHERE legal_id="'.$legal_id.'" AND language_id="'.$language_id.'"';
$rs = Database::query($sql);
return Database::result($rs,0,'type');
}
}

@ -292,6 +292,7 @@ class Plugin
{
// Check whether the language strings for the plugin have already been
// loaded. If so, no need to load them again.
if (is_null($this->strings)) {
global $language_interface;
$root = api_get_path(SYS_PLUGIN_PATH);
@ -455,7 +456,7 @@ class Plugin
*/
public function install_course_fields_in_all_courses($add_tool_link = true)
{
// Update existing courses to add conference settings
// Update existing courses to add plugin settings
$t_courses = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT id FROM $t_courses ORDER BY id";
$res = Database::query($sql);

@ -175,7 +175,7 @@ if (!empty($_SESSION['_user']['user_id']) && !($login || $logout)) {
unset($_user['user_id']);
}
//Platform legal terms and conditions
// Platform legal terms and conditions
if (api_get_setting('allow_terms_conditions') == 'true') {
if (isset($_POST['login']) && isset($_POST['password']) &&
isset($_SESSION['term_and_condition']['user_id'])

Loading…
Cancel
Save