unset_list
void unset_list()
Quick Description: Unset the first page list (datagrid)
This functionality simply unset the list (datagrid). So the user is not able to access the list page.
Example:
function unset_list_example() { $crud = new grocery_CRUD(); $crud->set_theme('datatables'); $crud->set_table('employees'); $crud->set_relation('officeCode','offices','city'); $crud->display_as('officeCode','Office City'); $crud->set_subject('Employee'); $crud->unset_list(); $output = $crud->render(); $this->_example_output($output); }
Notice: When a user land to the first list webapge then an unhandle exception with message "You don't have permissions for this operation".
We didn't want to add a show_error there because then you cannot handle the exception. So a quick way to have a default Codeigniter error message is:
try{ $crud->render(); } catch(Exception $e) { show_error($e->getMessage()); }
try{ $crud->render(); } catch(Exception $e) { if($e->getCode() == 14) //The 14 is the code of the "You don't have permissions" error on grocery CRUD. { $this->load->view('permission_denied.php');//This is a custom view that you have to create //Or you can simply have an error message for this //For example: show_error('You don\'t have permissions for this operation'); } else { show_error($e->getMessage()); } }
And if you want the user to have for example the add form you can easily copy the url of the add form for example: localhost/your_project/index.php/examples/test/add and simply direct him there. Or you can also do this:
try{ $crud->render(); } catch(Exception $e) { if($e->getCode() == 14) //The 14 is the code of the "You don't have permissions" error on grocery CRUD. { redirect(strtolower(__CLASS__).'/'.strtolower(__FUNCTION__).'/add'); } else { show_error($e->getMessage()); } }
You have the freedom to do whatever you like rather than have it into the core library.