XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
category.php
Go to the documentation of this file.
1 <?php
2 // $Id: category.php 9205 2012-03-27 08:07:04Z beckmi $
3 // ------------------------------------------------------------------------ //
4 // XOOPS - PHP Content Management System //
5 // Copyright (c) 2000 XOOPS.org //
6 // <http://www.xoops.org/> //
7 // ------------------------------------------------------------------------ //
8 // This program is free software; you can redistribute it and/or modify //
9 // it under the terms of the GNU General Public License as published by //
10 // the Free Software Foundation; either version 2 of the License, or //
11 // (at your option) any later version. //
12 // //
13 // You may not change or alter any portion of this comment or credits //
14 // of supporting developers from this source code or any supporting //
15 // source code which is considered copyrighted (c) material of the //
16 // original comment or credit authors. //
17 // //
18 // This program is distributed in the hope that it will be useful, //
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
21 // GNU General Public License for more details. //
22 // //
23 // You should have received a copy of the GNU General Public License //
24 // along with this program; if not, write to the Free Software //
25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
26 // ------------------------------------------------------------------------ //
27 // Author: XOOPS Foundation //
28 // URL: http://www.xoops.org/ //
29 // Project: The XOOPS Project //
30 // ------------------------------------------------------------------------- //
31 include 'admin_header.php';
34 
35 
36 $indexAdmin->addItemButton(_ADD . ' ' . _PROFILE_AM_CATEGORY, 'category.php?op=new', 'add', '');
37 
38 echo $indexAdmin->addNavigation('category.php');
39 echo $indexAdmin->renderButton('right', '');
40 
41 $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : (isset($_REQUEST['id']) ? "edit" : 'list');
42 
44 switch($op ) {
45 default:
46 case "list":
47  $criteria = new CriteriaCompo();
48  $criteria->setSort('cat_weight');
49  $criteria->setOrder('ASC');
50  $GLOBALS['xoopsTpl']->assign('categories', $handler->getObjects($criteria, true, false) );
51  $template_main = "profile_admin_categorylist.html";
52  break;
53 
54 case "new":
55  include_once '../include/forms.php';
56  $obj =& $handler->create();
57  $form = $obj->getForm();
58  $form->display();
59  break;
60 
61 case "edit":
62  include_once '../include/forms.php';
63  $obj = $handler->get($_REQUEST['id']);
64  $form = $obj->getForm();
65  $form->display();
66  break;
67 
68 case "save":
69  if ( !$GLOBALS['xoopsSecurity']->check() ) {
70  redirect_header('category.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors() ));
71  }
72  if ( isset($_REQUEST['id']) ) {
73  $obj =& $handler->get($_REQUEST['id']);
74  } else {
75  $obj =& $handler->create();
76  }
77  $obj->setVar('cat_title', $_REQUEST['cat_title']);
78  $obj->setVar('cat_description', $_REQUEST['cat_description']);
79  $obj->setVar('cat_weight', $_REQUEST['cat_weight']);
80  if ( $handler->insert($obj) ) {
81  redirect_header('category.php', 3, sprintf(_PROFILE_AM_SAVEDSUCCESS, _PROFILE_AM_CATEGORY) );
82  }
83  include_once '../include/forms.php';
84  echo $obj->getHtmlErrors();
85  $form =& $obj->getForm();
86  $form->display();
87  break;
88 
89 case "delete":
90  $obj =& $handler->get($_REQUEST['id']);
91  if ( isset($_REQUEST['ok']) && $_REQUEST['ok'] == 1 ) {
92  if ( !$GLOBALS['xoopsSecurity']->check() ) {
93  redirect_header('category.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors() ));
94  }
95  if ( $handler->delete($obj) ) {
96  redirect_header('category.php', 3, sprintf(_PROFILE_AM_DELETEDSUCCESS, _PROFILE_AM_CATEGORY) );
97  } else {
98  echo $obj->getHtmlErrors();
99  }
100  } else {
101  xoops_confirm(array('ok' => 1, 'id' => $_REQUEST['id'], 'op' => 'delete'), $_SERVER['REQUEST_URI'], sprintf(_PROFILE_AM_RUSUREDEL, $obj->getVar('cat_title') ));
102  }
103  break;
104 }
105 if ( isset($template_main) ) {
106  $GLOBALS['xoopsTpl']->display("db:{$template_main}");
107 }
108 include 'admin_footer.php';