phpDocumentor VFront
[ class tree: VFront ] [ index: VFront ] [ all elements ]

Source for file add.link.php

Documentation is available at add.link.php

  1. <?php
  2. /**
  3. * Finestra per la gestione dei link dalla scheda
  4. * Viene aperta in popup dal file {@link scheda.php}
  5. @package VFront
  6. @author Mario Marcello Verona <marcelloverona@gmail.com>
  7. @copyright 2007 Mario Marcello Verona
  8. @version 0.90
  9. @license http://www.gnu.org/licenses/gpl.html GNU Public License
  10. */
  11.  
  12. // Imposto l'esecuzione massima in 10 minuti
  13. ini_set('max_execution_time',600);
  14.     
  15.  
  16. include("./inc/conn.php");
  17. include("./inc/layouts.php");
  18. include("./inc/func.comuni.php");
  19. include("./inc/func.frontend.php");
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. /**
  28.  * Funzione di parsing del link.
  29.  * Controlla la validità del link e qualora non sia espresso un suffisso valido come http:// o https://
  30.  * se sovreascrive il contenuto
  31.  *
  32.  * @param string $user_link 
  33.  * @todo La funzione è da scrivere, attualmente restituisce la stringa così com'è.
  34.  * @return string 
  35.  */
  36. function parse_link($user_link){
  37.     
  38.     return $user_link;
  39. }
  40.  
  41.  
  42.  
  43.  
  44. ######################################################################
  45. #
  46. #    CASO ELIMINA ALLEGATO
  47. #
  48.  
  49.  
  50. if(isset($_GET['del'])){
  51.     
  52.     $id_da_eliminare=str_replace(_BASE64_PASSFRASE,'',base64_decode($_GET['del']));
  53.     
  54.     $id_da_eliminare=intval($id_da_eliminare);
  55.     
  56.     // elimino dal DB
  57.     $q_del=vmsql_query("DELETE FROM "._TABELLA_LINK." WHERE codicelink=$id_da_eliminare",$link);
  58.     
  59.     $test_del_db(vmsql_affected_rows($link,$q_del)==1true:false;
  60.  
  61.         
  62.     if($test_del_db){
  63.         header("Location: ".$_SERVER['PHP_SELF']."?t=".$_GET['t']."&id=".$_GET['id']."&az=del&feed=ok");
  64.         
  65.     }
  66.     else{
  67.         header("Location: ".$_SERVER['PHP_SELF']."?t=".$_GET['t']."&id=".$_GET['id']."&az=del&feed=ko");
  68.     }
  69.     
  70.     exit;
  71. }
  72.  
  73.  
  74. #
  75. #
  76. ######################################################################
  77.  
  78.  
  79.  
  80. #######################################################################
  81. #
  82. #    CASO UPLOAD ESEGUITO
  83. #
  84.  
  85. if(count($_POST['links'])>0){
  86.     
  87.     $tabella preg_replace("'[\W]+'","",trim($_POST['t']));
  88.     $id preg_replace("'[\W]+'","",trim($_POST['id']));
  89.     
  90.     
  91.     $success=0;
  92.         
  93.     for($i=0;$i<count($_POST['links']);$i++){
  94.         
  95.         $sql_ins="INSERT into "._TABELLA_LINK." (tipoentita,codiceentita,link)
  96.                  VALUES('$tabella','$id','".$_POST['links'][$i]."')";
  97.         
  98.         $q_ins=vmsql_query($sql_ins,$link);
  99.         if(vmsql_affected_rows($link,$q_ins)==1){
  100.             $success++;
  101.         }
  102.     }
  103.     
  104.     if(count($_POST['links'])==$success){
  105.         
  106.         header("Location: ".$_SERVER['PHP_SELF']."?t=".$_POST['t']."&id=".$_POST['id']."&feed=ok");
  107.         exit;
  108.     }
  109.     else{
  110.         header("Location: ".$_SERVER['PHP_SELF']."?t=".$_POST['t']."&id=".$_POST['id']."&feed=ko");
  111.     }
  112.     
  113.  
  114.     exit;
  115. }
  116. ########################################################################
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. ########################################################################
  131. #
  132. #    VISTA PAGINA - QUERY DI RICERCA LINK
  133. #
  134.  
  135.  
  136.  
  137.  
  138. # CASO SPECIALE NEW:
  139. // L'utente ha cliccato su allegato quando ancora il record non era salvato..
  140. if($_GET['id']=='new'){
  141.     
  142.     $msg="La corretta procedura per inserire link, prevede prima il salvataggio del nuovo record e solo allora l'inserimento dei link.";
  143.     openErrorGenerico('Impossibile inserire link prima di salvare il nuovo record',false,$msg,'popup');
  144.     exit;
  145. }
  146.  
  147. if($_GET['id']=='ric'){
  148.     
  149.     $msg="Si &egrave; in fase di ricerca. Eseguire o annullare la ricerca prima di inserire allegati.";
  150.     openErrorGenerico('Impossibile allegare file in modalit&agrave; ricerca',false,$msg,'popup');
  151.     exit;
  152. }
  153.  
  154. $tabella preg_replace("'[\W]+'","",trim($_GET['t']));
  155. $id preg_replace("'[\W]+'","",trim($_GET['id']));
  156.  
  157. // PRENDI IMPOSTAZIONI ALLEGATI PER TABELLA/REGISTO
  158. $q_reg=vmsql_query("SELECT  permetti_link_ins
  159.                             permetti_link_del
  160.                     FROM {$db1['frontend']}.registro_tab
  161.                     WHERE table_name='$tabella'
  162.                     AND gid=".$_SESSION['gid'],$link);
  163.  
  164. list($link_ins,$link_del)=vmsql_fetch_row($q_reg);
  165.  
  166.  
  167.  
  168. if(!is_tabella($tabella|| $id==''){
  169.     
  170.     openErrorGenerico('Errore nella richiesta',false);
  171.     exit;
  172. }
  173.  
  174.  
  175.  
  176.  
  177. // CERCA ALLEGATI PER QUESTA TABELLA
  178. $qa=vmsql_query("SELECT * FROM "._TABELLA_LINK."
  179.                 WHERE tipoentita='$tabella'
  180.                 AND codiceentita='$id'
  181.                 ORDER BY linklastdata",$link);
  182.  
  183. $num_link=vmsql_num_rows($qa);
  184.  
  185. $matrice_info_link=vmsql_fetch_assoc_all($qa);
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199. $files array('sty/linguette.css','sty/admin.css','js/clona_link.js');
  200.  
  201. $INIZIO_LAYOUTopenLayout1("Link",$files,'popup');
  202.  
  203. echo str_replace("<body>","<body onload=\"self.focus();\">",$INIZIO_LAYOUT);
  204.  
  205. echo "<h1 style=\"font-size:1.6em;\">Link per record <span style=\"color:#666;\">".$_GET['id']."</span> della tabella <span class=\"var\">".$_GET['t']."</span></h1>";
  206.  
  207. echo "<img src=\"./img/network.gif\" class=\"img-float\" alt=\"gestione link\" />\n";
  208.  
  209.  
  210.  
  211. $JS_aggiorna(isset($_GET['feed']&& $_GET['feed']=='ok'?  'window.opener.richiediAL();' "";
  212.  
  213.     
  214.  
  215.     // prendi aree tematiche
  216.     /*$q_aree=vmsql_query("SELECT codiceAreatematica, descAreatematica FROM areatematica ORDER BY descAreatematica",$link);
  217.     
  218.     $SELECT = "\t<select name=\"area[]\">\n";
  219.     
  220.     while($RS=vmsql_fetch_assoc($q_aree)){
  221.         $areetematiche[$RS['codiceAreatematica']]=$RS['descAreatematica'];
  222.         $SELECT.="\t\t<option value=\"".$RS['codiceAreatematica']."\">".$RS['descAreatematica']."</option>\n";
  223.     }
  224.     
  225.     $SELECT.="\t</select>\n";
  226.     */
  227.     
  228.     
  229.  
  230.     echo "    
  231.     <script type=\"text/javascript\">
  232.         
  233.         $JS_aggiorna
  234.     
  235.         var divs = new Array('link','nuovilink');
  236.     
  237.         var nuoviLink=0;
  238.     
  239.         function eti(ido){
  240.             
  241.             for (var i in divs){
  242.                 document.getElementById('cont-eti-'+divs[i]).style.display='none';
  243.                 document.getElementById('li-'+divs[i]).className='disattiva';
  244.             }
  245.             
  246.             // attiva il selezionato
  247.             document.getElementById('cont-eti-'+ido).style.display='';
  248.             document.getElementById('li-'+ido).className='attiva';
  249.             
  250.         }
  251.     
  252.     
  253.     </script>
  254.     ";
  255.     
  256.  
  257.     echo "    
  258. <div id=\"contenitore-variabili\">
  259.     <div id=\"box-etichette\">
  260.         
  261.         <ul class=\"eti-var-gr\">
  262.  
  263.         
  264.             <li onclick=\"eti('link');\" id=\"li-link\" class=\"attiva\">Link presenti</li>
  265.             "($link_ins"<li onclick=\"eti('nuovilink');\" id=\"li-nuovilink\" class=\"disattiva\">Inserisci link</li>" "","
  266.  
  267.         </ul>
  268.     
  269.     </div>";
  270.  
  271.         
  272.     // LINGUETTA NUOVO FLUSSO
  273.     echo "
  274.     <div class=\"cont-eti\" id=\"cont-eti-link\" >
  275.     
  276.         <p>Link presenti per questo record: <strong>$num_link</strong></p>
  277.         
  278.         <hr class=\"light2\" />
  279.         ";
  280.     
  281.     
  282.         // MOSTRA GLI ALLEGATI
  283.         for($i=0;$i<count($matrice_info_link);$i++){
  284.             
  285.             $elimina($link_del" - <span class=\"fakelink-rosso\" onclick=\"if(confirm('Vuoi davvero cancellare questo link?')){ window.location='".$_SERVER['PHP_SELF']."?t=$tabella&amp;id=$id&amp;del=".base64_encode($matrice_info_link[$i]['codicelink']._BASE64_PASSFRASE)."';}\" >Elimina</span>" "";
  286.             
  287.             echo "
  288.             <div class=\"link\">
  289.                 <p><a href=\"".parse_link($matrice_info_link[$i]['link'])."\">".$matrice_info_link[$i]['link']."</a$elimina<br />
  290.                 ".
  291. //            "<span class=\"grigio\">Area: ".$areetematiche[$matrice_info_link[$i]['codiceAreaTematica']]."</span>".
  292.             "</p>
  293.             </div>\n";
  294.         }
  295.     
  296.     
  297.     
  298.     
  299.     echo "
  300.     </div>
  301.     ";
  302.     
  303.     
  304.  
  305.     
  306.     // LINGUETTA AMMINISTRAZIONE FLUSSI
  307.     
  308.     if($link_ins){
  309.         
  310.     echo "
  311.     <div class=\"cont-eti\" id=\"cont-eti-nuovilink\" style=\"display:none;\">
  312.         <br />
  313.         ";
  314.     
  315.     
  316.     ?>
  317.     <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" >
  318.             <div>
  319.                 <div id="contenitore-link"><div><input type="text" name="links[]" size="68" value="http://" /><?php echo $SELECT?>
  320.                 <span onclick="rimuovi_link(this);" class="fakelink" style="font-size:0.7em;">rimuovi</span><br /></div></div>
  321.                 
  322.                 <span onclick="clona_link();" class="fakelink">Aggiungi un altro link</span><br /><br /><br />
  323.                 
  324.                 
  325.                 <input type="hidden" name="t" value="<?php echo $tabella;?>" />
  326.                 <input type="hidden" name="id" value="<?php echo $id;?>" />
  327.                 
  328.                 <input type="submit" name="aggiungi" value="  Invia  " onclick="submit();this.value='Attendere, prego';this.disabled=true;"  />
  329.                     
  330.             </div>
  331.         </form>
  332.  
  333. <?php
  334.  
  335.     
  336.         echo "</div>\n";
  337.     //-- fine clausola diritti nuovi inserimenti
  338.     
  339.     
  340. echo "</div><!-- fine contenitore -->\n\n";
  341.  
  342.  
  343.  
  344.  
  345. echo closeLayout1();
  346. ?>

Documentation generated on Sat, 22 Sep 2007 11:49:44 +0200 by phpDocumentor 1.4.0a2