/** * Edit a theme image. * * @param SHORT_TEXT The current theme image ID * @param ID_TEXT The theme the theme image is in * @param LANGUAGE_NAME The language the theme image is for (blank: all languages) * @param SHORT_TEXT The new theme image ID * @param URLPATH The URL to the theme image * @param boolean Whether to avoid cleanup, etc */ function actual_edit_theme_image($old_id, $theme, $lang, $id, $path, $quick = false) { if ($old_id != $id) { $where_map = array('theme' => $theme, 'id' => $id); if ($lang != '' && !is_null($lang)) { $where_map['lang'] = $lang; } $test = $GLOBALS['SITE_DB']->query_value_null_ok('theme_images', 'id', $where_map); if (!is_null($test)) { warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($id))); } } if (!$quick) { $old_url = find_theme_image($id, true, true, $theme, $lang == '' ? NULL : $lang); $where_map = array('theme' => $theme, 'id' => $id); if ($lang != '' && !is_null($lang)) { $where_map['lang'] = $lang; } $GLOBALS['SITE_DB']->query_delete('theme_images', $where_map); if ($old_url != $path && $old_url != '') { if ($theme == 'default' || strpos($old_url, 'themes/default/') === false) { require_code('themes3'); cleanup_theme_images($old_url); } } } else { $where_map = array('theme' => $theme, 'id' => $id); if ($lang != '' && !is_null($lang)) { $where_map['lang'] = $lang; } $GLOBALS['SITE_DB']->query_delete('theme_images', $where_map); } if ($lang == '') { $langs = array_keys(find_all_langs()); } else { $langs = array($lang); } foreach ($langs as $lang) { $GLOBALS['SITE_DB']->query_insert('theme_images', array('id' => $id, 'theme' => $theme, 'path' => $path, 'lang' => $lang)); } if (!$quick) { log_it('EDIT_THEME_IMAGE', $id, $theme); } }
/** * Delete a theme image. * * @param SHORT_TEXT The theme image ID * @param ?ID_TEXT The theme to delete in (NULL: all themes) * @param ?LANGUAGE_NAME The language to delete in (NULL: all languages) (blank: all languages) */ function actual_delete_theme_image($id, $theme = NULL, $lang = NULL) { if (!is_null($theme)) { $old_url = find_theme_image($id, true, true, $theme, $lang); $where_map = array('theme' => $theme, 'id' => $id); if ($lang != '' && !is_null($lang)) { $where_map['lang'] = $lang; } $test = $GLOBALS['SITE_DB']->query_value_null_ok('theme_images', 'path', $where_map); if (!is_null($test)) { $GLOBALS['SITE_DB']->query_delete('theme_images', array('id' => $id, 'path' => $test)); } } else { $old_url = find_theme_image($id, true, true); $GLOBALS['SITE_DB']->query_delete('theme_images', array('id' => $id)); } if ($old_url != '') { cleanup_theme_images($old_url); } log_it('DELETE_THEME_IMAGE', $id); }