public function incrementPostCount($post, $new_tid)
    {
        Container::get('hooks')->fire('model.post.increment_post_count_start', $post, $new_tid);

        if (!User::get()->is_guest) {
            $increment = DB::forTable('users')
                            ->where('id', User::get()->id)
                            ->find_one()
                            ->set('last_post', $post['time'])
                            ->set_expr('num_posts', 'num_posts+1');
            $increment = Container::get('hooks')->fireDB('model.post.increment_post_count_query', $increment);
            $increment = $increment->save();

            // Promote this user to a new group if enabled
            if (User::get()->g_promote_next_group != 0 &&
                User::get()->num_posts + 1 >= User::get()->g_promote_min_posts) {
                $new_group_id = User::get()->g_promote_next_group;
                $promote = DB::forTable('users')
                            ->where('id', User::get()->id)
                            ->find_one()
                            ->set('group_id', $new_group_id);
                $promote = Container::get('hooks')->fireDB('model.post.increment_post_count_query', $promote);
                $promote = $promote->save();
            }

            // Topic tracking stuff...
            $tracked_topics = Track::getTrackedTopics();
            $tracked_topics['topics'][$new_tid] = time();
            Track::setTrackedTopics($tracked_topics);
        } else {
            // Update the last_post field for guests
            $last_post = DB::forTable('online')
                            ->where('ident', Utils::getIp())
                            ->find_one()
                            ->set('last_post', $post['time']);
            $last_post = Container::get('hooks')->fireDB('model.post.increment_post_count_last_post', $last_post);
            $last_post = $last_post->save();
        }

        Container::get('hooks')->fire('model.post.increment_post_count');
    }
public function incrementPostCount($post, $new_tid)
    {
        Container::get('hooks')->fire('model.post.increment_post_count_start', $post, $new_tid);

        if (!User::get()->is_guest) {
            $increment = DB::forTable('users')
                            ->where('id', User::get()->id)
                            ->find_one()
                            ->set('last_post', $post['time'])
                            ->set_expr('num_posts', 'num_posts+1');
            $increment = Container::get('hooks')->fireDB('model.post.increment_post_count_query', $increment);
            $increment = $increment->save();

            // Promote this user to a new group if enabled
            if (User::get()->g_promote_next_group != 0 &&
                User::get()->num_posts + 1 >= User::get()->g_promote_min_posts) {
                $new_group_id = User::get()->g_promote_next_group;
                $promote = DB::forTable('users')
                            ->where('id', User::get()->id)
                            ->find_one()
                            ->set('group_id', $new_group_id);
                $promote = Container::get('hooks')->fireDB('model.post.increment_post_count_query', $promote);
                $promote = $promote->save();
            }

            // Topic tracking stuff...
            $tracked_topics = Track::getTrackedTopics();
            $tracked_topics['topics'][$new_tid] = time();
            Track::setTrackedTopics($tracked_topics);
        } else {
            // Update the last_post field for guests
            $last_post = DB::forTable('online')
                            ->where('ident', Utils::getIp())
                            ->find_one()
                            ->set('last_post', $post['time']);
            $last_post = Container::get('hooks')->fireDB('model.post.increment_post_count_last_post', $last_post);
            $last_post = $last_post->save();
        }

        Container::get('hooks')->fire('model.post.increment_post_count');
    }
public function incrementPostCount ( $ post , $ new_tid ) { Container :: get ( 'hooks' ) -> fire ( 'model.post.increment_post_count_start' , $ post , $ new_tid ) ; if ( ! User :: get ( ) -> is_guest ) { $ increment = DB :: forTable ( 'users' ) -> where ( 'id' , User :: get ( ) -> id ) -> find_one ( ) -> set ( 'last_post' , $ post [ 'time' ] ) -> set_expr ( 'num_posts' , 'num_posts+1' ) ; $ increment = Container :: get ( 'hooks' ) -> fireDB ( 'model.post.increment_post_count_query' , $ increment ) ; $ increment = $ increment -> save ( ) ; // Promote this user to a new group if enabled if ( User :: get ( ) -> g_promote_next_group != 0 && User :: get ( ) -> num_posts + 1 >= User :: get ( ) -> g_promote_min_posts ) { $ new_group_id = User :: get ( ) -> g_promote_next_group ; $ promote = DB :: forTable ( 'users' ) -> where ( 'id' , User :: get ( ) -> id ) -> find_one ( ) -> set ( 'group_id' , $ new_group_id ) ; $ promote = Container :: get ( 'hooks' ) -> fireDB ( 'model.post.increment_post_count_query' , $ promote ) ; $ promote = $ promote -> save ( ) ; } // Topic tracking stuff... $ tracked_topics = Track :: getTrackedTopics ( ) ; $ tracked_topics [ 'topics' ] [ $ new_tid ] = time ( ) ; Track :: setTrackedTopics ( $ tracked_topics ) ; } else { // Update the last_post field for guests $ last_post = DB :: forTable ( 'online' ) -> where ( 'ident' , Utils :: getIp ( ) ) -> find_one ( ) -> set ( 'last_post' , $ post [ 'time' ] ) ; $ last_post = Container :: get ( 'hooks' ) -> fireDB ( 'model.post.increment_post_count_last_post' , $ last_post ) ; $ last_post = $ last_post -> save ( ) ; } Container :: get ( 'hooks' ) -> fire ( 'model.post.increment_post_count' ) ; }
Increment post count, change group if needed
Increment post count change group if needed