سؤال

I am trying to make the UserPoints system in JomSocial 2.8 work like credits. I want to REQUIRE a certain amount of points in order to use a rule. Right now they have Give and Deduct points, but no option to Require a certain amount.

Can someone guide me to a solution to figure this out. I am looking either for a plugin/extension or an idea on the logic on how to develop this. I am a Front End Developer with knowledge of PHP so any help is appreciated!

هل كانت مفيدة؟

المحلول

With little help, i found a plugin for joomla which integrates with jomsocial and kunena. It is called AlphaUserPoints - www.alphaplug.com everything and more then I need with many extensions. Hope this helps someone!

Edit: this does not integrate fully with jomsocial, meaning most actions for not having enough points does not work. They are called by ajax and is not seen by the aup component in time to stop the operation.

نصائح أخرى

I know this is an old question, but I recently had the same exact need. After looking around for a few days, I decided to figure it out for myself. Most of it came from the AUP docs, so here is what you do: Jomsocial 4.2 - latest release Open components/com_community/controllers/photos.php Around line 2924 after

$preMessage = '';

        if (CLimitsLibrary::exceedDaily('photos', $my->id)) {

            $preMessage = JText::_('COM_COMMUNITY_PHOTOS_LIMIT_PERDAY_REACHED');

            $disableUpload = true;

        } else {

            $preMessage = JText::_('COM_COMMUNITY_PHOTOS_DEFAULT_UPLOAD_NOTICE');

            $disableUpload = false;

        }

Add:

//AlphaUserPoints start
$api_AUP =  JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);            
}
//Alphauserpoints Get user points
    $user = & JFactory::getUser(); 
    $userid = $user->id ; 
    $totalPoints = AlphaUserPointsHelper::getCurrentTotalPoints( '', $userid  ); 
// Function to check if enough points
if ($totalPoints < 5) { // enter your Points Cost per Upload

            $preMessage = JText::_('COM_COMMUNITY_PHOTOS_LIMIT_POINTS_REACHED');

            $disableUpload = true;

        } else {

            $preMessage = JText::_('COM_COMMUNITY_PHOTOS_POINTS_UPLOAD_NOTICE');

            $disableUpload = false;

        }

Now go to line 61601 - look for:

if ($my->id == 0) {

            $tokenId = $jinput->request->get('token', '', 'NONE');

            $userId = $jinput->request->get('uploaderid', '', 'NONE');

            $my = CFactory::getUserFromTokenId($tokenId, $userId);

            $session = JFactory::getSession();

            $session->set('user', $my);

        }

Add after:

//AlphaUserPoints start
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);            
}
//Alphauserpoints Get user points
$user = & JFactory::getUser(); 
$userid = $user->id ; 
$totalPoints = AlphaUserPointsHelper::getCurrentTotalPoints( '', $userid  ); 
  if (CLimitsLibrary::exceedDaily('photos', $my->id)) {
  $this->_showUploadError(true, JText::_('COM_COMMUNITY_PHOTOS_LIMIT_PERDAY_REACHED'));
            return;
        }
// Function to check if enough points
    if ($totalPoints < 5) {
    $this->_showUploadError(true, JText::_('COM_COMMUNITY_PHOTOS_LIMIT_POINTS_REACHED'));
    return;
        }

Now go to your langauge/en-GB/en-GB.com_community.ini file Add anywhere:

COM_COMMUNITY_PHOTOS_LIMIT_POINTS_REACHED="You do not have enough points to upload images. Images are 5 points each."

Change your message to whatever you are charging for Points. Also make sure you adjust the number of points in the code as well. You can also adapt and use this code for Video Uploads or File uploads.
If someone can make this into a installable PLUGIN for AUP or JomSocial, that would rock.
I hope this helps others!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top