[eluser]srpurdy[/eluser]
This is just one function I am posting. I got about 10 or so of this size, and im no where near done yet hehe. They are very simular just calling different model functions. I would like to trim them down further. Although I'm not sure of a better way to handle it. I already trimmed it down by about 20 lines per function by creating an error library, but any insight would be appreciated. Like could this be done easier with maybe case statments? I haven't really used them at all, but I see many people use them.
Thanks
Code:
function manage_series()
{
$expire_date = $this->main_web->bg_color();
foreach($expire_date->result() as $exp)
{
$datestring = "%Y-%m-%d %h:%i:%s";
$time = time();
$date = mdate($datestring, $time);
if($date > $exp->expire_date)
{
$this->leagues_error->expired();
}
else
{
$this->freakauth_light->check('league');
//move this to a model
$userid = $this->db->getwhere('ilr_league', array('user_id' => $this->db_session->userdata('id')), '', '');
//end move
if($userid->result() OR $this->freakauth_light->isSuperAdmin())
{
$data['query'] = $this->leagues_model->show_series();
if(!$data['query']->result())
{
$this->leagues_error->error_four_zero_four();
}
else
{
$data['seasons'] = $this->leagues_model->show_seasons();
$data['heading'] = "Manage Series";
$league_temp2 = $this->leagues_model->get_league_temp2();
$data['page'] = $this->config->item('FAL_template_dir'). $league_temp2. '/series_list';
$league_temp = $this->leagues_model->get_league_temp();
$this->_container = $this->config->item('FAL_template_dir'). $league_temp;
$this->load->vars($data);
$this->load->view($this->_container);
}
}
else
{
$data['query'] = $this->leagues_model->show_series();
if(!$data['query']->result())
{
$this->leagues_error->error_four_zero_four();
}
else
{
$this->leagues_error->access_denied();
}
}
}
}
}