Advertisement:

Author Topic: info needed on Converting an old ipb forum to SMF 2.0.9  (Read 4395 times)

Offline aboulafia

  • Newbie
  • *
  • Posts: 2
info needed on Converting an old ipb forum to SMF 2.0.9
« on: February 05, 2015, 05:09:10 AM »
Hello,
i'm on my wait to converte an old ipb 1.3.1 forum.
but i'm haviing some trouble with the board permission convertion.

In the invision_to_smf.sql file, on line 627 i have this :
Quote
   
if (!empty($perms))
      convert_insert('board_permissions', array('id_board', 'id_group', 'permission'), $perms, 'replace');

This trigger an error because there is no id_board column in the board_permission table !!

Any idear ?

Offline margarett

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,761
  • Gender: Male
Re: info needed on Converting an old ipb forum to SMF 2.0.9
« Reply #1 on: February 05, 2015, 06:37:27 AM »
Hi and welcome ;)

Which converter are you using? The one from our downloads page?

edit: id_board really doesn't exist in board_permissions... I'll check
« Last Edit: February 05, 2015, 06:54:34 AM by margarett »
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

Quote
Over 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Offline aboulafia

  • Newbie
  • *
  • Posts: 2
Re: info needed on Converting an old ipb forum to SMF 2.0.9
« Reply #2 on: February 05, 2015, 07:45:38 AM »
version :

/******************************************************************************/
---~ name: "Invision Power Board"
/******************************************************************************/
---~ version: "SMF 2.0"
---~ settings: "/conf_global.php"


Offline margarett

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,761
  • Gender: Male
Re: info needed on Converting an old ipb forum to SMF 2.0.9
« Reply #3 on: February 05, 2015, 08:25:22 AM »
Well, it's really the first time I'm looking at this converter so I don't totally understand the "flow".

