<?php
// $Id: notification.inc.php,v 1.3 2005/10/28 11:56:05 ohwada Exp $

// 2004-11-28 K.OHWADA
// write fair, delete unnecessary comments

// 2004/08/28 K.OHWADA
// bug fix : typo

// 2004/08/10 K.OHWADA
// enable to install this module two or more. 
// not use class weblinksCategory, weblinksLink

//  ------------------------------------------------------------------------ //
//                XOOPS - PHP Content Management System                      //
//                    Copyright (c) 2000 XOOPS.org                           //
//                       <http://www.xoops.org/>                             //
//  ------------------------------------------------------------------------ //

//================================================================
// notification
// use class weblinksCategory, weblinksLink
// 2004/01/14 K.OHWADA
//================================================================

// --- change function name ---
function weblinks_notify_iteminfo($category, $item_id)
{
	global $xoopsModule, $xoopsModuleConfig, $xoopsConfig;

	global $xoopsDB;

// --- change dir name ---
	$MODULE_DIRNAME = 'weblinks';

	$MODULE_URL     = XOOPS_URL."/modules/".$MODULE_DIRNAME;
	$table_cateogry = $xoopsDB->prefix("{$MODULE_DIRNAME}_cateogry");
	$table_link     = $xoopsDB->prefix("{$MODULE_DIRNAME}_link");

	if ( empty($xoopsModule) || $xoopsModule->getVar('dirname') != $MODULE_DIRNAME ) 
	{
		$module_handler =& xoops_gethandler('module');
		$module =& $module_handler->getByDirname($MODULE_DIRNAME);

		$config_handler =& xoops_gethandler('config');
		$config =& $config_handler->getConfigsByCat(0,$module->getVar('mid'));
	}
	else 
	{
		$module =& $xoopsModule;
		$config =& $xoopsModuleConfig;
	}

	if ($category=='global') 
	{
		$item['name'] = '';
		$item['url']  = '';
		return $item;
	}

	if ($category=='category') 
	{
// Assume we have a valid category id
		$sql = "SELECT * FROM $table_cateogry WHERE cid=$item_id";
		$row = $xoopsDB->fetchArray( $xoopsDB->query($sql) );

		$item['name'] = $row['title'];
		$item['url']  = $MODULE_URL."/viewcat.php?cid=$item_id";

		return $item;
	}

	if ($category=='link') 
	{
// Assume we have a valid link id
		$sql = "SELECT * FROM $table_link WHERE lid=$item_id";
		$row = $xoopsDB->fetchArray( $xoopsDB->query($sql) );

		$item['name'] = $row['title'];
		$item['url']  = $MODULE_URL."/singlelink.php?lid=$item_id";

		return $item;
	}
}

?>
