Exemplo n.º 1
0
                    } else {
                        echo $CONVERT['lbr'];
                    }
                    flush();
                    $count = 0;
                }
                $count++;
            } else {
                print "Error in message: " . $CONVERT['lbr'];
                print_var($newmessage);
                print $CONVERT['lbr'];
            }
        }
        echo "{$CONVERT['lbr']}Updating forum-statistics: {$CONVERT['lbr']}";
        flush();
        phorum_db_update_forum_stats(true);
        echo $CONVERT['lbr'];
        flush();
    }
}
unset($forums);
// storing the offsets of the forums
phorum_db_update_settings(array("conversion_offsets" => $offsets));
if ($CONVERT['do_groups'] && count($CONVERT['groups'])) {
    // here we set the group-permissions
    echo "Writing group-permissions ... {$CONVERT['lbr']}";
    foreach ($CONVERT['groups'] as $groupid => $groupdata) {
        phorum_db_update_group($groupdata);
    }
}
if ($CONVERT['do_users']) {
Exemplo n.º 2
0
 }
 if ($subscribe_type !== NULL) {
     phorum_api_user_subscribe($message["user_id"], $message["thread"], $PHORUM["forum_id"], $subscribe_type);
 } elseif ($mode == 'reply') {
     phorum_api_user_unsubscribe($message["user_id"], $message["thread"]);
 }
 if ($PHORUM["DATA"]["LOGGEDIN"]) {
     // Mark own message read.
     phorum_db_newflag_add_read(array(0 => array("id" => $message["message_id"], "forum" => $message["forum_id"])));
     // Increase the user's post count.
     phorum_api_user_increment_posts();
 }
 // Actions for messages which are approved.
 if ($message["status"] > 0) {
     // Update forum statistics.
     phorum_db_update_forum_stats(false, 1, $message["datestamp"]);
     // Mail subscribed users.
     phorum_email_notice($message);
 }
 // Mail moderators.
 if ($PHORUM["email_moderators"] == PHORUM_EMAIL_MODERATOR_ON) {
     phorum_email_moderators($message);
 }
 /*
  * [hook]
  *     after_post
  *
  * [description]
  *     This hook can be used for performing actions based on what the
  *     message contained. It is specifically useful for altering the
  *     redirect behavior.
Exemplo n.º 3
0
	/**
	 * Delete a message.
	 *
	 * This code is a modified from phorum_db_delete_message().
	 * There was no way around it except changing the mysql.php file,
	 * and I'm not sure the change would be accepted, so it must be
	 * re-implemented here.
	 *
	 * @param int $p_mode The mode of deletion,
	 * 		PHORUM_DELETE_MESSAGE for reconnecting the children,
	 * 		PHORUM_DELETE_TREE for deleting the children
	 * @return void
	 */
	public function delete($p_mode = PHORUM_DELETE_MESSAGE)
	{
		global $PHORUM;
		global $g_ado_db;
		unset($PHORUM['forum_id']);

		if (!$this->exists()) {
			return true;
		}
		
		$lockTables = array($PHORUM['message_table'],
                            $PHORUM['search_table'],
                            $PHORUM['subscribers_table']);
        $this->lockTables($lockTables);

	    if ($p_mode == PHORUM_DELETE_TREE) {
	    	$mids = phorum_db_get_messagetree($this->m_data['message_id'], $this->m_data['forum_id']);
	    } else {
	        $mids = $this->m_data['message_id'];
	    }

	    // unapprove the messages first so replies will not get posted
	    $sql = "UPDATE {$PHORUM['message_table']} "
	    		." SET status=".PHORUM_STATUS_HOLD
	    		." WHERE message_id IN ($mids)";
	    $g_ado_db->Execute($sql);

	    // Paul Baranowski: update thread depth for all children.
	    // Note this must come before you update the children's parent_id.
	    if ($p_mode == PHORUM_DELETE_MESSAGE) {
		    $this->__updateThreadDepth(array($this->m_data["message_id"]));
	    }

	    if ($p_mode == PHORUM_DELETE_MESSAGE) {
	        $count = 1;
	        // Change the children to point to their parent's parent.
	        // forum_id is in here for speed by using a key only
	        $sql = "UPDATE {$PHORUM['message_table']} "
	        		." SET parent_id=".$this->m_data["parent_id"]
	        		." WHERE forum_id=".$this->m_data["forum_id"]
	        		." AND parent_id=".$this->m_data["message_id"];
	        $g_ado_db->Execute($sql);
	    } else {
	        $count = count(explode(",", $mids));
	    }

	    // Delete the messages
	    $sql = "DELETE FROM {$PHORUM['message_table']} "
	    		." WHERE message_id IN ($mids)";
	    $g_ado_db->Execute($sql);

	    // start ft-search stuff
	    $sql = "DELETE FROM {$PHORUM['search_table']} "
	    	  ." WHERE message_id IN ($mids)";
	    $g_ado_db->Execute($sql);
	    // end ft-search stuff

	    $this->__updateThreadInfo();

	    // we need to delete the subscriptions for that thread too
	    $sql = "DELETE FROM {$PHORUM['subscribers_table']} "
	           ." WHERE forum_id > 0 AND thread=".$this->m_data['thread'];
	    $g_ado_db->Execute($sql);

	    // this function will be slow with a lot of messages.
	    // ??? Note: phorum_db_update_forum_stats() requires global parameter passing.
	    $PHORUM['forum_id'] = $this->m_data['forum_id'];
	    phorum_db_update_forum_stats(true);
	    $g_ado_db->Execute('UNLOCK TABLES');
	    
	    $this->unlockTables();

		$this->m_exists = false;

		return explode(",", $mids);
	} // fn delete
