$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
$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
} 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
<?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
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
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
}\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
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
}\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
\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
\r
return $this->selectById($c->theme_id);\r
}\r
+\r
}\r
\r
?>
\ No newline at end of file