Minor - format code.

1.9.x
Julio Montoya 11 years ago
parent 14d4fca65b
commit 9c8ddf56a9
  1. 1
      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. 76
      main/inc/lib/legal.lib.php
  6. 3
      main/inc/lib/plugin.class.php

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */
use \ChamiloSession as Session; use \ChamiloSession as Session;

@ -6,10 +6,6 @@
* @author Bart Mollet <bart.mollet@hogent.be> * @author Bart Mollet <bart.mollet@hogent.be>
* @package chamilo.backup * @package chamilo.backup
*/ */
/**
* Code
*/
/* INIT SECTION */
// Language files that need to be included // Language files that need to be included
$language_file = array('exercice', 'coursebackup', 'admin'); $language_file = array('exercice', 'coursebackup', 'admin');
@ -131,7 +127,9 @@ if ((isset($_POST['action']) &&
} }
} else { } else {
$user = api_get_user_info(); $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; $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'); $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; return $wanted_code;
} }
/** /**
* Gets the status of the users agreement in a course course-session * Gets the status of the users agreement in a course course-session
* *
* @param int user id * @param int $user_id
* @param string course code * @param string $course_code
* @param int session id * @param int $session_id
* @return boolean * @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); $user_id = intval($user_id);
$course_code = Database::escape_string($course_code); $course_code = Database::escape_string($course_code);
$session_id = intval($session_id); $session_id = intval($session_id);

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

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

@ -292,6 +292,7 @@ class Plugin
{ {
// Check whether the language strings for the plugin have already been // Check whether the language strings for the plugin have already been
// loaded. If so, no need to load them again. // loaded. If so, no need to load them again.
if (is_null($this->strings)) { if (is_null($this->strings)) {
global $language_interface; global $language_interface;
$root = api_get_path(SYS_PLUGIN_PATH); $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) 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); $t_courses = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT id FROM $t_courses ORDER BY id"; $sql = "SELECT id FROM $t_courses ORDER BY id";
$res = Database::query($sql); $res = Database::query($sql);

Loading…
Cancel
Save