Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New Coder
    Join Date
    Sep 2009
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Please Help Newbie

    Hi what i'm trying to do is have it when once a user clicks on a banner the join raffle button will show after clicking on the banner, along with opening up a new window to the link the banner had. I've been trying to set up a onclick event to do this but haven't had success any help would be appreciated.

    This is the code ive tried using.

    <div class="moduletable">
    <a onclick="{AUP::RAFFLE=4}" href="http://godaddy.com" target="_blank" mce_href="http://godaddy.com"><img src="/images/stories/godaddy%20image.jpg" alt=""></a> </div>

    Here is the code for the raffle


    <tr>
    <td valign="top" colspan="2">

    <form action="" method="post" name="RaffleForm">
    <input type="hidden" name="aupraffleid" id="aupraffleid" value="4" />
    <input type="hidden" name="aupraffleuserid" id="aupraffleuserid" value="63" />
    <input type="hidden" name="auprafflepoints" id="auprafflepoints" value="1" />
    <input type="hidden" name="auprafflepointsremove" id="auprafflepointsremove" value="1" />
    <input class="button" type="submit" name="Submit" value="Sign up for this raffle now!" />
    </form>
    </td>
    </tr>
    Last edited by eqoanq; 09-04-2009 at 07:05 AM.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    You must be using some strange framework, if you expected
    {AUP::RAFFLE=4}
    to be JavaScript code that actually does anything.

    And what I *really* don't get is that you want to send people off to GoDaddy.com when they click on your link! What in the heck is the HREF in there for if all you REALLY wanted was afor the onclick to activate the raffle button???

    I'd opt for the K.I.S.S. principle:
    Code:
    <a href="#" onclick="document.getElementById('theRaffleRow').style.display='block';return false;">
        click to see the raffle button 
    </a>
    
    ...
    <tr id="theRaffleRow" style="display: none;">
    <td valign="top" colspan="2">
        <form action="" method="post" name="RaffleForm">
        ...etc. ...
    </td>
    </tr>

  • #3
    New Coder
    Join Date
    Sep 2009
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Is there a simple way to have the raffle form appear only after a user clicks on a banner or link? What im trying to do is have the users view a banner/ad first before being able to enter into the raffle.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Code:
    <img src = "banner.jpg" onclick = "showRaffle()">
    <a href = "#" onclick = "showRaffle()">Click here to show the raffle form</a>
    <br><br>
    <div id = "raffleForm" style="display:none">
    
    Content of the raffle form in here 
    
    </div>
    
    <script type = "text/javascript">
    
    function showRaffle() {
    document.getElementById("raffleForm").style.display = "block"
    }
    
    </script>

    Do please read the posting guidelines regarding silly thread titles. The thread title is supposed to help people who have a similar problem in future. Yours is useless for this purpose.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Ummm...Philip, how is that answer different than the one I gave?

    I think the problem here is that the original poster means he wants the person to actually *READ* the ad, after clicking on it, *BEFORE* the button appears.

    I don't know any way to enforce that short of putting a message into the ad that gives "secret" instructions for entering the raffle.

    In any case, if the banner ad, when clicked on, replaces the current page, then of course you can't *also* click on the raffle button. Only if the banner add opens on another page...or only if you make it into some kind of modal dialog...can you have both actions happen.

  • #6
    New Coder
    Join Date
    Sep 2009
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I tried the code and whats happening is everything is going good until the end when the person tries to submit the raffle entry nothing ends up happening. Here is the code with the raffle that works, but without the process i need. Which is to have the user click on the banner which then opens up the link into a new page and also insert the submit raffle button on the old one.
    Code:
    <div>
    		
    <table class="contentpaneopen">
    
    
    
    
    <tr>
    <td valign="top" colspan="2">
    
    <form action="" method="post" name="RaffleForm">
    
    <input type="hidden" name="aupraffleid" id="aupraffleid" value="5" />
    <input type="hidden" name="aupraffleuserid" id="aupraffleuserid" value="64" />
    <input type="hidden" name="auprafflepoints" id="auprafflepoints" value="1" />
    <input type="hidden" name="auprafflepointsremove" id="auprafflepointsremove" value="1" />
    <input class="button" type="submit" name="Submit" value="Sign up for this raffle now!" />
    </form>
    </td>
    </tr>
    
    
    
    </table>
    <span class="article_separator">&nbsp;</span>
    		</div>
    		</td>
    
    </tr>
    
    <tr>
    	<td valign="top" align="center">
    				<br /><br />
    	</td>
    </tr>
    <tr>
    	<td valign="top" align="center">
    			</td>
    </tr>
    </table>
    
    										
    									</td>


    This code here doesn't enroll the user into the raffle after they click the sign up to raffle, but does everything else. Is there something wrong with this code not allowing the user to enter the raffle.

    Code:
    <a href="http://godaddy.com" target="_blank" mce_href="http://godaddy.com"><img onclick="return true;showRaffle()" src="/images/stories/godaddy%20image.jpg" mce_src="/images/stories/godaddy%20image.jpg">
    </a><a href="http://godaddy.com" target="_blank" mce_href="http://godaddy.com"></a>
    <br><br>
    <div id="raffleForm" style="display: none;">
    
    
    
    
    
    
    
    
    <table class="contentpaneopen mceVisualAid">
    
    
    
    
    <tbody><tr>
    <td class="mceVisualAid" colspan="2" valign="top">
    
    <form action="" method="post" name="RaffleForm">
    
    <input name="aupraffleid" id="aupraffleid" value="5" type="hidden">
    <input name="aupraffleuserid" id="aupraffleuserid" value="64" type="hidden">
    <input name="auprafflepoints" id="auprafflepoints" value="1" type="hidden">
    <input name="auprafflepointsremove" id="auprafflepointsremove" value="1" type="hidden">
    <input class="button" name="Submit" value="Sign up for this raffle now!" type="submit">
    </form>
    </td>
    </tr>
    
    
    
    </tbody></table>
    <span class="article_separator">&nbsp;</span>
    		</div>
    		
    	
    				<br><br>
    											
    	
    				<br><br>
    	
    
    	
    				<br><br>
    	
    		
    
    
    <script type="text/javascript">
    
    function showRaffle() {
    document.getElementById("raffleForm").style.display = "block"
    }
    
    </script>

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Ummm...you have the code backwards.

    Code:
    <img onclick="return true;showRaffle()" src="/images/stories/godaddy%20image.jpg" >
    When you do it like that, the return true says "return from the onclick right now and do *NOT* do anything more...period." So of course no call to showRaffle() is ever made.

    You need to turn it around:
    Code:
    <img onclick="showRaffle();return true;" src="/images/stories/godaddy%20image.jpg" >
    Oh...and that mce_XXX stuff is completely unnecessary. It's an artifact of some editor you used in creating the code.

  • #8
    New Coder
    Join Date
    Sep 2009
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I changed the code to what you said Old Pedant but it wont allow the user to submit into the raffle. The raffle shows up after clicking on the banner, but after trying to click on the submit button to join the raffle it just disappears and doesn't enter the user in the raffle.

  • #9
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    So where is the code that processes that <form>???

    Your code is
    Code:
    <form action="" method="post" name="RaffleForm">
    A blank action means that the form posts back to THIS SAME PAGE.

    If you don't have PHP (or whatever server-side code you are using) to handle this <form> on *THIS* page, then of course it does nothing.

    You know, if you showed us the page *LIVE* it would be a lot easier to make suggestions.

  • #10
    New Coder
    Join Date
    Sep 2009
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Here is the site my site that im trying to use it on. http://domaingiver.net
    Here is a user name and password you can use to log in user: test; password :12345a

    Once you log in you will be on the user home page, here you will see the godaddy image and once you click it, it will open a new page to godaddy. Along with the sign up for this raffle now button, but once you click on the sign up button it doesn't work.

    Now if you go to the test 2 page which is at the bottom of the user menu. You will see the join the raffle button on that page working, but without the godaddy banner.

    I made 2 raffles one for the user home page and one for the test 2 page since once you sign in to the raffle you will see the already registered for the raffle.

  • #11
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Looks to me like it's working fine. Except that your <form> doesn't *GO* any place!

    As I told you, your <form> is doing:
    Code:
    <form action="" method="post" name="RaffleForm">
    And the lack of any value in the action="" means that the form posts back to THIS SAME PAGE.

    And you have NO CODE AT ALL on this page to handle a post-back!

    Besides, this page is an HTML page, and you can *NOT* use METHOD="POST" when you post to an HTML page. HTML pages do not have any mechanism to access the post data.

    Now, since that "test 2" page *is* working, obviously what is happening is that you have some SERVER SIDE code that is handling the form posting. We just can't see it.

    CLEARLY there is no HTML or JavaScript code on either of those pages that handles the form posting. Unless it is hiding in one of those ".js" files you are including.

    If you don't understand how the form posting does its work, or can't show us the code that is handling the posting, then I don't know what we can do to help.

  • #12
    New Coder
    Join Date
    Sep 2009
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts
    This is the coding from the software for the raffle.

    This is from the view

    Code:
    <?php
    /*
     * @component AlphaUserPoints
     * @copyright Copyright (C) 2008 Bernard Gilly
     * @license : GNU/GPL
     * @Website : http://www.alphaplug.com
     */
    
    
    // Check to ensure this file is included in Joomla!
    defined('_JEXEC') or die();
    
    jimport( 'joomla.application.component.view' );
    jimport( 'joomla.html.pagination' );
    
    class alphauserpointsViewRaffle extends JView {
    
    	function _displaylist($tpl = null) {
    		global $mainframe;
    		$document	= & JFactory::getDocument();
    		
    		$this->assignRef( 'raffle', $this->raffle );
    	
    		$pagination = new JPagination( $this->total, $this->limitstart, $this->limit );		
    		$this->assignRef( 'pagination', $pagination );
    		
    		parent::display( $tpl) ;
    	}
    	
    	function _edit_raffle($tpl = null) {
    		global $mainframe;
    		
    		$document	= & JFactory::getDocument();
      		JHTML::_('behavior.mootools');
    		JHTML::_('behavior.calendar');
    		$document->addScriptDeclaration("window.addEvent('domready', function(){ var JTooltips = new Tips($$('.hasTip'), { maxTitleChars: 50, fixed: false}); });");
    		
    		$lists = array();
    		// build the html
    		$lists['published'] = JHTML::_('select.booleanlist', 'published', '', $this->row->published);		
    		$lists['inscription'] = JHTML::_('select.booleanlist', 'inscription', '', $this->row->inscription);
    		
    		$lists['removepointstoparticipate'] = JHTML::_('select.booleanlist', 'removepointstoparticipate', '', $this->row->removepointstoparticipate);
    		
    		$javascript = 'onchange="return mxctoggleSystemRaffle(\'rafflesystemexpand\'+this.value);"';
    		$rafflesys[] = JHTML::_('select.option', '0', JText::_( 'AUP_POINTS' ));
    		$rafflesys[] = JHTML::_('select.option', '1', JText::_( 'AUP_COUPON_CODES' ));		
    		$lists['rafflesystem'] = JHTML::_( 'select.genericlist', $rafflesys, 'rafflesystem', 'class="inputbox" size="1" ' . $javascript, 'value', 'text', $this->row->rafflesystem );
    		//$lists['rafflesystem'] = JHTML::_( 'select.genericlist', $rafflesys, 'rafflesystem' );
    		
    		$numwin[] = JHTML::_('select.option', '1', '1');
    		$numwin[] = JHTML::_('select.option', '2', '2');
    		$numwin[] = JHTML::_('select.option', '3', '3');
    		$lists['numwinner'] = JHTML::_( 'select.genericlist', $numwin, 'numwinner', 'class="inputbox" size="1"', 'value', 'text', $this->row->numwinner );
    		
    		$db			    =& JFactory::getDBO();
    		$query = "SELECT * FROM #__alpha_userpoints_coupons";
    		$db->setQuery($query);
    		$couponcodes = $db->loadObjectlist();
    		
    		$selCouponCode[] = JHTML::_('select.option', '0', JText::_( 'AUP_SELECT_A_COUPON_CODE_FOR_THIS_RANK' ));
    		if ( $couponcodes ) 
    		{
    			foreach ($couponcodes as $couponcode) 
    			{
    				$selCouponCode[] = JHTML::_('select.option', $couponcode->id, $couponcode->couponcode . ' [ '.$couponcode->points . ' ' . JText::_( 'AUP_POINTS' )  . ' ]');
    			}
    		}
    		
    		$lists['couponcodeid1'] = JHTML::_( 'select.genericlist', $selCouponCode, 'couponcodeid1' );
    		$lists['couponcodeid2'] = JHTML::_( 'select.genericlist', $selCouponCode, 'couponcodeid2' );
    		$lists['couponcodeid3'] = JHTML::_( 'select.genericlist', $selCouponCode, 'couponcodeid3' );		
    		
    		$lists['sendcouponbyemail'] = JHTML::_('select.booleanlist', 'sendcouponbyemail', '', $this->row->sendcouponbyemail);
    		
    		$this->assignRef( 'row', $this->row );
    		$this->assignRef( 'lists', $lists );				
    	
    		parent::display( "form" ) ;
    	}
    }
    ?>

    This is for the table

    Code:
    <?php
    /*
     * @component AlphaUserPoints
     * @copyright Copyright (C) 2008 Bernard Gilly
     * @license : GNU/GPL
     * @Website : http://www.alphaplug.com
     */
    
    // no direct access
    defined('_JEXEC') or die('Restricted access');
    
    
    class JTableRaffle_inscriptions extends JTable
    {
    	/**
    	 * Primary Key
    	 * @var int
    	 */
    	var $id = null;
    	/** @var int */
    	var $raffleid = '';
    	/** @var int */
    	var $userid = '';
    	
    	/**
    	 * Constructor
    	 *
    	 * @param object Database connector object
    	 */
    	function __construct(& $db) {
    		parent::__construct('#__alpha_userpoints_raffle_inscriptions', 'id', $db);
    	}
    }
    ?>

    Code:
    <?php
    /*
     * @component AlphaUserPoints
     * @copyright Copyright (C) 2008 Bernard Gilly
     * @license : GNU/GPL
     * @Website : http://www.alphaplug.com
     */
    
    // no direct access
    defined('_JEXEC') or die('Restricted access');
    
    
    class JTableRaffle extends JTable
    {
    	/**
    	 * Primary Key
    	 * @var int
    	 */
    	var $id = null;
    	/** @var string */
    	var $description = '';
    	/** @var int */
    	var $inscription = '';
    	/** @var int */
    	var $rafflesystem = '';
    	/** @var int */
    	var $numwinner = '1';
    	/** @var int */
    	var $couponcodeid1 = '';
    	/** @var int */
    	var $couponcodeid2 = '';
    	/** @var int */
    	var $couponcodeid3 = '';
    	/** @var int */
    	var $sendcouponbyemail = '';
    	/** @var int */
    	var $pointstoparticipate = '';
    	var $removepointstoparticipate = '';
    	/** @var int */
    	var $pointstoearn1 = '';
    	/** @var int */
    	var $pointstoearn2 = '';
    	/** @var int */
    	var $pointstoearn3 = '';
    	/** @var datetime */
    	var $raffledate = '';
    	/** @var int */
    	var $winner1 = '';
    	var $winner2 = '';
    	var $winner3 = '';
    	/** @var int */
    	var $published = '1';
    	
    	/**
    	 * Constructor
    	 *
    	 * @param object Database connector object
    	 */
    	function __construct(& $db) {
    		parent::__construct('#__alpha_userpoints_raffle', 'id', $db);
    	}
    }
    ?>
    This is from the raffle model

    Code:
    <?php
    /*
     * @component AlphaUserPoints
     * @copyright Copyright (C) 2008 Bernard Gilly
     * @license : GNU/GPL
     * @Website : http://www.alphaplug.com
     */
    
    // Check to ensure this file is included in Joomla!
    defined('_JEXEC') or die();
    
    jimport( 'joomla.application.component.model' );
    
    class alphauserpointsModelRaffle extends Jmodel {
    
    	function __construct(){
    		parent::__construct();
    	}
    	
    	function _load_raffle() {
    		global $mainframe;
    		
    		$db			    =& JFactory::getDBO();
    		
    		$total 			= 0;
    		
    		// Get the pagination request variables
    		$limit = $mainframe->getUserStateFromRequest('com_alphauserpoints.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
    		$limitstart = JRequest::getVar('limitstart', 0, '', 'int');
    		// In case limit has been changed, adjust limitstart accordingly
    		$limitstart = ( $limit != 0 ? (floor( $limitstart / $limit ) * $limit) : 0);
    
    		$query = "SELECT r.*, COUNT(ri.id) AS numregistered FROM #__alpha_userpoints_raffle AS r"
    		. " LEFT JOIN #__alpha_userpoints_raffle_inscriptions AS ri ON ri.raffleid=r.id"
    		. " GROUP BY r.id"
    		. " ORDER BY r.id DESC";
    		$total = @$this->_getListCount($query);
    		$result = $this->_getList($query, $limitstart, $limit);
    		
    		// message if rule disabled
    		$query = "SELECT id FROM #__alpha_userpoints_rules WHERE plugin_function = 'sysplgaup_raffle' AND published = '1'";
    		$db->setQuery($query);
    		$alert = $db->loadResult();
    		
    		if ( !$alert ) $mainframe->enqueueMessage( JText::_('AUP_THIS_RULE_IS_DISABLED'));		
    		
    		return array($result, $total, $limit, $limitstart);
    	
    	}	
    	
    	function _edit_raffle() {
    	
    		$db     =& JFactory::getDBO();
    
    		$cid 	= JRequest::getVar('cid', array(0));
    		$option = JRequest::getVar('option');
    		
    		if (!is_array( $cid )) {
    			$cid = array(0);
    		}
    
    		$lists = array();
    
    		$row =& JTable::getInstance('raffle');
    		$row->load( $cid[0] );
    		
    		return $row;
    	
    	}	
    	
    	function _delete_raffle() {
    		global $mainframe;
    
    		// initialize variables
    		$db			=& JFactory::getDBO();
    		$cid		= JRequest::getVar('cid', array(), 'post', 'array');
    		$msgType	= '';
    		
    		JArrayHelper::toInteger($cid);
    
    		if (count($cid)) {		
    			
    			$query = "DELETE FROM #__alpha_userpoints_raffle"
    					. "\n WHERE (`id` = " . implode(' OR `id` = ', $cid) . ")"
    					;
    			$db->setQuery($query);
    			
    			if (!$db->query()) {
    				$msg = $db->getErrorMsg();
    				$msgType = 'error';
    			}
    			
    			$query = "DELETE FROM #__alpha_userpoints_raffle_inscriptions"
    					. "\n WHERE (`raffleid` = " . implode(' OR `raffleid` = ', $cid) . ")"
    					;
    			$db->setQuery($query);
    			
    			if (!$db->query()) {
    				$msg = $db->getErrorMsg();
    				$msgType = 'error';
    			}
    
    		}
    
    		$mainframe->redirect('index.php?option=com_alphauserpoints&task=raffle', $msg, $msgType);
    		
    	}
    	
    	function _save_raffle() {
    		global $mainframe;
    
    		// initialize variables
    		$db =& JFactory::getDBO();
    		$post	= JRequest::get( 'post' );
    		$row =& JTable::getInstance('raffle');
    
    		if (!$row->bind( $post )) {
    			echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
    			exit();
    		}
    		
    		if (!$row->store()) {
    			echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
    			exit();
    		}
    
    		$msg = JText::_( 'AUP_DETAILSSAVED' );
    		$mainframe->redirect( 'index.php?option=com_alphauserpoints&task=raffle', $msg );
    	}
    	
    	function _make_raffle_now() {
    		global $mainframe;
    		
    		require_once (JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php');
    		
    		$db =& JFactory::getDBO();
    		
    		// Proceed raffle now
    		$cid 	= JRequest::getVar('cid', array(0));
    		$rowRaffle = $this->_edit_raffle();
    		
    		$jnow		=& JFactory::getDate();
    		$now		= $jnow->toMySQL();
    				
    		// add offset
    		$config =& JFactory::getConfig();
    		$tzoffset = $config->getValue('config.offset');
    		$datetimestamp = strtotime($now);
    		$now = date('Y-m-d H:i:s', $datetimestamp + ($tzoffset * 60 * 60));		
    		
    		// Raffle date is not today ?
    		if ( $rowRaffle->raffledate!='0000-00-00 00:00:00' && $now < $rowRaffle->raffledate ){
    			echo "<script> alert('".JText::_( 'AUP_DATE_OF_RAFFLE_IS_NOT_TODAY' )."'); window.history.go(-1); </script>\n";
    			exit();	
    		}
    		
    		$winner1 = 0;
    		$winner2 = 0;
    		$winner3 = 0;
    		$winner1_Referreid = 0;
    		$winner2_Referreid = 0;
    		$winner3_Referreid = 0;
    		
    		// exclude users if rule enabled
    		$queryExclude = "";
    		$query = "SELECT exclude_items FROM #__alpha_userpoints_rules WHERE plugin_function='sysplgaup_excludeusers' AND published='1'";
    		$db->setQuery( $query );
    		$resultExcludeUsers  = $db->loadResult();
    		if ( $resultExcludeUsers ) {
    			$uids = explode( ',', $resultExcludeUsers );
    			$queryExclude =  " AND (referreid!='" . implode( "' AND referreid!='", $uids ) . "')";
    		}
    	
    		// first raffle
    		// select all users registered or only users with registration for this raffle 
    		if ( $rowRaffle->inscription ) 
    		{			
    			$query = "SELECT userid as uid FROM #__alpha_userpoints_raffle_inscriptions WHERE raffleid=" . $rowRaffle->id;		
    		} 
    		else 
    		{
    			$query = "SELECT userid as uid FROM #__alpha_userpoints WHERE blocked='0'".$queryExclude;
    		}		
    		$db->setQuery($query);
    		$listParticipants = $db->loadObjectList();
    		
    		if ( !$listParticipants ) 
    		{ 
    			echo "<script> alert('".JText::_( 'AUP_NO_PARTICIPANT' )."'); window.history.go(-1); </script>\n";
    			exit();
    		}	
    		
    		$max = count($listParticipants)-1;		
    		$choice = rand(0, $max);		
    		$winner1 = $listParticipants[$choice]->uid;
    		
    		if ( $rowRaffle->numwinner>1 )
    		{
    			// 2th raffle without first winner
    			if ( $rowRaffle->inscription ) 
    			{			
    				$query = "SELECT userid as uid FROM #__alpha_userpoints_raffle_inscriptions WHERE raffleid=" . $rowRaffle->id . " AND userid!='$winner1'";		
    			} 
    			else 
    			{
    				$query = "SELECT userid as uid FROM #__alpha_userpoints WHERE blocked='0' AND userid!='$winner1'".$queryExclude;
    			}
    			$db->setQuery($query);
    			$listParticipants2 = $db->loadObjectList();
    	
    			$max2 = count($listParticipants2)-1;
    			$choice2 = rand(0, $max2);
    			$winner2 = @$listParticipants2[$choice2]->uid;
    		}
    		
    		if ( $rowRaffle->numwinner==3 )
    		{
    			// 3th raffle without first and second winner
    			if ( $rowRaffle->inscription ) 
    			{			
    				$query = "SELECT userid as uid FROM #__alpha_userpoints_raffle_inscriptions WHERE raffleid=" . $rowRaffle->id . " AND userid!='$winner1' AND userid!='$winner2'";		
    			} 
    			else 
    			{
    				$query = "SELECT userid as uid FROM #__alpha_userpoints WHERE blocked='0' AND userid!='$winner1' AND userid!='$winner2'".$queryExclude;
    			}
    			$db->setQuery($query);
    			$listParticipants3 = $db->loadObjectList();
    			
    			$max3 = count($listParticipants3)-1;
    			$choice3 = rand(0, $max3);
    			$winner3 = @$listParticipants3[$choice3]->uid;
    		}
    		
    		// Save winner(s)
    		$row =& JTable::getInstance('raffle');
    		$row->load( $rowRaffle->id );
    		
    		$row->winner1 = $winner1;
    		$row->winner2 = $winner2;
    		$row->winner3 = $winner3;
    		
    		if (!$row->store()) {
    			JError::raiseError(500, $row->getError());
    		}	
    		
    		// attribs points or coupon code
    		if ( $winner1 ) $winner1_Referreid = AlphaUserPointsHelper::getAnyUserReferreID( intval($winner1) );	
    		if ( $winner2 ) $winner2_Referreid = AlphaUserPointsHelper::getAnyUserReferreID( intval($winner2) );	
    		if ( $winner3 ) $winner3_Referreid = AlphaUserPointsHelper::getAnyUserReferreID( intval($winner3) );	
    		
    		if ( $rowRaffle->rafflesystem )
    		{
    			// coupon code ...			
    			if ( $rowRaffle->sendcouponbyemail )
    			{
    				if ( $winner1 && $rowRaffle->couponcodeid1 ) {
    					$this->sendnotification4couponcode ( $winner1_Referreid, $couponcodeid1 );
    				}
    				if ( $winner2 && $couponcodeid2 ) {
    					$this->sendnotification4couponcode ( $winner2_Referreid, $couponcodeid2 );
    				}
    				if ( $winner3 && $couponcodeid3 ) {
    					$this->sendnotification4couponcode ( $winner3_Referreid, $couponcodeid3 );
    				}
    			}
    		}
    		else
    		{
    			// points ...
    			if ( $winner1 ) {
    				AlphaUserPointsHelper::newpoints ( 'sysplgaup_raffle', $winner1_Referreid, '', $rowRaffle->description, $rowRaffle->pointstoearn1 );
    			}
    			if ( $winner2 ) {			
    				AlphaUserPointsHelper::newpoints ( 'sysplgaup_raffle', $winner2_Referreid, '', $rowRaffle->description, $rowRaffle->pointstoearn2 );
    			}
    			if ( $winner3 ) {							
    				AlphaUserPointsHelper::newpoints ( 'sysplgaup_raffle', $winner3_Referreid, '', $rowRaffle->description, $rowRaffle->pointstoearn3 );
    			}
    			
    		}
    		
    		$redirecturl = "index.php?option=com_alphauserpoints&task=raffle";
    		$mainframe->redirect( $redirecturl );
    	
    	}
    		
    	function sendnotification4couponcode ( $referrerid, $couponcode ) 
    	{
    		global $mainframe;
    		
    		if ( !$referrerid ) return;
    		
    		$MailFrom	= $mainframe->getCfg('mailfrom');
    		$FromName	= $mainframe->getCfg('fromname');
    		$SiteName	= $mainframe->getCfg('sitename');
    		
    		$userinfo = $this->getUserInfo( $referrerid );		
    		$email	  = $userinfo->email;
    		
    		if ( !$userinfo->block ) 
    		{		
    			$subject = JText::_('AUP_EMAILNOTIFICATION_SUBJECT_COUPONCODE');
    			$message = sprintf ( JText::_('AUP_EMAILNOTIFICATION_MSG_COUPONCODE'), $SiteName, $couponcode );
    			JUtility::sendMail( $MailFrom, $FromName, $email, $subject, $message );
    		}
    		
    	}
    	
    	function getUserInfo ( $referrerid='' ) 
    	{	
    		if ( !$referrerid ) return;
    	
    		$db	   =& JFactory::getDBO();
    		
    		$query = "SELECT a.*, u.* FROM #__alpha_userpoints AS a, #__users AS u WHERE a.referreid='$referrerid' AND a.userid=u.id";
    		$db->setQuery( $query );
    		$userinfo = $db->loadObjectList();
    	
    		return @$userinfo[0];	
    	}
    	
    	function _export_users_registration()
    	{
    		$raffleid	   = JRequest::getVar('id', 0, 'get', 'int');
    		
    		$db	   =& JFactory::getDBO();
    		
    		$query = "SELECT ari.userid AS uid, u.name, u.username " .
    				 "FROM #__alpha_userpoints_raffle_inscriptions AS ari, #__users AS u " .
    				 "WHERE ari.raffleid=" . $raffleid . " AND ari.userid=u.id";		
    		$db->setQuery( $query );
    		$userslist = $db->loadObjectList();
    		return @$userslist;
    	}
    
    }
    ?>

    This is the software i am using http://www.alphaplug.com/index.php/d...fileinfo&id=10

    Its called alphauserpoints.

  • #13
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Well, I am *NOT* a PHP user, at all. You are now into not only PHP coding but Joomla coding, and I doubt that the problem is directly related to JavaScript, at all. But no idea how to debug this.

    Hope somebody else can help you.

    Might want to post in the PHP forum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •