HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


OCRewards - Comments

Login / Search

 [ Join | More ]
 

OCRewards by Arbo

Downloads: 904
Added: 28 September 2012
Rating: Item has a rating of 5 (Liked by FletchLiked by JeanLiked by Duck)
UPDATED to V9.1 (9.28.12)

Allows 'rewards' of different types to be assigned to users, or automatically applied to users.   You can manually assign a user an award by going to their profile, selecting the edit tab then the rewards tab.   The automatically updated stuff (methods) is done in a cron job.   If you do not have cron set up for your site, you will need to run <yoursite>/data/cron_bridge.php manually in order for the 'method'ed rewards to be updated.

Methods…

Avatar
On v9.0.6 this addon errors in install so there is a fix needed to be added to it found here:

http://ocportal.com/tracker/file_download.php?file_id=488&type=bug

Avatar
A couple of bug fixes for this addon:

In sources_custom/hooks/systems/profiles_tabs_edit/rewards.php:

Code

          if ((!($GLOBALS['FORUM_DB']->query_select('ocrewards_members',array('id'),array('user_id'=>$member_id_of,'reward_id'=>$group['id']),NULL))) AND ($group['enabled']==1)) {
            $_rtype->attach(form_input_list_entry(strval($group['id']),0,$group['name']));
         }
         if ((($GLOBALS['FORUM_DB']->query_select('ocrewards_members',array('id'),array('user_id'=>$member_id_of,'reward_id'=>$group['id']),NULL))) AND ($group['enabled'])) {
           $_xtype->attach(form_input_list_entry(strval($group['id']),0,$group['name']));
         }
should be:

Code

          if ((!($GLOBALS['FORUM_DB']->query_select('ocrewards_members',array('id'),array('user_id'=>$member_id_of,'reward_id'=>$group['id']),NULL))) AND ($group['enabled']==1)) {
            $_rtype->attach(form_input_list_entry(strval($group['id']),'0',$group['name']));
         }
         if ((($GLOBALS['FORUM_DB']->query_select('ocrewards_members',array('id'),array('user_id'=>$member_id_of,'reward_id'=>$group['id']),NULL))) AND ($group['enabled'])) {
           $_xtype->attach(form_input_list_entry(strval($group['id']),'0',$group['name']));
         }

In adminzone/pages/modules_custom/admin_ocrewards.php, TINY_INTEGER needs to be SHORT_INTEGER.
Avatar
To fix profile editing, in sources/hooks/systems/profiles_tabs_edit/rewards.php change:

Code

      $fields->attach(form_input_list(do_lang_tempcode('RGIVE'),do_lang_tempcode('REWARD_GIVE'),'rtype',$_rtype,NULL,false,true));
      $fields->attach(form_input_tick(do_lang_tempcode('GIVE'),do_lang_tempcode('DESCRIPTION_GIVE'),'give',false));
      $fields->attach(form_input_list(do_lang_tempcode('RREMOVE'),do_lang_tempcode('REWARD_REMOVE'),'xtype',$_xtype,NULL,false,true));
      $fields->attach(form_input_tick(do_lang_tempcode('REMOVE'),do_lang_tempcode('DESCRIPTION_REMOVE'),'remove',false));
to:

Code

      if (!$_rtype->is_empty())
      {
         $fields->attach(form_input_list(do_lang_tempcode('RGIVE'),do_lang_tempcode('REWARD_GIVE'),'rtype',$_rtype,NULL,false));
         $fields->attach(form_input_tick(do_lang_tempcode('GIVE'),do_lang_tempcode('DESCRIPTION_GIVE'),'give',false));
      }
      if (!$_xtype->is_empty())
      {
         $fields->attach(form_input_list(do_lang_tempcode('RREMOVE'),do_lang_tempcode('REWARD_REMOVE'),'xtype',$_xtype,NULL,false));
         $fields->attach(form_input_tick(do_lang_tempcode('REMOVE'),do_lang_tempcode('DESCRIPTION_REMOVE'),'remove',false));
      }


Avatar
Excellent Work! Thanks so much for this Addon Arbo!

BTW I have a suggestion for future improvement if you're up to it. If not I may mod it myself when I have the time for it and add it back. But here is the idea:

I think For the Methods field in adding a reward it sould be a dropdown list of available methods for users to choose. I think it would be even better (but not absolutely neccessary) if that Drop down list was A) in nice human readable format (ie "User Posts Greater Than" instead of user_post_gt) and B) if upon selecting the method you had a little message that not only possibly described the method but also told you the acceptable paramaters for the method.

I think maybe (but I could be wrong) the best method for achieveing the basics of this is to add one more table that holds the following 5 fields:
id
method_code_name (ie users_posts_gt)
method_human_name
description
acceptable_parameters

Then in the rewards table you store the refernce to method id istead of method name.

Coders or user making new methods could add their methods to the methods table then and have em show up in the list.

Just a thought in case you were planning on future improvements but asis it is still an awesome product. Great work!
Avatar
Come to think of it you could probably skip the fifth field of acceptable paramaters and just have that in the description but I was thinking somehow that could also be used for validation somehow but again not necessary.

Avatar
That is a good idea, I had originally thought of listing them all out at the opening of the 'manage rewards' screen…  but this idea would be a bit better.   Would have to change a few things, but it would be an improvement.

Avatar
I can do the selection box, having trouble figuring out how to do the little message once an item is selected..  It would be nice if selecting a choice would refresh say the description, but can't figure out how to accomplish that..


Avatar
I would imagine ocPortal has some JS libraries to do that somewhere? The Question is where? lol
Avatar
Sound like what you are looking for is catching the onchange event. See BLOCK_SIDE_LANGUAGE.tpl for an example of doing that the OCP way
Avatar
Unfortunately I don't know squat about JS to know what any of that does.   Also, I don't want to edit a system template for that, and not sure that whichever one AED uses has any of that.
Avatar
Fair enough. That template just showed an example use of an "onchange" trigger attached to the dropdown list (the main point) and what to do if the user has javascript disabled (potentially useful).

Out of curiosity (and for potential future reference), I've just had a quick look at AED (for the first time) so see how it might be integrated. I can't see any obvious hooks for a field event, so my rough thinking, by just looking at the code and not actually playing with it, on how it might be doable is along the lines of:

* Make a new template based on FORM_SCREEN_INPUT_LIST.tpl and add an appropriate "onchange" attribute. Something like "onchange='updateRewardDescription();'" to handle the client side javascript update of the description.

* In order for that new template to be recognised you would override the "form_input_list" function (found in form_templates.php) and change the template name to match the new one. If you have more then one dropdown list on the page then make the template name change conditional.

* Add the actual updateRewardDescription() code to the $javascript variable.





1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: