Welcome, Guest
Username Password: Remember me

AUP Rule for YooTheme "Zoo" Component
(1 viewing) (1) Guest

TOPIC: AUP Rule for YooTheme "Zoo" Component

AUP Rule for YooTheme "Zoo" Component 2 years, 9 months ago #17790

  • adithya11
  • OFFLINE
  • Fresh Boarder
  • Get Rich or Die Trying
  • Posts: 13
  • Points: 157
  • Karma: 3
Hello,

I wasn't able to find a rule for Zoo component anywhere in the forum so I thought I would add one myself. Here's how.

1) This plugin adds points per each item added, only once(item id is used as reference).
2) Download and install the attached plugin in AUP plugins.
3) Add the following lines of code just before
// trigger saved event

in /components/com_zoo/controllers/submission.php file.
(I think its around line 448)

$auplink = JRoute::_('index.php?option=com_zoo&task=item&item_id='.$this->item->id.'&Itemid='.JRequest::getInt('Itemid', 0));
$auphref = '<a href="'.$auplink.'">'.$this->item->name.'</a>';
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);
AlphaUserPointsHelper::newpoints( 'plgaup_zoo', '', $this->item->id, $auphref);
}


I hope this helps. If you find any more rules for Zoo please post it here.
Thanks.
Adithya.S
Attachments:
Last Edit: 2 years, 9 months ago by adithya11.
The following user(s) said Thank You: modus

Re: AUP Rule for YooTheme "Zoo" Component 2 years, 9 months ago #17801

  • EWReport
  • OFFLINE
  • Fresh Boarder
  • Posts: 10
  • Points: 87
  • Karma: 0
Quick question on this one. I tried making a rule so it removes 10 points if the Submission gets deleted. All I did was changes "plgaup_zoo" to "plgaup_zoo2" in the pasted code as well as the plugin XML file. Also copied and renamed renamed the XML file to "plgaup_zoo2". Pasted the code right above

// trigger deleted event


In the same file. But nothing happens and they dont loose points when the submission is deleted. any ideas?

Re: AUP Rule for YooTheme "Zoo" Component 2 years, 9 months ago #17815

  • adithya11
  • OFFLINE
  • Fresh Boarder
  • Get Rich or Die Trying
  • Posts: 13
  • Points: 157
  • Karma: 3
Hello EWReport,

To deduct the points when an item is deleted by the user just add the following lines of code:

After
$msg = JText::_('Submission Deleted');
in the same file.

$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);
AlphaUserPointsHelper::newpoints( 'plgaup_zoo', '', '', 'Deleting an Item in Zoo');
}


Change the name of the plugin to whatever you want and this works only if the user deletes his own item from front end.

If you want to deduct points of the user who created the item but deleted by another person. Then I think this should help(I haven't checked it out personally).

$aupid = $this->item->created_by;
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);
AlphaUserPointsHelper::newpoints( 'plgaup_zoo', $aupid, '', 'Deleting an Item in Zoo');
}


Hope this helps.
Adithya.S
The following user(s) said Thank You: modus

Re: AUP Rule for YooTheme "Zoo" Component 2 years, 9 months ago #17817

  • EWReport
  • OFFLINE
  • Fresh Boarder
  • Posts: 10
  • Points: 87
  • Karma: 0
Thanks for the reply. Yes, I would like to to be done if its deleted by the admin. I would like the points to be added after it is "Published" by the admin as well, but that isnt needed to make my site go live, as long as they get the points, and the points are removed. I can go live and tweek it all day long. Lol.

So would I page the 2nd code you gave me in the same spot?

Re: AUP Rule for YooTheme "Zoo" Component 2 years, 9 months ago #17818

  • adithya11
  • OFFLINE
  • Fresh Boarder
  • Get Rich or Die Trying
  • Posts: 13
  • Points: 157
  • Karma: 3
Hello EWReport,

If you want to deduct points when you delete an item from admin backend then just add the following code in /administrator/components/com_zoo/controllers/item.php just after
$this->table->delete($this->table->get($id));
(around line 476)
$userID = $this->table->get($id)->created_by;
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if ( file_exists($api_AUP))
{
require_once ($api_AUP);
$aupid = AlphaUserPointsHelper::getAnyUserReferreID( $userID );
if ( $aupid )  AlphaUserPointsHelper::newpoints( 'plgaup_zoo', $aupid, '', 'Deleting an Item in Zoo', -10);
}


Change the negative points in the last parameter to whatever value you want(no need to create an additional plugin) and the point should be deducted from that particular user when you delete an item in the admin backend.

Thanks,
Adithya.S
The following user(s) said Thank You: modus

Re: AUP Rule for YooTheme "Zoo" Component 2 years, 9 months ago #17819

  • EWReport
  • OFFLINE
  • Fresh Boarder
  • Posts: 10
  • Points: 87
  • Karma: 0
Very Nice. Thank you so much for all the help. Is there a place I can add points from the admin backend when an item is published. This would make sure the user doesn't get points right off the bat, but after our team has reviewed and published the item (items from zoo are not published by default).
Moderators: adroussel, dalekurt, migus, some1new
Time to create page: 0.68 seconds
Goto Top