I was hoping someone with experience in PHP could review this code and suggest areas where it might be improved.
I've posted a snippet of the code as it's quite long, but I've also created a post on pastebin. That post can be viewed here.
Code snippet:
function school_page_handler($page){
global $CONFIG;
switch ($page[0])
{
case 'admin':
switch($page[1]) {
case 'delete':
set_input('method', 'delete');
set_input('admin_guid', $page[2]);
break;
default:
set_input('method','list');
}
include $CONFIG->pluginspath . 'school/pages/admin.php';
break;
case 'approval':
switch($page[1]) {
case 'event':
set_input('method','event');
break;
case 'product':
set_input('method','product');
break;
case 'announcement':
set_input('method','announcement');
break;
case 'program':
set_input('method','program');
break;
case 'permission':
set_input('method','permission');
break;
case 'file':
set_input('method','file');
break;
case 'service':
set_input('method','service');
break;
default: set_input('method','list'); break;
}
include $CONFIG->pluginspath . 'school/pages/approval.php';
break;
case 'teacher':
switch($page[1]) {
case 'new':
set_input('method','new');
break;
case 'edit':
set_input('method','edit');
set_input('teacher_guid',$page[2]);
break;
case 'view':
set_input('method','view');
set_input('teacher_guid',$page[2]);
break;
case 'delete':
set_input('method','delete');
set_input('teacher_guid',$page[2]);
break;
default: set_input('method','list'); break;
}
include $CONFIG->pluginspath . 'school/pages/teacher.php';
break;
case 'register':
switch($page[1]) {
case 'new':
set_input('method','new');
break;
case 'edit':
set_input('method','edit');
break;
case 'student':
set_input('method','link_student');
break;
}
include $CONFIG->pluginspath . 'school/pages/register.php';
break;
case 'student':
switch($page[1]) {
case 'new':
set_input('method','new');
break;
case 'edit':
set_input('method','edit');
set_input('student_guid',$page[2]);
break;
case 'view':
set_input('method','view');
set_input('student_guid',$page[2]);
break;
case 'delete':
set_input('method','delete');
set_input('student_guid',$page[2]);
break;
default: set_input('method','list'); break;
}
include $CONFIG->pluginspath . 'school/pages/student.php';
break;
case 'class':
switch($page[1]) {
case 'new': set_input('method','new'); break;
case 'edit':
set_input('method','edit');
set_input('class_guid',$page[2]);
break;
case 'view':
set_input('method','view');
set_input('class_guid',$page[2]);
break;
case 'delete':
set_input('method','delete');
set_input('class_guid',$page[2]);
break;
case 'list': set_input('method','list'); break;
}
include $CONFIG->pluginspath . 'school/pages/class.php';
break;
case 'parent':
switch($page[1]) {
case 'edit':
set_input('method','edit');
set_input('parent_guid',$page[2]);
break;
case 'view':
set_input('method','view');
set_input('parent_guid',$page[2]);
break;
case 'delete':
set_input('method','delete');
set_input('parent_guid',$page[2]);
break;
case 'unlink':
set_input('method','unlink');
set_input('parent_guid',$page[2]);
set_input('student_guid',$page[3]);
break;
default: set_input('method','list'); break;
}
include $CONFIG->pluginspath . 'school/pages/parent.php';
break;
case 'program':
switch($page[1]) {
case 'new':
set_input('method','new');
break;
case 'edit':
set_input('method','edit');
set_input('program_guid',$page[2]);
break;
case 'view':
set_input('method','view');
set_input('program_guid',$page[2]);
break;
case 'attendance':
set_input('method','attendance');
set_input('program_guid',$page[2]);
break;
case 'requests':
set_input('method','requests');
set_input('program_guid',$page[2]);
break;
case 'delete':
set_input('method','delete');
set_input('program_guid',$page[2]);
break;
default:
set_input('method','list');
set_input('school_guid',$page[1]);
break;
}
include $CONFIG->pluginspath . 'school/pages/program.php';
break;
case 'service':
switch($page[1]) {
case 'new':
set_input('method','new');
break;
case 'edit':
set_input('method','edit');
set_input('service_guid',$page[2]);
break;
case 'payment':
set_input('method','payment');
set_input('service_guid',$page[2]);
break;
case 'view':
set_input('method','view');
set_input('service_guid',$page[2]);
break;
case 'delete':
set_input('method','delete');
set_input('service_guid',$page[2]);
break;
default:
set_input('method','list');
set_input('school_guid',$page[1]);
break;
}
include $CONFIG->pluginspath . 'school/pages/service.php';
break;
case 'report':
set_input('type',$page[1]);
set_input('group',$page[2]);
include $CONFIG->pluginspath . 'school/pages/report.php';
break;
case 'popup_checkout':
include $CONFIG->pluginspath . 'school/pages/popup_checkout.php';
break;
case 'download':
set_input('file',$page[1]);
include $CONFIG->pluginspath . 'school/pages/download.php';
break;
case 'manage_members':
include $CONFIG->pluginspath . 'school/pages/manage_members.php';
break;
case 'sso':
include $CONFIG->pluginspath . 'school/pages/sso.php';
break;
}
return true;
}