]> _ Git - cubeextranet.git/commitdiff
wip #5701 @2
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 2 Feb 2023 14:06:43 +0000 (14:06 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 2 Feb 2023 14:06:43 +0000 (14:06 +0000)
inc/ws/Controlleur/class.ws.flash.php
inc/ws/Metier/class.ws.book.php
inc/ws/Util/packager/class.ws.packager.php

index 6a31c50d5764c91203cfaa266ab7d94455ad0fa4..f015b4ad5a449943c038087409b979d3529d4076 100644 (file)
@@ -62,6 +62,8 @@ class wsFlash extends cubeFlashGateway
         }
 
         $dao = new wsDAODocument($core->con);
+        $daoBook = new wsDAOBook($core->con);
+        $book = $daoBook->selectById($this->args['book_id']);
         $documents = [];
         foreach ($_FILES as $varname => $infos) {
             if ($infos['error']) {
@@ -69,6 +71,7 @@ class wsFlash extends cubeFlashGateway
             }
             // Initialisation du document
             $data = array();
+            $data['region'] = $book->region;
             $data['proprietaire'] = $core->user->utilisateur_id;
             $data['pages'] = 0;
             $data['version'] = 2;
@@ -282,6 +285,59 @@ class wsFlash extends cubeFlashGateway
         }
     }
 
+    public function testDocuments()
+    {
+        global $core;
+
+        $toload = $this->xml->addChild('toLoad');
+        $alreadyLoaded = $this->xml->addChild('alreadyLoaded');
+
+        $hash = array();
+
+        foreach ($this->args['fileName'] as $k => $name) {
+            $o = new wsDocumentLocalInfos();
+            $o->fileName = $name;
+            $o->fileSize = intval($this->args['fileSize'][$k]);
+            $o->modificationDate = intval($this->args['modificationDate'][$k]);
+            $o->creationDate = intval($this->args['creationDate'][$k]);
+
+            $hash[$k] = md5(serialize($o));
+        }
+
+        $in = array();
+        foreach ($hash as $h) {
+            $in[] = "'" . $h . "'";
+        }
+
+        $sql = 'SELECT document_id,localHash FROM documents WHERE localHash';
+        if (count($in) == 1) {
+            $sql .= ' = ' . implode(',', $in);
+        } else {
+            $sql .= ' IN (' . implode(',', $in) . ')';
+        }
+
+        $al = array();
+        $r = $core->con->select($sql);
+        while ($r->fetch()) {
+            $k = array_search($r->localHash, $hash);
+
+            if (!file_exists(wsDocument::getDir($r->document_id) . 'crop.pdf')) {
+                continue;
+            }
+
+            $al[$k] = true;
+            $f = $alreadyLoaded->addChild('file', $this->args['fileName'][$k]);
+            $f->addAttribute('document_id', $r->document_id);
+        }
+
+        foreach ($this->args['fileName'] as $k => $name) {
+            if (!isset($al[$k])) {
+                $toload->addChild('file', $name);
+            }
+        }
+    }
+
+
     public function getPagesOfBook()
     {
         global $core;
@@ -794,7 +850,7 @@ class wsFlash extends cubeFlashGateway
         global $core;
         $dao = new wsDAOBook($core->con);
 
-       // $log = $dao->compile($this->args['book_id'], '2');
+        // $log = $dao->compile($this->args['book_id'], '2');
 
         $book = $dao->selectById($this->args['book_id']);
         $viewer = 'viewer';
index 322cbd775c0ec0729c915894fbe7c6dc4db2191d..4f8ed212b1e62af98185274ffd6fc7159d68563e 100644 (file)
@@ -137,18 +137,22 @@ class wsBook extends cubeMetier
         wsMaintenance::timeoutRequest('https://workshop.fluidbook.com/maintenance/processBookPages/' . $book_id, 1);\r
     }\r
 \r
-    public static function getRegionDir($id)\r
+    public static function getRegionDir($id, $root = true)\r
     {\r
         if (!isset(self::$_bookDirs[$id])) {\r
             self::$_bookDirs[$id] = self::_getRegion($id);\r
         }\r
-        return (self::$_bookDirs[$id] === 'UE' ? WS_BOOKS : US_BOOKS) . '/';\r
+        if ($root) {\r
+            return (self::$_bookDirs[$id] === 'UE' ? WS_FILES : US_FILES) . '/';\r
+        } else {\r
+            return (self::$_bookDirs[$id] === 'UE' ? WS_BOOKS : US_BOOKS) . '/';\r
+        }\r
     }\r
 \r
 \r
     public static function getDir($id, $dir, $addSlash = true, $onlyroot = false)\r
     {\r
-        $res = self::getRegionDir($id);\r
+        $res = self::getRegionDir($id,false);\r
         $res .= $dir . '/';\r
         if (!$onlyroot) {\r
             $res .= $id . '/';\r
index 7d6667e9c81180d444caed527de1c7a1d4dec17b..44c18ec3c566f1662e68cee84ebef26346d2d2f6 100644 (file)
@@ -180,7 +180,7 @@ class wsPackager
         }
 
 
-        $res = $this->getRelativeBase();
+        $res .= $this->getRelativeBase();
         if ($ext != '') {
             $res .= '.' . $ext;
         }
@@ -189,7 +189,7 @@ class wsPackager
 
     protected function getPathBase($ext = '')
     {
-        $base=wsBook::getRegionDir($this->book_id);
+        $base = wsBook::getRegionDir($this->book_id,true);
         if (!file_exists($base . '/packager/download')) {
             mkdir($base . '/packager/download', 0777, true);
         }
@@ -197,7 +197,6 @@ class wsPackager
         if ($ext != '') {
             $res .= '.' . $ext;
         }
-
         return $res;
     }