Example #1
0
 public function edit()
 {
     $map = array('name' => 'DISPLAY_NAME', 'password' => 'PASSWORD', 'birthdate' => 'BIRTHDATE', 'twitter' => 'TWITTER', 'facebook' => 'FACEBOOK', 'email' => 'EMAIL', 'picture' => 'AVARTAR');
     person_login();
     $success = false;
     $this->load->model('person_model');
     $person_id = $this->session->userdata('person_id');
     $data['profile'] = $this->person_model->get_person($person_id);
     $name = $data['profile']->DISPLAY_NAME;
     $email = $data['profile']->EMAIL;
     //------------------------------------------------
     $this->load->model('signup');
     $this->load->library('form_validation');
     $this->load->library('form_validation');
     $this->form_validation->set_rules('password', 'Password', 'trim|required|matches[password2]|min_length[8]|max_length[45]');
     $this->form_validation->set_rules('password2', 'Password Confirmation', 'trim|required');
     if (!isset($_POST['name'])) {
         $this->form_validation->set_rules('name', 'Username', 'trim|required|min_length[3]|max_length[45]|xss_clean');
     } else {
         if ($name != $_POST['name']) {
             $this->form_validation->set_rules('name', 'Username', 'trim|required|min_length[3]|max_length[45]|xss_clean|callback_username_check');
         } else {
             $this->form_validation->set_rules('name', 'Username', 'trim|required|min_length[3]|max_length[45]|xss_clean');
         }
     }
     if (!isset($_POST['email'])) {
         $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
     } elseif ($email != $_POST['email']) {
         $this->form_validation->set_rules('email', 'Email', 'trim|required|matches[password2]|min_length[8]|max_length[45]|callback_email_check');
     } else {
         $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
     }
     // $this->form_validation->set_message('username_check','Member is already used!');
     // $this->form_validation->set_message('email_check','Email is already used!');
     $map = array('name' => 'DISPLAY_NAME', 'password' => 'PASSWORD', 'birthdate' => 'BIRTHDATE', 'twitter' => 'TWITTER', 'facebook' => 'FACEBOOK', 'email' => 'EMAIL');
     if ($this->form_validation->run() != false) {
         //if($this->signup->check_name($_POST['name'])&&$this->signup->check_email($_POST['email'])){
         $tmp = $this->signup->add_picture();
         // if(isset($tmp['upload_data'])){
         foreach ($map as $key => $value) {
             # code...
             $person[$value] = $_POST[$key];
         }
         $this->load->model('person_model');
         $person['AVATAR'] = $tmp['upload_data']['file_name'];
         $co = $this->signup->edit_person($person_id, $person);
         $success = true;
         $this->session->set_flashdata('alert', 'Successfully updated profile.');
         redirect('person/profile/' . $person_id);
         // }
         //}
     }
     // $data['type'] = 'edit';
     $data['type'] = 'edit';
     $data['header'] = $this->load->view('header', $this->header, TRUE);
     $data['footer'] = $this->load->view('footer', $this->footer, TRUE);
     $this->load->view('auth/signup', $data);
 }
Example #2
0
 public function edit_reply($post_id)
 {
     person_login();
     $data['reply'] = $this->post_model->get_reply_post($post_id);
     $topic_id = $data['reply']->TOPIC_ID;
     $data['post'] = $this->post_model->get_content($topic_id);
     // var_dump($data['post']);
     $this->load->library('form_validation');
     $this->form_validation->set_rules('content', 'Content', 'required');
     if ($this->form_validation->run()) {
         $post_data = array('content' => $this->input->post('content'), 'post_id' => $post_id);
         $this->post_model->edit($post_data, 1);
         redirect(base_url('post/view/' . $topic_id));
     }
     $data['header'] = $this->load->view('header', $this->header, TRUE);
     $data['footer'] = $this->load->view('footer', $this->footer, TRUE);
     $this->load->view('post/edit_post', $data);
 }
Example #3
0
function moderator_admin_login()
{
    person_login();
    if (!(is_moderator2() || is_admin())) {
        redirect('/');
    }
}