public function index() { if ($_POST) { //gets the interests from the request $interests = $this->input->post('interests'); //explodes the string into array $interests = procesTags($interests); //update interest in database $this->load->Model('InterestUserModel'); $this->InterestUserModel->update_interests($interests, get_user()->get_id()); // Set status message set_status_message('Your interests have been saved'); //redirect to profile main page return redirect(settings_route()); } $this->load->model('InterestUserModel'); $data['interests'] = $this->InterestUserModel->user_interests_toString(get_user()->get_id()); $data['action'] = interests_edit_route(); $data['submit_value'] = "Save"; //default fallback $this->template->load('settings/addInterestView', $data); }
public function edit($id = "") { // Should work with is_admin -> should be allowed to change settings for everyone if ($_POST) { //Post request // Set delimiters - hide this away (extend controller etc...) $this->form_validation->set_error_delimiters('<span class="error">', '</span>'); //validate form if ($this->form_validation->run('updateprofile')) { //get the values from the form $id = $this->input->post('id'); $email = $this->input->post('email'); $firstname = $this->input->post('firstname'); $lastname = $this->input->post('lastname'); $city = $this->input->post('city'); $zip = $this->input->post('zip'); $country = $this->input->post('country'); //updates the user $this->load->model('user/UserModel', 'UserModel'); $this->UserModel->update($id, array('firstname' => $firstname, 'lastname' => $lastname, 'city' => $city, 'zip' => $zip, 'country' => $country)); //success confirm message to user set_status_message('Your changes have been saved'); //redirects return redirect(settings_route()); } } //Set userid $userid = get_user()->get_id(); //check if id is sent with request and set userid if ($id != "") { $userid = $id; } // Get authenticated user by email $this->load->model('user/UserModel', 'UserModel'); $viewdata['user'] = $this->UserModel->get_by_id($userid); // default fallback $this->template->load('settings/edit', $viewdata); }
?> ">Sign up</a></li> <li><a href="<?php echo login_route(); ?> ">Login</a></li> <?php } else { ?> <li><a href="<?php echo profile_route(); ?> ">Home</a></li> <li><a href="<?php echo usersearch_route(); ?> ">Search</a></li> <li><a href="<?php echo settings_route(); ?> ">Settings</a></li> <li><a href="<?php echo logout_route(); ?> ">Logout</a></li> <?php } ?> </ul> </div>