Anyway, you can try 2 things:
* One, replace that line with:
Code: [Select]
convert_insert('board_permissions', array('id_group', 'permission'), $perms, 'replace');(didn't tested it, not really sure about the outcome...)

* Two, if that fails, remove the whole "boar permissions" conversion
Code: [Select]
/******************************************************************************/
--- Converting board permissions...
/******************************************************************************/

---# Transforming board permissions...
---{
// This is SMF equivalent permissions.
$perm_equiv = array(
'start_perms' => array(
'post_new' => 1,
'poll_post' => 1,
'poll_add_own' => 1,
'modify_own' => 1,
'delete_own' => 1,
),
'read_perms' => array(
'mark_notify' => 1,
'mark_any_notify' => 1,
'poll_view' => 1,
'poll_vote' => 1,
'report_any' => 1,
'send_topic' => 1,
'view_attachments' => 1,
),
'reply_perms' => array(
'post_reply_own' => 1,
'post_reply_any' => 1,
),
'upload_perms' => array(
'post_attachments' => 1,
),
);

global $groupMask;

// We need to load the member groups that we care about at all.
$result = convert_query("
SELECT g_id AS id_group, g_perm_id AS perms
FROM {$from_prefix}groups
WHERE g_id != 5 AND g_id != 1 AND g_id != 4");
$groups = array();
$groupMask = array();
while ($row = convert_fetch_assoc($result))
{
$groups[] = $row['id_group'];
$groupMask[$row['id_group']] = $row['perms'];
}
convert_free_result($result);

if (!function_exists('magicMask'))
{
function magicMask(&$group)
{
/*
Right... don't laugh... here we explode the string to an array. Then we replace each group
with the groups that use this mask. Then we remove duplicates and then we implode it again
*/

global $groupMask;

if ($group != '*')
{
$groupArray = explode(',', $group);

$newGroups = array();
foreach ($groupMask as $id => $perms)
{
$perm = explode(',', $perms);
foreach ($perm as $realPerm)
if (in_array($realPerm, $groupArray) && !in_array($id, $newGroups))
$newGroups[] = $id;
}

$group = implode(',', $newGroups);
}
}
}

if (!function_exists('smfGroup'))
{
function smfGroup(&$group)
{
foreach ($group as $key => $value)
{
// Admin doesn't need to have his permissions done.
if ($value == 4)
unset($group[$key]);
elseif ($value == 2)
$group[$key] = -1;
elseif ($value == 3)
$group[$key] = 0;
elseif ($value > 5)
$group[$key] = $value + 3;
else
unset($group[$key]);
}
}
}

while (true)
{
pastTime($substep);

$result = convert_query("
SELECT id AS id_board, start_perms, reply_perms, read_perms, upload_perms
FROM {$from_prefix}forums
LIMIT $_REQUEST[start], 100");
$perms = array();
while ($row = convert_fetch_assoc($result))
{
$row = addslashes_recursive($row);

// Oh yea... this is the "mask -> group" conversion stuffs...
magicMask($row['start_perms']);
magicMask($row['reply_perms']);
magicMask($row['read_perms']);
magicMask($row['upload_perms']);

// This is used for updating the groups allowed on this board.
$affectedGroups = array();

// This is not at all fun... or the MOST efficient code but it should work.
// first the patented "if everything is open do didley squat" routine.
if ($row['start_perms'] == $row['reply_perms'] && $row['start_perms'] == $row['read_perms'] && $row['start_perms'] == $row['upload_perms'])
{
if ($row['read_perms'] != '*')
{
$affectedGroups = explode(',', $row['read_perms']);
smfGroup($affectedGroups);

// Update the board with allowed groups - appears twice in case board is hidden... makes sense to me :)
convert_query("
UPDATE {$to_prefix}boards
SET member_groups = '" . implode(', ', $affectedGroups) . "'
WHERE id_board = $row[id_board]");
}
}
else
{
$tempGroup = array();
/* The complicated stuff :)
First we work out which groups can access the board (ie ones who can READ it) - and set the board
permission for this. Then for every group we work out what permissions they have and add them to the array */
if ($row['read_perms'] != '*')
{
$affectedGroups = explode(',', $row['read_perms']);
smfGroup($affectedGroups);
// Update the board with allowed groups - appears twice in case board is hidden... makes sense to me :)
convert_query("
UPDATE {$to_prefix}boards
SET member_groups = '" . implode(', ', $affectedGroups) . "'
WHERE id_board = $row[id_board]");
}
else
{
$affectedGroups[] = -1;
$affectedGroups[] = 0;
}
// Now we know WHO can access this board, lets work out what they can do!
// Everyone who is in affectedGroups can read so...
foreach ($affectedGroups as $group)
$tempGroup[$group] = $perm_equiv['read_perms'];
if ($row['start_perms'] == '*')
$affectedGroups2 = $affectedGroups;
else
{
$affectedGroups2 = explode(',', $row['start_perms']);
smfGroup($affectedGroups2);
}
foreach ($affectedGroups2 as $group)
$tempGroup[$group] = isset($tempGroup[$group]) ? array_merge($perm_equiv['start_perms'], $tempGroup[$group]) : $perm_equiv['start_perms'];
if ($row['reply_perms'] == '*')
$affectedGroups2 = $affectedGroups;
else
{
$affectedGroups2 = explode(',', $row['reply_perms']);
smfGroup($affectedGroups2);
}
foreach ($affectedGroups2 as $group)
$tempGroup[$group] = isset($tempGroup[$group]) ? array_merge($perm_equiv['reply_perms'], $tempGroup[$group]) : $perm_equiv['reply_perms'];
if ($row['upload_perms'] == '*')
$affectedGroups2 = $affectedGroups;
else
{
$affectedGroups2 = explode(',', $row['upload_perms']);
smfGroup($affectedGroups2);
}
foreach ($affectedGroups2 as $group)
$tempGroup[$group] = isset($tempGroup[$group]) ? array_merge($perm_equiv['upload_perms'], $tempGroup[$group]) : $perm_equiv['upload_perms'];

// Now we have $tempGroup filled with all the permissions for each group - better do something with it!
foreach ($tempGroup as $groupno => $group)
foreach ($group as $permission => $dummy)
$perms[] = array($row['id_board'], $groupno, $permission);
}
}

if (!empty($perms))
convert_insert('board_permissions', array('id_board', 'id_group', 'permission'), $perms, 'replace');

$_REQUEST['start'] += 100;
if (convert_num_rows($result) < 100)
break;

convert_free_result($result);
}

$_REQUEST['start'] = 0;
---}
---#
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

Quote
Over 90% of all computer problems can be traced back to the interface between the keyboard and the chair