Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezarticle/admin/fileedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: fileedit.php 6760 2001-08-30 07:55:56Z bf $
5 //
6 // Created on: <21-Dec-2000 18:01:48 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( "classes/INIFile.php" );
28 // include_once( "classes/eztemplate.php" );
29 // include_once( "classes/ezlog.php" );
30
31 // include_once( "classes/ezfile.php" );
32
33 // include_once( "ezfilemanager/classes/ezvirtualfile.php" );
34
35 $ini =& eZINI::instance( 'site.ini' );
36 $Language = $ini->variable( "eZArticleMain", "Language" );
37
38 // include_once( "ezarticle/classes/ezarticlecategory.php" );
39 // include_once( "ezarticle/classes/ezarticle.php" );
40
41 if ( isset( $DeleteSelected ) )
42 $Action = "Delete";
43
44 if ( $Action == "Insert" )
45 {
46 $file = new eZFile();
47
48 if ( $file->getUploadedFile( "userfile" ) )
49 {
50 $article = new eZArticle( $ArticleID );
51
52 $uploadedFile = new eZVirtualFile();
53 $uploadedFile->setName( $Name );
54 $uploadedFile->setDescription( $Description );
55
56 $uploadedFile->setFile( $file );
57
58 $uploadedFile->store();
59
60 eZObjectPermission::setPermission( -1, $uploadedFile->id(), "filemanager_file", "r" );
61 eZObjectPermission::setPermission( 1, $uploadedFile->id(), "filemanager_file", "w" );
62
63 $article->addFile( $uploadedFile );
64
65 eZPBLog::writeNotice( "File added to article $ArticleID from IP: $REMOTE_ADDR" );
66 }
67 else
68 {
69 print( $file->name() . " not uploaded successfully" );
70 }
71
72 // include_once( "classes/ezhttptool.php" );
73 eZHTTPTool::header( "Location: /article/articleedit/filelist/" . $ArticleID . "/" );
74 exit();
75 }
76
77 if ( $Action == "Update" )
78 {
79 $file = new eZFile();
80
81 if ( $file->getUploadedFile( "userfile" ) )
82 {
83 $article = new eZArticle( $ArticleID );
84
85 $oldFile = new eZFile( $FileID );
86 $article->deleteFile( $oldFile );
87
88 $uploadedFile = new eZVirtualFile();
89 $uploadedFile->setName( $Name );
90 $uploadedFile->setDescription( $Description );
91
92 $uploadedFile->setFile( $file );
93
94 $uploadedFile->store();
95
96 $article->addFile( $uploadedFile );
97 }
98 else
99 {
100 $uploadedFile = new eZVirtualFile( $FileID );
101 $uploadedFile->setName( $Name );
102 $uploadedFile->setDescription( $Description );
103 $uploadedFile->store();
104 }
105
106 // include_once( "classes/ezhttptool.php" );
107 eZHTTPTool::header( "Location: /article/articleedit/filelist/" . $ArticleID . "/" );
108 exit();
109 }
110
111
112 if ( $Action == "Delete" )
113 {
114 $article = new eZArticle( $ArticleID );
115
116 if ( count ( $FileArrayID ) != 0 )
117 {
118 foreach( $FileArrayID as $FileID )
119 {
120 $file = new eZVirtualFile( $FileID );
121 $article->deleteFile( $file );
122 }
123 }
124
125 // include_once( "classes/ezhttptool.php" );
126 eZHTTPTool::header( "Location: /article/articleedit/filelist/" . $ArticleID . "/" );
127 exit();
128 }
129
130 $t = new eZTemplate( "kernel/ezarticle/admin/" . $ini->variable( "eZArticleMain", "AdminTemplateDir" ),
131 "kernel/ezarticle/admin/intl/", $Language, "fileedit.php" );
132
133 $t->setAllStrings();
134
135 $t->set_file( "file_edit_page", "fileedit.tpl" );
136
137
138 //default values
139 $t->set_var( "name_value", "" );
140 $t->set_var( "description_value", "" );
141 $t->set_var( "action_value", "Insert" );
142 $t->set_var( "option_id", "" );
143 $t->set_var( "file", "" );
144
145 if ( $Action == "Edit" )
146 {
147 $article = new eZArticle( $ArticleID );
148 $file = new eZVirtualFile( $FileID );
149
150 $t->set_var( "article_name", $article->name() );
151
152 $t->set_var( "file_id", $file->id() );
153 $t->set_var( "name_value", $file->name() );
154 $t->set_var( "description_value", $file->description() );
155 $t->set_var( "action_value", "Update" );
156 }
157
158 $article = new eZArticle( $ArticleID );
159
160 $t->set_var( "article_name", $article->name() );
161 $t->set_var( "article_id", $article->id() );
162
163
164
165 $t->pparse( "output", "file_edit_page" );
166
167 ?>
$Description
$Description
Definition: articlelistrss.php:38
eZArticle
Definition: ezarticle.php:82
eZFile
Tool class which has convencience functions for files and directories.
Definition: ezfile.php:19
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZObjectPermission\setPermission
static setPermission( $group, $objectID, $moduleTable, $permission)
Definition: ezobjectpermission.php:236
eZPBLog\writeNotice
static writeNotice( $notice)
Definition: ezpblog.php:166
eZTemplate
Definition: eztemplate.php:107
eZVirtualFile
Definition: ezvirtualfile.php:42
$Action
$Action
Definition: companysearch.php:80
$ArticleID
$ArticleID
Definition: export.php:48
$Language
$Language
Definition: ezarticle/admin/fileedit.php:36
$ini
$ini
Definition: ezarticle/admin/fileedit.php:35
$t
if( $Action=="Insert") if( $Action=="Update") if( $Action=="Delete") $t
Definition: ezarticle/admin/fileedit.php:130
$article
if( $Action=="Edit") $article
Definition: ezarticle/admin/fileedit.php:158
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
exit
exit
Definition: folder.php:81
$Name
$Name
Definition: polledit.php:250
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.