Esempio n. 1
0
 function edit($id = 0)
 {
     $role = new role($id);
     if ($_SERVER['REQUEST_METHOD'] == "GET") {
     } else {
         $role->name_vietnamese = $this->input->post('name_vietnamese');
         $role->name_english = $this->input->post('name_english');
         $role->fieldname = $this->input->post('fieldname');
         if ($role->save()) {
             redirect($this->admin . 'roles/list_all/');
         }
     }
     $dis['base_url'] = base_url();
     $dis['title'] = "Menu";
     $dis['menu_active'] = "Role";
     $dis['view'] = "role/edit";
     $dis['object'] = $role;
     $this->viewadmin($dis);
 }
     if ($_POST['roles_name'] == '') {
         $_POST['action'] = 'enter_data';
         $error_level = 1;
         // No roles_name
     } else {
         if ($_POST['categories_id'] == '') {
             $_POST['action'] = 'enter_data';
             $error_level = 2;
             // No categories_id
         } else {
             /******************************/
             /*** OK, entry can be saved ***/
             /******************************/
             $administration_role = new role($_POST['roles_id']);
             $administration_role->fill($_POST['roles_name'], $_POST['roles_description'], $_POST['roles_mandatory_ticket_entry'], $_POST['projects_id'], $_POST['categories_id']);
             $administration_role->save();
             // Clear all values except mPath and projects_id
             foreach ($_POST as $key => $value) {
                 if ($key != 'mPath' && $key != 'projects_id') {
                     unset($_POST[$key]);
                 }
             }
         }
     }
     break;
 case 'delete_entry':
     // Check for dependencies
     $administration_role = new role($_POST['roles_id']);
     if ($administration_role->has_dependencies()) {
         $error_level = 3;
         // Related employee-role(s) exist