Browse Source

Minor - Format code.

Julio Montoya 10 years ago
parent
commit
4375228b14
2 changed files with 115 additions and 58 deletions
  1. 79 38
      main/inc/lib/SequenceManager.php
  2. 36 20
      main/install/configuration.dist.php

+ 79 - 38
main/inc/lib/SequenceManager.php

@@ -1,6 +1,9 @@
 <?php
 /* For licensing terms, see /license.txt */
 
+/**
+ * Class SequenceManager
+ */
 class SequenceManager
 {
     const _debug = false;
@@ -17,7 +20,8 @@ class SequenceManager
         $row_entity_id = intval(Database::escape_string($row_entity_id));
         if ($row_entity_id > 0) {
             $seq_table = Database::get_main_table(TABLE_MAIN_SEQUENCE);
-            $sql = "SELECT sequence_row_entity_id FROM $seq_table WHERE sequence_row_entity_id_next = $row_entity_id";
+            $sql = "SELECT sequence_row_entity_id FROM $seq_table
+                    WHERE sequence_row_entity_id_next = $row_entity_id";
             $result = Database::query($sql);
             if (Database::num_rows($result) > 0) {
                 while ($temp_pre_req = Database::fetch_array($result, 'ASSOC')){
@@ -29,6 +33,12 @@ class SequenceManager
         return false;
     }
 
+    /**
+     * @param int $entity_id
+     * @param int $row_entity_id
+     * @param int $course_id
+     * @return array|bool
+     */
     public static function get_next_by_row_id($entity_id, $row_entity_id, $course_id = null)
     {
         if (self::_debug) {
@@ -62,11 +72,12 @@ class SequenceManager
                 return $next;
             }
         }
+
         return false;
     }
 
     /**
-     * @param $entity_id
+     * @param int $entity_id
      * @return array|bool
      */
     public static function get_entity_by_id($entity_id)
@@ -91,9 +102,9 @@ class SequenceManager
     }
 
     /**
-     * @param $row_entity_id
-     * @param null $user_id
-     * @param $session_id
+     * @param int $row_entity_id
+     * @param int $user_id
+     * @param int $session_id
      * @param int $rule_id
      * @return bool
      */
@@ -166,8 +177,11 @@ class SequenceManager
             $rule_id = intval($rule_id);
             $met_table = Database::get_main_table(TABLE_SEQUENCE_METHOD);
             $rul_met_table = Database::get_main_table(TABLE_SEQUENCE_RULE_METHOD);
-            $sql = "SELECT rm.sequence_method_id FROM $rul_met_table rm WHERE rc.sequence_rule_id = $rule_id";
-            $sql = "SELECT * FROM $met_table co WHERE co.id IN ($sql)";
+            $sql = "SELECT rm.sequence_method_id
+                    FROM $rul_met_table rm
+                    WHERE rc.sequence_rule_id = $rule_id";
+            $sql = "SELECT * FROM $met_table co
+                    WHERE co.id IN ($sql)";
             $result = Database::query($sql);
             if (Database::num_rows($result) > 0) {
                 while ($temp_method = Database::fetch_array($result, 'ASSOC')){
@@ -176,6 +190,7 @@ class SequenceManager
                 return $method;
             }
         }
+
         return false;
     }
 
