diff options
author | plegall <plg@piwigo.org> | 2010-03-22 14:11:10 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2010-03-22 14:11:10 +0000 |
commit | 15499d5dc13cb4680fa2a683f459bbfe785d70a5 (patch) | |
tree | e665409a80a6f934925a09f9742ccb2a0624c0c0 /admin/include/themes.class.php | |
parent | cf9af7d0628053b16c3bfc82c2146c3cd7ecec8f (diff) |
feature 1514: improvement, impossible to delete a theme that is required
by another installed theme.
git-svn-id: http://piwigo.org/svn/trunk@5258 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/include/themes.class.php')
-rw-r--r-- | admin/include/themes.class.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/admin/include/themes.class.php b/admin/include/themes.class.php index 98a75339c..ad32b6f7f 100644 --- a/admin/include/themes.class.php +++ b/admin/include/themes.class.php @@ -140,6 +140,19 @@ DELETE // nothing to do here break; } + + $children = $this->get_children_themes($theme_id); + if (count($children) > 0) + { + array_push( + $errors, + sprintf( + l10n('Impossible to delete this theme. Other themes depends on it: %s'), + implode(', ', $children) + ) + ); + break; + } if (!$this->deltree(PHPWG_THEMES_PATH.$theme_id)) { @@ -155,6 +168,21 @@ DELETE return $errors; } + function get_children_themes($theme_id) + { + $children = array(); + + foreach ($this->fs_themes as $test_child) + { + if (isset($test_child['parent']) and $test_child['parent'] == $theme_id) + { + array_push($children, $test_child['name']); + } + } + + return $children; + } + function set_default_theme($theme_id) { // first we need to know which users are using the current default theme @@ -267,6 +295,10 @@ SELECT list( , $extension) = explode('extension_view.php?eid=', $theme['uri']); if (is_numeric($extension)) $theme['extension'] = $extension; } + if (preg_match('/["\']parent["\'][^"\']+["\']([^"\']+)["\']/', $theme_data, $val)) + { + $theme['parent'] = $val[1]; + } // screenshot $screenshot_path = $path.'/screenshot.png'; |