}\r
$fname = cubeFiles::tidyName($infos['name']);\r
$dest = '/' . $this->args['theme_id'] . '/' . $fname;\r
+\r
+ if (!file_exists(WS_THEMES . '/' . $this->args['theme_id'])) {\r
+ mkdir(WS_THEMES . '/' . $this->args['theme_id'], 0755, true);\r
+ }\r
+\r
move_uploaded_file($infos['tmp_name'], WS_THEMES . $dest);\r
$this->xml->addChild('file', $fname);\r
return;\r
} else {\r
$table = 'themes_vue';\r
}\r
- $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
+ $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
return $this->singleton($r);\r
}\r
\r
}\r
$c->parametres = serialize($p);\r
$c->update('WHERE theme_id=\'' . $this->con->escape($data['theme_id']) . '\'');\r
- if (file_exists(ROOT . '/themes/' . $data['theme_id'] . '.jpg')) {\r
- unlink(ROOT . '/themes/' . $data['theme_id'] . '.jpg');\r
+ if (file_exists(WS_THEMES . '/' . $data['theme_id'] . '.jpg')) {\r
+ unlink(WS_THEMES . '/' . $data['theme_id'] . '.jpg');\r
}\r
}\r
\r
return $r->theme_id + 1;\r
}\r
\r
- public function delete($theme_id)\r
+ public function delete($theme_id, $onlyFiles=false)\r
{\r
if (is_null($theme_id) || $theme_id == '') {\r
return;\r
}\r
- $this->con->execute('DELETE FROM themes WHERE theme_id=\'' . $this->con->escape($theme_id) . '\'');\r
- if (file_exists(ROOT . '/themes/' . $theme_id)) {\r
- files::deltree(ROOT . '/themes/' . $theme_id);\r
- unlink(ROOT . '/themes/' . $theme_id . '.jpg');\r
+ if (!$onlyFiles) {\r
+ $this->con->execute('DELETE FROM themes WHERE theme_id=\'' . $this->con->escape($theme_id) . '\'');\r
}\r
}\r
\r
$c->proprietaire = $proprietaire;\r
$c->date = TIME;\r
$c->insert();\r
+\r
+ $this->delete($c->theme_id, true);\r
// Copie des fichiers\r
- $from = ROOT . '/themes/' . $theme_id ;\r
- $to = ROOT . '/themes/' . $c->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
mkdir($to, 0777, true);\r