]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 23 Feb 2012 16:46:30 +0000 (16:46 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 23 Feb 2012 16:46:30 +0000 (16:46 +0000)
inc/ws/Controlleur/class.ws.flash.php
inc/ws/DAO/class.ws.dao.theme.php

index 592ce51c0010598ac81e034749df896a17ad5008..5f53957d05ab775c1e3985a6fe7064d2d1801505 100644 (file)
@@ -165,12 +165,12 @@ class wsFlash extends cubeFlashGateway {
                                $icotool->setArg('o', $dir . '/fluidbook.ico');\r
 \r
                                $sizes = array(256, 128, 64, 32, 16);\r
-                               \r
+\r
                                foreach ($sizes as $s) {\r
                                        $r = $dir . '/ico-' . $s . '.png';\r
                                        $it = new cubeImageTools();\r
                                        $it->loadImage($dest);\r
-                                       $it->resize($s, $s, 'crop', true,'C','M','transparent');\r
+                                       $it->resize($s, $s, 'crop', true, 'C', 'M', 'transparent');\r
                                        $it->output('png', $r);\r
                                        $icotool->setArg(null, $r);\r
                                }\r
@@ -339,8 +339,11 @@ class wsFlash extends cubeFlashGateway {
                        $this->args['book_id'] = 0;\r
                }\r
 \r
+               $demos = array(1161, 1160);\r
+               $readOnly = array(1);\r
+\r
                $dao = new wsDAOTheme($core->con);\r
-               $themes = $dao->getAllThemes($core->user, 'ORDER BY FIELD (theme_id,' . $this->args['book_id'] . ',1) DESC, theme_id DESC', true);\r
+               $themes = $dao->getAllThemes($core->user, 'ORDER BY FIELD (theme_id,' . $this->args['book_id'] . ',' . implode(',', $demos) . ') DESC, theme_id DESC', $demos);\r
                foreach ($themes as $theme) {\r
                        $t = $this->xml->addChild('theme');\r
                        $t->addAttribute('id', $theme->theme_id);\r
@@ -351,7 +354,13 @@ class wsFlash extends cubeFlashGateway {
                        } else {\r
                                $mine = false;\r
                        }\r
-                       if (wsDroits::revendeur() && wsDroits::creation()) {\r
+                       if (wsDroits::admin()) {\r
+                               $right = 'w';\r
+                       } elseif (in_array($theme->theme_id, $demos)) {\r
+                               $right = 'r';\r
+                       } elseif (in_array($theme->theme_id, $readOnly)) {\r
+                               $right = 'r';\r
+                       } elseif (wsDroits::revendeur() && wsDroits::creation()) {\r
                                $right = 'w';\r
                        } else {\r
                                $right = 'r';\r
index 82bb9b3ac62870ead564bfb19a5568a9ddabe796..2d28707badd7b4baa4a63f2551c42a82c20f34ae 100644 (file)
@@ -1,7 +1,8 @@
 <?php\r
+\r
 class wsDAOTheme extends commonDAO {\r
-       protected function singleton($r)\r
-       {\r
+\r
+       protected function singleton($r) {\r
                $theme = new wsTheme();\r
                $theme->theme_id = $r->theme_id;\r
                $theme->nom = $r->nom;\r
@@ -26,14 +27,12 @@ class wsDAOTheme extends commonDAO {
                return $theme;\r
        }\r
 \r
-       public function selectById($theme_id, $table = 'themes_vue')\r
-       {\r
+       public function selectById($theme_id, $table = 'themes_vue') {\r
                $r = $this->con->select('SELECT * FROM ' . $table . ' WHERE theme_id=\'' . $this->con->escape($theme_id) . '\' LIMIT 1');\r
                return $this->singleton($r);\r
        }\r
 \r
-       public function getThemeOfBook($book_id, $basic = false)\r
-       {\r
+       public function getThemeOfBook($book_id, $basic = false) {\r
                if ($basic) {\r
                        $table = 'themes';\r
                } else {\r
@@ -43,24 +42,27 @@ class wsDAOTheme extends commonDAO {
                return $this->singleton($r);\r
        }\r
 \r
-       public function getAllThemes($user, $order = '')\r
-       {\r
+       public function getAllThemes($user, $order = '', $demos = null) {\r
                if (wsDroits::admin(false)) {\r
                        $sql = 'SELECT * FROM themes_vue';\r
                } else {\r
-                       $sql = 'SELECT * FROM themes_vue WHERE theme_id IN (SELECT theme FROM books WHERE proprietaire IN(' . $user->ws_rights . '))';\r
+                       $or = '';\r
+                       if (wsDroits::revendeur() && !is_null($demos)) {\r
+                               fb($demos);\r
+                               $or = ' OR theme_id IN(' . implode(',', $demos) . ')';\r
+                       }\r
+                       $sql = 'SELECT * FROM themes_vue WHERE theme_id IN (SELECT theme FROM books WHERE proprietaire IN(' . $user->ws_rights . ') ' . $or . ')';\r
                }\r
                $r = $this->con->select($sql . ' ' . $order);\r
                return $this->factory($r);\r
        }\r
 \r
-       public function sauve($data)\r
-       {\r
+       public function sauve($data) {\r
                $parent = $this->selectById($data['theme_id']);\r
                $c = $this->con->openCursor('themes');\r
                $c->date = TIME;\r
                $p = new wsThemeParametres($parent);\r
-               foreach($data as $k => $v) {\r
+               foreach ($data as $k => $v) {\r
                        if (!isset($p->$k)) {\r
                                continue;\r
                        }\r
@@ -73,8 +75,7 @@ class wsDAOTheme extends commonDAO {
                }\r
        }\r
 \r
-       protected function getNextId()\r
-       {\r
+       protected function getNextId() {\r
                $r = $this->con->select('SELECT MAX(theme_id) AS theme_id FROM themes');\r
                if ($r->theme_id < 1000) {\r
                        return 1000;\r
@@ -82,8 +83,7 @@ class wsDAOTheme extends commonDAO {
                return $r->theme_id + 1;\r
        }\r
 \r
-       public function delete($theme_id, $onlyFiles = false)\r
-       {\r
+       public function delete($theme_id, $onlyFiles = false) {\r
                if (is_null($theme_id) || $theme_id == '') {\r
                        return;\r
                }\r
@@ -99,15 +99,13 @@ class wsDAOTheme extends commonDAO {
                }\r
        }\r
 \r
-       public function rename($theme_id, $newname)\r
-       {\r
+       public function rename($theme_id, $newname) {\r
                $c = $this->con->openCursor('themes');\r
                $c->nom = $newname;\r
                $c->update('WHERE theme_id=\'' . $this->con->escape($theme_id) . '\'');\r
        }\r
 \r
-       public function duplicate($theme_id, $proprietaire)\r
-       {\r
+       public function duplicate($theme_id, $proprietaire) {\r
                if (is_null($theme_id) || $theme_id == '') {\r
                        return;\r
                }\r
@@ -125,7 +123,7 @@ class wsDAOTheme extends commonDAO {
 \r
                $this->delete($c->theme_id, true);\r
                // Copie des fichiers\r
-               $from = WS_THEMES . '/' . $theme_id ;\r
+               $from = WS_THEMES . '/' . $theme_id;\r
                $to = WS_THEMES . '/' . $c->theme_id;\r
                $dr = opendir($from);\r
                if (!file_exists($to)) {\r
@@ -146,6 +144,7 @@ class wsDAOTheme extends commonDAO {
 \r
                return $this->selectById($c->theme_id);\r
        }\r
+\r
 }\r
 \r
 ?>
\ No newline at end of file