Home arrow Forum

Remository Forum

 


binarystar

Karma: 0  
Custom Module For Download Credits Or Similar - 2010/07/30 20:04 In fact I am trying to find my ways to pull the data from remository remaining credits into my jvb_login panel so the moment u login it it says "Greetings [Username] Your remaining credit for today is ...etc

OR

A custom module that displays a user remaining credits and relevant info.

--

If anyone can provide with help on how to draw out the individual data from sql to show a users remaining credits please let me know because I have tried finding but could not find it as well so I can keep trying on it.

Post edited by: binarystar, at: 2010/07/30 20:05
  | | Sorry, you do not currently have permission to write here.
chrissy6930

Karma: 27  
Re:Custom Module For Download Credits Or Similar - 2010/07/31 06:13 you could try adding the following query:

$database->setQuery("SELECT credit FROM #__vodes_credits WHERE userid = $this->id");
$credits = $database->loadResult();

replacing $this->id with the variable used for userid in your module

then use $credits for the html of the credits message
  | | Sorry, you do not currently have permission to write here.
binarystar

Karma: 0  
Re:Custom Module For Download Credits Or Similar - 2010/07/31 08:06 I have tried, but couldn't make it work.

Thank you chrissy for your reply, totally appreciate it but if it doesn't take too much of your time , perhaps you could explain a little more on how to do it ? I have listed my codings underneath. Where would be the correct place to insert the method you mentioned ?

------------------- helper.php --------------------------------------------

<?php
/**
*
* @package jvbPlugin
* @version $Id: helper.php, v 1.0 2008/08/18 15:37:17 koudanshi Exp $
* @copyright (c) 2003-2008 BBPixel
*
* Minimum Requirement: PHP 4.3.3 | MySQL 4.1
*/


// no direct access
defined('_JEXEC') or die('Restricted access');

class modJvbLoginHelper
{
var $_exURL;

function getReturnURL($params, $type)
{
if($params->get($type))
{
//$url = 'index.php?Itemid='.$itemid;
//$url = JRoute::_($url, false);
$url = $params->get($type);
}
else
{
// Redirect to login
$uri = JFactory::getURI();
$url = $uri->toString();
}

return $url;
}

function getType()
{
$user = & JFactory::getUser();
return (!$user->get('guest')) ? 'logout' : 'login';
}
/**
* get Forum Avatar
*
* @param Integer $userID
*/
function getForumAvatar($userID=null, $width=0) {

global $jvbpixel;

if (!$userID) return;

$query = "SELECT avatarid FROM ".$jvbpixel->_bbDBprefix."user WHERE userid='{$userID}' LIMIT 1";
$jvbpixel->_bbDB->setQuery($query);
$avatarid = $jvbpixel->_bbDB->loadResult();

$query = "SELECT avatarpath FROM ".$jvbpixel->_bbDBprefix."avatar WHERE avatarid='{$avatarid}' LIMIT 1";
$jvbpixel->_bbDB->setQuery($query);
$avatarpath = $jvbpixel->_bbDB->loadResult();

$timeNow = time();
$width = ($width > 0 ) ? 'width="'.$width.'"' : '';

if ($jvbpixel->_wrapperID) {
$userLink = $this->_exURL.'member.php?userid_'.$userID;
} else {
$userLink = $jvbpixel->_bbURL.'/member.php?userid='.$userID;
}
if ($avatarid) {
$avatarImg = '<a href="'.$userLink.'"><img src="'.$jvbpixel-" alt="Avatar" title="Avatar" border="0" /></a>';
} else {
$avatarImg = '<a href="'.$userLink.'"><img src="'.$jvbpixel-" alt="Avatar" title="Avatar" border="0" /></a>';
}

return $avatarImg;
}

/**
* get forum new messages
*
* @param unknown_type $userID
* @return unknown
*/
function getForumNewMsg($userID=null) {

global $jvbpixel;

if (!$userID) return;

$query = "SELECT count(pmtextid) as inmsgs FROM ".$jvbpixel->_bbDBprefix."pm WHERE userid='{$userID}' AND folderid=0";
$jvbpixel->_bbDB->setQuery($query);
$newMsg = $jvbpixel->_bbDB->loadResult();

$newMsg = intval($newMsg);
if ($jvbpixel->_wrapperID) {
$msgLink = $this->_exURL.'private.php';
} else {
$msgLink = $jvbpixel->_bbURL.'/private.php';
}
$text = "Message Inbox [ <a href="%7B$msgLink%7D" title="Private message">$newMsg</a> ]";

return $text;

}
}

