|
From: Bart v. B. <ba...@us...> - 2001-12-06 18:04:42
|
Update of /cvsroot/phpbb/phpBB2
In directory usw-pr-cvs1:/tmp/cvs-serv4619
Modified Files:
upgrade.php
Log Message:
Added conversion of private forums
Index: upgrade.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/upgrade.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** upgrade.php 2001/12/01 12:43:43 1.5
--- upgrade.php 2001/12/06 18:04:38 1.6
***************
*** 308,312 ****
{
// Print out link to next step and wait only if we are not debugging.
! print "<br><a href=\"$PHP_SELF?next=$next\">Next step: $next</a><br>\n";
break;
}
--- 308,312 ----
{
// Print out link to next step and wait only if we are not debugging.
! print "<br><a href=\"$PHP_SELF?next=$next\">Next step: <b>$next</b></a><br>\n";
break;
}
***************
*** 361,365 ****
case 'mod_old_tables':
common_header();
- echo "<H2>Step 2: Rename tables</H2>\n";
$modtables = array(
--- 361,364 ----
***************
*** 403,407 ****
case 'create_tables':
common_header();
- echo "<H2>Step 2: Create new phpBB2 tables</H2>\n";
// Create array with tables in 'old' database
--- 402,405 ----
***************
*** 464,474 ****
query($sql, "Couldn't update config table with values from old config table");
}
- end_step('droptables');
case 'droptables':
//drop access, whosonline, sessions (recreate)
echo "Nothing here yet<br>\n";
- end_step('convert_ip_date');
case 'convert_ip_date':
common_header();
--- 462,472 ----
query($sql, "Couldn't update config table with values from old config table");
}
+ end_step('droptables');
case 'droptables':
//drop access, whosonline, sessions (recreate)
echo "Nothing here yet<br>\n";
+ end_step('convert_ip_date');
case 'convert_ip_date':
common_header();
***************
*** 494,499 ****
common_footer();
end_step('fix_addslashes');
-
case 'fix_addslashes':
$slashfields[TOPICS_TABLE] = array('topic_title');
--- 492,497 ----
common_footer();
+
end_step('fix_addslashes');
case 'fix_addslashes':
$slashfields[TOPICS_TABLE] = array('topic_title');
***************
*** 528,533 ****
}
lock_tables(0);
end_step('convert_users');
-
case 'convert_users':
$sql = "
--- 526,531 ----
}
lock_tables(0);
+
end_step('convert_users');
case 'convert_users':
$sql = "
***************
*** 639,643 ****
case '4':
$row['user_level'] = ADMIN;
- print $row['username'] . " is an admin. Giving level: ". ADMIN . "<br>\n";
break;
case '-1':
--- 637,640 ----
***************
*** 667,673 ****
lock_tables(0);
}
end_step('convert_posts');
-
-
case 'convert_posts':
common_header();
--- 664,669 ----
lock_tables(0);
}
+
end_step('convert_posts');
case 'convert_posts':
common_header();
***************
*** 750,756 ****
lock_tables(0);
}
-
- end_step('convert_pm');
case 'convert_pm':
$sql = "
--- 746,751 ----
lock_tables(0);
}
+ end_step('convert_pm');
case 'convert_pm':
$sql = "
***************
*** 851,858 ****
}
lock_tables(0);
- end_step('convert_mods');
case 'convert_mods';
- echo "<h3>Converting moderator table</h3>";
$sql = "SELECT * FROM forum_mods";
$result = query($sql, "Couldn't get list with all forum moderators");
--- 846,852 ----
}
lock_tables(0);
+ end_step('convert_mods');
case 'convert_mods';
$sql = "SELECT * FROM forum_mods";
$result = query($sql, "Couldn't get list with all forum moderators");
***************
*** 883,895 ****
$group_id = $group_id['group_id'];
$sql = "INSERT INTO ".AUTH_ACCESS_TABLE." (group_id, forum_id, auth_mod) VALUES ($group_id, ".$row['forum_id'].", 1)";
query($sql, "Couldn't set moderator (user_id = ".$row['user_id'].") for forum ".$row['forum_id'].".");
}
-
-
!
! end_step('update_schema');
case 'update_schema':
common_header();
--- 877,934 ----
$group_id = $group_id['group_id'];
+ print "Adding moderator for forum ".$row['forum_id']."<br>\n";
$sql = "INSERT INTO ".AUTH_ACCESS_TABLE." (group_id, forum_id, auth_mod) VALUES ($group_id, ".$row['forum_id'].", 1)";
query($sql, "Couldn't set moderator (user_id = ".$row['user_id'].") for forum ".$row['forum_id'].".");
}
! end_step('convert_privforums');
! case 'convert_privforums':
! $sql = "SELECT fa.*, forum_name FROM forum_access fa LEFT JOIN forums f using (forum_id) ORDER BY fa.forum_id, fa.user_id";
! $forum_access = query($sql, "Couldn't get list with special forum access (forum_access)");
! while($row = mysql_fetch_array($forum_access))
! {
! // Iterate trough access table
! if($row['forum_id'] != $forum_id)
! {
! // This is a new forum, create new group.
! $forum_id = $row['forum_id'];
! $sql = "INSERT INTO ".GROUPS_TABLE."
! (group_type, group_name, group_description, group_moderator, group_single_user)
! VALUES
! (".GROUP_HIDDEN.", '".addslashes($row['forum_name'])." Group', 'Converted group', ".$row['user_id'].", 0)
! ";
!
! print "Creating new group for (private) forum: $forum_id<br>\n";
! $result = query($sql, "Couldn't create group for ".$row['forum_name']);
! $group_id = $db->sql_nextid($result);
! if( $group_id <= 0 )
! {
! print "<font color=\"red\">Group creation failed. Aborting creation of groups...<br></font>\n";
! continue 2;
! }
! print "Creating auth_access group for forum: $forum_id<br>\n";
! $sql = "INSERT INTO ".AUTH_ACCESS_TABLE."
! (group_id, forum_id, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete)
! VALUES
! ($group_id, $forum_id, 1, 1, 1, 1, 1, 1)
! ";
! $result = query($sql, "Unable to set group auth access.");
! if( $db->sql_affectedrows($result) <= 0 )
! {
! print "<font color=\"red\">Group creation failed. Aborting creation of groups...</font><br>\n";
! continue 2;
! }
! }
! // Add user to the group
! $user_id = $row['user_id'];
! $sql = "INSERT INTO ".USER_GROUP_TABLE ."
! (group_id, user_id, user_pending)
! VALUES
! ($group_id, $user_id, 0)
! ";
! query($sql, "Unable to add user_id $user_id to group_id $group_id <br>\n");
! }
+ end_step('update_schema');
case 'update_schema':
common_header();
***************
*** 985,988 ****
--- 1024,1103 ----
}
+ end_step('convert_forums');
+ case 'convert_forums':
+ $sql = "SELECT * FROM ".FORUMS_TABLE;
+ $result = query($sql, "Couldn't get list with all forums");
+ while($row = mysql_fetch_array($result))
+ {
+ print "Converting forumpermissions for forum: '".$row['forum_name'] ."'.<br>\n";
+ // Old auth structure:
+ // forum_type: (only concerns viewing)
+ // 0 = Public
+ // 1 = Private
+ switch($row['forum_type'])
+ {
+ case 0:
+ $auth_view = AUTH_ALL;
+ $auth_read = AUTH_ALL;
+ break;
+ default:
+ $auth_view = AUTH_ALL;
+ $auth_read = AUTH_ALL;
+ break;
+ }
+
+ // forum_access: (only concerns posting)
+ // 1 = Registered users only
+ // 2 = Anonymous Posting
+ // 3 = Moderators/Administrators only
+ switch($row['forum_access'])
+ {
+ case 1:
+ // Public forum, no anonymous posting
+ $auth_post = AUTH_REG;
+ $auth_reply = AUTH_REG;
+ $auth_edit = AUTH_REG;
+ $auth_delete = AUTH_REG;
+ $auth_vote = AUTH_REG;
+ $auth_pollcreate = AUTH_REG;
+ $auth_sticky = AUTH_MOD;
+ $auth_announce = AUTH_MOD;
+ break;
+ case 2:
+ $auth_post = AUTH_ALL;
+ $auth_reply = AUTH_ALL;
+ $auth_edit = AUTH_ALL;
+ $auth_delete = AUTH_ALL;
+ $auth_vote = AUTH_ALL;
+ $auth_pollcreate = AUTH_ALL;
+ $auth_sticky = AUTH_MOD;
+ $auth_announce = AUTH_MOD;
+ break;
+ default:
+ $auth_post = AUTH_MOD;
+ $auth_reply = AUTH_MOD;
+ $auth_edit = AUTH_MOD;
+ $auth_delete = AUTH_MOD;
+ $auth_vote = AUTH_MOD;
+ $auth_pollcreate = AUTH_MOD;
+ $auth_sticky = AUTH_MOD;
+ $auth_announce = AUTH_MOD;
+ break;
+ }
+
+ $sql = "UPDATE ".FORUMS_TABLE." SET
+ auth_view = $auth_view,
+ auth_read = $auth_read,
+ auth_post = $auth_post,
+ auth_edit = $auth_edit,
+ auth_delete = $auth_delete,
+ auth_vote = $auth_vote,
+ auth_pollcreate = $auth_pollcreate,
+ auth_sticky = $auth_sticky,
+ auth_announce = $auth_announce
+ WHERE forum_id = ". $row['forum_id'];
+ query($sql, "Was unable to update forum permissions!");
+ }
+
end_step('insert_themes');
case 'insert_themes':
|