Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

file.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: file.php 6969 2001-09-05 11:54:47Z jhe $
5 //
6 // Created on: <23-Oct-2000 17:53:46 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "ezfilemanager/classes/ezvirtualfile.php" );
28 // include_once( "ezuser/classes/ezobjectpermission.php" );
29 // include_once( "ezxmlrpc/classes/ezxmlrpcarray.php" );
30 // include_once( "ezxmlrpc/classes/ezxmlrpcbool.php" );
31 // include_once( "ezxmlrpc/classes/ezxmlrpcint.php" );
32
33 if ( $Command == "data" ) // return all the data in the category
34 {
35 $file = new eZVirtualFile();
36 if ( $file->get( $ID ) )
37 {
38 $writeGroups = eZObjectPermission::getGroups( $ID, "filemanager_file", 'w', false );
39 $readGroups = eZObjectPermission::getGroups( $ID, "filemanager_file", 'r', false );
40 $rgp = array();
41 $wgp = array();
42 foreach ( $readGroups as $group )
43 $rgp[] = new eZXMLRPCInt( $group );
44 foreach ( $writeGroups as $group )
45 $wgp[] = new eZXMLRPCInt( $group );
46 $originalFileName = $file->originalFileName();
47 $filePath = $file->filePath( true );
48 $location = "/filemanager/filedownload/$filePath/$originalFileName";
49 $ReturnData = new eZXMLRPCStruct( array( "Name" => new eZXMLRPCString( $file->name() ),
50 "Description" => new eZXMLRPCString( $file->description() ),
51 "WebURL" => new eZXMLRPCString( $location ),
52 "FileName" => new eZXMLRPCString( $file->fileName() ),
53 "OriginalFileName" => new eZXMLRPCString( $file->originalFileName() ),
54 "UserID" => new eZXMLRPCInt( $file->user( false ) ),
55 "FileSize" => new eZXMLRPCInt( $file->fileSize() ),
56 "ReadGroups" => new eZXMLRPCArray( $rgp ),
57 "WriteGroups" => new eZXMLRPCArray( $wgp )
58 ) );
59 }
60 else
61 {
62 $Error = createErrorMessage( EZERROR_NONEXISTING_OBJECT );
63 }
64 }
65 else if ( $Command == "storedata" )
66 {
67 eZPBLog::writeNotice( "file: $ID" );
68 if ( isset( $Data["Name"] ) and isset( $Data["Description"] ) )
69 {
70 $name = $Data["Name"]->value();
71 $description = $Data["Description"]->value();
72 $file = new eZVirtualFile();
73 if ( $ID != 0 )
74 {
75 if ( !$file->get( $ID ) )
76 $Error = createErrorMessage( EZERROR_NONEXISTING_OBJECT );
77 }
78 if ( !$Error )
79 {
80 $file->setName( $name );
81 $file->setDescription( $description );
82 if ( isset( $Data["File"] ) and isset( $Data["FileName"] ) )
83 {
84 $file_data = $Data["File"]->value();
85 $orig_file = $Data["FileName"]->value();
86 $file_store = new eZFile();
87 $file_store->dumpDataToFile( $file_data, $orig_file );
88 if ( !$file->setFile( $file_store ) )
89 {
90 $Error = createErrorMessage( EZERROR_CUSTOM, "Failed to set file sent by client to virtual file $ID",
91 EZFILEMANAGER_BAD_FILE );
92 }
93 }
94 if ( !$Error )
95 {
96 $file->store();
97
98 $ID = $file->id();
99
100 $ReturnData = new eZXMLRPCStruct( array( "Location" => createURLStruct( "ezfilemanager", "file", $ID ),
101 // TODO: Fix Path
102 "Path" => new eZXMLRPCArray( array() ),
103 "UpdateType" => new eZXMLRPCString( $Command )
104 )
105 );
106 $Command = "update";
107 }
108 }
109 }
110 else
111 {
112 $Error = createErrorMessage( EZERROR_BAD_REQUEST_DATA );
113 }
114 }
115 else if ( $Command == "delete" )
116 {
117 $file = new eZVirtualFile();
118 if ( $file->get( $ID ) )
119 {
120 $file->delete();
121 $ReturnData = new eZXMLRPCStruct( array( "Location" => createURLStruct( "ezfilemanager", "file", $ID ),
122 "UpdateType" => new eZXMLRPCString( $Command )
123 ) );
124 $Command = "update";
125 }
126 else
127 $Error = createErrorMessage( EZERROR_NONEXISTING_OBJECT );
128 }
129
130 ?>
$group
$group
Definition: admin/articleedit.php:799
eZFile
Tool class which has convencience functions for files and directories.
Definition: ezfile.php:19
eZObjectPermission\getGroups
static getGroups( $objectID, $moduleTable, $permission, $GroupReturn=true)
Definition: ezobjectpermission.php:365
eZPBLog\writeNotice
static writeNotice( $notice)
Definition: ezpblog.php:166
eZVirtualFile
Definition: ezvirtualfile.php:42
eZXMLRPCArray
Definition: ezxmlrpcarray.php:37
eZXMLRPCInt
Definition: ezxmlrpcint.php:37
eZXMLRPCString
Definition: ezxmlrpcstring.php:37
eZXMLRPCStruct
Definition: ezxmlrpcstruct.php:37
$name
$name
Definition: companytypelist.php:194
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$filePath
$filePath
Definition: ezfilemanager/user/filedownload.php:50
$originalFileName
else $originalFileName
Definition: ezfilemanager/user/filedownload.php:48
EZFILEMANAGER_BAD_FILE
const EZFILEMANAGER_BAD_FILE
Definition: ezfilemanager/xmlrpc/datasupplier.php:28
$Error
if(isset( $EditButton)) if(!empty( $CancelButton)) if(!empty( $PreviewButton)) if( $Action=="preview") switch( $Action) $Error
Definition: ezforum/user/messageedit.php:134
$ReturnData
$ReturnData
Definition: tag.php:48
$location
$location
Definition: user/gotolink.php:43
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.