]> _ Git - cubeextranet.git/commitdiff
done #928 @1
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 28 Nov 2016 12:24:56 +0000 (12:24 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 28 Nov 2016 12:24:56 +0000 (12:24 +0000)
inc/commons/class.common.core.php
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/DAO/class.ws.dao.book.php

index bd9bef9795093bf2c21aa3e2bcbe34d958972e10..badefc77e962b1f510e31509baded926469ff0d1 100644 (file)
@@ -438,6 +438,10 @@ class commonCore extends cubeCore {
                $db->book_short_url->index('index_book_short_url_long_url', 'BTREE', 'long_url');\r
                $db->book_short_url->index('index_book_short_url_book_id', 'BTREE', 'book_id');\r
                // .\r
+               // Books\r
+               $db->books_chapters_versions->book_id('integer', 0, false);\r
+               $db->books_chapters_versions->time('integer', 0, false);\r
+               $db->books_chapters_versions->chapters('text', 0, false);\r
                // Table des collections de fluidbooks\r
                $db->book_collection->collection_id('integer', 0, false);\r
                $db->book_collection->nom('varchar', 64, false);\r
index 625db5717267167cebea5cc2460903deb809beef..d12407c0b305ea1f3cd84b7dbbfbb32a491b7cbc 100644 (file)
@@ -938,6 +938,22 @@ class wsMaintenance {
                `gzip /home/extranet/www/fluidbook/docs/*/*.txt`;
        }
 
+
+       public static function restoreChapters($args) {
+               global $core;
+
+               $book_id = $args[0];
+               $r = $core->con->select('SELECT chapters FROM books_chapters_versions WHERE book_id=\'' . $core->con->escape($book_id) . '\' ORDER BY `time` DESC LIMIT 1');
+               while ($r->fetch()) {
+                       $c = $core->con->openCursor('books');
+                       $c->chapters = $r->chapters;
+                       $c->changedate = TIME;
+                       $c->update('WHERE book_id=\'' . $core->con->escape($book_id) . '\'');
+                       break;
+               }
+               echo $r->chapters;
+       }
+
        public static function offsetLinksPos($args) {
                global $core;
                $book_id = $args[0];
@@ -1111,4 +1127,5 @@ class wsMaintenance {
                echo '<pre>OK</pre>';
        }
 
+
 }
index 557d8f9e2da4e01f0f567a6985da8febb61dda6e..f4e6cbf6a0a0a98a2931f64fe0b18248471c4d22 100644 (file)
@@ -527,10 +527,25 @@ class wsDAOBook extends commonDAO {
                        $res[] = $c;
                }
 
+               $json_chapters = json_encode($res);
+
                $c = $this->con->openCursor('books');
-               $c->chapters = json_encode($res);
+               $c->chapters = $json_chapters;
                $c->changedate = TIME;
                $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
+
+               if ($json_chapters && $json_chapters != '[]') {
+                       if(count($res)==1){
+                               if($res[0]['label']=='' && $res[0]['page']==''){
+                                       return;
+                               }
+                       }
+                       $c = $this->con->openCursor('books_chapters_versions');
+                       $c->book_id = $book_id;
+                       $c->chapters = $json_chapters;
+                       $c->time = TIME;
+                       $c->insert();
+               }
        }
 
        public function setSpecialLinksAndRulers($book_id, $links, $rulers) {
@@ -1484,14 +1499,13 @@ class wsDAOBook extends commonDAO {
        }
 
 
-
        public static function getWorkingFile($path, $book_id, $dir = "") {
                if (substr($path, 0, 1) == '/' && file_exists($path)) {
                        return $path;
                }
 
                $workingDir = WS_BOOKS . '/working/' . $book_id . '/';
-               return $workingDir . trim($dir,'/') . '/' . $path;
+               return $workingDir . trim($dir, '/') . '/' . $path;
        }
 
        public function compileWidget($book, $pages) {