Skip to main content
Topic: SMF Points (Read 5445 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

SMF Points

Hey people!

I'm thinking of manually editing elkarte files to include this mod: http://custom.simplemachines.org/mods/index.php?mod=1741

Of course some tweaking here and there is necessary but I'm curious to know what you folks think?

Is it quite a simple thing and should kinda work?

Or is it very hard to accomplish? :O
Facta, non verba.

Re: SMF Points

Reply #1

From a quick look it should generally work after its been converted to ElkArte ... The work will mostly be around converting the db querys to Elk format (easy) and then replacing the source edits in the install.xml with hooks (its unlikely that you will find those exact lines of code, but you should find hooks in the areas that were changed.)

Re: SMF Points

Reply #2

Alright nice, will give it a shot after 1.1 goes gold! :)
Facta, non verba.

Re: SMF Points

Reply #3

Consider that 1.1 will be "stable" in not less than 6 months. ;)
Bugs creator.
Features destroyer.
Template killer.

Re: SMF Points

Reply #4

 O:-)  Prays for the best haha
Facta, non verba.

Re: SMF Points

Reply #5

Yay I'm sort of done.

But there's one problem...

I've somehow hard coded the count based groups to follow the "points" instead of "posts". And it works.

But the problem is, everytime the points increase to the next group, it will not auto-refresh or auto-update.

Instead, I will need to go to any post-count based group, and just save it (without changing anything) and it will be refreshed.

Is there some "cronn" setting or something which functions to auto-update these groups?

What am I missing here? :O
Facta, non verba.

Re: SMF Points

Reply #6

I suppose you don't have any cache enabled, right?
You may have missed the update code?
See what you changed may help...
Bugs creator.
Features destroyer.
Template killer.

Re: SMF Points

Reply #7

These are what I've changed so far... hmm...

#Load.php
'points' => comma_format($profile['points']),
'points' => empty($user_settings['points']) ? 0 : $user_settings['points'],

================================


#GenericMessages.template.php
$poster_div .= '<li class="listlevel1 title">Points: ' . $message['member']['points'] . '</li>';

================================

#Membergroups.subs.php
WHEN points >= ' . $min_posts . (!empty($lastMin) ? ' AND points <= ' . $lastMin : '') . ' THEN ' . $id;



================================

#ProfileInfo.template.php
<dt>Points:</dt>

<dd>', $context['num_points'], ' points</dd>

if (!isset($context['disabled_fields']['posts']))
echo '
<dt>Points:</dt>
<dd>', $context['member']['points'], ' Points</dd>';



================================

#ProfileInfo.controller.php

$context['num_points'] = comma_format($user_profile[$this->_memID]['points']);



================================

#Post.subs.php

if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved'])
   {
            
      $point = 0;

      // no, BBCCode won't count
      $plaintext = preg_replace('[\[(.*?)\]]', ' ', $msgOptions['body']);
      // convert newlines to spaces
      $plaintext = str_replace(array('
', "\r", "\n"), ' ', $plaintext);
      // convert multiple spaces into one
      $plaintext = preg_replace('/\s+/', ' ', $plaintext);
         
      $words = str_word_count($plaintext);
         
      $point += (floor($words/25));

      // Limit?
      if ($point > 10)
         $point = 10;

      $db->query('', '
      UPDATE {db_prefix}members
      SET points = points + {int:point}
      WHERE id_member = {int:id_member}
      LIMIT 1',
         array(
            'point' => $point,
            'id_member' => $posterOptions['id']
         )
      );
   }




================================

 :o
Facta, non verba.

Re: SMF Points

Reply #8

This:
Code: [Select]
'points' => empty($user_settings['points']) ? 0 : $user_settings['points'], 
should likely be:
Code: [Select]
'points' => empty($profile['points']) ? 0 : $profile['points'], 
Bugs creator.
Features destroyer.
Template killer.

Re: SMF Points

Reply #9

Alright changed that! But sadly, still the same.

But oh well, at least it works in general.. as long as you manually refresh the post-count based groups every now and then. :)
Facta, non verba.

Re: SMF Points

Reply #10

Looking at the code of Post.subs.php you posted, a question: does it mean you removed the update of post counts at all?
Do you have the post count enabled on the boards you are posting to?
Bugs creator.
Features destroyer.
Template killer.

Re: SMF Points

Reply #11

Nope, the post counts are still working. You will still +1 for each post.

And yup, I have post counts enabled on those boards too. 
Last Edit: July 10, 2016, 04:23:39 am by niloc
Facta, non verba.

Re: SMF Points

Reply #12

Could you attach the modified files?
I have to test them and see what's happening. :)
Bugs creator.
Features destroyer.
Template killer.

Re: SMF Points

Reply #13

It would be great if the addon is ready for ElkArte :)

Re: SMF Points

Reply #14

Oh my... nearly forgot about this. @emanuele

Here's the modified files attached! :)

And also, yeah you'll need a new column "points" under the members table in the database.

Facta, non verba.