Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezcontact/admin/typeedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: typeedit.php 6927 2001-09-04 12:06:17Z 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 This code can be reused for simple type edits. It requires an object with the following functions:
29 name() and setName(): Used for reading and setting the name of the type.
30 id(): Used for retrieving the id of the type in the database
31 count(): Used for calculating the number of external items dependent on this type
32
33 The object must be initialized in the $item_type variable.
34 Also these following variables must be set properly.
35 $language_file: The file used for reading language translations, for example: consultationtype.php
36 $page_path: The base name of the url, for example: /contact/consultationtype
37 */
38
39 $ini =& $GlobalSiteIni;
40 $Language = $ini->variable( "eZContactMain", "Language" );
41 $DOC_ROOT = $ini->variable( "eZContactMain", "DocumentRoot" );
42
43 // include_once( "classes/eztemplate.php" );
44
45 // include_once( "ezuser/classes/ezuser.php" );
46 // include_once( "ezuser/classes/ezusergroup.php" );
47 // include_once( "ezuser/classes/ezmodule.php" );
48 // include_once( "ezuser/classes/ezpermission.php" );
49
50 require( "kernel/ezuser/admin/admincheck.php" );
51
52 $t = new eZTemplate( $DOC_ROOT . "/admin/" . $ini->variable( "eZContactMain", "AdminTemplateDir" ),
53 $DOC_ROOT . "admin/intl", $Language, $language_file );
54 $t->setAllStrings();
55
56 $item_error = true;
57
58 if ( empty( $HTTP_REFERER ) )
59 {
60 if ( empty( $BackUrl ) )
61 {
62 $back_command = "$page_path/list";
63 }
64 else
65 {
66 $back_command = $BackUrl;
67 }
68 }
69 else
70 {
71 $back_command = $HTTP_REFERER;
72 }
73
74 if ( $Action == "delete" )
75 {
76 // Check to see if the count has changed since the confirmation was done
77 $item_id = $item_type->id();
78 $reconfirm = "Location: $page_path/confirm/$item_id";
79 $count = $item_type->count();
80 if ( !isset( $TypeCount ) )
81 {
82 $Action = "confirm";
83 $TypeError = true;
84 }
85 else if ( $count != $TypeCount )
86 {
87 $Action = "confirm";
88 }
89 else
90 {
91 // The counts are the same as when confirming so we can delete
92
93 $item_type->delete( true );
94 // include_once( "classes/ezhttptool.php" );
95 eZHTTPTool::header( "Location: $page_path/list" );
96 exit();
97 }
98 }
99
100 if ( $Action == "up" )
101 {
102 $item_type->moveUp();
103 // include_once( "classes/ezhttptool.php" );
104 eZHTTPTool::header( "Location: $page_path/list" );
105 exit();
106 }
107
108 if ( $Action == "down" )
109 {
110 $item_type->moveDown();
111 // include_once( "classes/ezhttptool.php" );
112 eZHTTPTool::header( "Location: $page_path/list" );
113 exit();
114 }
115
116 if ( $Action == "insert" or $Action == "update" )
117 {
118 if ( $Action == "insert" )
119 unset( $item_type->ID );
120
121 if ( isset( $func_call_set ) and is_array( $func_call_set ) )
122 {
123 reset( $func_call_set );
124 while( list( $key, $val ) = each( $func_call_set ) )
125 {
126 $item_type->$key( ${$val} );
127 }
128 }
129 else
130 {
131 $item_type->setName( $ItemName );
132 }
133 $item_type->store();
134 // include_once( "classes/ezhttptool.php" );
135 eZHTTPTool::header( "Location: $page_path/list" );
136 }
137
138 if ( !isset( $typeedit ) )
139 $typeedit = "typeedit.tpl";
140 if ( isset( $template_array ) and isset( $block_array ) and
141 is_array( $template_array ) and is_array( $block_array ) )
142 {
143 $standard_array = array( "list_page" => $typeedit );
144 $t->set_file( array_merge( $standard_array, $template_array ) );
145 $t->set_file_block( $template_array );
146 $t->parse( $block_array );
147 }
148 else
149 {
150 $t->set_var( "extra_type_input", "" );
151 $t->set_file( "list_page", $typeedit );
152 }
153 $t->set_block( "list_page", "type_edit_tpl", "type_edit" );
154 $t->set_block( "list_page", "type_confirm_tpl", "type_confirm" );
155
156 $t->set_block( "type_edit_tpl", "line_item_tpl", "line_item" );
157 $t->set_block( "type_edit_tpl", "no_line_item_tpl", "no_line_item" );
158
159 $t->set_block( "type_confirm_tpl", "errors_tpl", "errors" );
160 $t->set_block( "errors_tpl", "error_count_change_item_tpl", "error_count_change_item" );
161 $t->set_block( "errors_tpl", "error_no_confirm_item_tpl", "error_no_confirm_item" );
162
163 $t->set_var( "no_line_item", "" );
164 $t->set_var( "line_item", "" );
165
166 $t->set_var( "item_edit_command", "$page_path/edit" );
167 $t->set_var( "item_delete_command", "$page_path/delete" );
168 $t->set_var( "item_view_command", "$page_path/view" );
169 $t->set_var( "item_list_command", "$page_path/list" );
170 $t->set_var( "item_new_command", "$page_path/new" );
171
172 $t->set_var( "item_id", isset( $ItemID ) ? $ItemID : false );
173 $t->set_var( "item_name", isset( $ItemName ) ? $ItemName : false );
174
175 $t->set_var( "back_url", $back_command );
176 $t->set_var( "item_back_command", $back_command );
177
178 if ( $Action == "confirm" )
179 {
180 $t->set_var( "error_count_change_item", "" );
181 $t->set_var( "error_no_confirm_item", "" );
182
183 if ( isset( $TypeCount ) )
184 {
185 if ( $TypeCount != $item_type->count() )
186 {
187 $t->parse( "error_count_change_item", "error_count_change_item_tpl" );
188 $error = true;
189 }
190 }
191 if ( isset( $TypeError ) )
192 {
193 $t->parse( "error_no_confirm_item", "error_no_confirm_item_tpl" );
194 $error = true;
195 }
196
197 if ( $error == true )
198 {
199 $t->parse( "errors", "errors_tpl" );
200 }
201 }
202
203 if ( !isset( $error ) or $error == false )
204 {
205 $t->set_var( "errors", "" );
206 }
207
208 if ( isset( $func_call ) and is_array( $func_call ) )
209 {
210 reset( $func_call );
211 foreach( $func_call as $key => $value )
212 {
213 $t->set_var( $key, $item_type->$val() );
214 }
215 }
216 else
217 {
218 if ( is_numeric( $item_type->id() ) )
219 {
220 $t->set_var( "item_id", $item_type->id() );
221 $t->set_var( "item_name", $item_type->name() );
222 }
223 }
224
225 if ( $Action == "edit" )
226 {
227 $action_value = "update";
228
229 if ( is_numeric( $item_type->id() ) )
230 {
231 $item_error = false;
232 }
233 }
234
235 if ( $Action == "confirm" )
236 {
237 $action_value = "delete";
238 $t->set_var( "confirm_item", $item_type->name() );
239 $t->set_var( "item_count", $item_type->count() );
240 }
241
242 if ( $Action == "new" )
243 {
244 $action_value = "insert";
245 $item_error = false;
246 }
247
248 if ( $item_error == true )
249 {
250 $t->parse( "no_line_item", "no_line_item_tpl" );
251 }
252 else
253 {
254 $t->parse( "line_item", "line_item_tpl" );
255 }
256
257 if ( $Action == "confirm" )
258 {
259 $t->set_var( "type_edit", "" );
260 $t->parse( "type_confirm", "type_confirm_tpl", true );
261 }
262 else
263 {
264 $t->parse( "type_edit", "type_edit_tpl", true );
265 $t->set_var( "type_confirm", "" );
266 }
267
268 $t->set_var( "form_path", $page_path );
269 $t->set_var( "action_value", $action_value );
270 $t->pparse( "output", "list_page" );
271
272 ?>
$language_file
$language_file
Definition: addresstypeedit.php:30
$item_type
$item_type
Definition: addresstypeedit.php:31
$page_path
if(isset( $ItemArrayID) and is_array( $ItemArrayID)) $page_path
Definition: addresstypeedit.php:42
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZTemplate
Definition: eztemplate.php:107
$Action
$Action
Definition: companysearch.php:80
$typeedit
$typeedit
Definition: countryedit.php:42
$func_call
$func_call
Definition: countryedit.php:46
$func_call_set
$func_call_set
Definition: countryedit.php:51
$block_array
$block_array
Definition: countryedit.php:44
$template_array
$template_array
Definition: countryedit.php:43
$error
$error
Definition: ezarticle/admin/categoryedit.php:51
$GlobalSiteIni
$GlobalSiteIni
Definition: ezarticle/xmlrpc/xmlrpcserver.php:33
$DOC_ROOT
$DOC_ROOT
Definition: ezcontact/admin/typeedit.php:41
$t
$t
Definition: ezcontact/admin/typeedit.php:52
$item_error
$item_error
Definition: ezcontact/admin/typeedit.php:56
$Language
$Language
Definition: ezcontact/admin/typeedit.php:40
$ini
$ini
Definition: ezcontact/admin/typeedit.php:39
$action_value
$action_value
Definition: ezforum/admin/categoryedit.php:212
exit
exit
Definition: folder.php:81
$count
$count
Definition: onlinetypelist.php:108
$item_id
$item_id
Definition: personedit.php:76
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.