XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
step.php
Go to the documentation of this file.
1 <?php
20 include 'admin_header.php';
23 
24 $indexAdmin->addItemButton(_ADD . ' ' . _PROFILE_AM_STEP, 'step.php?op=new', 'add', '');
25 echo $indexAdmin->addNavigation('step.php');
26 echo $indexAdmin->renderButton('right', '');
27 
28 $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : (isset($_REQUEST['id']) ? "edit" : 'list');
29 
31 switch ($op ) {
32  case "list":
33  $GLOBALS['xoopsTpl']->assign('steps', $handler->getObjects(null, true, false) );
34  $template_main = "profile_admin_steplist.html";
35  break;
36 
37  case "new":
38  $obj =& $handler->create();
39  include_once "../include/forms.php";
40  $form = profile_getStepForm($obj);;
41  $form->display();
42  break;
43 
44  case "edit":
45  $obj =& $handler->get($_REQUEST['id']);
46  include_once "../include/forms.php";
47  $form = profile_getStepForm($obj);;
48  $form->display();
49  break;
50 
51  case "save":
52  if ( isset($_REQUEST['id']) ) {
53  $obj =& $handler->get($_REQUEST['id']);
54  } else {
55  $obj =& $handler->create();
56  }
57  $obj->setVar('step_name', $_REQUEST['step_name']);
58  $obj->setVar('step_order', $_REQUEST['step_order']);
59  $obj->setVar('step_desc', $_REQUEST['step_desc']);
60  $obj->setVar('step_save', $_REQUEST['step_save']);
61  if ( $handler->insert($obj) ) {
62  redirect_header('step.php', 3, sprintf(_PROFILE_AM_SAVEDSUCCESS, _PROFILE_AM_STEP) );
63  }
64  echo $obj->getHtmlErrors();
65  $form = $obj->getForm();
66  $form->display();
67  break;
68 
69  case "delete":
70  $obj =& $handler->get($_REQUEST['id']);
71  if ( isset($_REQUEST['ok']) && $_REQUEST['ok'] == 1 ) {
72  if ( $handler->delete($obj) ) {
73  redirect_header('step.php', 3, sprintf(_PROFILE_AM_DELETEDSUCCESS, _PROFILE_AM_STEP) );
74  } else {
75  echo $obj->getHtmlErrors();
76  }
77  } else {
78  xoops_confirm(array('ok' => 1, 'id' => $_REQUEST['id'], 'op' => 'delete'), $_SERVER['REQUEST_URI'], sprintf(_PROFILE_AM_RUSUREDEL, $obj->getVar('step_name') ));
79  }
80  break;
81 
82 
83  case 'toggle':
84  if (isset($_GET['step_id'])) {
85  $field_id=intval($_GET['step_id']);
86  if (isset($_GET['step_save'])) {
87  $step_save = intval($_GET['step_save']);
88  profile_stepsave_toggle($step_id, $step_save);
89  }
90  }
91  break;
92 }
93 
94 if ( !empty($template_main) ) {
95  $GLOBALS['xoopsTpl']->display("db:{$template_main}");
96 }
97 
98 function profile_stepsave_toggle($step_d, $step_save)
99 {
100  $step_save = ($step_save == 1) ? 0 : 1;
101  $handler =& xoops_getmodulehandler('regstep');
102  $obj =& $handler->get($_REQUEST['step_id']);
103  $obj->setVar('step_save', $step_save);
104  if ($handler->insert($obj,true)) {
106  }else {
108  }
109 }
110 
111 include 'admin_footer.php';