@@ -191,7 +206,8 @@ class SequenceManager
         $row_entity_id = intval(Database::escape_string($row_entity_id));
         if ($row_entity_id > 0) {
             $val_table = Database::get_main_table(TABLE_SEQUENCE_VALUE);
-            $sql = "SELECT * FROM $val_table val WHERE val.sequence_row_entity_id = $row_entity_id";
+            $sql = "SELECT * FROM $val_table val
+                    WHERE val.sequence_row_entity_id = $row_entity_id";
             $result = Database::query($sql);
             if (Database::num_rows($result) > 0) {
                 while ($temp_value = Database::fetch_array($result, 'ASSOC')){
@@ -233,8 +249,8 @@ class SequenceManager
     }
 
     /**
-     * @param null $row_entity_id
-     * @param null $user_id
+     * @param int $row_entity_id
+     * @param int $user_id
      * @param $session_id
      * @param string $met_type
      * @param int $available
@@ -310,16 +326,18 @@ class SequenceManager
                         $result = Database::query($sql);
                     }
                 }
+
                 return true;
             }
         }
+
         return false;
     }
 
     /**
-     * @param null $row_entity_id
-     * @param null $user_id
-     * @param null $session_id
+     * @param int $row_entity_id
+     * @param int $user_id
+     * @param int $session_id
      * @param int $available
      * @param int $success
      * @return array|bool
@@ -372,9 +390,11 @@ class SequenceManager
                 while($temp_value = Database::fetch_array($result,'ASSOC')){
                     $value[] = $temp_value;
                 }
+
                 return $value;
             }
         }
+
         return false;
     }
 
@@ -397,6 +417,7 @@ class SequenceManager
                 return $var_array;
             }
         }
+
         return false;
     }
 
@@ -448,13 +469,15 @@ class SequenceManager
         $row_entity_id = intval(Database::escape_string($row_entity_id));
         $seq_table = Database::get_main_table(TABLE_MAIN_SEQUENCE);
         $val_table = Database::get_main_table(TABLE_SEQUENCE_VALUE);
-        $sql = "SELECT DISTINCT seq.sequence_row_entity_id, val.user_id FROM $seq_table seq, $val_table val
-            WHERE seq.is_part != 1
-            AND val.success = 0
-            AND val.user_id = $user_id
-            AND val.session_id = $session_id
-            AND val.sequence_row_entity_id = seq.sequence_row_entity_id
-            AND seq.sequence_row_entity_id_next = $row_entity_id";
+        $sql = "SELECT DISTINCT seq.sequence_row_entity_id, val.user_id
+                FROM $seq_table seq, $val_table val
+                WHERE
+                    seq.is_part != 1
+                    AND val.success = 0
+                    AND val.user_id = $user_id
+                    AND val.session_id = $session_id
+                    AND val.sequence_row_entity_id = seq.sequence_row_entity_id
+                    AND seq.sequence_row_entity_id_next = $row_entity_id";
         $result = Database::query($sql);
         while ($temp = Database::fetch_array($result, 'ASSOC')){
             $pre_req[$temp['user_id']] = $temp['sequence_row_entity_id'];
@@ -463,17 +486,27 @@ class SequenceManager
             if (self::get_value_by_user_id($row_entity_id, $user_id, $session_id) === false) {
                 self::temp_hack_4_insert(1, $row_entity_id, $user_id, 0, $session_id);
             }
-            self::execute_formulas_by_user_id($row_entity_id, $user_id, $session_id, 'pre', 0, null, null, $available_end_date);
+            self::execute_formulas_by_user_id(
+                $row_entity_id,
+                $user_id,
+                $session_id,
+                'pre',
+                0,
+                null,
+                null,
+                $available_end_date
+            );
             return true;
         } else {
             self::temp_hack_4_set_aval($row_entity_id, $user_id, $session_id, 0);
         }
+
         return false;
     }
 
     /**
-     * @param $row_entity_id
-     * @param $user_id
+     * @param int $row_entity_id
+     * @param int $user_id
      * @param $session_id
      * @param null $available_end_date
      */
@@ -535,6 +568,7 @@ class SequenceManager
                 return $row_entity;
             }
         }
+
         return array();
     }
 
@@ -554,22 +588,26 @@ class SequenceManager
         $c_id = intval(Database::escape_string($c_id));
         if ($row_id > 0 && $entity_id > 0 && $c_id > 0) {
             $row_table = Database::get_main_table(TABLE_SEQUENCE_ROW_ENTITY);
-            $sql = "SELECT row.* FROM $row_table row WHERE
-            row.sequence_type_entity_id = $entity_id AND
-            row.row_id = $row_id AND
-            row.c_id = $c_id LIMIT 0, 1";
+            $sql = "SELECT row.*
+                    FROM $row_table row
+                    WHERE
+                        row.sequence_type_entity_id = $entity_id AND
+                        row.row_id = $row_id AND
+                        row.c_id = $c_id LIMIT 0, 1";
             $result = Database::query($sql);
             if (Database::num_rows($result) > 0) {
+
                 return Database::fetch_array($result, 'ASSOC');
             }
         }
