Browse Source

Add initial branch_sync

Angel Fernando Quiroz Campos 8 years ago
parent
commit
033bfd98b3

+ 57 - 0
app/Migrations/Schema/V111/Version20160727155600.php

@@ -0,0 +1,57 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Application\Migrations\Schema\V111;
+
+use Application\Migrations\AbstractMigrationChamilo,
+    Doctrine\DBAL\Schema\Schema;
+use Chamilo\CoreBundle\Entity\BranchSync;
+
+/**
+ * Class Version20160727155600
+ * Add an initial branch_sync
+ * @package Application\Migrations\Schema\V111
+ */
+class Version20160727155600 extends AbstractMigrationChamilo
+{
+
+    /**
+     * @param Schema $schema
+     */
+    public function up(Schema $schema)
+    {
+        $em = $this->getEntityManager();
+
+        $cont = $em
+            ->createQuery('SELECT COUNT(bs.id) FROM ChamiloCoreBundle:BranchSync AS bs')
+            ->getSingleScalarResult();
+
+        if (!$cont) {
+            $branchSync = new BranchSync();
+            $branchSync
+                ->setBranchName('localhost')
+                ->setAccessUrlId(1);
+
+            $em->persist($branchSync);
+            $em->flush();
+        }
+    }
+
+    /**
+     * @param Schema $schema
+     */
+    public function down(Schema $schema)
+    {
+        $em = $this->getEntityManager();
+
+        $branchSync = $em
+            ->getRepository('ChamiloCoreBundle:BranchSync')
+            ->findOneBy([
+                'branchName' => 'localhost',
+                'accessUrlId' => 1
+            ]);
+
+        $em->remove($branchSync);
+        $em->flush();
+    }
+}

+ 4 - 0
main/install/data.sql

@@ -1882,3 +1882,7 @@ UPDATE settings_current SET selected_value = '1.11.0.6' WHERE variable = 'chamil
 INSERT INTO settings_current (variable, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('icons_mode_svg', NULL, 'radio', 'Tuning', 'false', 'IconsModeSVGTitle', 'IconsModeSVGComment', '', NULL, 1);
 INSERT INTO settings_options (variable, value, display_text) VALUES ('icons_mode_svg', 'true', 'Yes');
 INSERT INTO settings_options (variable, value, display_text) VALUES ('icons_mode_svg', 'false', 'No');
+
+INSERT INTO branch_sync (access_url_id, branch_name, unique_id, ssl_pub_key)
+VALUES
+(1, 'localhost', SHA1(UUID()), SHA1(UUID()));

+ 1 - 0
src/Chamilo/CoreBundle/Entity/BranchSync.php

@@ -204,6 +204,7 @@ class BranchSync
     public function __construct()
     {
         $this->uniqueId = sha1(uniqid());
+        $this->sslPubKey = sha1(uniqid());
         // $this->lastSyncTransDate = new \DateTime();
     }