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