Beispiel #1
0
$new_forum_permission = 0;
if (count($_POST)) {
    if (isset($_POST['action']) && $_POST['action'] == "deleteGroups") {
        $count = 0;
        foreach ($_POST['deleteIds'] as $id => $deluid) {
            phorum_db_delete_group($deluid);
            $count++;
        }
        echo "{$count} Group(s) deleted.<br />";
    }
    switch ($_POST["section"]) {
        case "add":
            $group_id = 0;
            $_POST["group_name"] = trim($_POST["group_name"]);
            if (!empty($_POST["group_name"])) {
                $group_id = phorum_db_add_group($_POST["group_name"]);
            }
            if (!$group_id) {
                echo "Error adding group<br />";
            } else {
                echo "Group added<br />";
            }
            break;
        case "edit":
            $group = array("group_id" => $_POST["group_id"], "name" => $_POST["name"], "open" => $_POST["open"]);
            if (phorum_db_update_group($group)) {
                echo "Group Saved";
            } else {
                echo "Error Saving Group Name";
            }
            break;
// set the old data link's charset
mysql_query("SET NAMES '{$PHORUM['DBCONFIG']['charset']}'", $oldlink);
// checking attachment-dir
if (!file_exists($CONVERT['attachmentdir']) || empty($CONVERT['attachmentdir'])) {
    echo "Directory {$CONVERT['attachmentdir']} doesn't exist. Attachments won't be converted. (doesn't matter if you don't have message-attachments) {$CONVERT['lbr']}";
}
$CONVERT['groups'] = array();
$CONVERT['do_groups'] = false;
// checking if the groups-table exists
if (phorum_convert_check_groups($oldlink)) {
    // reading groups (should be not too much, therefore we keep the array for later use)
    $CONVERT['groups'] = phorum_convert_getGroups($oldlink);
    if (count($CONVERT['groups'])) {
        echo "Writing groups ... {$CONVERT['lbr']}";
        foreach ($CONVERT['groups'] as $groupid => $groupdata) {
            phorum_db_add_group($groupdata['name'], $groupid);
            $CONVERT['groups'][$groupid]['group_id'] = $groupid;
        }
    }
    $CONVERT['do_groups'] = true;
}
$CONVERT['do_users'] = false;
// checking if the users-table exists
if (phorum_convert_check_users($oldlink)) {
    $CONVERT['do_users'] = true;
}
// reading the forums
$forums = phorum_convert_getForums($oldlink);
// going through all the forums (and folders)
echo "Writing forumdata ... {$CONVERT['lbr']}";
flush();
// Find out which forums already have a moderator group available.
$forum_has_moderator = array();
$groups = phorum_db_get_groups();
foreach ($groups as $id => $group) {
    foreach ($group['permissions'] as $forum_id => $permission) {
        if ($permission & PHORUM_USER_ALLOW_MODERATE_MESSAGES) {
            $forum_has_moderator[$forum_id] = TRUE;
        }
    }
}
print_r($forum_has_moderator);
foreach ($forums as $forum_id => $fdata) {
    if (!empty($fdata['folder_flag'])) {
        continue;
    }
    print "> forum {$fdata['name']} ";
    if (!empty($forum_has_moderator[$forum_id])) {
        print "[USE EXISTING]\n";
        continue;
    }
    $path = $fdata['forum_path'];
    array_unshift($path);
    $name = implode('::', $path);
    $group_id = phorum_db_add_group("Moderate {$name}");
    if (!$group_id) {
        die("Error adding group \"{$name}\".\n");
    }
    phorum_db_update_group(array('group_id' => $group_id, 'open' => 0, 'permissions' => array($forum_id => PHORUM_USER_ALLOW_READ | PHORUM_USER_ALLOW_REPLY | PHORUM_USER_ALLOW_NEW_TOPIC | PHORUM_USER_ALLOW_EDIT | PHORUM_USER_ALLOW_ATTACH | PHORUM_USER_ALLOW_MODERATE_MESSAGES | PHORUM_USER_ALLOW_MODERATE_USERS)));
    print "[CREATED GROUP]\n";
}
print "\n\n";