+
         return array();
     }
 
     /**
-     * @param $row_entity_id
-     * @param $user_id
-     * @param $session_id
+     * @param int $row_entity_id
+     * @param int $user_id
+     * @param int $session_id
      * @return mixed
      */
     public static function getValIdByRowEntityId($row_entity_id, $user_id, $session_id)
@@ -622,9 +660,9 @@ class SequenceManager
     }
 
     /**
-     * @param $entity_id
-     * @param $row_id
-     * @param $c_id
+     * @param int $entity_id
+     * @param int $row_id
+     * @param int $c_id
      * @param string $name
      * @return int
      */
@@ -644,11 +682,13 @@ class SequenceManager
         if ($row_id > 0 && $entity_id > 0 && $c_id > 0) {
             $row_table = Database::get_main_table(TABLE_SEQUENCE_ROW_ENTITY);
             $clp_table = Database::get_course_table(TABLE_LP_MAIN);
-            $sql = "SELECT row.id FROM $row_table row WHERE
-                row.sequence_type_entity_id = $entity_id AND
-                row.row_id = $row_id AND
-                row.c_id = $c_id
-                LIMIT 0, 1";
+            $sql = "SELECT row.id
+                    FROM $row_table row
+                    WHERE
+                        row.sequence_type_entity_id = $entity_id AND
+                        row.row_id = $row_id AND
+                        row.c_id = $c_id
+                    LIMIT 0, 1";
             $result = Database::query($sql);
             if (Database::num_rows($result) > 0) {
                 while ($temp_row_entity = Database::fetch_array($result, 'ASSOC')) {
@@ -1091,6 +1131,7 @@ class SequenceManager
         }
         return false;
     }
+
     public static function temp_hack_4_set_aval($row_entity_id, $user_id, $session_id, $available, $available_end_date = null) {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);

+ 36 - 20
main/install/configuration.dist.php

@@ -26,14 +26,14 @@
 /**
  * Database connection settings
  */
-// Your MySQL server
+// Database host
 $_configuration['db_host'] = '{DATABASE_HOST}';
-// Your MySQL username
+// Database name
+$_configuration['main_database'] = '{DATABASE_MAIN}';
+// Database username
 $_configuration['db_user'] = '{DATABASE_USER}';
-// Your MySQL password
+// Database password
 $_configuration['db_password'] = '{DATABASE_PASSWORD}';
-// main Chamilo database
-$_configuration['main_database'] = '{DATABASE_MAIN}';
 // Enable access to database management for platform admins.
 $_configuration['db_manager_enabled'] = false;
 
@@ -46,13 +46,16 @@ $_configuration['root_web'] = '{ROOT_WEB}';
 // Path to the webroot of system, example: /var/www/
 $_configuration['root_sys'] = '{ROOT_SYS}';
 
-// Path from your WWW-root to the root of your Chamilo installation, example: chamilo (this means chamilo is installed in /var/www/chamilo/
+// Path from your WWW-root to the root of your Chamilo installation,
+// example: chamilo (this means chamilo is installed in /var/www/chamilo/
 $_configuration['url_append'] = '{URL_APPEND_PATH}';
 
-// Directory of the Chamilo code. You could change this but it is not advised since this has not been tested yet.
+// Directory of the Chamilo code.
+// You could change this but it is not advised since this has not been tested yet.
 $_configuration['code_append'] = "main/";
 
-// Directory to store all course-related files. You could change this but it is not advised since this has not been tested yet.
+// Directory to store all course-related files.
+// You could change this but it is not advised since this has not been tested yet.
 $_configuration['course_folder'] = "courses/";
 
 // URL to your phpMyAdmin installation.
@@ -67,7 +70,7 @@ $_configuration['db_admin_path'] = '';
 // You can leave these lines uncommented even if you don't use CAS authentification
 $extAuthSource["cas"]["login"] = $_configuration['root_sys'].$_configuration['code_append']."auth/cas/login.php";
 $extAuthSource["cas"]["newUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/cas/newUser.php";
-//
+
 // NEW LDAP IMPLEMENTATION BASED ON external_login info
 // -> Uncomment the two lines bellow to activate LDAP AND edit main/auth/external_login/ldap.conf.php for configuration
 // $extAuthSource["extldap"]["login"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_login/login.ldap.php";
@@ -102,8 +105,10 @@ $_configuration[1]['hosting_limit_sessions'] = 0;
 // Set a maximum disk space used, in MB (set to 1024 for 1GB, 5120 for 5GB, etc)
 // Default (0) = no limit
 $_configuration[1]['hosting_limit_disk_space'] = 0;
-// Set a maximum number of usable courses. Default (0) = no limit. Should always be lower than the hosting_limit_courses.
-// If set, defining a course as "hidden" will free room for new courses (up to the hosting_limit_courses, if any value is set there).
+// Set a maximum number of usable courses. Default (0) = no limit.
+// Should always be lower than the hosting_limit_courses.
+// If set, defining a course as "hidden" will free room for
+// new courses (up to the hosting_limit_courses, if any value is set there).
 // hosting_limit_enabled_courses is the maximum number of courses that are *not* hidden.
 $_configuration[1]['hosting_limit_active_courses'] = 0;
 // Email to warn if limit was reached.
@@ -122,11 +127,20 @@ $_configuration['hosting_total_size_limit'] = 0;
 $_configuration['cdn_enable'] = false;
 // The following setting will be ignored if the previous one is set to false
 $_configuration['cdn'] = array(
-  //You can define several CDNs and split them by extensions
-  //Replace the following by your full CDN URL, which should point to
-  // your Chamilo's root directory. DO NOT INCLUDE a final slash! (won't work)
-    'http://cdn.chamilo.org' => array('.css','.js','.jpg','.jpeg','.png','.gif','.avi','.flv'),
-  // copy the line above and modify following your needs
+    // You can define several CDNs and split them by extensions
+    // Replace the following by your full CDN URL, which should point to
+    // your Chamilo's root directory. DO NOT INCLUDE a final slash! (won't work)
+    'http://cdn.chamilo.org' => array(
+        '.css',
+        '.js',
+        '.jpg',
+        '.jpeg',
+        '.png',
+        '.gif',
+        '.avi',
+        '.flv'
+    ),
+    // copy the line above and modify following your needs
 );
 
 /**
@@ -143,7 +157,7 @@ $_configuration['session_stored_in_db'] = false;
 // Session lifetime
 $_configuration['session_lifetime'] = SESSION_LIFETIME;
 // Activation for multi-url access
-//$_configuration['multiple_access_urls']					= true;
+//$_configuration['multiple_access_urls'] = true;
 $_configuration['software_name'] = 'Chamilo';
 $_configuration['software_url'] = 'http://www.chamilo.org/';
 //Deny the elimination of users
@@ -168,7 +182,8 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
 // Enable captcha
 //$_configuration['enable_captcha'] = true;
 //$_configuration['allow_captcha'] = true;
-// Prevent account from logging in for a certain amount of time if captcha is wrong for the specified number of times
+// Prevent account from logging in for a certain amount of time
+// if captcha is wrong for the specified number of times
 //$_configuration['captcha_number_mistakes_to_block_account'] = 5;
 // Prevent account from logging in for the specified number of minutes
 //$_configuration['captcha_time_to_block'] = 5;//minutes
@@ -263,7 +278,7 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
 //$_configuration['openbadges_backpack'] = 'https://backpack.openbadges.org/';
 // Custom name_order_conventions
 //$_configuration['name_order_conventions'] = array(
-//  'french' => array('format' => 'title last_name first_name',  'sort_by' => 'last_name')
+// 'french' => array('format' => 'title last_name first_name', 'sort_by' => 'last_name')
 //);
 // Shows a warning message explaining that the site uses cookies
 //$_configuration['cookie_warning'] = false;
@@ -282,7 +297,8 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
 //$_configuration['allow_delete_attendance'] = false;
 // Enable Gravatar profile image if no local image has been given
 //$_configuration['gravatar_enabled'] = true;
-// If Gravatar is enabled, tells which type of picture we want (default is "mm"). Options: mm | identicon | monsterid | wavatar
+// If Gravatar is enabled, tells which type of picture we want (default is "mm").
+// Options: mm | identicon | monsterid | wavatar
 //$_configuration['gravatar_type'] = 'mm';
 // Course log - Default columns to hide
 //$_configuration['course_log_hide_columns'] = array(1, 9);