From: vincent@cubedesigners.com Date: Wed, 28 Apr 2010 08:31:07 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=860f3222cf06491ac477ba9266b2614e19c83203;p=cubeextranet.git --- diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index 6f2f133ba..405d6012c 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -144,6 +144,7 @@ class wsFlash extends cubeFlashGateway { if (isset($this->args['book_id'])) { $dao = new wsDAOBook($core->con); $book = $dao->selectById($this->args['book_id']); + } $dao = new wsDAOTheme($core->con); @@ -164,11 +165,24 @@ class wsFlash extends cubeFlashGateway { } else { $right = '-'; } - $t->addAttribute('right', rand(0,1)?'w':'r'/*$right*/); + $t->addAttribute('right', rand(0, 1)?'w':'r'/*$right*/); $t->addAttribute('books', $theme->nbBooks); } } + public function duplicateTheme() + { + global $core; + $dao = new wsDAOTheme($core->con); + $theme = $dao->duplicate($this->args['theme_id'], $core->user->utilisateur_id); + $this->xml->addChild('theme_id', $theme->theme_id); + if (isset($this->args['book_id'])) { + $dao = new wsDAOBook($core->con); + $data = array('book_id' => $this->args['book_id'], 'theme' => $theme->theme_id); + $dao->sauve($core->user->utilisateur_id, $data); + } + } + public function setTheme() { global $core; diff --git a/inc/ws/DAO/class.ws.dao.theme.php b/inc/ws/DAO/class.ws.dao.theme.php index 463432291..3927572d7 100644 --- a/inc/ws/DAO/class.ws.dao.theme.php +++ b/inc/ws/DAO/class.ws.dao.theme.php @@ -8,7 +8,7 @@ class wsDAOTheme extends extranetDAO { $theme->date = $r->date; $theme->proprietaire = $r->proprietaire; $theme->books = explode(',', $r->books); - $theme->nbBooks=$r->nb_books; + $theme->nbBooks = $r->nb_books; $theme->signature = $r->signature; $theme->icones = $r->icones; $p = unserialize($r->parametres); @@ -47,6 +47,41 @@ class wsDAOTheme extends extranetDAO { $r = $this->con->select($sql . ' ' . $order); return $this->factory($r); } + + protected function getNextId() + { + $r = $this->con->select('SELECT MAX(theme_id) AS theme_id FROM themes'); + return $r->theme_id + 1; + } + + public function duplicate($theme_id, $proprietaire) + { + $theme = $this->selectById($theme_id); + // Copie des données + $c = $this->con->openCursor('themes'); + $c->theme_id = $this->getNextId(); + $c->nom = $theme->nom . ' (copy)'; + $c->parametres = serialize($theme->parametres); + $c->signature = $theme->signature; + $c->icones = $theme->icones; + $c->proprietaire = $proprietaire; + $c->date = TIME; + $c->insert(); + // Copie des fichiers + $from = ROOT . '/themes/' . $theme_id . '/'; + $to = ROOT . '/themes/' . $c->theme_id . '/'; + $dr = opendir($from); + if (!file_exists($to)) { + mkdir($to, 0777, true); + } while ($file = readdir($dr)) { + if ($file == '.' || $file == '..') { + continue; + } + copy($from . $file, $to . $file); + } + + return $this->selectById($c->theme_id); + } } ?> \ No newline at end of file diff --git a/swf/_src/wsComposer.fla b/swf/_src/wsComposer.fla index 26707572a..856700c04 100644 Binary files a/swf/_src/wsComposer.fla and b/swf/_src/wsComposer.fla differ