示例#1
0
文件: mysql.php 项目: sheldon/dejavu
/**
 * Split a thread.
 *
 * @param integer $message_id
 *     The id of the message at which to split a thread.
 *
 * @param integer $forum_id
 *     The id of the forum in which the message can be found.
 */
function phorum_db_split_thread($message_id, $forum_id)
{
    settype($message_id, 'int');
    settype($forum_id, 'int');
    if ($message_id > 0 && $forum_id > 0) {
        // Retrieve the message tree for all messages below the split message.
        // This tree is used for updating the thread ids of the children
        // below the split message.
        $tree = phorum_db_get_messagetree($message_id, $forum_id);
        // Turn the message into a thread starter message.
        phorum_db_interact(DB_RETURN_RES, "UPDATE {$GLOBALS['PHORUM']['message_table']}\n             SET    thread     = {$message_id},\n                    parent_id  = 0\n             WHERE  message_id = {$message_id}", NULL, DB_MASTERQUERY);
        // Link the messages below the split message to the split off thread.
        phorum_db_interact(DB_RETURN_RES, "UPDATE {$GLOBALS['PHORUM']['message_table']}\n             SET    thread = {$message_id}\n             WHERE  message_id IN ({$tree})", NULL, DB_MASTERQUERY);
    }
}
示例#2
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
示例#3
0
         if (isset($PHORUM['args']['onlyunapproved']) && is_numeric($PHORUM['args']['onlyunapproved'])) {
             if (!empty($addcode)) {
                 $addcode .= ",";
             }
             $addcode .= "onlyunapproved=" . $PHORUM['args']['onlyunapproved'];
         }
         $PHORUM['DATA']["URL"]["REDIRECT"] = phorum_get_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_UNAPPROVED, $addcode);
     } else {
         $PHORUM['DATA']["URL"]["REDIRECT"] = $PHORUM["DATA"]["URL"]["LIST"];
     }
     break;
 case PHORUM_HIDE_POST:
     // hiding a message (and its replies)
     $old_message = phorum_db_get_message($msgthd_id);
     $newpost = array("status" => PHORUM_STATUS_HIDDEN);
     $mids = phorum_db_get_messagetree($msgthd_id, $old_message["forum_id"]);
     // make an array from the string
     $mids_arr = explode(",", $mids);
     // count the entries for later use
     $num_hidden = count($mids_arr);
     foreach ($mids_arr as $key => $mid) {
         // setting the new status
         phorum_db_update_message($mid, $newpost);
     }
     /*
      * [hook]
      *     hide_thread
      *
      * [description]
      *     This hook can be used for performing actions like sending
      *     notifications or making log entries after hiding a message.
示例#4
0
/**
 * split thread
 */
function phorum_db_split_thread($message, $forum_id)
{
    settype($message, "int");
    settype($forum_id, "int");

    if($message > 0 && $forum_id > 0){
        // get message tree for update thread id
        $tree =phorum_db_get_messagetree($message, $forum_id);
        $queries =array();
        $queries[0]="UPDATE {$GLOBALS['PHORUM']['message_table']} SET thread='$message', parent_id='0' WHERE message_id ='$message'";
        $queries[1]="UPDATE {$GLOBALS['PHORUM']['message_table']} SET thread='$message' WHERE message_id IN ($tree)";
        phorum_db_run_queries($queries);
    }
}