Exemplo n.º 4
0
/**
 * Move a thread to another forum.
 *
 * @param integer $thread_id
 *     The id of the thread that has to be moved.
 *
 * @param integer
 *     The id of the destination forum.
 */
function phorum_db_move_thread($thread_id, $toforum)
{
    $PHORUM = $GLOBALS['PHORUM'];
    settype($thread_id, 'int');
    settype($toforum, 'int');
    if ($toforum > 0 && $thread_id > 0) {
        // Retrieve the messages from the thread, so we know for which
        // messages we have to update the newflags and search data below.
        $thread_messages = phorum_db_get_messages($thread_id);
        unset($thread_messages['users']);
        // All we have to do to move the thread to a different forum,
        // is update the forum_id for the messages in that thread.
        // Simple, isn't it?
        phorum_db_interact(DB_RETURN_RES, "UPDATE {$PHORUM['message_table']}\n             SET    forum_id = {$toforum}\n             WHERE  thread   = {$thread_id}", NULL, DB_MASTERQUERY);
        // Update the stats for the source forum.
        phorum_db_update_forum_stats(TRUE);
        // Update the stats for the destination forum.
        $old_id = $GLOBALS['PHORUM']['forum_id'];
        $GLOBALS['PHORUM']['forum_id'] = $toforum;
        phorum_db_update_forum_stats(TRUE);
        $GLOBALS['PHORUM']['forum_id'] = $old_id;
        // Move the newflags and search data to the destination forum.
        /**
         * @todo In the move thread code, there are some flaws. The
         *       newflags for the user that is moving the message
         *       are used as the source for deciding what flags
         *       to delete or move for all other users. This results
         *       in strange newflag problems.
         *
         *       This main issue here is that the newflags should be
         *       handled separately for each user; no updates should be
         *       based on the newflags for the active user. The current
         *       algorithm will only make sure that the newflags will look
         *       correct for that specific user. The problem is that we
         *       do not yet have an idea on how to handle this with
         *       enough performance.
         */
        // First, gather information for doing the updates.
        $new_newflags = phorum_db_newflag_get_flags($toforum);
        $message_ids = array();
        $delete_ids = array();
        $search_ids = array();
        foreach ($thread_messages as $mid => $data) {
            // Gather information for updating the newflags.
            // Moving the newflag is only useful if it is higher than the
            // min_id of the target forum.
            if (!empty($new_newflags['min_id'][$toforum]) && $mid > $new_newflags['min_id'][$toforum]) {
                $message_ids[] = $mid;
            } else {
                // Other newflags can be deleted.
                $delete_ids[] = $mid;
            }
            // gather the information for updating the search table
            $search_ids[] = $mid;
        }
        // Move newflags.
        if (count($message_ids)) {
            phorum_db_newflag_update_forum($message_ids);
        }
        // Update subscriptions.
        if (count($message_ids)) {
            $ids_str = implode(', ', $message_ids);
            phorum_db_interact(DB_RETURN_RES, "UPDATE {$PHORUM['subscribers_table']}\n                 SET    forum_id = {$toforum}\n                 WHERE  thread IN ({$ids_str})", NULL, DB_MASTERQUERY);
        }
        // Delete newflags.
        if (count($delete_ids)) {
            $ids_str = implode(', ', $delete_ids);
            phorum_db_interact(DB_RETURN_RES, "DELETE FROM {$PHORUM['user_newflags_table']}\n                 WHERE  message_id IN({$ids_str})", NULL, DB_MASTERQUERY);
        }
        // Update search data.
        if (count($search_ids)) {
            $ids_str = implode(', ', $search_ids);
            phorum_db_interact(DB_RETURN_RES, "UPDATE {$PHORUM['search_table']}\n                 SET    forum_id = {$toforum}\n                 WHERE  message_id in ({$ids_str})", NULL, DB_MASTERQUERY);
        }
    }
}
Exemplo n.º 5
0
/**
 * actually moves a thread to the given forum
 */
