Location: PHPKode > projects > WebETB > doku/list_doc.php4
<?php
/******************************************************************************/
/*	MODUL:	doku/list_doc.php4         													*/
/*																										*/
/* DATUM:	27.03.2006, Version 0.1															*/
/* BESCHR.:	Anzeigen der angelegten Dokumentstruktur                          */
/*          Subfunktion von manage.php4                                       */
/*																										*/
/*	AUTOR:   Marcus Groh																			*/
/*	LIZENZ:  GPL v2 vom Juni 1991 															*/
/*																										*/
/*	AENDERUNGEN:	25.07.2005        -initiale Version								   */
/*                27.03.2006 v 0.1, -Versionskennzeichnung eingefuehrt        */
/*                                  -Code unter GPL v2 gestellt               */
/*                                  -Tabellenname dynamisiert                 */
/*																										*/
/******************************************************************************/
$allowed_groups=array("elw");
include ('../_include/header_2.php4');
       
function list_subs ($db_fid,$pos)
{
      include "../config/conf_glbl.php4";
      
      // Look for subfolders
      $select_file_pid="select * from $T_dokumnt where file_pid=$db_fid";
      $result_file_pid=@mysql_db_query($database["database"],$select_file_pid,$db);
      
      // if none exists return, otherwise print out
      if ( mysql_num_rows($result_file_pid) != 0 )
      {
         $pos=$pos + 3;
         while ($row=mysql_fetch_array($result_file_pid))
         {
            $picto="../_img/fold.gif";
            $linkstyle="style=\"text-decoration: none;\"";
            $db_sub_fid=$row['file_id'];
            $db_sub_titel=$row['titel'];
            $db_sub_typ=$row['typ'];
            
            if ( $db_sub_typ == 2 )
            {
               $picto="../_img/file.gif";    
               $linkstyle="style=\"text-decoration: none;   font-weight: normal;\"";        
            }
         
            echo "<tr>\n";
            echo "<td valign=\"middle\"><p id=\"sw10_s\">";
            for ($i=1; $i<=$pos; $i++)
                  { echo "&nbsp;"; }
            echo "<a href=\"?mode=del&typ=$db_sub_typ&oid=$db_sub_fid\" onFocus=\"blur();\" $linkstyle>";
            echo "<img src=\"$picto\" width=\"22\" height=\"22\" border=\"0\" title=\"L&ouml;schen\"></a> $db_sub_titel</p></td>\n";
            echo "</tr>\n";
            list_subs ($db_sub_fid,$pos);            
         }
      }
      else
      {
         return ;         
      }
      
      return $pos;
}

if ($mode == "del" ) 
{
   // check wheter we have a file or not
   if ( $typ == 2 )
   {
      // physically delete file
      $select_filename="select * from $T_dokumnt where file_id=$oid";
      $result_filename=@mysql_db_query($database["database"],$select_filename,$db);
      if ( mysql_num_rows($result_filename) != 0)
      {
         while ( $row=mysql_fetch_array($result_filename) )
         {
            $filename=$row['f_name'];
            $file_to_delete=$file_path . "/" . $filename;
            unlink ($file_to_delete);
         }
      }
      
      // delete entry in db
      $delete_file="delete from $T_dokumnt where file_id=$oid";
      mysql_db_query($database["database"],$delete_file,$db);
   }
   else
   {
      // check if folder is emtpy
      $select_folder="select * from $T_dokumnt where file_pid=$oid";
      $result_folder=@mysql_db_query($database["database"],$select_folder,$db);
      if ( mysql_num_rows($result_folder) == 0)
      {
         // folder is empty and can be deleted
         $delete_folder="delete from $T_dokumnt where file_id=$oid";
         mysql_db_query($database["database"],$delete_folder,$db);
      }
   }
   
   // reset-values
   $mode="";
   $typ="";
   $oid="";
}
   // Start inner table
   echo "</center><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"704\">\n";
   
          // Get structure of files and folders, started by main-folder
          $select_all_entrys="select * from $T_dokumnt where file_pid like '0' order by titel ";
          $result_all_entrys=@mysql_db_query($database["database"],$select_all_entrys,$db);
          if ( mysql_num_rows($result_all_entrys) == 0)
          {
            // We have a blank table
            echo "<tr>\n";
            echo "<td width=\"704\" ><p id=\"sw10_s\">&nbsp;Keine Eintr&auml;ge vorhanden.</p></td>";
            echo "</tr>\n";
          }
          else
          {
            // List files, folders and subfolders and files and bla
               while ( $row=mysql_fetch_array($result_all_entrys))
               {
                  $db_fid=$row['file_id'];
                  $db_titel=$row['titel'];
                  $db_descr=$row['descr'];
                  $pos=0;
                  echo "<tr>\n";
                  echo "<td width=\"704\" valign=\"middle\"><p id=\"sw10_s\">";
                  echo "<a href=\"?mode=del&typ=0&oid=$db_fid\" onFocus=\"blur();\" style=\"text-decoration: none;\">";
                  echo "<img src=\"../_img/fold.gif\" width=\"22\" height=\"22\" border=\"0\" title=\"L&ouml;schen\"></a>";
                  echo "&nbsp;$db_titel</p></td>\n";
                  echo "</tr>\n";
                  list_subs($db_fid,$pos);
               }          
          }

   // Stop inner table
   echo "</table>\n";
include ('../_include/footer_2.php4');

?>
          
Return current item: WebETB