]> _ Git - cubeextranet.git/commitdiff
wip #3839 @2
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 19 Aug 2020 14:46:14 +0000 (14:46 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 19 Aug 2020 14:46:14 +0000 (14:46 +0000)
inc/ws/Controlleur/class.ws.droits.php
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/Util/class.ws.util.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index 9046e615e676bc980aaf4657f7b414cdc2adfa4d..c83a5d7110d51bf18d937abd7bb7a19e969d5cac 100644 (file)
@@ -128,6 +128,20 @@ class wsDroits
 \r
     }\r
 \r
-}\r
+    public static function hasRightsOnBook($book_id)\r
+    {\r
+        global $core;\r
+        if (self::admin()) {\r
+            return true;\r
+        }\r
+        $daoBook = new wsDAOBook($core->con);\r
+        $books = $daoBook->getListe(null, null, null, true);\r
+        foreach ($books as $book) {\r
+            if ($book->book_id == $book_id) {\r
+                return true;\r
+            }\r
+        }\r
+        return false;\r
+    }\r
 \r
-?>
\ No newline at end of file
+}
\ No newline at end of file
index 3d08d071edc0685e954d87a8746ec6b96427b50a..0859469190ac09f701d5b27f50345fe2f078a014 100644 (file)
@@ -1294,6 +1294,28 @@ class wsMaintenance
         }
         $daoBook->setComposition($book_id, $pages, false);
     }
+
+    public static function downloadWorkingFiles($args)
+    {
+        global $core;
+
+        $book_id = $args[0];
+
+        if (!wsDroits::hasRightsOnBook($book_id)) {
+            echo ':(';
+            return;
+        }
+
+        $tmp = CubeIT_Files::tempnam() . ".zip";
+        CubeIT_Util_Zip::archive(WS_BOOKS . '/working/' . $book_id, $tmp);
+        header('Content-Type: application/zip');
+        header('Content-Disposition: attachment; filename="working_' . $book_id . '.zip"');
+        header('Content-Length: ' . filesize($tmp));
+        ob_end_clean();
+        readfile($tmp);
+        unlink($tmp);
+        exit;
+    }
 }
 
 
index c0d8b5b37c5556a8629a02a2380140891017d081..fcdd9c0408f0f246268cb1cf5d40251d97db1339 100644 (file)
@@ -75,6 +75,34 @@ class wsUtil
         return $res;\r
     }\r
 \r
+    public static function excelToArrayKeyVars($excelFile)\r
+    {\r
+        $worksheets = self::excelToArray($excelFile);\r
+        $res = [];\r
+        foreach ($worksheets as $worksheet) {\r
+\r
+            foreach ($worksheet as $i => $line) {\r
+                if ($i === 0) {\r
+                    $vars = [];\r
+                    foreach ($line as $j => $varname) {\r
+                        if ($j === 0) {\r
+                            continue;\r
+                        }\r
+                        $vars[$j] = $varname;\r
+                    }\r
+                } else {\r
+                    $r = [];\r
+                    foreach ($vars as $j => $varname) {\r
+                        $r[$varname] = trim($line[$j]);\r
+                    }\r
+                    $res[trim($line[0])] = $r;\r
+                }\r
+            }\r
+            break;\r
+        }\r
+        return $res;\r
+    }\r
+\r
     public static function excelToArrayKeyValMulti($excelFile)\r
     {\r
         $worksheets = self::excelToArray($excelFile);\r
index 82a2bdb58fd7cd591186dee29fcc4e27eeb9bcf2..27b33e3756078e02c197fe81c38fc6cb15e41e5c 100644 (file)
@@ -624,9 +624,29 @@ class wsHTML5Compiler
             if (!$this->book->parametres->tagcommander_prod) {
                 $id .= '/uat';
             }
-            $this->book->parametres->googleAnalyticsCustom .= '<script src="//cdn.tagcommander.com/' . $id . '/tc_Multisite_Head.js"></script>';
+
+            $default = ['page_name' => '', 'page_cat1_name' => '', 'page_cat2_name' => '', 'page_cat3_name' => ''];
+            $this->config->tagcommander_default_vars = array_merge($default, $this->parseVariables($this->book->parametres->tagcommander_default_vars));
+            $this->config->tagcommander_default_vars['env_work'] = $this->book->parametres->tagcommander_prod ? 'prod' : 'pre-prod';
+
+            $this->book->parametres->googleAnalyticsCustom .= '<script>window.tc_vars=' . json_encode($this->config->tagcommander_default_vars) . ';</script><script src="//cdn.tagcommander.com/' . $id . '/tc_Multisite_Head.js"></script>';
             $this->book->parametres->statsCustom .= '<script src="//cdn.tagcommander.com/' . $id . '/tc_Multisite_Analytics.js"></script>';
             $this->book->parametres->statsCustom .= '<script src="//cdn.tagcommander.com/' . $id . '/tc_Multisite_Medias.js"></script>';
+
+
+            if ($this->book->parametres->tagcommander_plan) {
+                $plan = wsUtil::excelToArrayKeyVars($this->wdir . '/' . $this->book->parametres->tagcommander_plan);
+                $fixedplan = [];
+                foreach ($plan as $k => $v) {
+                    $e = explode('#', $k);
+                    if (count($e) === 2) {
+                        $k = $e[1];
+                    }
+
+                    $fixedplan[trim($k, '#/')] = $v;
+                }
+                $this->config->tagcommander_plan = $fixedplan;
+            }
         }
     }
 
@@ -1140,20 +1160,27 @@ class wsHTML5Compiler
         }
         $this->vdir->file_put_contents('imsmanifest.xml', $manifest);
 
+
+        $this->config->scorm_variables = $this->book->parametres->scorm_variables = $this->parseVariables($this->book->parametres->scorm_variables);
+        if ($this->book->parametres->scorm_quizdata) {
+            $this->config->scorm_quizdata = wsUtil::excelToArray($this->wdir . '/' . $this->book->parametres->scorm_quizdata);
+        }
+    }
+
+    protected function parseVariables($f)
+    {
         $variables = [];
-        $e = CubeIT_Text::explodeNewLines($this->book->parametres->scorm_variables);
+        $f = str_replace("\r", "\n", $f);
+        $e = CubeIT_Text::explodeNewLines($f);
         foreach ($e as $item) {
             $item = trim($item);
             if ($item == '') {
                 continue;
             }
             $f = explode('=', $item, 2);
-            $variables[$f[0]] = $f[1];
-        }
-        $this->config->scorm_variables = $this->book->parametres->scorm_variables = $variables;
-        if ($this->book->parametres->scorm_quizdata) {
-            $this->config->scorm_quizdata = wsUtil::excelToArray($this->wdir . '/' . $this->book->parametres->scorm_quizdata);
+            $variables[trim($f[0])] = trim($f[1]);
         }
+        return $variables;
     }
 
     protected function writePrint()