Browse Source

Minor - format code, fix sql error

Julio Montoya 6 years ago
parent
commit
b8d62d612d
2 changed files with 13 additions and 13 deletions
  1. 3 3
      main/auth/inscription.php
  2. 10 10
      main/inc/lib/legal.lib.php

+ 3 - 3
main/auth/inscription.php

@@ -82,7 +82,7 @@ if ($extraConditions && isset($extraConditions['conditions'])) {
 
 $form = new FormValidator('registration');
 $user_already_registered_show_terms = false;
-if (api_get_setting('allow_terms_conditions') == 'true') {
+if (api_get_setting('allow_terms_conditions') === 'true') {
     $user_already_registered_show_terms = isset($_SESSION['term_and_condition']['user_id']);
 }
 
@@ -505,7 +505,7 @@ if (!empty($_GET['openid_msg']) && $_GET['openid_msg'] == 'idnotfound') {
 
 $showTerms = false;
 // Terms and conditions
-if (api_get_setting('allow_terms_conditions') == 'true' && $user_already_registered_show_terms) {
+if (api_get_setting('allow_terms_conditions') === 'true' && $user_already_registered_show_terms) {
     if (!api_is_platform_admin()) {
         if (api_get_setting('show_terms_if_profile_completed') === 'true') {
             $userInfo = api_get_user_info();
@@ -648,7 +648,7 @@ if ($form->validate()) {
         $values['official_code'] = api_strtoupper($values['username']);
     }
 
-    if (api_get_setting('login_is_email') == 'true') {
+    if (api_get_setting('login_is_email') === 'true') {
         $values['username'] = $values['email'];
     }
 

+ 10 - 10
main/inc/lib/legal.lib.php

@@ -27,23 +27,23 @@ class LegalManager
      */
     public static function add($language, $content, $type, $changes)
     {
-        $legal_table = Database::get_main_table(TABLE_MAIN_LEGAL);
+        $legalTable = Database::get_main_table(TABLE_MAIN_LEGAL);
         $last = self::get_last_condition($language);
         $type = (int) $type;
         $time = time();
 
         if ($last['content'] != $content) {
-            $version = (int) self::get_last_condition_version($language);
+            $version = self::getLastVersion($language);
             $version++;
             $params = [
                 'language_id' => $language,
                 'content' => $content,
                 'changes' => $changes,
                 'type' => $type,
-                'version' => (int) $version,
+                'version' => $version,
                 'date' => $time,
             ];
-            Database::insert($legal_table, $params);
+            Database::insert($legalTable, $params);
 
             return true;
         } elseif ($last['type'] != $type && $language == $last['language_id']) {
@@ -54,7 +54,7 @@ class LegalManager
                 'type' => $type,
                 'date' => $time,
             ];
-            Database::update($legal_table, $params, ['id => ?' => $id]);
+            Database::update($legalTable, $params, ['id = ?' => $id]);
 
             return true;
         } else {
@@ -68,9 +68,9 @@ class LegalManager
     public static function delete($id)
     {
         /*
-        $legal_table = Database::get_main_table(TABLE_MAIN_LEGAL);
+        $legalTable = Database::get_main_table(TABLE_MAIN_LEGAL);
         $id = (int) $id;
-        $sql = "DELETE FROM $legal_table WHERE id = '".$id."'";
+        $sql = "DELETE FROM $legalTable WHERE id = '".$id."'";
         */
     }
 
@@ -79,9 +79,9 @@ class LegalManager
      *
      * @param int $language language id
      *
-     * @return array all the info of a Term and condition
+     * @return int
      */
-    public static function get_last_condition_version($language)
+    public static function getLastVersion($language)
     {
         $table = Database::get_main_table(TABLE_MAIN_LEGAL);
         $language = (int) $language;
@@ -91,7 +91,7 @@ class LegalManager
         $result = Database::query($sql);
         $row = Database::fetch_array($result);
         if (Database::num_rows($result) > 0) {
-            return $row['version'];
+            return (int) $row['version'];
         } else {
             return 0;
         }