phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] tts/inc class.attachedFiles.inc.php, NONE, 1.1.2.1 cl


From: Dave Hall <address@hidden>
Subject: [Phpgroupware-cvs] tts/inc class.attachedFiles.inc.php, NONE, 1.1.2.1 class.subcategories.inc.php, NONE, 1.1.2.1
Date: Fri, 31 Oct 2003 07:10:20 +0000

Update of /cvsroot/phpgroupware/tts/inc
In directory subversions:/tmp/cvs-serv19948

Added Files:
      Tag: Version-0_9_16-branch
        class.attachedFiles.inc.php class.subcategories.inc.php 
Log Message:
probiz changes from lars - untested

--- NEW FILE: class.subcategories.inc.php ---
<?php
        
/**************************************************************************\
        * phpGroupWare API - Subcategories                                      
   *
        * This file written by Joseph Engo <address@hidden>                *
        *                  and Bettina Gille address@hidden                *
        * Subcategory manager                                                   
   *
        * Copyright (C) 2000, 2001 Joseph Engo, Bettina Gille                   
   *
        * Copyright (C) 2002, 2003 Bettina Gille                                
   *
        * Copyright (C) 2003 probusiness AG (Lars Piepho)                       
                           *
        * 
------------------------------------------------------------------------ *
        * This library is part of the phpGroupWare API                          
   *
        * http://www.phpgroupware.org                                           
   * 
        * 
------------------------------------------------------------------------ *
        * This library is free software; you can redistribute it and/or modify 
it  *
        * under the terms of the GNU Lesser General Public License as published 
by *
        * the Free Software Foundation; either version 2.1 of the License,      
   *
        * or any later version.                                                 
   *
        * This library is distributed in the hope that it will be useful, but   
   *
        * WITHOUT ANY WARRANTY; without even the implied warranty of            
   *
        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  
   *
        * See the GNU Lesser General Public License for more details.           
   *
        * You should have received a copy of the GNU Lesser General Public 
License *
        * along with this library; if not, write to the Free Software 
Foundation,  *
        * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA         
   *
        
\**************************************************************************/
        // $Id: class.subcategories.inc.php,v 1.1.2.1 2003/10/31 07:10:17 
skwashd Exp $
        // $Source: 
/cvsroot/phpgroupware/tts/inc/Attic/class.subcategories.inc.php,v $

        require_once constant('PHPGW_INCLUDE_ROOT') . 
"/phpgwapi/inc/class.categories.inc.php";

        /*!
        @class subcategories
        @abstract class adds ability for applications to make use of 
subcategories
        @discussion examples can be found in notes app
        */
        
        class subcategories extends categories
        {
                var $platform_id = 0;
                var $type_id = 0;
                /*!
                @function subcategories
                @abstract constructor for subcategories class
                @param $accountid account id
                @param $app_name app name defaults to current app
                */
                function subcategories($accountid = '',$app_name = '')
                {
                        parent::categories($accountid,$app_name);
                        $this->platform_id = $this->getSubCatId('platform');
                        $this->type_id = $this->getSubCatId('type');            
        
                }

                /*!
                @function filter
                @abstract ?
                @param $type string
                @result string either subs or mains
                */
                function filter($type)
                {
                        $s = parent::filter($type);
                        switch ($type)
                        {
                                case 'appandplatform': $s = " OR 
(cat_appname='phpgw' AND cat_parent=" . $this->platform_id . ')'; break;
                                case 'appandtype': $s = " OR 
(cat_appname='phpgw' AND cat_parent=" . $this->type_id . ')'; break;
                                default:                        return False;
                        }                       
                        return $s;
                }
                
                function getSubCatId($subcat_name)
                {
                        $sql = "SELECT cat_id FROM phpgw_categories WHERE 
cat_name='tts' AND cat_appname='phpgw'";                      
                        $this->db->query($sql,__LINE__,__FILE__);
                        if(!$this->db->num_rows())
                        {
                                return 0;
                        }
                        $this->db->next_record();
                        $tts_id = $this->db->f('cat_id');
                        
                        
                        $sql = "SELECT cat_id FROM phpgw_categories WHERE 
cat_name='" . $this->db->db_addslashes($subcat_name) . "' "
                                                        ."AND 
cat_appname='phpgw' AND cat_parent=" . $tts_id;                                 
  
                        $this->db->query($sql,__LINE__,__FILE__);
                        if(!$this->db->num_rows())
                        {
                                return 0;
                        }
                        $this->db->next_record();                       
                        return $this->db->f('cat_id');
                }

                
                function getSubCatElementId($subcat_name,$subcatelement_name)
                {         
         $cat_id = $this->getSubCatId($subcat_name);
                 $sql = "SELECT cat_id FROM phpgw_categories WHERE cat_parent=" 
. $cat_id . " AND cat_name='" . $subcatelement_name . "'";                      
                
                 $this->db->query($sql,__LINE__,__FILE__);
                 if(!$this->db->num_rows())
                 {
                  return 0;
                 }
                 $this->db->next_record();               
                 return $this->db->f('cat_id'); 
                }
                
        }
?>

--- NEW FILE: class.attachedFiles.inc.php ---
<?php
  /**************************************************************************\
  * phpGroupWare - attachedFiles                                             *
  * http://www.phpgroupware.org                                              *
  * This file is written by Lars Piepho <address@hidden>             *
  * Copyright (C) 2003 probusiness AG (Lars Piepho)                          *
  *                                                                          *
  * --------------------------------------------                             *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
  \**************************************************************************/

        /* $Id: class.attachedFiles.inc.php,v 1.1.2.1 2003/10/31 07:10:17 
skwashd Exp $ */

        
        class attachedFiles
        {

                var $public_functions = array(
                        'show_file' => True
                );
                var $file;
                var $vfs;

                function attachedFiles()
                {               
                 $this->file = $_REQUEST['file'];
                                  
                 $GLOBALS['phpgw_info']['flags'] = array
                (
                        'currentapp'    => 'tts',
                        'noheader'      => True,
                        'nofooter'      => True,
                        'enable_vfs_class'      => True,
                        'enable_browser_class'  => True
                );
                
                $this->vfs = CreateObject('phpgwapi.vfs');
                
                }

                function show_file()
                {                       
                        $ls_array = $this->vfs->ls(array (
                        'string'        => $this->file,
                        'relatives'     => array (RELATIVE_ALL),
                        'checksubdirs'  => False,
                        'nofiles'       => True));

                        if ($ls_array[0]['mime_type'])
                        {
                                $mime_type = $ls_array[0]['mime_type'];
                        }
                        elseif ($GLOBALS['settings']['viewtextplain'])
                        {
                                $mime_type = 'text/plain';
                        }
                        $filename = basename($this->file);
                        header('Content-type: ' . $mime_type);
                        header('Content-Disposition: attachment; filename=' . 
$filename);
                        echo $this->vfs->read (array (
                                        'string'        => $this->file,
                                        'relatives'     => array 
(RELATIVE_NONE)));
                        $GLOBALS['phpgw']->common->phpgw_exit ();
                }
                
        }
?>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]