Beispiel #1
0
    // no module language file exists for the language set by the user, include default module language file DE.php
    require_once WB_PATH . '/modules/foldergallery/languages/DE.php';
} else {
    // a module language file exists for the language defined by the user, load it
    require_once WB_PATH . '/modules/foldergallery/languages/' . LANGUAGE . '.php';
}
require_once WB_PATH . '/modules/foldergallery/info.php';
require_once WB_PATH . '/modules/foldergallery/admin/scripts/backend.functions.php';
require_once WB_PATH . '/modules/foldergallery/class/DirectoryHandler.Class.php';
//  Set the mySQL encoding to utf8
$oldMysqlEncoding = mysql_client_encoding();
mysql_set_charset('utf8', $database->db_handle);
$settings = getSettings($section_id);
$flag = false;
/* syncDB($galerie) ist kompletter updatealgorithmus */
if (syncDB($settings)) {
    echo "<div class=\"info\">" . $MOD_FOLDERGALLERY['SYNC_DATABASE'] . "</div><br />";
    // Wieder alle Angaben aus der DB holen um Sortierung festzulegen
    $results = array();
    $sql = "SELECT * FROM " . TABLE_PREFIX . "mod_foldergallery_categories WHERE section_id =" . $section_id;
    $query = $database->query($sql);
    if ($query->numRows() > 0) {
        while ($result = $query->fetchRow()) {
            if ($result['parent'] != -1) {
                $folder = $settings['root_dir'] . '/' . $result['parent'] . '/' . $result['categorie'];
                $pathToFolder = $path . $folder;
                if (!is_dir(DirectoryHandler::DecodePath($pathToFolder))) {
                    $delete_sql = 'DELETE FROM ' . TABLE_PREFIX . 'mod_foldergallery_categories WHERE id="' . $result['id'] . '";';
                    $database->query($delete_sql);
                    continue;
                }
Beispiel #2
0
    deleteFolder($pathToFolder);
}
if ($oldSettings['root_dir'] != $newSettings['root_dir']) {
    // Und jetzt noch alte DB Einträge
    $sql = 'SELECT `parent`, `categorie` FROM ' . TABLE_PREFIX . 'mod_foldergallery_categories WHERE section_id=' . $oldSettings['section_id'] . ';';
    $query = $database->query($sql);
    while ($cat = $query->fetchRow()) {
        $sql = 'DELETE FROM ' . TABLE_PREFIX . 'mod_foldergallery_files WHERE parent_id=' . $cat['parent'];
        $database->query($sql);
    }
    $sql = 'DELETE FROM ' . TABLE_PREFIX . 'mod_foldergallery_categories WHERE section_id=' . $oldSettings['section_id'] . ';';
    $database->query($sql);
    // Root als Kategorie eintragen
    $sql = 'INSERT INTO ' . TABLE_PREFIX . "mod_foldergallery_categories ( `section_id`,`parent_id`,`categorie`,`parent`,`cat_name`,`active`,`is_empty`,`position`,`niveau`,`has_child`,`childs`,`description` )\n    VALUES ( '{$section_id}', '-1', 'Root', '-1', 'Root', '1', '0', '0', '-1', '0', '', 'Root Description' );";
    $query = $database->query($sql);
    if ($database->is_error()) {
        $admin->print_error($database->get_error(), WB_URL . '/modules/foldergallery/admin/modify_settings.php?page_id=' . $page_id . '&section_id=' . $section_id);
    }
}
// Jetzt wird die DB neu synchronisiert //Anm CHio: Wozu? Wenn ein Fehler ist, kann man nichtmal die Settings speichern.
syncDB($newSettings);
// Überprüfen ob ein Fehler aufgetreten ist, sonst Erfolg ausgeben
if ($database->is_error()) {
    $admin->print_error($database->get_error(), WB_URL . '/modules/foldergallery/admin/modify_settings.php?page_id=' . $page_id . '&section_id=' . $section_id);
} else {
    $admin->print_success($TEXT['SUCCESS'], WB_URL . '/modules/foldergallery/admin/sync.php?page_id=' . $page_id . '&section_id=' . $section_id);
}
// reset the mySQL encoding
mysql_set_charset($oldMysqlEncoding, $database->db_handle);
// Print admin footer
$admin->print_footer();