DevFuse Forums: Custom edit mod tools - DevFuse Forums

Jump to content

View All ProductsRandom Products

Logo View

Random Logos



IP.Board: IPB 3.1.x
Price: $ 14.95
Main Page

Timeslip System



IP.Board: IPB 3.1.x
Price: $ 18.95
Personal Message

Auto Birthday Greeter



IP.Board: IPB 3.1.x
Price: $ 10.95
Global Messages Public View

Global Messages



IP.Board: IPB 3.1.x
Price: $ 21.95
Manage Models

Garage System



IP.Board: IPB 3.1.x
Price: $ 34.95
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Custom edit mod tools

#1 User is offline   ShaneV 

  • Advanced Member
  • Group: Customers
  • Posts: 48
  • Joined: 16-April 09
  • Gender:Male
  • IP.Board Version:IPB 3.0.x

Posted 08 February 2010 - 02:10 PM

Hi,

I'm making an addon for my mods and everything working fine but i have one problem.
When a mod use it his postcount resets to 0 and also the reply count of the topic.

But i really cant see the problem or solution :p

Piece of the cake :p

		if($this->request['postREPLY'] == 'y')
		{
			$reply_author = "".$_COOKIE['member_id']."";
			$reply_author_name = $this->DB->buildAndFetch( array( 'select' => 'name', 'from' => 'members', 'where' => "member_id={$reply_author}") );
		
			$time_stamp = time();
			
			$mod_message = $this->request['reason'];
			
			$search  = array( "/%topic_title%/", "/%topic_link%/", "/%reason_note%/" );
			$replace = array( $this->topic['title'], "[url='{$this->settings['board_url']}/index.php?showtopic={$this->topic['tid']}']{$this->settings['board_url']}/index.php?showtopic={$this->topic['tid']}[/url]", $mod_message );			
			
			$tmessage = $this->settings['bs_advancedmodtools_disapprove_tm'];
			$tmessage = str_replace("\n", "<br />", $tmessage );

			$tmessage = preg_replace( $search, $replace, $tmessage );
			
			$this->DB->insert( 'posts', array(
												'author_id'			=> $reply_author,
												'author_name'		=> $reply_author_name,
												'ip_address'		=> '127.0.0.1',
												'post_date'			=> $time_stamp,
												'post'				=> $tmessage,
												'topic_id'			=> $this->topic['tid'] ,
							)				);			
			
			$this->DB->update( 'topics', array( 'posts' => 'posts+1',
												'last_poster_id' => $reply_author, 
												'last_post' => $time_stamp,
												'last_poster_name' => $reply_author_name['name']
											),
												'tid=' . $this->topic['tid'] 
								);
								
			$this->DB->update( 'members', array( 'posts' => 'posts+1' ),
												'member_id=' . $reply_author 
								);								
									
		}

0

#2 User is offline   Michael 

  • Management
  • Group: Management
  • Posts: 2,345
  • Joined: 22-September 05
  • Gender:Male
  • Location:Australia
  • IP.Board Version:IPB 3.0.x
  • First Name:Michael

Posted 09 February 2010 - 01:00 AM

Both your 'posts+1' updates won't work. There are 2 ways to have the post count increase.

1. This is from IPB3 own update query for post count. (Ideal for the topic post count, as you can include your last poster info as well.)

				$ta = array (
							  'db_field1'		=> 'blahblah',
							  'db_field2'	=> 'test2'
							);

				$this->DB->buildAndFetch( array( 'update' => 'topics', 'set' => $this->DB->compileUpdateString( $ta ) . ", posts=posts+1", 'where' => 'tid='.$tid ) );


2. The set data doesn't have to be in array format, it's either true then false or false then true at the end.

$this->DB->update( 'members', 'posts=posts+1', 'member_id=' . $reply_author, true, false ); 


If there is no specific reason, I suggest you use IPB3's inbuilt topic function, will handle all this plus other topic related functions.
DevFuse - My IP.Board development forums. Read my development blog here.

View My Paid Mods | View My Free Mods | Twitter Updates
0

#3 User is offline   ShaneV 

  • Advanced Member
  • Group: Customers
  • Posts: 48
  • Joined: 16-April 09
  • Gender:Male
  • IP.Board Version:IPB 3.0.x

Posted 13 February 2010 - 08:56 AM

Hi thanks Michael,

Query's looks like this now:
Wont reset to zero but also not increasing the count for topic count and user post count.

			$this->DB->insert( 'posts', array(
												'author_id'			=> $reply_author,
												'author_name'		=> $reply_author_name,
												'ip_address'		=> '127.0.0.1',
												'post_date'			=> $time_stamp,
												'post'				=> $tmessage,
												'topic_id'			=> $this->topic['tid'] ,
							)				);			
			
			$this->DB->update( 'topics', array( 'last_poster_id' => $reply_author, 
												'last_post' => $time_stamp,
												'last_poster_name' => $reply_author_name['name']
											),
												'tid=' . $this->topic['tid'] 
								);
								
								
			$this->DB->update( 'topics', 'posts=posts+1', 'tid=' . $this->topic['tid'], true, false ); 
			$this->DB->update( 'members', 'posts=posts+1', 'member_id=' . $reply_author, true, false ); 


I'm i still doing something wrong?

Grtz Shane
0

#4 User is offline   Michael 

  • Management
  • Group: Management
  • Posts: 2,345
  • Joined: 22-September 05
  • Gender:Male
  • Location:Australia
  • IP.Board Version:IPB 3.0.x
  • First Name:Michael

Posted 14 February 2010 - 12:52 AM

Try the other way around.

                        $this->DB->update( 'topics', 'posts=posts+1', 'tid=' . $this->topic['tid'], false, true ); 
                        $this->DB->update( 'members', 'posts=posts+1', 'member_id=' . $reply_author, false, true ); 

DevFuse - My IP.Board development forums. Read my development blog here.

View My Paid Mods | View My Free Mods | Twitter Updates
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users