------------------- mod_jvb_login.php --------

<?php
/**
*
* @package jvbPlugin
* @version $Id: mod_jvb_login.php, v 1.0 2008/08/18 15:37:17 koudanshi Exp $
* @copyright (c) 2003-2008 BBPixel
*
* Minimum Requirement: PHP 4.3.3 | MySQL 4.1
*/


// no direct access
defined('_JEXEC') or die('Restricted access');

// Include the syndicate functions only once
require_once (dirname(__FILE__).DS.'helper.php');

$params->def('greeting', 1);

global $jvbpixel;

$jURL = JURI::base();
$exURL = "$jURL/index.php?option=com_wrapper&view=wrapper&Itemid=".$jvbpixel->_wrapperID."&bbact=";

//Init common
$jvbHelper = new modJvbLoginHelper();
$jvbHelper->_exURL = $exURL;

$type = $jvbHelper->getType();
$return = $jvbHelper->getReturnURL($params, $type);

//Init logout link
if ($type == 'logout') {
$logoutHash = $jvbpixel->getLogoutHash();
if ($jvbpixel->_wrapperID) {
$logoutLink = $jURL."index.php?option=com_user&task=logout&redirect={$return}";
$usercpLink = $exURL."usercp.php";
} else {
$logoutLink = $jvbpixel->_bbURL."/login.php?do=logout&logouthash=$logoutHash&redirect={$return}";
$usercpLink = $jvbpixel->_bbURL."/usercp.php";
}
}

//Init login link
if ($jvbpixel->_wrapperID) {
$regLink = $exURL."register.php";
$lostPwdLink = $exURL."login.php?do=lostpw";
} else {
$regLink = $jvbpixel->_bbURL."/register.php";
$lostPwdLink = $jvbpixel->_bbURL."/login.php?do=lostpw";
}

$user =& JFactory::getUser();

$avatar = $jvbHelper->getForumAvatar($user->id, $params->get('avatar_size', 0));
$newMsg = $jvbHelper->getForumNewMsg($user->id);

require(JModuleHelper::getLayoutPath('mod_jvb_login'));
  | | Sorry, you do not currently have permission to write here.
chrissy6930

Karma: 27  
Re:Custom Module For Download Credits Or Similar - 2010/07/31 08:30 try adding below function getForumNewMsg:

Code:

 function getCredits($userID=null) {     global $jvbpixel;     if (!$userID) return;     $query "SELECT credit FROM #__vodes_credits WHERE userid = '{$userID}' ";     $jvbpixel->_bbDB->setQuery($query);     $credits $jvbpixel->_bbDB->loadResult();     $credits intval($credits);     $text "Your remaining credit for today is"$credits;     return $text;



and add below
Code:

 $avatar $jvbHelper->getForumAvatar($user->id$params->get('avatar_size'0)); $newMsg $jvbHelper->getForumNewMsg($user->id);



Code:

 $credits $jvbHelper->getCredits($user->id);



let me know if it works as I cannot test...
  | | Sorry, you do not currently have permission to write here.
binarystar

Karma: 0  
Re:Custom Module For Download Credits Or Similar - 2010/07/31 09:55 joomla display a blank page after the edits, hmm i wonder what is wrong.
  | | Sorry, you do not currently have permission to write here.

Login

Subscribe to Premium Support

Get priority support for Remository and Glossary, sign up now for a Premium Support monthly subscription:

Your Remository user name

Or purchase a year's support:

Your Remository user name

Recommended SEF

SEF Advance

Who is Online

Remository welcomes guests and visitors

We have 7 guest online