]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 28 Apr 2010 08:31:07 +0000 (08:31 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 28 Apr 2010 08:31:07 +0000 (08:31 +0000)
inc/ws/Controlleur/class.ws.flash.php
inc/ws/DAO/class.ws.dao.theme.php
swf/_src/wsComposer.fla

index 6f2f133ba906a56c1c818c95972973ad2c243c78..405d6012c75cf52be7d182380b74f63aec13d6ba 100644 (file)
@@ -144,6 +144,7 @@ class wsFlash extends cubeFlashGateway {
                if (isset($this->args['book_id'])) {\r
                        $dao = new wsDAOBook($core->con);\r
                        $book = $dao->selectById($this->args['book_id']);\r
+\r
                }\r
 \r
                $dao = new wsDAOTheme($core->con);\r
@@ -164,11 +165,24 @@ class wsFlash extends cubeFlashGateway {
                        } else {\r
                                $right = '-';\r
                        }\r
-                       $t->addAttribute('right', rand(0,1)?'w':'r'/*$right*/);\r
+                       $t->addAttribute('right', rand(0, 1)?'w':'r'/*$right*/);\r
                        $t->addAttribute('books', $theme->nbBooks);\r
                }\r
        }\r
 \r
+       public function duplicateTheme()\r
+       {\r
+               global $core;\r
+               $dao = new wsDAOTheme($core->con);\r
+               $theme = $dao->duplicate($this->args['theme_id'], $core->user->utilisateur_id);\r
+               $this->xml->addChild('theme_id', $theme->theme_id);\r
+               if (isset($this->args['book_id'])) {\r
+                       $dao = new wsDAOBook($core->con);\r
+                       $data = array('book_id' => $this->args['book_id'], 'theme' => $theme->theme_id);\r
+                       $dao->sauve($core->user->utilisateur_id, $data);\r
+               }\r
+       }\r
+\r
        public function setTheme()\r
        {\r
                global $core;\r
index 463432291f84da89471b6d5ee9917074dad37d0d..3927572d79d989b6b97f52cb5ab5295a3abe55dc 100644 (file)
@@ -8,7 +8,7 @@ class wsDAOTheme extends extranetDAO {
                $theme->date = $r->date;\r
                $theme->proprietaire = $r->proprietaire;\r
                $theme->books = explode(',', $r->books);\r
-               $theme->nbBooks=$r->nb_books;\r
+               $theme->nbBooks = $r->nb_books;\r
                $theme->signature = $r->signature;\r
                $theme->icones = $r->icones;\r
                $p = unserialize($r->parametres);\r
@@ -47,6 +47,41 @@ class wsDAOTheme extends extranetDAO {
                $r = $this->con->select($sql . ' ' . $order);\r
                return $this->factory($r);\r
        }\r
+\r
+       protected function getNextId()\r
+       {\r
+               $r = $this->con->select('SELECT MAX(theme_id) AS theme_id FROM themes');\r
+               return $r->theme_id + 1;\r
+       }\r
+\r
+       public function duplicate($theme_id, $proprietaire)\r
+       {\r
+               $theme = $this->selectById($theme_id);\r
+               // Copie des donnĂ©es\r
+               $c = $this->con->openCursor('themes');\r
+               $c->theme_id = $this->getNextId();\r
+               $c->nom = $theme->nom . ' (copy)';\r
+               $c->parametres = serialize($theme->parametres);\r
+               $c->signature = $theme->signature;\r
+               $c->icones = $theme->icones;\r
+               $c->proprietaire = $proprietaire;\r
+               $c->date = TIME;\r
+               $c->insert();\r
+               // Copie des fichiers\r
+               $from = ROOT . '/themes/' . $theme_id . '/';\r
+               $to = ROOT . '/themes/' . $c->theme_id . '/';\r
+               $dr = opendir($from);\r
+               if (!file_exists($to)) {\r
+                       mkdir($to, 0777, true);\r
+               } while ($file = readdir($dr)) {\r
+                       if ($file == '.' || $file == '..') {\r
+                               continue;\r
+                       }\r
+                       copy($from . $file, $to . $file);\r
+               }\r
+\r
+               return $this->selectById($c->theme_id);\r
+       }\r
 }\r
 \r
 ?>
\ No newline at end of file
index 26707572ac8a93b7b39b840d91fae3a11a97c488..856700c04643db14639ebe8a514b0ff4065c9529 100644 (file)
Binary files a/swf/_src/wsComposer.fla and b/swf/_src/wsComposer.fla differ