Exemplo n.º 1
0
/**
 * Edit a zone.
 *
 * @param  ID_TEXT		The current name of the zone
 * @param  SHORT_TEXT	The zone title
 * @param  ID_TEXT		The zones default page
 * @param  SHORT_TEXT	The header text
 * @param  ID_TEXT		The theme
 * @param  BINARY			Whether the zone is wide
 * @param  BINARY			Whether the zone requires a session for pages to be used
 * @param  BINARY			Whether the zone in displayed in the menu coded into some themes
 * @param  ID_TEXT		The new name of the zone
 */
function actual_edit_zone($zone, $title, $default_page, $header_text, $theme, $wide, $require_session, $displayed_in_menu, $new_zone)
{
    if ($zone != $new_zone) {
        require_code('type_validation');
        if (!is_alphanumeric($new_zone, true)) {
            warn_exit(do_lang_tempcode('BAD_CODENAME'));
        }
        if (get_file_base() != get_custom_file_base()) {
            warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
        }
        // Check doesn't already exist
        $test = $GLOBALS['SITE_DB']->query_value_null_ok('zones', 'zone_header_text', array('zone_name' => $new_zone));
        if (!is_null($test)) {
            warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($new_zone)));
        }
        require_code('abstract_file_manager');
        force_have_afm_details();
        afm_move($zone, $new_zone);
    }
    $_header_text = $GLOBALS['SITE_DB']->query_value('zones', 'zone_header_text', array('zone_name' => $zone));
    $_title = $GLOBALS['SITE_DB']->query_value('zones', 'zone_title', array('zone_name' => $zone));
    $GLOBALS['SITE_DB']->query_update('zones', array('zone_name' => $new_zone, 'zone_title' => lang_remap($_title, $title), 'zone_default_page' => $default_page, 'zone_header_text' => lang_remap($_header_text, $header_text), 'zone_theme' => $theme, 'zone_wide' => $wide, 'zone_require_session' => $require_session, 'zone_displayed_in_menu' => $displayed_in_menu), array('zone_name' => $zone), '', 1);
    if ($new_zone != $zone) {
        actual_rename_zone_lite($zone, $new_zone, true);
        $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => $new_zone), array('i_url' => $zone), '', 1);
    }
    // If we're in this zone, update the theme
    global $ZONE;
    if ($ZONE['zone_name'] == $zone) {
        $ZONE['theme'] = $theme;
    }
    decache('side_zone_jump');
    decache('side_stored_menu');
    decache('main_sitemap');
    persistant_cache_delete(array('ZONE', $zone));
    persistant_cache_delete('ALL_ZONES');
    log_it('EDIT_ZONE', $zone);
}
Exemplo n.º 2
0
/**
 * Rename a zone in the database and move any custom pages in it.
 *
 * @param  ID_TEXT		The old name of the zone
 * @param  ID_TEXT		The new name of the zone
 * @param  boolean		Whether to assume the main zone row has already been renamed as part of a wider editing operation
 */
function fu_rename_zone($zone, $new_zone, $dont_bother_with_main_row = false)
{
    if (function_exists('set_time_limit')) {
        @set_time_limit(0);
    }
    require_code('zones2');
    if (file_exists(get_file_base() . '/sources/zones3.php')) {
        require_code('zones3');
    }
    actual_rename_zone_lite($zone, $new_zone, $dont_bother_with_main_row);
    $pages = find_all_pages_wrap($zone, true, false, FIND_ALL_PAGES__ALL);
    foreach ($pages as $page => $type) {
        $path = get_file_base() . '/' . $zone . '/pages/' . $type . '/' . $page;
        $new_path = get_file_base() . '/' . $new_zone . '/pages/' . $type . '/' . $page;
        if (is_writable_wrap($path) && is_writable_wrap($new_path)) {
            rename($path, $new_path);
            sync_file_move($path, $new_path);
        }
    }
}