From 3a08ce791cc831aa5fe12d4b88134af821349276 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 29 Dec 2010 18:42:53 +0000 Subject: [PATCH] --- inc/ws/Controlleur/class.ws.flash.php | 5 +++++ inc/ws/Controlleur/class.ws.url.php | 2 +- inc/ws/DAO/class.ws.dao.theme.php | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index 90e5f6a74..37d878f09 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -47,6 +47,11 @@ class wsFlash extends cubeFlashGateway { } $fname = cubeFiles::tidyName($infos['name']); $dest = '/' . $this->args['theme_id'] . '/' . $fname; + + if (!file_exists(WS_THEMES . '/' . $this->args['theme_id'])) { + mkdir(WS_THEMES . '/' . $this->args['theme_id'], 0755, true); + } + move_uploaded_file($infos['tmp_name'], WS_THEMES . $dest); $this->xml->addChild('file', $fname); return; diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 225b81c89..864be578a 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -104,7 +104,7 @@ html{height:100%}' . "\n"; $res .= ''; $res .= '' . __('Edition de la publication') . ' #' . $args[0] . ''; $res .= ''; - $res .= ''; + $res .= ''; $res .= self::editComposition($args); $res .= ''; $res .= ''; diff --git a/inc/ws/DAO/class.ws.dao.theme.php b/inc/ws/DAO/class.ws.dao.theme.php index a853e2e5a..937a45f46 100644 --- a/inc/ws/DAO/class.ws.dao.theme.php +++ b/inc/ws/DAO/class.ws.dao.theme.php @@ -37,7 +37,7 @@ class wsDAOTheme extends extranetDAO { } else { $table = 'themes_vue'; } - $r = $this->con->select('SELECT * FROM '.$table.' WHERE theme_id IN (SELECT theme FROM books WHERE book_id=\'' . $this->con->escape($book_id) . '\') LIMIT 1'); + $r = $this->con->select('SELECT * FROM ' . $table . ' WHERE theme_id IN (SELECT theme FROM books WHERE book_id=\'' . $this->con->escape($book_id) . '\') LIMIT 1'); return $this->singleton($r); } @@ -75,8 +75,8 @@ class wsDAOTheme extends extranetDAO { } $c->parametres = serialize($p); $c->update('WHERE theme_id=\'' . $this->con->escape($data['theme_id']) . '\''); - if (file_exists(ROOT . '/themes/' . $data['theme_id'] . '.jpg')) { - unlink(ROOT . '/themes/' . $data['theme_id'] . '.jpg'); + if (file_exists(WS_THEMES . '/' . $data['theme_id'] . '.jpg')) { + unlink(WS_THEMES . '/' . $data['theme_id'] . '.jpg'); } } @@ -86,15 +86,13 @@ class wsDAOTheme extends extranetDAO { return $r->theme_id + 1; } - public function delete($theme_id) + public function delete($theme_id, $onlyFiles=false) { if (is_null($theme_id) || $theme_id == '') { return; } - $this->con->execute('DELETE FROM themes WHERE theme_id=\'' . $this->con->escape($theme_id) . '\''); - if (file_exists(ROOT . '/themes/' . $theme_id)) { - files::deltree(ROOT . '/themes/' . $theme_id); - unlink(ROOT . '/themes/' . $theme_id . '.jpg'); + if (!$onlyFiles) { + $this->con->execute('DELETE FROM themes WHERE theme_id=\'' . $this->con->escape($theme_id) . '\''); } } @@ -121,9 +119,11 @@ class wsDAOTheme extends extranetDAO { $c->proprietaire = $proprietaire; $c->date = TIME; $c->insert(); + + $this->delete($c->theme_id, true); // Copie des fichiers - $from = ROOT . '/themes/' . $theme_id ; - $to = ROOT . '/themes/' . $c->theme_id; + $from = WS_THEMES . '/' . $theme_id ; + $to = WS_THEMES . '/' . $c->theme_id; $dr = opendir($from); if (!file_exists($to)) { mkdir($to, 0777, true); -- 2.39.5