Example #1
0
            if ($PHORUM['cache_messages']) {
                phorum_api_cache_remove('message', $PHORUM["forum_id"] . "-" . $message_id);
            }
        }
    }
}
// Update all thread messages to the same closed setting.
if (!$message["parent_id"] && $origmessage["closed"] != $dbmessage["closed"]) {
    if ($dbmessage["closed"]) {
        $PHORUM['DB']->close_thread($message["thread"]);
    } else {
        $PHORUM['DB']->reopen_thread($message["thread"]);
    }
}
// Update thread info.
phorum_api_thread_update_metadata($message['thread']);
// Update thread subscription.
if (isset($message["subscription"])) {
    $subscribe_type = NULL;
    switch ($message["subscription"]) {
        case "bookmark":
            if ($PHORUM["DATA"]["OPTION_ALLOWED"]["subscribe"]) {
                $subscribe_type = PHORUM_SUBSCRIPTION_BOOKMARK;
            }
            break;
        case "message":
            if ($PHORUM["DATA"]["OPTION_ALLOWED"]["subscribe_mail"]) {
                $subscribe_type = PHORUM_SUBSCRIPTION_MESSAGE;
            }
            break;
        case "":
Example #2
0
         $PHORUM['DB']->update_settings($settings);
         // Generate the (at this point empty) cache data for the
         // custom field handling.
         phorum_api_custom_field_rebuild_cache();
         // posting forum and test-message
         // create an announcements forum
         $forum = array("name" => 'Announcements', "active" => 1, "description" => 'Read this forum first to find out the latest information.', "template" => $default_forum_options['template'], "folder_flag" => 0, "parent_id" => 0, "list_length_flat" => $default_forum_options['list_length_flat'], "list_length_threaded" => $default_forum_options['list_length_threaded'], "read_length" => $default_forum_options['read_length'], "moderation" => $default_forum_options['moderation'], "threaded_list" => $default_forum_options['threaded_list'], "threaded_read" => $default_forum_options['threaded_read'], "float_to_top" => $default_forum_options['float_to_top'], "display_ip_address" => $default_forum_options['display_ip_address'], "allow_email_notify" => $default_forum_options['allow_email_notify'], "language" => $default_forum_options['language'], "email_moderators" => $default_forum_options['email_moderators'], "display_order" => 99, "pub_perms" => $default_forum_options['pub_perms'], "reg_perms" => $default_forum_options['reg_perms'], "inherit_id" => 0, "forum_path" => 'a:2:{i:0;s:8:"Phorum 5";i:1;s:13:"Announcements";}');
         $PHORUM['DB']->add_forum($forum);
         // create a test forum
         $forum = array("name" => 'Test Forum', "active" => 1, "description" => 'This is a test forum.  Feel free to delete it or edit after installation, using the admin interface.', "template" => $default_forum_options['template'], "folder_flag" => 0, "parent_id" => 0, "list_length_flat" => $default_forum_options['list_length_flat'], "list_length_threaded" => $default_forum_options['list_length_threaded'], "read_length" => $default_forum_options['read_length'], "moderation" => $default_forum_options['moderation'], "threaded_list" => $default_forum_options['threaded_list'], "threaded_read" => $default_forum_options['threaded_read'], "float_to_top" => $default_forum_options['float_to_top'], "display_ip_address" => $default_forum_options['display_ip_address'], "allow_email_notify" => $default_forum_options['allow_email_notify'], "language" => $default_forum_options['language'], "email_moderators" => $default_forum_options['email_moderators'], "display_order" => 0, "pub_perms" => $default_forum_options['pub_perms'], "reg_perms" => $default_forum_options['reg_perms'], "inherit_id" => 0, "forum_path" => 'a:2:{i:0;s:8:"Phorum 5";i:2;s:10:"Test Forum";}');
         $PHORUM['forum_id'] = $PHORUM['DB']->add_forum($forum);
         $PHORUM['vroot'] = 0;
         // create a test post
         $test_message = array("forum_id" => $PHORUM["forum_id"], "thread" => 0, "parent_id" => 0, "author" => 'Phorum Installer', "subject" => 'Test Message', "email" => '', "ip" => '127.0.0.1', "user_id" => 0, "moderator_post" => 0, "closed" => 0, "status" => PHORUM_STATUS_APPROVED, "sort" => PHORUM_SORT_DEFAULT, "msgid" => '', "body" => "This is a test message. You can delete it after installation using the moderation tools. These tools will be visible in this screen if you log in as the administrator user that you created during install.\n\nPhorum 5 Team");
         $PHORUM['DB']->post_message($test_message);
         phorum_api_thread_update_metadata($test_message["thread"]);
         $PHORUM['DB']->update_forum_stats(true);
     }
     $frm = new PhorumInputForm("", "post", "Continue ->");
     $frm->addbreak("Creating tables....");
     $frm->addmessage($message);
     $frm->hidden("step", "create_tables");
     $frm->hidden("module", "install");
     $frm->hidden("sanity_checks_done", "1");
     $frm->show();
     break;
 case "create_admin_user":
     $frm = new PhorumInputForm("", "post");
     $frm->hidden("step", "create_admin_user");
     $frm->hidden("module", "install");
     $frm->hidden("sanity_checks_done", "1");
Example #3
0
 /**
  * Delete a message or a message tree from the database.
  *
  * @param integer $message_id
  *     The message_id of the message which should be deleted.
  *
  * @param integer $mode
  *     The mode of deletion. This is one of:
  *     - PHORUM_DELETE_MESSAGE: Delete a message and reconnect
  *       its reply messages to the parent of the deleted message.
  *     - PHORUM_DELETE_TREE: Delete a message and all its reply messages.
  *
  * @return array - An array of the message-ids deleted
  */
 public function delete_message($message_id, $mode = PHORUM_DELETE_MESSAGE)
 {
     settype($message_id, 'int');
     settype($mode, 'int');
     // Find the info for the message that has to be deleted.
     $msg = $this->interact(DB_RETURN_ASSOC, "SELECT forum_id, message_id, thread, parent_id\n             FROM   {$this->message_table}\n             WHERE  message_id = {$message_id}");
     // The message was not found in the database. Since this is the
     // situation that we want to end up with, consider this an okay
     // situation. If we would trigger an error here, moderators that
     // accidentally try to remove the same message twice (or two
     // moderators that try to delete the same message) would get
     // a nasty error message as a result.
     if (empty($msg)) {
         return array();
     }
     // Find all message_ids that have to be deleted, based on the mode.
     if ($mode == PHORUM_DELETE_TREE) {
         $mids = $this->get_messagetree($message_id, $msg['forum_id']);
         $where = "message_id IN ({$mids})";
         $mids = explode(',', $mids);
     } else {
         $mids = array($message_id);
         $where = "message_id = {$message_id}";
     }
     // First, the messages are unapproved, so replies will not get posted
     // during the time that we need for deleting them. There is still a
     // race condition here, but this already makes things quite reliable.
     $this->interact(DB_RETURN_RES, "UPDATE {$this->message_table}\n             SET    status=" . PHORUM_STATUS_HOLD . "\n             WHERE  {$where}", NULL, DB_MASTERQUERY);
     $thread = $msg['thread'];
     // Change reply messages to point to the parent of the deleted message.
     if ($mode == PHORUM_DELETE_MESSAGE) {
         // The forum_id is in here for speeding up the query
         // (with the forum_id a lookup key will be used).
         $this->interact(DB_RETURN_RES, "UPDATE {$this->message_table}\n                 SET    parent_id = {$msg['parent_id']}\n                 WHERE  forum_id  = {$msg['forum_id']} AND\n                        parent_id = {$msg['message_id']}", NULL, DB_MASTERQUERY);
     }
     // Delete the messages.
     $this->interact(DB_RETURN_RES, "DELETE FROM {$this->message_table}\n             WHERE {$where}", NULL, DB_MASTERQUERY);
     // Delete the read flags.
     $this->interact(DB_RETURN_RES, "DELETE FROM {$this->user_newflags_table}\n             WHERE {$where}", NULL, DB_MASTERQUERY);
     // Delete the edit tracking.
     $this->interact(DB_RETURN_RES, "DELETE FROM {$this->message_tracking_table}\n             WHERE {$where}", NULL, DB_MASTERQUERY);
     // Full text searching updates.
     $this->interact(DB_RETURN_RES, "DELETE FROM {$this->search_table}\n             WHERE {$where}", NULL, DB_MASTERQUERY);
     if ($mode != PHORUM_DELETE_TREE) {
         $mids = array($message_id);
     }
     // delete custom profile fields
     if (count($mids)) {
         $this->delete_custom_fields(PHORUM_CUSTOM_FIELD_MESSAGE, $mids);
     }
     // It kind of sucks to have this here, but it is the best way
     // to ensure that thread info gets updated if messages are deleted.
     // Leave this include down here, so it is included conditionally.
     require_once PHORUM_PATH . '/include/api/thread.php';
     phorum_api_thread_update_metadata($thread);
     // We need to delete the subscriptions for the thread too.
     $this->interact(DB_RETURN_RES, "DELETE FROM {$this->subscribers_table}\n             WHERE forum_id > 0 AND thread = {$thread}", NULL, DB_MASTERQUERY);
     // This function will be slow with a lot of messages.
     $this->update_forum_stats(TRUE);
     return $mids;
 }
Example #4
0
    while ($tcount) {
        $f = $forum_ids[$count % count($forum_ids)];
        print ".";
        $count++;
        $treemsgs = array();
        $parent = 0;
        $thread = 0;
        for ($i = 0; $i < $mcount; $i++) {
            $u = $user_ids[$i % count($user_ids)];
            $msg = array("parent_id" => $parent, "thread" => $thread, "forum_id" => $f, "subject" => "Message {$i} of stress batch thread {$batch} / {$count}", "body" => "I am just a test message, created by the Phorum\n" . "stress testing software. I have no value at all.\n", "user_id" => $u, "author" => $users[$u]["username"], "email" => '', "ip" => "127.0.0.1", "status" => PHORUM_STATUS_APPROVED, "msgid" => "<stressbatch_{$batch}_{$count}_{$i}@localhost>", "moderator_post" => 0, "sort" => PHORUM_SORT_DEFAULT, "closed" => 0);
            $PHORUM['DB']->post_message($msg);
            $thread = $msg["thread"];
            $treemsgs[] = $msg["message_id"];
            $parent = $treemsgs[array_rand($treemsgs)];
        }
        phorum_api_thread_update_metadata($thread);
        $tcount--;
    }
    print "\n";
    foreach ($forum_ids as $id) {
        $PHORUM["forum_id"] = $id;
        $PHORUM['DB']->update_forum_stats(true);
    }
}
if ($ncount) {
    print "\nSetting {$ncount} newflags for " . count($users) . " users:\n\n";
    $recent = $PHORUM['DB']->get_recent_messages($ncount);
    $markread = array();
    foreach ($recent as $id => $msg) {
        if ($id == 'users') {
            continue;
Example #5
0
settype($_POST['message'], "int");
settype($_POST['thread'], "int");
$PHORUM['DATA']['OKMSG'] = $PHORUM["DATA"]['LANG']['MsgSplitOk'];
$PHORUM['DATA']["URL"]["REDIRECT"] = $PHORUM["DATA"]["URL"]["LIST"];
$new_subject = isset($_POST['new_subject']) ? $_POST['new_subject'] : NULL;
$update_subjects = isset($_POST['update_subjects']);
$PHORUM['DB']->split_thread($_POST['message'], $_POST['forum_id'], $new_subject, $update_subjects);
if ($PHORUM['cache_messages']) {
    $message = $PHORUM['DB']->get_message($_POST['thread']);
    foreach ($message['meta']['message_ids'] as $message_id) {
        phorum_api_cache_remove('message', $message_id);
    }
}
// update message count / stats
phorum_api_thread_update_metadata($_POST['thread']);
phorum_api_thread_update_metadata($_POST['message']);
$PHORUM['DB']->update_forum_stats(TRUE);
/*
 * [hook]
 *     after_split
 *
 * [description]
 *     This hook can be used for performing actions on
 *     splitting threads
 *
 * [category]
 *     Moderation
 *
 * [when]
 *     In <filename>moderation.php</filename>, right after a thread has
 *     been split by a moderator.
Example #6
0
/**
 * @deprecated Replaced by {@link phorum_api_thread_update_metadata()}.
 */
function phorum_update_thread_info($thread_id)
{
    require_once PHORUM_PATH . '/include/api/thread.php';
    return phorum_api_thread_update_metadata($thread_id);
}
Example #7
0
     // Link attached files to the new message id.
     $linked_files = $PHORUM['DB']->get_message_file_list($oldid);
     foreach ($linked_files as $linked_file) {
         $PHORUM['DB']->file_link($linked_file['file_id'], $msg['message_id'], PHORUM_LINK_MESSAGE);
     }
     // save the new message-id for later use
     $msgid_translation[$oldid] = $msg['message_id'];
 }
 // deleting messages which are now doubled
 $PHORUM['DB']->delete_message($_POST['thread'], PHORUM_DELETE_TREE);
 // Update message count / stats.
 $PHORUM['DB']->update_forum_stats(true);
 // Change forum_id for the following calls to update the right forum.
 $PHORUM['forum_id'] = $target['forum_id'];
 // update message count / stats
 phorum_api_thread_update_metadata($target['thread']);
 $PHORUM['DB']->update_forum_stats(true);
 /*
  * [hook]
  *     after_merge
  *
  * [description]
  *     This hook can be used for performing actions on
  *     merging threads
  *
  * [category]
  *     Moderation
  *
  * [when]
  *     In <filename>moderation.php</filename>, right after two threads have
  *     been merged by a moderator.
Example #8
0
    echo "This script cannot be run from a browser.";
    return;
}
define('phorum_page', 'rebuild_thread_info');
define('PHORUM_ADMIN', 1);
require_once dirname(__FILE__) . '/../include/api.php';
require_once PHORUM_PATH . '/include/api/thread.php';
// Make sure that the output is not buffered.
phorum_api_buffer_clear();
if (!ini_get('safe_mode')) {
    set_time_limit(0);
    ini_set("memory_limit", "128M");
}
print "\nRebuilding thread info meta data ...\n";
$count_total = $PHORUM['DB']->interact(DB_RETURN_VALUE, "SELECT count(*)\n     FROM   {$PHORUM["message_table"]}\n     WHERE  parent_id = 0 AND\n            message_id = thread");
$res = $PHORUM['DB']->interact(DB_RETURN_RES, "SELECT message_id, forum_id\n     FROM   {$PHORUM["message_table"]}\n     WHERE  parent_id = 0 AND\n            message_id = thread");
$size = strlen($count_total);
$count = 0;
while ($row = $PHORUM['DB']->fetch_row($res, DB_RETURN_ROW)) {
    $PHORUM['forum_id'] = $row[1];
    phorum_api_thread_update_metadata($row[0]);
    $count++;
    $perc = floor($count / $count_total * 100);
    $barlen = floor(20 * ($perc / 100));
    $bar = "[";
    $bar .= str_repeat("=", $barlen);
    $bar .= str_repeat(" ", 20 - $barlen);
    $bar .= "]";
    printf("updating %{$size}d / %{$size}d  %s (%d%%)\r", $count, $count_total, $bar, $perc);
}
print "\n\n";