Professional CodeIgniter, Thomas Myer
Chapter 7: Improving the Dashboard
221
if ($this-
>
session-
>
userdata(`userid')
<
1){
redirect(`welcome/verify','refresh');
}
}
function index(){
$data[`title'] = "Manage Sizes";
$data[`main'] = `admin_sizes_home';
$data[`sizes'] = $this-
>
MSizes-
>
getAllSizes();
$this-
>
load-
>
vars($data);
$this-
>
load-
>
view(`dashboard');
}
function create(){
if ($this-
>
input-
>
post(`name')){
$this-
>
MSizes-
>
createSize();
$this-
>
session-
>
set_flashdata(`message','Size created');
redirect(`admin/sizes/index','refresh');
}else{
$data[`title'] = "Create Size";
$data[`main'] = `admin_sizes_create';
$this-
>
load-
>
vars($data);
$this-
>
load-
>
view(`dashboard');
}
}
function edit($id=0){
if ($this-
>
input-
>
post(`name')){
$this-
>
MSizes-
>
updateSize();
$this-
>
session-
>
set_flashdata(`message','Size updated');
redirect(`admin/sizes/index','refresh');
}else{
$data[`title'] = "Edit Size";
$data[`main'] = `admin_sizes_edit';
$data[`size'] = $this-
>
MSizes-
>
getSize($id);
$this-
>
load-
>
vars($data);
$this-
>
load-
>
view(`dashboard');
}
}
function delete($id){
$this-
>
MSizes-
>
deleteSize($id);
$this-
>
session-
>
set_flashdata(`message','Size deleted');
redirect(`admin/sizes/index','refresh');
}
}//end class
?
>
c07.indd 221
c07.indd 221
6/10/08 5:36:50 PM
6/10/08 5:36:50 PM