<?
require("../clases/enlace.class.php");
$obj = new enlace();
$t = $_REQUEST["text"];
if($t=="R"){	
         $id = $obj->Correlativo();
		 $idp = $_REQUEST['idpersona'];	
		 $a = $_REQUEST["titulo"];	
		 $u = $_REQUEST["url"];		
		 $v = "PUBLICO";//$_REQUEST["visible"];
		 $idpc=0;
		// echo $id.$idp.$a.$u.$v;
		if($obj->Crear($id,$idp,$a,$u,$v,$idpc)){		
					echo "<script languaje=javascript>\n"; 
	 				echo "alert('Enlace Registrad0!!!');location.href ='../listaenlace.php?id=$idp';";					
	 				echo "</script>"; 
							
		}else{
		       echo "no pasa nada";
		     }
}

if($t=="M"){
         $idp = $_REQUEST['idpersona'];	/////para redireccionar	
         $id = $_REQUEST['idenlace'];	
		 $a = $_REQUEST["titulo"];	
		 $u = $_REQUEST["url"];		
		 $v = $_REQUEST["visible"];
		if($obj->Actualizar($id,$a,$u,$v)){		
					echo "<script languaje=javascript>\n"; 
	 				echo "alert('Enlace Modificado Correctamente!!!');location.href ='../listaenlace.php?id=$idp';";					
	 				echo "</script>"; 
							
		}else{
		       echo "no pasa nada";
		     }
}

if($t=="C"){	
        echo $id = $obj->Correlativo();
		$idp = $_REQUEST['idpersona'];	
		 $idpc = $_REQUEST['idpersonacom'];	
		 $a = $_REQUEST["titulo"];	
		 $u = $_REQUEST["url"];		
		 $v = "PUBLICO";//$_REQUEST["visible"];
		if($obj->Comparte($id,$idpc,$a,$u,$v,$idp)){		
					echo "<script languaje=javascript>\n"; 
	 				echo "alert('Enlace Compartido!!!');location.href ='../listaenlace.php?id=$idp';";					
	 				echo "</script>"; 
							
		}else{
		       echo "no pasa nada";
		     }
}

if($t=="E"){
 $idp = $_REQUEST["idpersona"];
 $cod = $_REQUEST["id"];
   if($obj->Eliminar($cod)){
   
       echo "<script languaje=javascript>\n"; 
	 	echo "alert('Enlace Eliminado !!!');location.href ='../listaenlace.php?id=$idp';";				
	 	echo "</script>";		
   }
   else
   {
    echo "no pasa nada";
	}

}
?>