function phorum_db_move_thread($thread_id, $toforum)
{
    $PHORUM = $GLOBALS["PHORUM"];

    settype($thread_id, "int");
    settype($toforum, "int");

    if($toforum > 0 && $thread_id > 0){
        $conn = phorum_db_postgresql_connect();
        // retrieving the messages for the newflags and search updates below
        $thread_messages=phorum_db_get_messages($thread_id);

        // just changing the forum-id, simple isn't it?
        $sql = "UPDATE {$PHORUM['message_table']} SET forum_id=$toforum where thread=$thread_id";

        $res = pg_query($conn, $sql);
        if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");

        // we need to update the number of posts in the current forum
        phorum_db_update_forum_stats(true);

        // and of the new forum
        $old_id=$GLOBALS["PHORUM"]["forum_id"];
        $GLOBALS["PHORUM"]["forum_id"]=$toforum;
        phorum_db_update_forum_stats(true);
        $GLOBALS["PHORUM"]["forum_id"]=$old_id;

        // move the new-flags and the search records for this thread
        // to the new forum too
        unset($thread_messages['users']);

        $new_newflags=phorum_db_newflag_get_flags($toforum);
        $message_ids = array();
        $delete_ids = array();
        $search_ids = array();
        foreach($thread_messages as $mid => $data) {
            // gather information for updating the newflags
            if($mid > $new_newflags['min_id']) { // only using it if its higher than min_id
                $message_ids[]=$mid;
            } else { // newflags to delete
                $delete_ids[]=$mid;
            }

            // gather the information for updating the search table
            $search_ids[] = $mid;
        }

        if(count($message_ids)) { // we only go in if there are messages ... otherwise an error occured

            $ids_str=implode(",",$message_ids);

            // then doing the update to newflags
            $sql="UPDATE {$PHORUM['user_newflags_table']} SET forum_id = $toforum where message_id IN($ids_str)";
            $res = pg_query($conn, $sql);
            if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");

            // then doing the update to subscriptions
            $sql="UPDATE {$PHORUM['subscribers_table']} SET forum_id = $toforum where thread IN($ids_str)";
            $res = pg_query($conn, $sql);
            if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");

        }

        if(count($delete_ids)) {
            $ids_str=implode(",",$delete_ids);
            // then doing the delete
            $sql="DELETE FROM {$PHORUM['user_newflags_table']} where message_id IN($ids_str)";
            pg_query($conn, $sql);
            if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");
        }

        if (count($search_ids)) {
            $ids_str = implode(",",$search_ids);
            // then doing the search table update
            $sql = "UPDATE {$PHORUM['search_table']} set forum_id = $toforum where message_id in ($ids_str)";
            pg_query($conn, $sql);
            if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");
        }

    }
}