<?php
if (strstr($_SERVER["PHP_SELF"], "/modules/"))  die ("You can't access this file directly...");

//if this module is enabled, this will tell phpwebthings that we are here
$modules["links"]=true;

//include any language dependent text for this module
include_once( "modules/links/lang/msg_".check_lang($cfg["core"]["lang"]).".php" );

//Add a menu item to the user menu
$config["menu"][100] = array( "title"=>$lang["LINKS_TITLE"], "file"=>"links.php", "type"=>"A", "newwindow"=>"N" );

//Add any menu items to the Admin menu
$lang["LINKS_CAT_EDIT_TITLE"] = "Links categories";
$lang["LINKS_EDIT_TITLE"] = "Links";

$config["admmenu"]["links_cat"] = array(
	"title"=>$lang["LINKS_CAT_EDIT_TITLE"], "file"=>"adm_linkscat.php", "class"=>"links" );
$config["admmenu"]["links_edit"] = array(
	"title"=>$lang["LINKS_EDIT_TITLE"], "file"=>"adm_links.php", "class"=>"links" );
$config["admmenu"]["links_pending"] = array(
	"title"=>$lang["LINKS_PENDING"], "file"=>"adm_linkspend.php", "class"=>"links" );

$config["stylecss"]["links"] = false;

if( !isset($cfg["links"]["max_per_page"]) ) $cfg["links"]["max_per_page"] = 20;
if( !isset($cfg["links"]["useradd"]) ) $cfg["links"]["useradd"] = true;
$cfg["links"]["version"] = "1.0";

function check_links_pending()
{
	global $config, $lang, $pending_actions;
	if( !check_user_class($config["admmenu"]["links_pending"]["class"]) ) return;
	// list news that are waiting for publish
	$stmt = "select count(*) from {$config["prefix"]}_links where active='N'";
	$ret = db_query( $stmt );
	$pqty = 0;
	if( $ret ) {
		$pqty = db_result( $ret, 0, 0 );
		db_free_result( $ret );
	}
	if( $pqty > 0 )
		$pending_actions[] = array( "title"=>"Links", "qty"=>$pqty, "link"=>"adm_linkspend.php" );
}

check_links_pending();
?>
