Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

companytypeedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: companytypeedit.php 9529 2002-05-14 11:17:05Z 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 /*
28 Edit company types
29 */
30
31 // include_once( "classes/INIFile.php" );
32
33 $ini =& eZINI::instance( 'site.ini' );
34 $Language = $ini->variable( "eZContactMain", "Language" );
35
36 // include_once( "classes/eztemplate.php" );
37 // include_once( "ezcontact/classes/ezcompanytype.php" );
38 // include_once( "ezimagecatalogue/classes/ezimage.php" );
39 // include_once( "classes/ezimagefile.php" );
40 // include_once( "ezuser/classes/ezusergroup.php" );
41 // include_once( "ezuser/classes/ezpermission.php" );
42
43 $user =& eZUser::currentUser();
44 if ( !is_a( $user, "eZUser" ) )
45 {
46 // include_once( "classes/ezhttptool.php" );
47 eZHTTPTool::header( "Location: /contact/nopermission/login" );
48 exit();
49 }
50
51 if ( isset( $Action ) && $Action == "edit" || isset( $Action ) && $Action == "update" )
52 {
53 if ( !eZPermission::checkPermission( $user, "eZContact", "CategoryModify" ) )
54 {
55 // include_once( "classes/ezhttptool.php" );
56 eZHTTPTool::header( "Location: /contact/nopermission/category/edit" );
57 exit();
58 }
59 }
60 else if ( isset( $Action ) && $Action == "new" || isset( $Action ) && $Action == "insert" )
61 {
62 if ( !eZPermission::checkPermission( $user, "eZContact", "CategoryAdd" ) )
63 {
64 // include_once( "classes/ezhttptool.php" );
65 eZHTTPTool::header( "Location: /contact/nopermission/category/new" );
66 exit();
67 }
68 }
69 else if ( isset( $Action ) && $Action == "delete" )
70 {
71 if ( !eZPermission::checkPermission( $user, "eZContact", "CategoryDelete" ) )
72 {
73 // include_once( "classes/ezhttptool.php" );
74 eZHTTPTool::header( "Location: /contact/nopermission/category/delete" );
75 exit();
76 }
77 }
78
79 if ( empty( $TypeID ) )
80 {
81 $TypeID = 0;
82 }
83
84 $type = new eZCompanyType();
85 $type->get( $TypeID );
86
87 if ( isset( $Action ) && $Action == "insert" || isset( $Action ) && $Action == "update" )
88 {
89 $type = new eZCompanyType();
90
91 if ( !empty( $TypeID ) )
92 {
93 $type->get( $TypeID );
94 }
95 $type->setName( $TypeName );
96 $type->setDescription( $TypeDescription );
97 if ( !empty( $TypeID ) )
98 {
99 if ( $SelectParentID != $type->id() )
100 {
101 $tree =& $type->getTree( $type->id() );
102 foreach ( $tree as $item )
103 {
104 if ( $item[0]->id() == $SelectParentID )
105 {
106 $SelectParentID = 0;
107 break;
108 }
109 }
110 }
111 else
112 {
113 $SelectParentID = 0;
114 }
115 }
116 $type->setParentID( $SelectParentID );
117
118 $file = new eZPBImageFile();
119 if ( $file->getUploadedFile( "ImageFile" ) )
120 {
121 $image = new eZImage( );
122 $image->setName( "Image" );
123 $image->setImage( $file );
124
125 $image->store();
126
127 $type->setImageID( $image->id() );
128 }
129
130 $type->store();
131
132 $TypeID = $type->id();
133
134 // include_once( "classes/ezhttptool.php" );
135 eZHTTPTool::header( "Location: /contact/company/list/$TypeID" );
136
137 }
138
139 if ( !$type->id() && isset( $Action ) && $Action != "new" )
140 {
141 // include_once( "classes/ezhttptool.php" );
142 eZHTTPTool::header( "Location: /error.php?type=404&reason=missingpage&module=ezcontact&hint=/contact/company/list/0" );
143 exit();
144 }
145
146
147 if ( isset( $Action ) && $Action == "delete" )
148 {
149 $type = new eZCompanyType();
150 $type->get( $TypeID );
151 $ParentID = $type->parentID();
152 $type->delete( );
153
154 // include_once( "classes/ezhttptool.php" );
155 eZHTTPTool::header( "Location: /contact/company/list/$ParentID" );
156 exit();
157 }
158
159
160 $t = new eZTemplate( "kernel/ezcontact/admin/" . $ini->variable( "eZContactMain", "AdminTemplateDir" ),
161 "kernel/ezcontact/admin/intl/", $Language, "companytype.php" );
162 $t->setAllStrings();
163
164 $t->set_file( "type_page", "companytypeedit.tpl" );
165
166 $t->set_block( "type_page", "current_type_tpl", "current_type" );
167 $t->set_block( "type_page", "path_tpl", "path" );
168 $t->set_block( "path_tpl", "path_item_tpl", "path_item" );
169 $t->set_block( "path_tpl", "current_path_item_tpl", "current_path_item" );
170 $t->set_block( "current_type_tpl", "parent_item_tpl", "parent_item" );
171 $t->set_block( "current_type_tpl", "image_item_tpl", "image_item" );
172 $t->set_block( "current_type_tpl", "no_image_item_tpl", "no_image_item" );
173
174 $t->set_var( "command_type", "company" );
175 $t->set_var( "page_args", isset( $args ) ? $args : false );
176 $t->set_var( "no_image_item", "" );
177 $t->set_var( "image_item", "" );
178 $t->set_var( "path_item", "" );
179 $t->set_var( "current_path_item", "" );
180
181 if ( empty( $TypeID ) || $TypeID == 0 )
182 {
183 $t->parse( "path", "path_tpl" );
184 }
185 else
186 {
187 $paths = $type->path( $TypeID );
188
189 $countingPaths = count( $paths );
190
191 $t->set_var( "path_item", "" );
192 foreach ( $paths as $path )
193 {
194 $t->set_var( "parent_id", $path[0] );
195 if ( $path[0] == $type->id() )
196 {
197 $t->parse( "current_path_item", "current_path_item_tpl" );
198 }
199 else
200 {
201 $t->set_var( "parent_name", $path[1] );
202 $t->parse( "path_item", "path_item_tpl", true );
203 }
204 }
205
206 $t->parse( "path", "path_tpl" );
207 }
208
209 if ( isset( $Action ) && $Action == "edit" || isset( $Action ) && $Action == "new" )
210 {
211 if ( $Action == "edit" )
212 {
213 $t->set_var( "action_value", "update" );
214 }
215 else
216 {
217 $t->set_var( "action_value", "insert" );
218 }
219
220 $type = new eZCompanyType();
221 $type->get( $TypeID );
222
223 $id = $type->id();
224 $name = $type->name();
225 $desc = $type->description();
226 $parentid = $type->parentID();
227 if ( isset( $NewParentID ) )
228 $parentid = $NewParentID;
229
230 $t->set_var( "current_id", $id );
231 $t->set_var( "current_name", $name );
232 $t->set_var( "current_description", $desc );
233 $t->set_var( "parent_id", $parentid );
234
235 $ImageID = $type->imageID();
236
237 if ( is_numeric( $ImageID ) && $ImageID != 0 )
238 {
239 $imageWidth = $ini->variable( "eZContactMain", "CategoryImageWidth" );
240 $imageHeight = $ini->variable( "eZContactMain", "CategoryImageHeight" );
241
242 $image = new eZImage( $ImageID );
243
244 $variation =& $image->requestImageVariation( $imageWidth, $imageHeight );
245
246 $imageURL = "/" . $variation->imagePath();
247 $imageWidth = $variation->width();
248 $imageHeight = $variation->height();
249 $imageCaption = $image->caption();
250
251 $t->set_var( "image_width", $imageWidth );
252 $t->set_var( "image_height", $imageHeight );
253 $t->set_var( "image_url", $imageURL );
254 $t->set_var( "image_caption", $imageCaption );
255 $t->parse( "image_item", "image_item_tpl" );
256 }
257 else
258 {
259 $t->parse( "no_image_item", "no_image_item_tpl" );
260 }
261
262
263 $category = new eZCompanyType();
264
265 $tree = $category->getTree();
266
267 foreach ( $tree as $item )
268 {
269 $t->set_var( "select_parent_id", $item[0]->id() );
270 $t->set_var( "select_parent_name", $item[0]->name() );
271
272 if ( $item[1] > 0 )
273 $t->set_var( "parent_level", str_repeat( "&nbsp;", $item[1] ) );
274 else
275 $t->set_var( "parent_level", "" );
276
277 if ( $item[0]->id() == $parentid )
278 {
279 $t->set_var( "selected", "selected" );
280 $selected = true;
281 }
282 else
283 {
284 $t->set_var( "selected", "" );
285 }
286
287 $t->parse( "parent_item", "parent_item_tpl", true );
288 }
289
290 if ( count( $tree ) == 0 )
291 {
292 $t->set_var( "parent_item", "" );
293 }
294
295 if ( isset( $selected ) && $selected == false )
296 {
297 $t->set_var( "root_selected", "selected" );
298 }
299 else
300 {
301 $t->set_var( "root_selected", "" );
302 }
303
304 $t->parse( "current_type", "current_type_tpl" );
305 }
306
307 $t->pparse( "output", "type_page" );
308
309 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZImage
Definition: ezimage.php:95
eZPBImageFile
Definition: ezpbimagefile.php:71
eZPermission\checkPermission
static checkPermission( $user, $moduleName, $permissionName)
Definition: ezpermission.php:430
eZTemplate
Definition: eztemplate.php:107
eZUser\get
get( $id=-1)
Definition: ezuser.php:266
eZUser\store
store()
Definition: ezuser.php:105
eZUser\delete
delete()
Definition: ezuser.php:245
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
eZUser\id
id()
Definition: ezuser.php:576
eZUser\name
name()
Definition: ezuser.php:643
$item
$item
Definition: classes/admin/linklist.php:228
$Action
$Action
Definition: companysearch.php:80
$t
if(isset( $Action) && $Action=="insert"||isset( $Action) && $Action=="update") if(! $type->id() &&isset( $Action) && $Action !="new") if(isset( $Action) && $Action=="delete") $t
Definition: companytypeedit.php:160
$user
$user
Definition: companytypeedit.php:43
$type
if(!is_a( $user, "eZUser")) if(isset( $Action) && $Action=="edit"||isset( $Action) && $Action=="update") else if(isset( $Action) && $Action=="new"||isset( $Action) && $Action=="insert") else if(isset( $Action) && $Action=="delete") if(empty( $TypeID)) $type
Definition: companytypeedit.php:84
$Language
$Language
Definition: companytypeedit.php:34
$ini
$ini
Definition: companytypeedit.php:33
$countingPaths
$countingPaths
Definition: companytypeedit.php:189
$desc
$desc
Definition: companytypelist.php:195
$args
$args
Definition: companytypelist.php:125
$name
$name
Definition: companytypelist.php:194
$ImageID
$ImageID
Definition: companytypelist.php:201
$id
$id
Definition: companytypelist.php:193
$tree
$tree
Definition: ezad/admin/categoryedit.php:172
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
$ParentID
$ParentID
Definition: eztrade/admin/categorylist.php:171
exit
exit
Definition: folder.php:81
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.