]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 8 Dec 2010 18:15:29 +0000 (18:15 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 8 Dec 2010 18:15:29 +0000 (18:15 +0000)
inc/extranet/Controlleur/class.extranet.core.php
inc/ws/Controlleur/class.ws.flash.php
inc/ws/Controlleur/class.ws.url.php
inc/ws/DAO/class.ws.dao.book.php
inc/ws/Metier/class.ws.book.php

index 0306be5a3d9e1520bd0c62a54a170db205f3d7d1..769f20780a954bb711b630a135f70020c1b30632 100644 (file)
@@ -348,6 +348,8 @@ class extranetCore extends cubeCore {
                $db->books->traductions('text', 0, false);\r
                $db->books->date('integer', 0, false);\r
                $db->books->numerotation('text', 0, false);\r
+               $db->books->changedate('integer', 0, false);\r
+               $db->books->compiledate('integer', 0, false);\r
                // Clés\r
                $db->books->primary('pk_books', 'book_id');\r
                $db->books->index('index_books_nom', 'BTREE', 'nom');\r
index ad34eec1b0e07477917d4d741d6edad6d7f80dee..84cee528e64deab99c37453133e06e04dd6243cd 100644 (file)
@@ -487,7 +487,9 @@ class wsFlash extends cubeFlashGateway {
        {\r
                global $core;\r
                $dao = new wsDAOBook($core->con);\r
-               $dao->compile($this->args['book_id'], 3);\r
+               if (!$dao->isUpToDate($this->args['book_id'])) {\r
+                       $dao->compile($this->args['book_id'], 3);\r
+               }\r
 \r
                $absoluteURL = 'http://' . $_SERVER['HTTP_HOST'] . '/fluidbook/books/final/' . $this->args['book_id'] . '/';\r
                $this->xml->addChild('compiledBook', $absoluteURL . 'index.swf?base=' . $absoluteURL);\r
index 6cd4cf50c30cb8c892ec128c6f0f855c06a4870b..07fa6291910024bdaeaa0fc130c28cc10bab0375 100644 (file)
@@ -121,6 +121,9 @@ html{height:100%}' . "\n";
 \r
        public static function viewer($args)\r
        {\r
+               global $core;\r
+               global $css;\r
+               global $js;\r
                $args = cubePage::getArgs($args);\r
 \r
                $e = explode('_', $args[0]);\r
@@ -129,6 +132,13 @@ html{height:100%}' . "\n";
                        http::redirect(SITE_PATH . '/viewer/' . implode('_', $e));\r
                        exit;\r
                }\r
+\r
+               $dao = new wsDAOBook($core->con);\r
+               $book = $dao->selectById($e[0]);\r
+               if ($book->hash != $e[1]) {\r
+                       http::head(401);\r
+                       exit;\r
+               }\r
        }\r
 \r
        public static function statsxls($args)\r
index c2c215ed3ea3a65dc191d9dc2727a79ba076eb30..f298cb4b509fbee36ac152478ff95cf31fd54709 100644 (file)
@@ -22,6 +22,8 @@ class wsDAOBook extends extranetDAO {
                $book->parametres = $r->parametres;\r
                $book->extras = $r->extras;\r
                $book->numerotation = $r->numerotation;\r
+               $book->changedate = $r->changedate;\r
+               $book->compiledate = $r->compiledate;\r
 \r
                return $book;\r
        }\r
@@ -90,10 +92,12 @@ class wsDAOBook extends extranetDAO {
                        $c->hash = md5(rand(0, 1234567893));\r
                        $c->compteur_visites = 20;\r
                        $c->parametres = serialize(new wsParametres());\r
+                       $c->changedate = TIME;\r
                        $book_id = $c->book_id = $this->getNextId();\r
 \r
                        $c->insert();\r
                } else {\r
+                       $c->changedate = TIME;\r
                        $book_id = $data['book_id'];\r
                        $c->update('WHERE book_id=\'' . $this->con->escape($data['book_id']) . '\'');\r
                }\r
@@ -115,6 +119,8 @@ class wsDAOBook extends extranetDAO {
                $c->parametres = $r->parametres;\r
                $c->nom = $r->nom;\r
                $c->theme = $r->theme;\r
+               $c->changedate = TIME;\r
+               $c->compiledate = 0;\r
                $book_id = $c->book_id = $this->getNextId();\r
                $c->insert();\r
 \r
@@ -133,6 +139,8 @@ class wsDAOBook extends extranetDAO {
                $c->parametres = serialize(new wsParametres());\r
                $c->theme = 1;\r
                $c->lang = $lang;\r
+               $c->changedate = TIME;\r
+               $c->compiledate = TIME;\r
                $book_id = $c->book_id = $this->getNextId();\r
                $c->insert();\r
                return $this->selectById($book_id);\r
@@ -269,6 +277,7 @@ class wsDAOBook extends extranetDAO {
        {\r
                $c = $this->con->openCursor('books');\r
                $c->chapters = json_encode(json_decode($json, false));\r
+               $c->changedate = TIME;\r
                $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
        }\r
 \r
@@ -277,6 +286,7 @@ class wsDAOBook extends extranetDAO {
                $c = $this->con->openCursor('books');\r
                $c->links = json_encode(json_decode($links, false));\r
                $c->rulers = json_encode(json_decode($rulers, false));\r
+               $c->changedate = TIME;\r
                $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
        }\r
 \r
@@ -297,6 +307,7 @@ class wsDAOBook extends extranetDAO {
 \r
                $c = $this->con->openCursor('books');\r
                $c->extras = $extras;\r
+               $c->changedate = TIME;\r
                $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
                return true;\r
        }\r
@@ -306,6 +317,7 @@ class wsDAOBook extends extranetDAO {
                $c = $this->con->openCursor('books');\r
                $c->lang = $base;\r
                $c->traductions = json_encode(json_decode($traductions, false));\r
+               $c->changedate = TIME;\r
                $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
        }\r
 \r
@@ -320,6 +332,7 @@ class wsDAOBook extends extranetDAO {
                $c = $this->con->openCursor('books');\r
                $c->nom = $parametres->title;\r
                $c->parametres = serialize($parametres);\r
+               $c->changedate = TIME;\r
                $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
        }\r
 \r
@@ -330,6 +343,26 @@ class wsDAOBook extends extranetDAO {
                $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
        }\r
 \r
+       public function touch($book_id)\r
+       {\r
+               $c = $this->con->openCursor('books');\r
+               $c->changedate = TIME;\r
+               $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
+       }\r
+\r
+       public function touchCompile($book_id)\r
+       {\r
+               $c = $this->con->openCursor('books');\r
+               $c->compiledate = TIME;\r
+               $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
+       }\r
+\r
+       public function isUpToDate($book_id)\r
+       {\r
+               $r = $this->con->select('SELECT changedate,compiledate FROM books WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
+               return $r->compiledate > $r->updatedate;\r
+       }\r
+\r
        public function setComposition($book_id, $pages)\r
        {\r
                $numerotation = array();\r
@@ -346,6 +379,7 @@ class wsDAOBook extends extranetDAO {
                $c = $this->con->openCursor('books');\r
                $c->parametres = serialize($parametres);\r
                $c->numerotation = implode(',', $numerotation);\r
+               $c->changedate = TIME;\r
                $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
 \r
                $this->con->execute('DELETE FROM book_pages WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
@@ -449,6 +483,7 @@ class wsDAOBook extends extranetDAO {
                if ($version == 3) {\r
                        return $this->compile3($book_id, $complete);\r
                }\r
+               $this->touchCompile($book_id);\r
        }\r
 \r
        /**\r
@@ -574,6 +609,8 @@ class wsDAOBook extends extranetDAO {
                        }\r
                }\r
 \r
+               $this->touchCompile($book_id);\r
+\r
                return $res;\r
        }\r
 }\r
index 851f341df9bbe2c8346cc734078a8c82f799b42c..93df8706e5dfd5a486871d0be41904cf1e13eff0 100644 (file)
@@ -32,6 +32,9 @@ class wsBook extends cubeMetier {
        protected $traductions;\r
        protected $numerotation;\r
 \r
+       protected $changedate;\r
+       protected $compiledate;\r
+\r
        public function __get($varname)\r
        {\r
                if (!property_exists($this, $varname)) {\r