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'));
|