Ejemplo n.º 1
0
function migrate_phpbb()
{
    global $gBitDb, $gBitSystem, $gLibertySystem, $db;
    if (!$gLibertySystem->isPluginActive('bbcode')) {
        $gLibertySystem->setActivePlugin('bbcode');
        $gLibertySystem->scanAllPlugins();
        if (!class_exists('HTML_BBCodeParser')) {
            print "bbcode format plugin is not active. make sure you have installed Pear Text_Wiki_BBCode with: <br/><code>pear install Text_Wiki_BBCode-alpha</code>";
            die;
        }
    }
    require_once LIBERTY_PKG_PATH . 'plugins/format.bithtml.php';
    if (ini_get('max_execution_time') < 300) {
        print "Your max_execution_time in your php.ini is set to " . ini_get('max_execution_time') . " seconds. We recommend you increase that.";
    }
    if (empty($_POST['Migrate'])) {
        print '<form method="POST"><input type="submit" name="Migrate" value="Migrate"/></form>';
        die;
    }
    $gBitDb->StartTrans();
    if ($forumList = $gBitDb->getAssoc("SELECT `forum_id`,`forum_name`, `forum_desc`,`content_id` FROM " . FORUMS_TABLE . " bbf LEFT JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (lc.`content_type_guid`='bitboard' AND bbf.`forum_name`=lc.`title`) ORDER BY bbf.forum_id")) {
        vd($forumList);
        flush();
        foreach (array_keys($forumList) as $forumId) {
            print "Migrating forum {$forumId}<br/>\n";
            flush();
            if (empty($forumList[$forumId]['content_id'])) {
                $forumStore = array();
                $forumStore['user_id'] = ROOT_USER_ID;
                $forumStore['title'] = $forumList[$forumId]['forum_name'];
                $forumStore['edit'] = $forumList[$forumId]['forum_desc'];
                $forumStore['migrate_board_id'] = $forumId;
                $forumStore['format_guid'] = 'bbcode';
                $newBoard = new BitBoard();
                if ($newBoard->store($forumStore)) {
                    $contentId = $newBoard->mContentId;
                    if ($gBitSystem->isPackageActive('pigeonholes')) {
                        // add board to pigeonhole category that should already be created...
                    }
                } else {
                    vd($newBoard->mErrors);
                }
            } else {
                $contentId = $forumList[$forumId]['content_id'];
            }
            if (!empty($contentId)) {
                migrate_phpbb_forum($forumId, $contentId);
            } else {
                vd("NO content_id for forum {$forumId}");
            }
        }
    }
    $gBitDb->CompleteTrans();
}
Ejemplo n.º 2
0
 /**
  * @param array pParamHash hash of values that will be used to store the group
  * be sure to pass by reference in case we need to make modifcations to the hash
  *
  * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
  *
  * @access public
  **/
 function store(&$pParamHash)
 {
     global $gBitUser, $gBitSystem;
     // Merge down groups prefix. This is a hack but is faster
     // than rewriting verify to use things from the "group" prefix.
     // @TODO: Rewire verify() to pull all data from 'group' prefix
     if (!empty($pParamHash['group'])) {
         $pParamHash = array_merge($pParamHash, $pParamHash['group']);
     }
     $this->mDb->StartTrans();
     // Verify and then store group and content.
     if ($this->verify($pParamHash) && $gBitUser->storeGroup($pParamHash) && LibertyMime::store($pParamHash)) {
         $table = BIT_DB_PREFIX . "groups";
         if ($this->mGroupId) {
             // editing an existing group
             $locId = array("group_id" => $pParamHash['group_id']);
             $result = $this->mDb->associateUpdate($table, $pParamHash['group_pkg_store'], $locId);
         } else {
             // new group
             $pParamHash['group_pkg_store']['content_id'] = $pParamHash['content_id'];
             $pParamHash['group_pkg_store']['group_id'] = $pParamHash['group_store']['group_id'];
             $this->mGroupId = $pParamHash['group_store']['group_id'];
             $result = $this->mDb->associateInsert($table, $pParamHash['group_pkg_store']);
             // Make sure this user is in the group
             $gBitUser->addUserToGroup($gBitUser->mUserId, $this->mGroupId);
             // Restore the group in users table to update the home link now that we have a group id
             $pParamHash['home'] = GROUP_PKG_URL . "index.php?group_id=" . $this->mGroupId;
             // Restore the home now
             $gBitUser->storeGroup($pParamHash);
             // Autogenerate a board for this group
             if ($gBitSystem->isPackageActive('boards')) {
                 require_once BOARDS_PKG_PATH . 'BitBoard.php';
                 $board = new BitBoard();
                 $boardHash = array("title" => $pParamHash['title'] . " " . tra('Forum'), "data" => tra('Message board for the ') . $pParamHash['title'] . " " . tra('Group'), 'boards_mailing_list' => preg_replace('/[^a-z0-9]/', '', strtolower($pParamHash['content_store']['title'])), 'boards_mailing_list_password' => substr(md5(rand()), 0, 8), 'group' => array('bypass_map_required' => TRUE));
                 if ($board->store($boardHash)) {
                     $this->linkContent($board->mInfo);
                     $this->mBoardObj =& $board;
                 } else {
                     $this->mErrors['board'] = tra('Unknown error while creating the board.');
                     $this->mErrors = array_merge($this->mErrors, $board->mErrors);
                 }
             }
         }
         // @TODO: This should be in boards
         if ($gBitSystem->isPackageActive('boards')) {
             if (empty($board) || !is_object($board)) {
                 $board = $this->getBoard();
             }
             // pass moderate messages selection on to our group board
             $modComments = $pParamHash['group_pkg_store']['mod_msgs'] == 'y' ? $pParamHash['group_pkg_store']['mod_msgs'] : NULL;
             $board->storePreference('moderate_comments', $modComments);
             $list = $board->getPreference('boards_mailing_list');
             if (!empty($list)) {
                 require_once UTIL_PKG_PATH . 'mailman_lib.php';
                 mailman_setmoderated($list, $modComments == 'y' ? 1 : 0);
             }
         }
         if (count($this->mErrors) == 0) {
             $this->mDb->CompleteTrans();
             $this->load();
         } else {
             $this->mDb->RollbackTrans();
             // Clear out the IDs
             $this->mContentId = NULL;
             $this->mGroupId = NULL;
         }
     }
     return count($this->mErrors) == 0;
 }