Page 1 of 1

Rule for Alphauserpoints

Posted: 19 Mar 2012, 18:14
by RuneMykle
Hello beloved community! :)

I'm trying to find a rule for aup with Phoca gallery, but with no success either here or on the aup site.

So let's cut to the chase; any of you got a link to a rule for aup?
Thanks! :)

Re: Rule for Alphauserpoints

Posted: 19 Mar 2012, 20:23
by RuneMykle
I found a rule for JoomGallery and figured that it shouldn't be too hard to rewrite it to suit our needs, but even though the install works like a charm there's no points awarded! :)

If any of you are wizzes on the field, please finish this little project, the only thing missing is the actual writing of the points to the base.

Rule:
upload.xml:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<alphauserpoints type="plugin">
  <rule>Upload image</rule>
  <description>Assign points when a registered user uploads an image in Phoca Gallery (may also be negative to reduce points)</description>
  <component>phocaGallery</component>
  <plugin_function>plgaup_phocagallery_upload</plugin_function>
  <fixed_points>true</fixed_points>
</alphauserpoints>
Mod:
phocaalphauserpoints.xml

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<install version="1.5" type="plugin" group="phocagallery" method="upgrade">
  <name>PhocaGallery - AlphaUserPoints</name>
  <author>Rune Myklebostad (Wood)</author>
  <creationDate>19.03.2012</creationDate>
  <copyright>Copyright (C) 2005 - 2008 - Nope, none at all</copyright>
  <license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
  <authorEmail>wood@exalted-gaming.com</authorEmail>
  <authorUrl>www.exalted-gaming.com</authorUrl>
  <version>1.0</version>
  <description>Integrates AlphaUserPoints in PhocaGallery</description>
  <files>
    <filename plugin="phocaalphauserpoints">phocaalphauserpoints.php</filename>
  </files>
  <languages folder="language">
    <language tag="en-GB">en-GB.plg_phocagallery_alphauserpoints.ini</language>
  </languages>
  <params>
    <param name="points_for_comment_on_own_image" type="radio" default="1" label="JDS_POINTS_FOR_COMMENT_ON_OWN_IMAGE" description="JDS_POINTS_FOR_COMMENT_ON_OWN_IMAGE_DESC">
      <option value="0">No</option>
      <option value="1">YES</option>
    </param>
    <param name="points_for_ones_own_tag" type="radio" default="1" label="JDS_POINTS_FOR_ONES_OWN_TAG" description="JDS_POINTS_FOR_ONES_OWN_TAG_DESC">
      <option value="0">No</option>
      <option value="1">YES</option>
    </param>
  </params>
</install>
phocaalphauserpoints.php

Code: Select all

<?php
// $HeadURL: https://joomgallery.org/svn/joomgallery/JG-1.5/Plugins/PhocaAlphaUserPoints/trunk/phocaalphauserpoints.php $
// $Id: phocaalphauserpoints.php 2904 2011-03-14 13:44:50Z chraneco $
/******************************************************************************\
**   PhocaGallery Plugin 'JoomAlphaUserPoints' 1.5 BETA2                       **
**   By: Wood                                                                 **
**   Copyright (C) None at all                                                **
**   Released under GNU GPL Public License                                    **
**   License: http://www.gnu.org/copyleft/gpl.html                            **
\******************************************************************************/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

jimport('joomla.plugin.plugin');

/**
 * JoomGallery Plugin 'JoomAlphaUserPoints'
 *
 * @package     Joomla
 * @subpackage  JoomGallery
 * @since       1.5
 */
class plgPhocaGalleryPhocaAlphaUserPoints extends JPlugin
{
  /**
   * Constructor
   *
   * For php4 compatability we must not use the __constructor as a constructor for plugins
   * because func_get_args ( void ) returns a copy of all passed arguments NOT references.
   * This causes problems with cross-referencing necessary for the observer design pattern.
   *
   * @access  protected
   * @param   object    $subject  The object to observe
   * @param   object    $params   The object that holds the plugin parameters
   * @return  void
   * @since   1.5
   */
  function plgPhocaGalleryPhocaAlphaUserPoints(&$subject, $params)
  {
    $file = JPATH_ROOT.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
    if(file_exists($file))
    {
      require_once($file);
    }
    else
    {
      JError::raiseError(500, JText::_('AlphaUserPoints seems not to be installed'));
    }

    parent::__construct($subject, $params);
  }

  /**
   * onJoomBeforeUpload method
   *
   * Method is called before starting to upload an image
   *
   * @access  public
   * @return  boolean False will stop the upload from being performed
   * @since   1.5
   */
  function onPhoceBeforeUpload()
  {
    $user       = & JFactory::getUser();

    $referreid  = AlphaUserPointsHelper::getAnyUserReferreID($user->get('id'));

    $numpoints  = AlphaUserPointsHelper::getPointsRule('plgaup_phocagallery_upload');

    if($referreid && !AlphaUserPointsHelper::operationIsFeasible($referreid, $numpoints))
    {
      $msg = JText::_('AUP_YOUDONOTHAVEENOUGHPOINTSTOPERFORMTHISOPERATION');
      JError::raiseNotice(500, $msg);

      return false;
    }

    return true;
  }

  /**
   * onPhocaAfterUpload method
   *
   * Method is called after an image was successfully uploaded and saved
   *
   * @access  public
   * @return  void
   * @since   1.5
   */
  function onPhocaAfterUpload()
  {
    AlphaUserPointsHelper::newpoints('plgaup_phocagallery_upload', '',  '', JText::_('Upload in PhocaGallery'));
  }
}
language/en-GB.plg_phocagallery_alphauserpoints.ini

Code: Select all

INTEGRATES ALPHAUSERPOINTS IN PHOCAGALLERY=Integrates AlphaUserPoints in PhocaGallery
JDS_POINTS_FOR_COMMENT_ON_OWN_IMAGE=Points for comments on own images
JDS_POINTS_FOR_COMMENT_ON_OWN_IMAGE_DESC=If this option is enabled, users will receive points for commenting on their own images, too.
JDS_POINTS_FOR_ONES_OWN_TAG=Points for ones own tags
JDS_POINTS_FOR_ONES_OWN_TAG_DESC=If this option is enabled, users will receive points for tags with their own name, too.

Re: Rule for Alphauserpoints

Posted: 19 Mar 2012, 22:33
by Jan
Hi, thank you very much for the guide.

Jan

Re: Rule for Alphauserpoints

Posted: 20 Mar 2012, 00:13
by RuneMykle
Hi Jan!

Unfortunately the above wont work as it's not adding or deducting points in it's current state. Hence I hope others here might know the fix :)

Re: Rule for Alphauserpoints

Posted: 22 Mar 2012, 00:09
by Jan
:-(