ElkArte Community

Extending Elk => Addons => Addons ideas and questions => Topic started by: niloc on June 16, 2016, 11:09:22 pm

Title: SMF Points
Post by: niloc on June 16, 2016, 11:09:22 pm
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
Title: Re: SMF Points
Post by: Spuds on June 17, 2016, 07:50:45 pm
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.)
Title: Re: SMF Points
Post by: niloc on June 18, 2016, 04:13:27 am
Alright nice, will give it a shot after 1.1 goes gold! :)
Title: Re: SMF Points
Post by: emanuele on June 18, 2016, 07:51:00 am
Consider that 1.1 will be "stable" in not less than 6 months. ;)
Title: Re: SMF Points
Post by: niloc on June 18, 2016, 07:54:40 am
 O:-)  Prays for the best haha
Title: Re: SMF Points
Post by: niloc on June 30, 2016, 11:13:54 pm
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
Title: Re: SMF Points
Post by: emanuele on July 01, 2016, 04:04:38 am
I suppose you don't have any cache enabled, right?
You may have missed the update code?
See what you changed may help...
Title: Re: SMF Points
Post by: niloc on July 01, 2016, 05:12:43 am
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
Title: Re: SMF Points
Post by: emanuele on July 01, 2016, 08:00:30 am
This:
Code: [Select]
'points' => empty($user_settings['points']) ? 0 : $user_settings['points'], 
should likely be:
Code: [Select]
'points' => empty($profile['points']) ? 0 : $profile['points'], 
Title: Re: SMF Points
Post by: niloc on July 02, 2016, 01:16:06 am
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. :)
Title: Re: SMF Points
Post by: emanuele on July 02, 2016, 04:35:18 am
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?
Title: Re: SMF Points
Post by: niloc on July 02, 2016, 10:31:35 pm
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. 
Title: Re: SMF Points
Post by: emanuele on July 06, 2016, 07:42:04 am
Could you attach the modified files?
I have to test them and see what's happening. :)
Title: Re: SMF Points
Post by: Jason on July 31, 2016, 09:24:48 am
It would be great if the addon is ready for ElkArte :)
Title: Re: SMF Points
Post by: niloc on July 31, 2016, 11:54:19 am
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.

Title: Re: SMF Points
Post by: Jason on July 31, 2016, 01:59:14 pm
Quote from: niloc – 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.



Is it ready Niloc? Should i test it in my localhost
Title: Re: SMF Points
Post by: meetdilip on July 31, 2016, 02:00:25 pm
Quote from: niloc – And also, yeah you'll need a new column "points" under the members table in the database.

How can we do that ?
Title: Re: SMF Points
Post by: ahrasis on August 01, 2016, 12:10:52 am
Quote from: niloc – Here's the modified files attached! :)

And also, yeah you'll need a new column "points" under the members table in the database.
Great job! Keep it up.

But may be you can create the new column via the addon itself? I can't remember "the how" very well, unless I really put my mind into it, but I think others can help on that.
Title: Re: SMF Points
Post by: niloc on August 01, 2016, 01:11:07 am
Quote from: Jason –
Quote from: niloc – 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.



Is it ready Niloc? Should i test it in my localhost

Oh no it's not ready.. it's just for emanuele to help me sort out with a bug. :(