Exemple #1
0
 public function edit_permission($id = NULL)
 {
     if ($id) {
         $this->data['permission'] = $this->permissionmodel->get($id);
         if (count($this->data['permission'])) {
             $this->data['subview'] = 'dashboard/permission/_edit_permission';
         } else {
         }
     }
     if ($_POST) {
         $permid = $this->input->post('permissionid', true);
         $permname = $this->input->post('permissionname', true);
         $permkey = $this->input->post('permissionkey', true);
         $permdesc = $this->input->post('permissiondescription', true);
         $rules = $this->permissionmodel->rules;
         $permission = $this->permissionmodel->get($permid);
         $old_value_pem_name = trim($permission->perm_name);
         $old_value_pem_key = trim($permission->perm_key);
         if ($permname != $old_value_pem_name) {
             $rules['PermissionName']['rules'] = 'trim|required|is_unique[tbl_permission.perm_name]';
         } else {
             $rules['PermissionName']['rules'] = 'trim|required';
         }
         if ($permkey != $old_value_pem_key) {
             $rules['PermissionKey']['rules'] = 'trim|required|is_unique[tbl_permission.perm_key]';
         } else {
             $rules['PermissionKey']['rules'] = 'trim|required';
         }
         //  $rules['PermissionName']['rules'] = 'trim|required|edit_unique[tbl_permission.perm_name.' . $permname . ']';
         $this->load->library('form_validation');
         $this->form_validation->set_rules($rules);
         if ($this->form_validation->run() == FALSE) {
         } else {
             $datatoupdate = array('perm_name' => $permname, 'perm_key' => put_underscore($permkey), 'perm_desc' => $permdesc);
             $this->permissionmodel->save($datatoupdate, $permid);
             $this->data['permission'] = $this->permissionmodel->get($permid);
             redirect('dashboard/rabc/view_permissions');
         }
         /* */
     }
     $this->load->view('dashboard/_rabc_layout', $this->data);
 }
Exemple #2
0
 public function edit($id = NULL)
 {
     $datatoinsert = null;
     $posttitle = "";
     $categoryid = "";
     $postcontent = "";
     $posttype = "";
     $publictiondate = "";
     $postname = "";
     $userid = "";
     $postslug = "";
     $parentid = "";
     $posttemplate = "";
     $validationrules = "";
     if ($id != NULL) {
         $this->data['post'] = $this->postmodel->get((int) $id);
         $this->data["loadedposts"] = $this->loadedpostmodel->get_loaded_post_by_post_id((int) $id);
     }
     if ($_POST) {
         if (isset($_POST['updatecontent'])) {
             $posttitle = $this->input->post('posttitle', true);
             $parentid = $this->input->post('parentid', true);
             $post_id = $this->input->post('postid', true);
             $posttemplate = $this->input->post('posttemplate', true);
             $publicationdate = $this->input->post('publicationdate', true);
             $posttype = $this->input->post('posttype', true);
             $postisactive = $this->input->post('postisactive', true);
             $categoryid = $this->input->post('categoryid', true);
             $postcontent = $this->input->post('postcontent', true);
             $postname = $this->input->post('postname', true);
             $userid = $this->input->post('userid', true);
             $postisactive = strcmp($postisactive, "on") == 0 ? 1 : 0;
             $datatoupdate = array("user_id" => $userid, "category_id" => $categoryid, "parent_id" => $parentid, "post_type" => $posttype, "is_active" => $postisactive, "post_template" => $posttemplate, "post_title" => $posttitle, "post_name" => $postname, "publication_date" => $publicationdate, "post_content" => $postcontent);
             $rules = $this->postmodel->create_rules;
         }
         if (isset($_POST['updatedescription'])) {
             $post_id = $this->input->post('postid', true);
             $user_id = $this->input->post('userid', true);
             $postslug = $this->input->post('postslug', true);
             $post_keywords = $this->input->post('postkeywords', true);
             $post_description = $this->input->post('postdescription', true);
             $datatoupdate = array("user_id" => $user_id, "post_keywords" => $post_keywords, "post_slug" => put_underscore($postslug), "post_description" => $post_description);
             $rules = $this->postmodel->description_rules;
         }
         ///    $validationrules = $this->postmodel->create_rules;
         $this->form_validation->set_rules($rules);
         if ($this->form_validation->run() == FALSE) {
             $this->data['errors'] = 'form validation error';
         } else {
             $post_id = $this->postmodel->save($datatoupdate, $post_id);
             $this->data['post'] = $this->postmodel->get($post_id);
         }
     }
     $this->data['subview'] = "dashboard/post/_edit_post";
     $this->load->view("dashboard/_main_layout", $this->data);
 }