Julio Montoya 12 years ago
parent
commit
d97cb1bbdf

+ 14 - 45
main/admin/legal_add.php

@@ -8,8 +8,6 @@ $this_section = SECTION_PLATFORM_ADMIN;
 
 api_protect_admin_script();
 
-require_once api_get_path(LIBRARY_PATH).'legal.lib.php';
-
 // Create the form
 $form = new FormValidator('addlegal');
 
@@ -78,22 +76,8 @@ if( $form->validate()) {
 				}
 			}
 		}
-} else {
-	/*
-	if (!isset($_POST['language'])) {
-		$language = api_get_setting('platformLanguage');
-		$language = api_get_language_id($language);
-		$term_preview = LegalManager::get_last_condition($language);
-		$defaults['type']=$term_preview['type'];
-		if (!$term_preview) {
-			// there are not terms and conditions
-			$term_preview['type']=-1;
-			$defaults['type']=0;
-		}
-		$defaults['content']=$term_preview['content'];
-		$defaults['changes']=$term_preview['changes'];
-	}*/
 }
+
 $form->setDefaults($default);
 
 if(isset($_POST['send'])) {
@@ -103,43 +87,29 @@ $token = Security::get_token();
 
 $form->addElement('hidden','sec_token');
 $form->setConstants(array('sec_token' => $token));
-
-$text  = '<div class="row">
-		  	<div class="label"></div>
-			<div class="formw">
-				'.get_lang('DisplayTermsConditions').'
-			</div>
-		 </div>';
-
-$form->addElement('html',$text);
-
-//$form->addElement('select_language', 'language', get_lang('Language'),null,array('id'=>'language','onchange'=>'sendlang();'));
-
+$form->addElement('label', null, get_lang('DisplayTermsConditions'));
 
 if (isset($_POST['language'])) {
-//$form->addElement('html_editor', 'content', null, null, array('ToolbarSet' => 'Basic', 'Width' => '100%', 'Height' => '250'));
+
 	$form->addElement('static', Security::remove_XSS($_POST['language']));
 	$form->addElement('hidden', 'language',Security::remove_XSS($_POST['language']));
 	$form->add_html_editor('content', get_lang('Content'), true, false, array('ToolbarSet' => 'terms_and_conditions', 'Width' => '100%', 'Height' => '250'));
-	//$form->addElement('textarea', 'content', get_lang('Content'),array('cols'=>'120','rows'=>'10'));
+	
 	$form->addElement('radio', 'type', '', get_lang('HTMLText') ,'0');
 	$form->addElement('radio', 'type', '', get_lang('PageLink') ,'1');
 	$form->addElement('textarea', 'changes', get_lang('ExplainChanges'),array('width'=>'20'));
 
-	$preview = LegalManager::show_last_condition($term_preview);
+    
+	$preview = LegalManager::show_last_condition($term_preview);    
+    
 	if ($term_preview['type']!=-1) {
-		$term_preview  = '<div class="row">
-				<div class="label">'.get_lang('Preview').'</div>
-				<div class="formw">
-				'.$preview.'
-				</div>
-				</div>';
-		$form->addElement('html',$term_preview);
+		$form->addElement('label', get_lang('Preview'),  $preview);
 	}
+    
 	// Submit & preview button
-
-		$navigator_info = api_get_navigator();
-		//ie6 fix
+    $navigator_info = api_get_navigator();
+    
+    //ie6 fix
 	if ($navigator_info['name']=='Internet Explorer' &&  $navigator_info['version']=='6') {
 		$buttons = '<div class="row" align="center">
 				<div class="formw">
@@ -163,7 +133,7 @@ if (isset($_POST['language'])) {
 	$form->addElement('select_language', 'language', get_lang('Language'),null,array());
 	$buttons = '<div class="row">
 					<div class="formw">
-					<button type="submit" class="save" 	 name="send" value="load">'.get_lang('Load').'</button>
+					<button type="submit" class="save" name="send" value="load">'.get_lang('Load').'</button>
 					</div>
 				</div>';
 	$form->addElement('html',$buttons);
@@ -198,5 +168,4 @@ if (isset ($_GET['action'])) {
 }
 
 $form->setDefaults($defaults);
-$form->display();
-?>
+$form->display();

+ 18 - 34
main/auth/inscription.php

@@ -13,8 +13,6 @@ if (!empty($_POST['language'])) { //quick hack to adapt the registration form re
 require_once '../inc/global.inc.php';
 require_once api_get_path(CONFIGURATION_PATH).'profile.conf.php';
 require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
-require_once api_get_path(LIBRARY_PATH).'legal.lib.php';
-//require_once api_get_path(LIBRARY_PATH).'custompages.lib.php';moved to autoload
 
 if (!empty($_SESSION['user_language_choice'])) {
     $user_selected_language = $_SESSION['user_language_choice'];
@@ -248,8 +246,6 @@ if ($display_all_form) {
     }
 }
 
-$form->addElement('style_submit_button', 'submit', get_lang('RegisterUser'), 'class="btn"');
-
 if (isset($_SESSION['user_language_choice']) && $_SESSION['user_language_choice'] != '') {
     $defaults['language'] = $_SESSION['user_language_choice'];
 } else {
@@ -324,7 +320,6 @@ if (!CustomPages::enabled()) {
         }
     }
 
-
     if (file_exists($home.'register_top_'.$user_selected_language.'.html')) {
         $home_top_temp = @(string)file_get_contents($home.'register_top_'.$user_selected_language.'.html');
         $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
@@ -349,13 +344,12 @@ if (!CustomPages::enabled()) {
     }
 }
 
-
-
 // Terms and conditions
 if (api_get_setting('allow_terms_conditions') == 'true') {
     $language = api_get_interface_language();
     $language = api_get_language_id($language);
     $term_preview = LegalManager::get_last_condition($language);
+    
     if (!$term_preview) {
         //we load from the platform
         $language = api_get_setting('platformLanguage');
@@ -367,6 +361,7 @@ if (api_get_setting('allow_terms_conditions') == 'true') {
             $term_preview = LegalManager::get_last_condition($language);
         }
     }
+    
     // Version and language
     $form->addElement('hidden', 'legal_accept_type', $term_preview['version'].':'.$term_preview['language_id']);
     $form->addElement('hidden', 'legal_info', $term_preview['legal_id'].':'.$term_preview['language_id']);
@@ -374,25 +369,19 @@ if (api_get_setting('allow_terms_conditions') == 'true') {
     if (isset($_SESSION['info_current_user'][1]) && isset($_SESSION['info_current_user'][2])) {
         $form->addElement('hidden', 'login', $_SESSION['info_current_user'][1]);
         $form->addElement('hidden', 'password', $_SESSION['info_current_user'][2]);
-    }
+    }    
     if ($term_preview['type'] == 1) {
         $form->addElement('checkbox', 'legal_accept', null, get_lang('IHaveReadAndAgree').'&nbsp;<a href="inscription.php?legal" target="_blank">'.get_lang('TermsAndConditions').'</a>');
         $form->addRule('legal_accept',  get_lang('ThisFieldIsRequired'), 'required');
     } else {
         if (!empty($term_preview['content'])) {
-            $preview = LegalManager::show_last_condition($term_preview);
-            $term_preview  = '<div class="row">
-                    <div class="label">'.get_lang('TermsAndConditions').'</div>
-                    <div class="formw">
-                    '.$preview.'
-                    <br />
-                    </div>
-                    </div>';
-            $form->addElement('html', $term_preview);
+            $preview = LegalManager::show_last_condition($term_preview);    
+            $form->addElement('label', get_lang('TermsAndConditions'), $preview);
         }
     }
 }
 
+$form->addElement('button', 'submit', get_lang('RegisterUser'));
 
 if ($form->validate()) {
     /*
@@ -413,7 +402,6 @@ if ($form->validate()) {
       $values['username'] = $values['email'];  
     }
 
-
     // creating a new user
     $user_id = UserManager::create_user($values['firstname'], $values['lastname'], $values['status'], $values['email'], $values['username'], $values['pass1'], $values['official_code'], $values['language'], $values['phone'], $picture_uri);
 
@@ -508,6 +496,7 @@ if ($form->validate()) {
                 $emailsubject	 = get_lang('ApprovalForNewAccount',null,$values['language']).': '.$values['username'];
                 $emailbody		 = get_lang('ApprovalForNewAccount',null,$values['language'])."\n";
                 $emailbody		.= get_lang('UserName',null,$values['language']).': '.$values['username']."\n";
+                
                 if (api_is_western_name_order()) {
                     $emailbody	.= get_lang('FirstName',null,$values['language']).': '.$values['firstname']."\n";
                     $emailbody	.= get_lang('LastName',null,$values['language']).': '.$values['lastname']."\n";
@@ -532,9 +521,7 @@ if ($form->validate()) {
             exit;
         }
 
-        /*
-                  SESSION REGISTERING
-         */
+        /* SESSION REGISTERING */
         $_user['firstName'] = stripslashes($values['firstname']);
         $_user['lastName'] 	= stripslashes($values['lastname']);
         $_user['mail'] 		= $values['email'];
@@ -551,9 +538,7 @@ if ($form->validate()) {
 
         Session::write('user_last_login_datetime',$user_last_login_datetime);
 
-        /*
-                     EMAIL NOTIFICATION
-         */
+        /* EMAIL NOTIFICATION */
 
         if (strpos($values['email'], '@') !== false) {
             // Let us predefine some variables. Be sure to change the from address!
@@ -589,8 +574,7 @@ if ($form->validate()) {
         $display_text.= '<p>'.get_lang('MailHasBeenSent',null,$_user['language']).'.</p>';
     }
     $button_text = '';
-    if ($is_allowedCreateCourse) {
-        
+    if ($is_allowedCreateCourse) {        
         $display_text .= '<p>'. get_lang('NowGoCreateYourCourse',null,$_user['language']). ".</p>\n";
         $action_url = '../create_course/add_course.php';
         $button_text = api_get_setting('course_validation') == 'true'
@@ -608,16 +592,16 @@ if ($form->validate()) {
     // ?uidReset=true&uidReq=$_user['user_id']
 
     $display_text .= '<form action="'. $action_url. '"  method="post">'. "\n". '<button type="submit" class="next" name="next" value="'. get_lang('Next',null,$_user['language']). '" validationmsg=" '. get_lang('Next',null,$_user['language']). ' ">'. $button_text. '</button>'. "\n". '</form><br />'. "\n";
-  if (CustomPages::enabled()) {
-    CustomPages::display(CustomPages::REGISTRATION_FEEDBACK, array('info' => $display_text));
-  }
+    if (CustomPages::enabled()) {
+        CustomPages::display(CustomPages::REGISTRATION_FEEDBACK, array('info' => $display_text));
+    }
     echo $display_text;
 } else {
   // Custom pages
-  if (CustomPages::enabled()) {
-    CustomPages::display(CustomPages::REGISTRATION, array('form' => $form));
-  } else {
-    $form->display();
-  }
+    if (CustomPages::enabled()) {
+        CustomPages::display(CustomPages::REGISTRATION, array('form' => $form));
+    } else {
+        $form->display();
+    }
 }
 Display :: display_footer();

+ 10 - 18
main/inc/global.inc.php

@@ -24,21 +24,10 @@
 // Showing/hiding error codes in global error messages.
 define('SHOW_ERROR_CODES', false);
 
-// PHP version requirement.
-define('REQUIRED_PHP_VERSION', '5');
-
 // Determine the directory path where this current file lies.
 // This path will be useful to include the other intialisation files.
 $includePath = dirname(__FILE__);
 
-// PHP version check.
-if (!function_exists('version_compare') || version_compare(phpversion(), REQUIRED_PHP_VERSION, '<')) {
-    $global_error_code = 1;
-    // Incorrect PHP version.
-    require $includePath.'/global_error_message.inc.php';
-    die();
-}
-
 // @todo Isn't this file renamed to configuration.inc.php yet?
 // Include the main Chamilo platform configuration file.
 $main_configuration_file_path = $includePath.'/conf/configuration.php';
@@ -76,9 +65,12 @@ if (empty($_configuration['system_version'])) {
 $_configuration['dokeos_version']       = $_configuration['system_version'];
 $_configuration['dokeos_stable']        = $_configuration['system_stable'];
 
+
 // Include the main Chamilo platform library file.
 require_once $includePath.'/lib/main_api.lib.php';
 
+check_php_version($includePath.'/');
+
 // Do not over-use this variable. It is only for this script's local use.
 $lib_path = api_get_path(LIBRARY_PATH);
 
@@ -95,8 +87,8 @@ ini_set('auto_detect_line_endings', '1');
 require_once dirname(__FILE__).'/autoload.inc.php';
 
 require_once $lib_path.'database.lib.php';
-require_once $lib_path.'template.lib.php';
-require_once $lib_path.'display.lib.php';
+//require_once $lib_path.'template.lib.php'; moved to autoload
+//require_once $lib_path.'display.lib.php';
 require_once $lib_path.'text.lib.php';
 //require_once $lib_path.'image.lib.php';   moved to autoload
 require_once $lib_path.'array.lib.php';
@@ -107,13 +99,13 @@ require_once $lib_path.'events.lib.inc.php';
 
 require_once $lib_path.'model.lib.php';
 //require_once $lib_path.'sortable_table.class.php';  moved to autoload
-require_once $lib_path.'usermanager.lib.php';
-require_once $lib_path.'message.lib.php';
-require_once $lib_path.'social.lib.php';
-require_once $lib_path.'notification.lib.php';
+//require_once $lib_path.'usermanager.lib.php'; moved to autoload
+//require_once $lib_path.'message.lib.php'; moved to autoload
+//require_once $lib_path.'social.lib.php'; moved to autoload
+//require_once $lib_path.'notification.lib.php'; moved to autoload
 require_once $lib_path.'course.lib.php';
 //require_once $lib_path.'sessionmanager.lib.php'; moved to autoload
-require_once $lib_path.'tracking.lib.php';
+//require_once $lib_path.'tracking.lib.php'; moved to autoload
 
 //require_once $lib_path.'formvalidator/FormValidator.class.php'; moved to autoload
 require_once $lib_path.'online.inc.php';

+ 22 - 21
main/inc/global_error_message.inc.php

@@ -27,7 +27,8 @@ $ErrorCode = 'Error code';
 
 // Error code 1.
 $IncorrectPhpVersionTitle = 'Incorrect PHP version';
-$IncorrectPhpVersionDescription = 'Scripting language version %s1 on your server is incorrect. PHP %s2 should be supported. %s3 Read the installation guide.';
+$IncorrectPhpVersionDescription = 'Warning: we have detected that your version of PHP is %s1. To install Chamilo, you need to have PHP %s2 or superior. If you don\'t know what we\'re talking about, please contact your hosting provider or your support team. 
+    %s3 Read the installation guide.';
 
 // Error code 2.
 $InstallationTitle = 'Chamilo has not been installed';
@@ -86,12 +87,10 @@ if (is_int($global_error_code) && $global_error_code > 0) {
         $css_base_chamilo_file = $root_sys.$css_item;
         if (file_exists($css_base_chamilo_file)) {            
             $css_def .= @file_get_contents($css_base_chamilo_file);
-        }        
-    }
+        }
+    }    
     
-    
-    $css_def = str_replace("@import url('bootstrap.css');", '', $css_def);    
-	$css_def = str_replace('behavior:url("/main/css/csshover3.htc");', '', $css_def);    
+    $css_def = str_replace("@import url('bootstrap.css');", '', $css_def);
 	$css_def = str_replace('main/', $root_rel.'main/', $css_def);
 	$css_def = str_replace('images/', $root_rel.$css_path.$theme.'images/', $css_def);
 	$css_def = str_replace('../../img/', $root_rel.'main/img/', $css_def);
@@ -111,7 +110,7 @@ if (is_int($global_error_code) && $global_error_code > 0) {
 				$length = strlen($IncorrectPhpVersionDescription);
 				$read_installation_guide = substr($IncorrectPhpVersionDescription, $pos + 3, $length);
 				$IncorrectPhpVersionDescription = substr($IncorrectPhpVersionDescription, 0, $pos);
-				$IncorrectPhpVersionDescription .= '<br /><a href="'.$installation_guide_url.'" target="_blank">'.$read_installation_guide.'</a>';
+				$IncorrectPhpVersionDescription .= '<br /><a class="btn" href="'.$installation_guide_url.'" target="_blank">'.$read_installation_guide.'</a>';
 			}
 			$global_error_message['description'] = $IncorrectPhpVersionDescription;
 			break;
@@ -179,22 +178,24 @@ if (is_int($global_error_code) && $global_error_code > 0) {
 		</head>
 		<body>
 		<div id="wrapper">
-			<div id="header">				
-                <div id="logo">    
-                    <img vspace="10" hspace="10" alt="Chamilo" src="{CHAMILO_LOGO}">        
-                </div>				
-				
+            <div id="main" class="container">
+                <header>
+                    <div class="row">
+                    <div id="header_left" class="span4">
+                        <div id="logo">
+                            <img vspace="10" hspace="10" alt="Chamilo" src="{CHAMILO_LOGO}">        
+                        </div>
+                    </div>                
+                </header>	
                 <ul class="breadcrumb">
                     <li><a href="#">{SECTION}</a></li>
-                </ul>				
-			</div>
-			<div class="clear"> </div>
-
-			<div id="main">
-				<div style="text-align: center;">
-						{DESCRIPTION}
-						{CODE}
-				</div>
+                </ul>
+                <section>
+                    <div style="text-align:center">
+                        {DESCRIPTION}
+                        {CODE}				
+                    </div>
+                </section>        
 			</div>
 			<div class="push"/></div>
 		</div>

+ 2 - 2
main/inc/lib/diagnoser.lib.php

@@ -98,8 +98,8 @@ class Diagnoser
         // General Functions
 
         $version = phpversion();
-        $status = $version > MIN_PHP_VERSION ? self :: STATUS_OK : self :: STATUS_ERROR;
-        $array[] = $this->build_setting($status, '[PHP]', 'phpversion()', 'http://www.php.net/manual/en/function.phpversion.php', phpversion(), '>= '.MIN_PHP_VERSION, null, get_lang('PHPVersionInfo'));
+        $status = $version > REQUIRED_PHP_VERSION ? self :: STATUS_OK : self :: STATUS_ERROR;
+        $array[] = $this->build_setting($status, '[PHP]', 'phpversion()', 'http://www.php.net/manual/en/function.phpversion.php', phpversion(), '>= '.REQUIRED_PHP_VERSION, null, get_lang('PHPVersionInfo'));
 
         $setting = ini_get('output_buffering');
         $req_setting = 1;

+ 18 - 5
main/inc/lib/main_api.lib.php

@@ -13,6 +13,9 @@
  * Constants declaration
  */
 
+// PHP version requirement.
+define('REQUIRED_PHP_VERSION', '5.3');
+
 // USER STATUS CONSTANTS
 /** global status of a user: student */
 define('STUDENT', 5);
@@ -28,7 +31,7 @@ define('ANONYMOUS', 6);
  * the teacher through HTMLPurifier */
 define('COURSEMANAGERLOWSECURITY', 10);
 
-define('MIN_PHP_VERSION', '5.2.4');
+
 
 // Table of status
 $_status_list[COURSEMANAGER]    = 'teacher';        // 1
@@ -179,8 +182,6 @@ define('IS_PHP_SUP_OR_EQ_53', ($php_version >= 5.3));
 define('IS_PHP_SUP_OR_EQ_52', ($php_version >= 5.2 && !IS_PHP_53));
 define('IS_PHP_SUP_OR_EQ_51', ($php_version >= 5.1 && !IS_PHP_52 && !IS_PHP_53));
 
-
-
 // This constant is a result of Windows OS detection, it has a boolean value:
 // true whether the server runs on Windows OS, false otherwise.
 define('IS_WINDOWS_OS', api_is_windows_os());
@@ -1653,7 +1654,7 @@ function api_set_anonymous() {
  */
 function api_get_last_failure() {
     global $api_failureList;
-    return array_pop($api_failureList);
+    return $api_failureList[count($api_failureList) - 1];
 }
 
 /**
@@ -1700,7 +1701,7 @@ class api_failure {
     function get_last_failure() {
         global $api_failureList;
         if (count($api_failureList) == 0) { return ''; }
-        return array_pop($api_failureList);
+        return $api_failureList[count($api_failureList) - 1];
     }
 }
 
@@ -5803,3 +5804,15 @@ function block_course_item_locked_by_gradebook($item_id, $link_type, $course_cod
         api_not_allowed(true, $message);
     }    
 }
+
+function check_php_version($my_inc_path = null) {
+    if (!function_exists('version_compare') || version_compare( phpversion(), REQUIRED_PHP_VERSION, '<')) {
+        $global_error_code = 1;
+        // Incorrect PHP version
+        $global_page = $my_inc_path.'global_error_message.inc.php';
+        if (file_exists($global_page)) {
+            require $global_page;    
+        }
+        exit;
+    }
+}

+ 3 - 10
main/install/index.php

@@ -25,23 +25,16 @@ define('MAX_FORM_FIELD_LENGTH',                 80);
 
 /*		PHP VERSION CHECK */
 
-// PHP version requirement.
-define('REQUIRED_PHP_VERSION', '5');
+// Including necessary libraries.
+require_once '../inc/lib/main_api.lib.php';
 
-if (!function_exists('version_compare') || version_compare( phpversion(), REQUIRED_PHP_VERSION, '<')) {
-	$global_error_code = 1;
-	// Incorrect PHP version.
-	require '../inc/global_error_message.inc.php';
-	die();
-}
+check_php_version('../inc/');
 
 /*		INITIALIZATION SECTION */
 
 ob_implicit_flush(true);
 session_start();
 
-// Including necessary libraries.
-require_once '../inc/lib/main_api.lib.php';
 require_once api_get_path(LIBRARY_PATH).'session.class.php';
 require_once api_get_path(LIBRARY_PATH).'database.lib.php';
 require_once api_get_path(LIBRARY_PATH).'log.class.php';

+ 2 - 2
main/install/install.lib.php

@@ -1043,9 +1043,9 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u
     echo '<div class="RequirementContent">';
     echo '<table class="requirements">
             <tr>
-                <td class="requirements-item">'.get_lang('PHPVersion').'>= '.MIN_PHP_VERSION.'</td>
+                <td class="requirements-item">'.get_lang('PHPVersion').'>= '.REQUIRED_PHP_VERSION.'</td>
                 <td class="requirements-value">';
-    if (phpversion() < MIN_PHP_VERSION) {
+    if (phpversion() < REQUIRED_PHP_VERSION) {
         echo '<strong><font color="red">'.get_lang('PHPVersionError').'</font></strong>';
     } else {
         echo '<strong><font color="green">'.get_lang('PHPVersionOK'). ' '.phpversion().'</font></strong>';