Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

eztrade/admin/categoryedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: categoryedit.php 9895 2004-04-06 11:08:44Z br $
5 //
6 // Created on: <18-Sep-2000 14:46:19 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/ezhttptool.php" );
28 // include_once( "ezuser/classes/ezobjectpermission.php" );
29
30 if ( isset( $Cancel ) )
31 {
32 eZHTTPTool::header( "Location: /trade/categorylist/" );
33 exit();
34 }
35
36 if ( isset ( $DeleteCategories ) )
37 {
38 $Action = "DeleteCategories";
39 }
40 // include_once( "ezsitemanager/classes/ezsection.php" );
41 // include_once( "classes/INIFile.php" );
42 // include_once( "classes/eztemplate.php" );
43
44 $ini =& eZINI::instance( 'site.ini' );
45 $Language = $ini->variable( "eZTradeMain", "Language" );
46
47 // include_once( "eztrade/classes/ezproductcategory.php" );
48
49 if ( isset( $Action ) && $Action == "New" )
50 {
51 $CategoryID = false;
52 $sectionID = false;
53 }
54
55 // Get images from the image browse function.
56 if ( ( isset ( $AddImages ) ) and ( is_numeric( $CategoryID ) ) and ( is_numeric ( $ImageID ) ) )
57 {
58 $image = new eZImage( $ImageID );
59 $category = new eZProductCategory( $CategoryID );
60 $category->setImage( $image );
61 $category->store();
62 $Action = "Edit";
63 }
64
65 // Direct actions
66 if ( isset( $Action ) && $Action == "Insert" )
67 {
68 $parentCategory = new eZProductCategory();
69 $parentCategory->get( $ParentID );
70
71 $category = new eZProductCategory();
72 $category->setName( $Name );
73 $category->setParent( $parentCategory );
74 $category->setDescription( $Description );
75 $category->setSectionID( $SectionID );
76 $category->setSortMode( $SortMode );
77
78 $file = new eZPBImageFile();
79 if ( $file->getUploadedFile( "ImageFile" ) )
80 {
81 $image = new eZImage( );
82 $image->setName( "Image" );
83 $image->setImage( $file );
84
85 $image->store();
86 $category->setImage( $image );
87 }
88
89 $category->store();
90
91 $categoryID = $category->id();
92
93 /* write access select */
94 if( isset( $WriteGroupArray ) )
95 {
96 if( $WriteGroupArray[0] == 0 )
97 {
98 eZObjectPermission::setPermission( -1, $categoryID, "trade_category", 'w' );
99 }
100 else
101 {
102 eZObjectPermission::removePermissions( $categoryID, "trade_category", 'w' );
103 foreach( $WriteGroupArray as $groupID )
104 {
105 eZObjectPermission::setPermission( $groupID, $categoryID, "trade_category", 'w' );
106 }
107 }
108 }
109 else
110 {
111 eZObjectPermission::removePermissions( $categoryID, "trade_category", 'w' );
112 }
113
114 /* read access thingy */
115 if ( isset( $ReadGroupArray ) )
116 {
117 if( $ReadGroupArray[0] == 0 )
118 {
119 eZObjectPermission::setPermission( -1, $categoryID, "trade_category", 'r' );
120 }
121 else // some groups are selected.
122 {
123 eZObjectPermission::removePermissions( $categoryID, "trade_category", 'r' );
124 foreach ( $ReadGroupArray as $groupID )
125 {
126 eZObjectPermission::setPermission( $groupID, $categoryID, "trade_category", 'r' );
127 }
128 }
129 }
130 else
131 {
132 eZObjectPermission::removePermissions( $categoryID, "trade_category", 'r' );
133 }
134
135 // include_once( "classes/ezcachefile.php" );
136 $files = eZCacheFile::files( "kernel/eztrade/cache/", array( "productlist",
137 array( $ParentID, $category->id() ),
138 NULL, NULL ),
139 "cache", "," );
140 foreach( $files as $file )
141 {
142 $file->delete();
143 }
144
145 if ( isset ( $Browse ) )
146 {
147 $categoryID = $category->id();
148 $session = eZSession::globalSession();
149 $session->setVariable( "SelectImages", "single" );
150 $session->setVariable( "ImageListReturnTo", "/trade/categoryedit/edit/$categoryID/" );
151 $session->setVariable( "NameInBrowse", $category->name() );
152 eZHTTPTool::header( "Location: /imagecatalogue/browse/" );
153 exit();
154 }
155
156 eZHTTPTool::header( "Location: /trade/categorylist/" );
157 exit();
158 }
159
160 if ( isset( $Action ) && $Action == "Update" )
161 {
162 $parentCategory = new eZProductCategory();
163 $parentCategory->get( $ParentID );
164
165 $category = new eZProductCategory();
166 $category->get( $CategoryID );
167 $category->setName( $Name );
168
169 if( $ParentID == 0 ) {
170 $category->setParent( $ParentID );
171 }
172 else {
173 $category->setParent( $parentCategory );
174 }
175
176 $category->setDescription( $Description );
177 $category->setSectionID( $SectionID );
178 $category->setSortMode( $SortMode );
179
180 $file = new eZPBImageFile();
181 if ( $file->getUploadedFile( "ImageFile" ) )
182 {
183 $image = new eZImage( );
184 $image->setName( "Image" );
185 $image->setImage( $file );
186
187 $image->store();
188 $category->setImage( $image );
189 }
190
191 if ( $DeleteImage == "on" )
192 $category->setImage( 0 );
193
194 $category->store();
195
196 $categoryID = $category->id();
197
198 /* write access select */
199 if( isset( $WriteGroupArray ) )
200 {
201 if( $WriteGroupArray[0] == 0 )
202 {
203 eZObjectPermission::setPermission( -1, $categoryID, "trade_category", 'w' );
204 }
205 else
206 {
207 eZObjectPermission::removePermissions( $categoryID, "trade_category", 'w' );
208 foreach( $WriteGroupArray as $groupID )
209 {
210 eZObjectPermission::setPermission( $groupID, $categoryID, "trade_category", 'w' );
211 }
212 }
213 }
214 else
215 {
216 eZObjectPermission::removePermissions( $categoryID, "trade_category", 'w' );
217 }
218
219 /* read access thingy */
220 if ( isset( $ReadGroupArray ) )
221 {
222 if( $ReadGroupArray[0] == 0 )
223 {
224 eZObjectPermission::setPermission( -1, $categoryID, "trade_category", 'r' );
225 }
226 else // some groups are selected.
227 {
228 eZObjectPermission::removePermissions( $categoryID, "trade_category", 'r' );
229 foreach ( $ReadGroupArray as $groupID )
230 {
231 eZObjectPermission::setPermission( $groupID, $categoryID, "trade_category", 'r' );
232 }
233 }
234 }
235 else
236 {
237 eZObjectPermission::removePermissions( $categoryID, "trade_category", 'r' );
238 }
239
240
241 // include_once( "classes/ezcachefile.php" );
242 $files = eZCacheFile::files( "kernel/eztrade/cache/", array( "productlist",
243 array( $ParentID, $CategoryID ), NULL, NULL ),
244 "cache", "," );
245 foreach( $files as $file )
246 {
247 $file->delete();
248 }
249
250 if ( isset ( $Browse ) )
251 {
252 $categoryID = $category->id();
253 $session = eZSession::globalSession();
254 $session->setVariable( "SelectImages", "single" );
255 $session->setVariable( "ImageListReturnTo", "/trade/categoryedit/edit/$categoryID/" );
256 $session->setVariable( "NameInBrowse", $category->name() );
257 eZHTTPTool::header( "Location: /imagecatalogue/browse/" );
258 exit();
259 }
260
261 if ( $ParentID )
262 eZHTTPTool::header( "Location: /trade/categorylist/parent/".$ParentID."/" );
263 else
264 eZHTTPTool::header( "Location: /trade/categorylist/" );
265 exit();
266 }
267
268 if ( isset( $Action ) && $Action == "Delete" )
269 {
270 $category = new eZProductCategory();
271 $category->get( $CategoryID );
272
273 if ( file_exists( "kernel/ezarticle/cache/menubox.cache" ) )
274 eZPBFile::unlink( "kernel/ezarticle/cache/menubox.cache" );
275
276 // include_once( "classes/ezcachefile.php" );
277
278 $parent = $category->parent();
279 if ( is_a( $parent, "eZProductCategory" ) )
280 $parent = $parent->id();
281 $files = eZCacheFile::files( "kernel/eztrade/cache/",
282 array( "productlist",
283 array( $category->id(), $parent ),
284 NULL, NULL ),
285 "cache", "," );
286 foreach( $files as $file )
287 {
288 $file->delete();
289 }
290
291 $category->delete();
292
293 eZHTTPTool::header( "Location: /trade/categorylist/" );
294 exit();
295 }
296
297 if ( isset( $Action ) && $Action == "DeleteCategories" )
298 {
299 if ( count ( $CategoryArrayID ) != 0 )
300 {
301 if ( file_exists( "kernel/ezarticle/cache/menubox.cache" ) )
302 eZPBFile::unlink( "kernel/ezarticle/cache/menubox.cache" );
303
304 // include_once( "classes/ezcachefile.php" );
305 foreach( $CategoryArrayID as $ID )
306 {
307 $category = new eZProductCategory();
308 $category->get( $ID );
309
310 $parent = $category->parent();
311 if ( is_a( $parent, "eZProductCategory" ) )
312 $parent = $parent->id();
313 $files = eZCacheFile::files( "kernel/eztrade/cache/",
314 array( "productlist",
315 array( $category->id(), $parent ),
316 NULL, NULL ),
317 "cache", "," );
318 foreach( $files as $file )
319 {
320 $file->delete();
321 }
322
323 $category->delete();
324 }
325 }
326
327 eZHTTPTool::header( "Location: /trade/categorylist/" );
328 exit();
329 }
330
331 if ( isset( $Action ) && $Action == "CopyCategoires" )
332 {
333 if ( count ( $CategoryArrayID ) > 0 )
334 {
335 foreach( $CategoryArrayID as $ID )
336 {
337 }
338 }
339 }
340
341 $t = new eZTemplate( "kernel/eztrade/admin/" . $ini->variable( "eZTradeMain", "AdminTemplateDir" ),
342 "kernel/eztrade/admin/intl/", $Language, "categoryedit.php" );
343
344 $t->setAllStrings();
345
346 $t->set_file( array( "category_edit_tpl" => "categoryedit.tpl" ) );
347
348
349 $t->set_block( "category_edit_tpl", "value_tpl", "value" );
350 $t->set_block( "category_edit_tpl", "image_item_tpl", "image_item" );
351
352 $t->set_block( "category_edit_tpl", "read_group_item_tpl", "read_group_item" );
353 $t->set_block( "category_edit_tpl", "write_group_item_tpl", "write_group_item" );
354 $t->set_block( "category_edit_tpl", "section_item_tpl", "section_item" );
355
356
357 $headline = new eZINI( "kernel/eztrade/admin/intl/" . $Language . "/categoryedit.php.ini", false );
358 $t->set_var( "head_line", $headline->variable( "strings", "head_line_insert" ) );
359
360 $category = new eZProductCategory();
361
362 $categoryArray = $category->getTree( );
363
364 $t->set_var( "description_value", "" );
365 $t->set_var( "name_value", "" );
366 $t->set_var( "action_value", "insert" );
367
368 $t->set_var( "1_selected", "" );
369 $t->set_var( "2_selected", "" );
370 $t->set_var( "3_selected", "" );
371 $t->set_var( "4_selected", "" );
372 $t->set_var( "image_item", "" );
373
374 $writeGroupsID = array();
375 $readGroupsID = array();
376
377 // edit
378 if ( isset( $Action ) && $Action == "Edit" )
379 {
380 $category = new eZProductCategory();
381 $category->get( $CategoryID );
382
383 $t->set_var( "name_value", $category->name() );
384 $t->set_var( "description_value", $category->description() );
385 $t->set_var( "action_value", "update" );
386 $t->set_var( "category_id", $category->id() );
387
388 $parent = $category->parent();
389 switch ( $category->sortMode() )
390 {
391 case "time" :
392 {
393 $t->set_var( "1_selected", "selected" );
394 }
395 break;
396
397 case "alpha" :
398 {
399 $t->set_var( "2_selected", "selected" );
400 }
401 break;
402
403 case "alphadesc" :
404 {
405 $t->set_var( "3_selected", "selected" );
406 }
407 break;
408
409 case "absolute_placement" :
410 {
411 $t->set_var( "4_selected", "selected" );
412 }
413 break;
414 }
415
416 $sectionID = $category->sectionID();
417
418 $image =& $category->image( true );
419 if ( is_a( $image, "eZImage" ) && $image->id() != 0 )
420 {
421 $imageWidth =& $ini->variable( "eZTradeMain", "CategoryImageWidth" );
422 $imageHeight =& $ini->variable( "eZTradeMain", "CategoryImageHeight" );
423
424 $variation =& $image->requestImageVariation( $imageWidth, $imageHeight );
425
426 $imageURL = "/" . $variation->imagePath();
427 $imageWidth = $variation->width();
428 $imageHeight = $variation->height();
429 $imageCaption = $image->caption();
430
431 $t->set_var( "image_width", $imageWidth );
432 $t->set_var( "image_height", $imageHeight );
433 $t->set_var( "image_url", $imageURL );
434 $t->set_var( "image_caption", $imageCaption );
435 $t->parse( "image_item", "image_item_tpl" );
436 }
437 else
438 {
439
440 }
441
442 $writeGroupsID = eZObjectPermission::getGroups( $CategoryID, "trade_category", 'w' , false );
443 $readGroupsID = eZObjectPermission::getGroups( $CategoryID, "trade_category", 'r', false );
444
445 $headline = new eZINI( "kernel/eztrade/admin/intl/" . $Language . "/categoryedit.php.ini", false );
446 $t->set_var( "head_line", $headline->variable( "strings", "head_line_edit" ) );
447 }
448
449 foreach ( $categoryArray as $catItem )
450 {
451 if ( $CategoryID != $catItem[0]->id() )
452 {
453 $t->set_var( "option_value", $catItem[0]->id() );
454 $t->set_var( "option_name", $catItem[0]->name() );
455
456 if ( $Action == "Edit" )
457 {
458 if ( $parent )
459 {
460 if ( $catItem[0]->id() == $parent->id() )
461 {
462 $t->set_var( "selected", "selected" );
463 }
464 else
465 {
466 $t->set_var( "selected", "" );
467 }
468 }
469
470 }
471 else
472 {
473 $t->set_var( "selected", "" );
474 }
475
476 if ( $catItem[1] > 0 )
477 $t->set_var( "option_level", str_repeat( "&nbsp;", $catItem[1] ) );
478 else
479 $t->set_var( "option_level", "" );
480
481 $t->parse( "value", "value_tpl", true );
482 }
483 }
484
485 $sectionList =& eZSection::getAll();
486
487 if ( count( $sectionList ) > 0 )
488 {
489 foreach ( $sectionList as $section )
490 {
491 $t->set_var( "section_id", $section->id() );
492 $t->set_var( "section_name", $section->name() );
493
494 if ( $sectionID == $section->id() )
495 $t->set_var( "section_is_selected", "selected" );
496 else
497 $t->set_var( "section_is_selected", "" );
498
499 $t->parse( "section_item", "section_item_tpl", true );
500 }
501 }
502 else
503 $t->set_var( "section_item", "" );
504
505
506 // group selector
507 $group = new eZUserGroup();
508 $groupList = $group->getAll();
509
510 $t->set_var( "selected", "" );
511
512 $writeAllGroupFound = false;
513 if ( in_array( "-1", $readGroupsID ) )
514 {
515 $t->set_var( "all_selected", "selected=\"selected\"" );
516 $writeAllGroupFound = true;
517 }
518 else
519 {
520 $t->set_var( "all_selected", "" );
521 }
522
523 $readAllGroupFound = false;
524 if ( in_array( "-1", $writeGroupsID ) )
525 {
526 $t->set_var( "all_write_selected", "selected=\"selected\"" );
527 $writeAllGroupFound = true;
528 }
529 else
530 {
531 $t->set_var( "all_write_selected", "" );
532 }
533
534
535
536 foreach( $groupList as $groupItem )
537 {
538 /* for the group owner selector */
539 $t->set_var( "read_id", $groupItem->id() );
540 $t->set_var( "read_name", $groupItem->name() );
541
542 if( in_array( $groupItem->id() , $readGroupsID ) && $readAllGroupFound == false )
543 $t->set_var( "selected", "selected=\"selected\"" );
544 else
545 $t->set_var( "selected", "" );
546
547 if ( in_array( "-1", $readGroupsID ) )
548 $t->set_var( "all_selected", "selected" );
549 else
550 $t->set_var( "all_selected", "" );
551
552 $t->parse( "read_group_item", "read_group_item_tpl", true );
553
554 /* for the read access groups selector */
555 $t->set_var( "write_id", $groupItem->id() );
556 $t->set_var( "write_name", $groupItem->name() );
557
558 if( in_array( $groupItem->id(), $writeGroupsID ) && $writeAllGroupFound == false )
559 $t->set_var( "is_selected", "selected=\"selected\"" );
560 else
561 $t->set_var( "is_selected", "" );
562
563 if ( in_array( "-1", $writeGroupsID ) )
564 $t->set_var( "all_write_selected", "selected" );
565 else
566 $t->set_var( "all_write_selected", "" );
567
568 $t->parse( "write_group_item", "write_group_item_tpl", true );
569 }
570
571
572 $t->pparse( "output", "category_edit_tpl" );
573
574 ?>
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$session
$session
Definition: admin/articlelist.php:44
$Description
$Description
Definition: articlelistrss.php:38
$files
$files
Definition: articlepreview.php:91
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZINI
Reads and writes .ini style configuration files.
eZImage
Definition: ezimage.php:95
eZObjectPermission\getGroups
static getGroups( $objectID, $moduleTable, $permission, $GroupReturn=true)
Definition: ezobjectpermission.php:365
eZObjectPermission\setPermission
static setPermission( $group, $objectID, $moduleTable, $permission)
Definition: ezobjectpermission.php:236
eZObjectPermission\removePermissions
static removePermissions( $objectID, $moduleTable, $permission)
Definition: ezobjectpermission.php:320
eZPBFile\unlink
static unlink( $filename)
Definition: ezpbfile.php:352
eZPBImageFile
Definition: ezpbimagefile.php:71
eZProductCategory
Definition: ezproductcategory.php:90
eZSection\getAll
static getAll( $offset=0, $limit=40)
Definition: ezsection.php:177
eZSession\globalSession
static & globalSession( $id="", $fetch=true)
Definition: kernel/ezsession/classes/ezsession.php:614
eZTemplate
Definition: eztemplate.php:107
eZUserGroup
Definition: ezusergroup.php:66
$Action
$Action
Definition: companysearch.php:80
$ImageID
$ImageID
Definition: companytypelist.php:201
file_exists
static file_exists( $inifilename)
Definition: eZPBINIFile.php:195
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$SectionID
$SectionID
Definition: ezfilemanager/user/filelist.php:46
$groupID
$groupID
Definition: ezgroupeventcalendar/user/dayview.php:90
$section
$section
Definition: ezimagecatalogue/user/categoryedit.php:393
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
$writeGroupsID
$writeGroupsID
Definition: eztrade/admin/categoryedit.php:374
$category
$category
Definition: eztrade/admin/categoryedit.php:360
$t
if(isset( $Action) && $Action=="New") if((isset( $AddImages)) and(is_numeric( $CategoryID)) and(is_numeric( $ImageID))) if(isset( $Action) && $Action=="Insert") if(isset( $Action) && $Action=="Update") if(isset( $Action) && $Action=="Delete") if(isset( $Action) && $Action=="DeleteCategories") if(isset( $Action) && $Action=="CopyCategoires") $t
Definition: eztrade/admin/categoryedit.php:341
$ini
if(isset( $Cancel)) if(isset( $DeleteCategories)) $ini
Definition: eztrade/admin/categoryedit.php:44
$headline
$headline
Definition: eztrade/admin/categoryedit.php:357
$groupList
$groupList
Definition: eztrade/admin/categoryedit.php:508
$Language
$Language
Definition: eztrade/admin/categoryedit.php:45
$readAllGroupFound
$readAllGroupFound
Definition: eztrade/admin/categoryedit.php:523
$writeAllGroupFound
$writeAllGroupFound
Definition: eztrade/admin/categoryedit.php:512
$group
$group
Definition: eztrade/admin/categoryedit.php:507
$categoryArray
$categoryArray
Definition: eztrade/admin/categoryedit.php:362
$sectionList
if(isset( $Action) && $Action=="Edit") foreach( $categoryArray as $catItem) $sectionList
Definition: eztrade/admin/categoryedit.php:485
$readGroupsID
$readGroupsID
Definition: eztrade/admin/categoryedit.php:375
$ParentID
$ParentID
Definition: eztrade/admin/categorylist.php:171
exit
exit
Definition: folder.php:81
$Name
$Name
Definition: polledit.php:250
$categoryID
else $categoryID
Definition: productview.php:66
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.