|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/logicswapweb/aplicaciones/admon/noticias/tb_relaciones/ |
Upload File : |
<?php
/************************************************************
M�TODO: btn_opernoticias
DESCRIPCION: despliega botones adicionar, eliminar, modificar, visualizar
dependiendo del perfil del usuario
PARAMETROS: $permisos: array con los permisos asignados al usuario
RETORNA:
************************************************************/
function btn_operelaciones($permisos){
list($adicionar, $insimagenes, $eliminar, $modificar, $visualizar) = $permisos;
$cadena ='<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr height="25"><td width="60%" align="left"> ';
if($adicionar==1)
$cadena .="<input type='button' onClick='llama_pagina(3)' name='Modificar' value='Relacionar' class='boton1' style='width:70 '> ";
$cadena .='</td><td width="40%" align="rigth"> ';
if($eliminar==1)
$cadena .="<input type='button' onClick='llama_pagina(4)' name='Eliminar' value='Eliminar' class='boton1' style='width:70 '> ";
if($visualizar==1)
$cadena .='<input type="button" onClick="llama_pagina(5)" name="Visualizar" value="Visualizar" class="boton1" style="width:70 ">';
$cadena .='</td>';
$cadena .="</tr></table>";
echo $cadena;
}
/************************************************************
M�TODO: numrelaciones
DESCRIPCION: cuenta el n�mero de relaciones entre noticias en la base de datos
PARAMETROS:
RETORNA: numrelaciones
*************************************************************/
function numrelaciones(){
$consulta = " select count(*) as num_relaciones
from noticias ";
$resultado = consultar($consulta);
$filas = mysql_fetch_assoc($resultado);
return $filas['num_relaciones'];
}
/************************************************************
M�TODO: numpaginas
DESCRIPCION: cuenta el n�mero de p�ginas a desplegar
PARAMETROS:
RETORNA: numpaginas
*************************************************************/
function numpagrel($numlineas){
$numrelaciones = numrelaciones();
$numpaginas = ceil($numrelaciones/$numlineas);
return $numpaginas;
}
/************************************************************
M�TODO: distitulotema
DESCRIPCION: despliega el titulo y el tema de una noticia
PARAMETROS: $nocitia_id identificador de la noticia
RETORNA:
*************************************************************/
function distitulotema($noticia_id){
$consulta = " select noticia_titulo as titulo, noticiatema_titulo as tema
from noticias, noticia_temas
where noticia_id = '$noticia_id'
and noticia_tema=noticiatema_id";
$resultado = consultar($consulta);
$filas = mysql_fetch_assoc($resultado);
echo "<tr>";
echo '<td width="2%"> </td>';
echo '<td width="50%" align="left" class="texto1"><strong>'.$filas['titulo'].'</strong></td>';
echo '<td width="28%" align="left" class="texto1"><strong>'.$filas['tema'].'</strong></td>';
echo '<td width="20%" align="center"> </td>';
echo '</tr>';
echo "<tr>";
echo '<td width="2%"> </td>';
echo '<td width="50%" align="left"> </td>';
echo "<td width='28%' align='left'> </td>";
echo '<td width="20%" align="center"> </td>';
echo '</tr>';
}
/************************************************************
M�TODO: listar_relaciones
DESCRIPCION: despliega las relaciones existentes para una noticia
PARAMETROS: $noticia_id identificar de la noticia
RETORNA:
*************************************************************/
function listar_relaciones($noticia_id){
$consulta = " select b.noticia_titulo as titulo, c.noticiatema_titulo as tema
from noticia_relaciones as a, noticias as b, noticia_temas as c
where a.noticia_id='$noticia_id'
and a.noticia_idrelacion = b.noticia_id
and b.noticia_tema=c.noticiatema_id";
$resultado = consultar($consulta);
if($resultado)
$cantidad_registros = mysql_num_rows($resultado);
if($cantidad_registros>0)
{
$i=0;
echo "<tr >";
echo '<td width="2%"> </td>';
echo '<td width="50%" align="center" class="texto1"><strong>Noticias relacionadas</strong></td>';
echo "<td width='28%' align='left'> </td>";
echo '<td width="20%" align="center"> </td>';
echo '</tr>';
while($filas = mysql_fetch_assoc($resultado)){
$i++;
//echo "<tr id=\"tr_$i\" onMouseOut=mOut(this,'#FFFFFF') onMouseOver=mOvr(this,'#FAFF95')>";
echo '<td width="2%">'.$i.'</td>';
echo '<td width="50%" align="left" class="texto1">'.$filas['titulo'].'</td>';
echo "<td width='28%' align='left' class='texto1'>".$filas['tema']."</td>";
echo '<td width="20%" align="center"> </td>';
echo '</tr>';
}
}//fin de if($cantidad_registros>0)
}
/************************************************************
M�TODO: listar_notixrelaciones
DESCRIPCION: despliega las noticias candidatas a establecer relacion
con la noticia seleccionada
PARAMETROS: $noticia_id identificar de la noticia seleccionada
RETORNA:
*************************************************************/
function listar_notixrelaciones($noticia_id){
//***********************prepara arreglo para subquery***********************************************
$consulta = "select noticia_idrelacion as relacion
from noticia_relaciones
where noticia_id='$noticia_id'";
$resultado = consultar($consulta);
$filas = mysql_fetch_assoc($resultado);
$i=1;$Con = 0;
$CadScript="(";
do {
if($Con > 0)
{
$CadScript.=" \"); \n";
}
$CadScript.="\"".$filas['relacion']."\",";
}while($filas = mysql_fetch_assoc($resultado));
$CadScript=substr($CadScript,0,strlen($CadScript)-1).")";
/**********/
$consulta = " select noticia_id as id, noticia_titulo as titulo, noticiatema_titulo as tema
from noticias, noticia_temas
where noticia_tema=noticiatema_id
and noticia_id!='$noticia_id'
and noticia_id not in $CadScript";
$resultado = consultar($consulta);
if($resultado)
$cantidad_registros = mysql_num_rows($resultado);
if($cantidad_registros>0)
{
$i=0;
while($filas = mysql_fetch_assoc($resultado)){
$i++;
echo "<tr id=\"tr_$i\" onMouseOut=mOut(this,'#FFFFFF') onMouseOver=mOvr(this,'#FAFF95')>";
echo '<td width="2%">'.$i.'</td>';
echo '<td width="50%" align="left" class="texto1">'.$filas['titulo'].'</td>';
echo "<td width='28%' align='left' class='texto1'>".$filas['tema']."</td>";
echo '<td width="20%" align="center"><input class="radio" type="radio" name="seleccion" value="'.$filas['id'].'"></td>';
echo '</tr>';
}
}//fin de if($cantidad_registros>0)
}
/************************************************************
M�TODO: listar_relacionesxeliminar
DESCRIPCION: despliega las relaciones existentes para una noticia
para permitir el eliminar dicha relacion
PARAMETROS: $noticia_id identificar de la noticia
RETORNA:
*************************************************************/
function listar_relacionesxeliminar($noticia_id){
$consulta = " select a.noticia_idrelacion as id, b.noticia_titulo as titulo, c.noticiatema_titulo as tema
from noticia_relaciones as a, noticias as b, noticia_temas as c
where a.noticia_id='$noticia_id'
and a.noticia_idrelacion = b.noticia_id
and b.noticia_tema=c.noticiatema_id";
$resultado = consultar($consulta);
if($resultado)
$cantidad_registros = mysql_num_rows($resultado);
if($cantidad_registros>0)
{
$i=0;
echo "<tr >";
echo '<td width="2%"> </td>';
echo '<td width="50%" align="center" class="texto1"><strong>Noticias relacionadas</strong></td>';
echo "<td width='28%' align='left'> </td>";
echo '<td width="20%" align="center"> </td>';
echo '</tr>';
while($filas = mysql_fetch_assoc($resultado)){
$i++;
echo "<tr id=\"tr_$i\" onMouseOut=mOut(this,'#FFFFFF') onMouseOver=mOvr(this,'#FAFF95')>";
echo '<td width="2%" class="texto1">'.$i.'</td>';
echo '<td width="50%" align="left" class="texto1">'.$filas['titulo'].'</td>';
echo "<td width='28%' align='left' class='texto1'>".$filas['tema']."</td>";
echo '<td width="20%" align="center"><input class="radio" type="radio" name="seleccion" value="'.$filas['id'].'"></td>';
echo '</tr>';
}
}//fin de if($cantidad_registros>0)
}
/************************************************************
M�TODO: ins_relacion
DESCRIPCION: inserta una relacion en la base de datos
PARAMETROS:
RETORNA:
*************************************************************/
function ins_relacion($noticia_id, $noticia_idrelacion){
$consulta = " insert into noticia_relaciones (noticia_id, noticia_idrelacion)
values ('$noticia_id', '$noticia_idrelacion')";
$resultado = consultar($consulta);
if($resultado){
echo "<script> alert ('Noticias relacionadas con �xito');</script>";
$url='adi_relaciones.php?noticia_id='.$noticia_id;
echo "<script> window.location.href='$url';</script>";
}
}
/************************************************************
M�TODO: eli_relacion
DESCRIPCION: inserta una relacion en la base de datos
PARAMETROS:
RETORNA:
*************************************************************/
function eli_relacion($noticia_id, $noticia_idrelacion){
$consulta = " delete from noticia_relaciones
where noticia_id = '$noticia_id'
and noticia_idrelacion = '$noticia_idrelacion'";
$resultado = consultar($consulta);
if($resultado){
echo "<script> alert ('Eliminaci�n realizada');</script>";
$url='eli_relaciones.php?noticia_id='.$noticia_id;
echo "<script> window.location.href='$url';</script>";
}
}
?>