Преглед на файлове

Move prevent_multiple_simultaneous_login setting to database - refs #7794

Yannick Warnier преди 9 години
родител
ревизия
628e0ccd81
променени са 4 файла, в които са добавени 77 реда и са изтрити 7 реда
  1. 71 0
      app/Migrations/Schema/V110/Version20150813143000.php
  2. 1 3
      main/inc/lib/online.inc.php
  3. 0 2
      main/install/configuration.dist.php
  4. 5 2
      main/install/data.sql

+ 71 - 0
app/Migrations/Schema/V110/Version20150813143000.php

@@ -0,0 +1,71 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Application\Migrations\Schema\V110;
+
+use Application\Migrations\AbstractMigrationChamilo;
+use Doctrine\DBAL\Schema\Schema;
+
+/**
+ * Calendar color
+ */
+class Version20150813143000 extends AbstractMigrationChamilo
+{
+    /**
+     * @param Schema $schema
+     */
+    public function up(Schema $schema)
+    {
+        $this->addSettingCurrent(
+            'prevent_multiple_simultaneous_login',
+            null,
+            'radio',
+            'Security',
+            'false',
+            'PreventMultipleSimultaneousLoginTitle',
+            'PreventMultipleSimultaneousLoginComment',
+            null,
+            null,
+            1,
+            true,
+            false,
+            [
+                0 => ['value' => 'true', 'text' => 'Yes'],
+                1 => ['value' => 'false', 'text' => 'No']
+            ]
+        );
+    }
+
+    /**
+     * @param Schema $schema
+     */
+    public function down(Schema $schema)
+    {
+        $entityManage = $this->getEntityManager();
+
+        $deleteOptions = $entityManage->createQueryBuilder();
+
+        $deleteOptions->delete('ChamiloCoreBundle:SettingsOptions', 'o')
+            ->andWhere(
+                $deleteOptions->expr()->in(
+                    'o.variable',
+                    [
+                        'prevent_multiple_simultaneous_login'
+                    ]
+                )
+            );
+        $deleteOptions->getQuery()->execute();
+
+        $deleteSettings = $entityManage->createQueryBuilder();
+        $deleteSettings->delete('ChamiloCoreBundle:SettingsCurrent', 's')
+            ->andWhere(
+                $deleteSettings->expr()->in(
+                    's.variable',
+                    [
+                        'prevent_multiple_simultaneous_login'
+                    ]
+                )
+            );
+        $deleteSettings->getQuery()->execute();
+    }
+}

+ 1 - 3
main/inc/lib/online.inc.php

@@ -57,9 +57,7 @@ function preventMultipleLogin($userId)
     $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
     $userId = intval($userId);
 
-    if (isset($_configuration['prevent_multiple_simultaneous_login']) &&
-        $_configuration['prevent_multiple_simultaneous_login']
-    ) {
+    if (api_get_settings('prevent_multiple_simultaneous_login') === 'true') {
         if (!empty($userId) && !api_is_anonymous()) {
 
             $isFirstLogin = Session::read('first_user_login');

+ 0 - 2
main/install/configuration.dist.php

@@ -176,8 +176,6 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
 //);
 // Define the frequency to which the data must be stored in the database
 //$_configuration['session_stored_after_n_times'] = 10;
-// One connection per user
-//$_configuration['prevent_multiple_simultaneous_login'] = false;
 // If the database is down this css style will be used to show the errors.
 //$_configuration['theme_fallback'] = 'chamilo'; // (chamilo theme)
 // The default template that will be use in the system.

+ 5 - 2
main/install/data.sql

@@ -1719,7 +1719,8 @@ VALUES
 ('dropbox_hide_course_coach', NULL, 'radio', 'Tools', 'false', 'DropboxHideCourseCoachTitle', 'DropboxHideCourseCoachComment', NULL, NULL, 1),
 ('sso_force_redirect', NULL, 'radio', 'Security', 'false', 'SSOForceRedirectTitle', 'SSOForceRedirectComment', NULL, NULL, 1),
 ('session_course_ordering', NULL, 'radio', 'Session', 'false', 'SessionCourseOrderingTitle', 'SessionCourseOrderingComment', NULL, NULL, 1),
-('gamification_mode', NULL, 'radio', 'Platform', '0', 'GamificationModeTitle', 'GamificationModeComment', NULL, NULL, 1);
+('gamification_mode', NULL, 'radio', 'Platform', '0', 'GamificationModeTitle', 'GamificationModeComment', NULL, NULL, 1),
+('prevent_multiple_simultaneous_login', NULL, 'radio', 'Security', 'false', 'PreventMultipleSimultaneousLoginTitle', 'PreventMultipleSimultaneousLoginComment', NULL, NULL, 1);
 
 INSERT INTO settings_options (variable, value, display_text)
 VALUES
@@ -1795,6 +1796,8 @@ VALUES
 ('session_course_ordering', 'true', 'Yes'),
 ('session_course_ordering', 'false', 'No'),
 ('gamification_mode', '1', 'Yes'),
-('gamification_mode', '0', 'No');
+('gamification_mode', '0', 'No'),
+('prevent_multiple_simultaneous_login', '1', 'Yes'),
+('prevent_multiple_simultaneous_login', '0', 'No');
 
 UPDATE settings_current SET selected_value = '1.10.0.43' WHERE variable = 'chamilo_database_version';