Jump to content

  • twitter
  • youtube
  • googleplus
  • facebook
  • rss
  • newsletter


Custom edit mod tools


  • Please log in to reply
3 replies to this topic

#1 ShaneV

ShaneV

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts
  • 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 
								);								
									
		}


#2 Michael

Michael

    Management

  • Management
  • 3,135 posts
  • Gender:Male
  • Location:Australia
  • IP.Board Version:IPB 3.1.x
  • First Name:Michael
Donator

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.

Keep up to date with DevFuse mod development and releases.

Posted Image Posted Image Posted Image Posted Image Posted Image


#3 ShaneV

ShaneV

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts
  • 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

#4 Michael

Michael

    Management

  • Management
  • 3,135 posts
  • Gender:Male
  • Location:Australia
  • IP.Board Version:IPB 3.1.x
  • First Name:Michael
Donator

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 ); 

Keep up to date with DevFuse mod development and releases.

Posted Image Posted Image Posted Image Posted Image Posted Image





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users