/** * Edit My Account * * @return void * @author Merrick Christensen */ public function action_edit() { $this->template->content = View::factory('account/edit'); $this->template->content->user = $this->user; $this->template->scripts = array('public/js/vendor/word-count.js', 'public/js/account/vanity_preview.js'); $this->template->content->set(array('tv_shows' => Helper_Favorite::get_available_answers(1), 'musical_artists' => Helper_Favorite::get_available_answers(2), 'movies' => Helper_Favorite::get_available_answers(3), 'foods' => Helper_Favorite::get_available_answers(4), 'colors' => Helper_Favorite::get_available_answers(5), 'animals' => Helper_Favorite::get_available_answers(6), 'sports' => Helper_Favorite::get_available_answers(7), 'video_games' => Helper_Favorite::get_available_answers(8), 'school_subjects' => Helper_Favorite::get_available_answers(9), 'seasons' => Helper_Favorite::get_available_answers(10), 'app' => Helper_Favorite::get_available_answers(11), 'book' => Helper_Favorite::get_available_answers(12))); $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar()); if ($_POST) { $original_post = $_POST; $user = $this->user; $post = $user->validate_create_edit($_POST); if ($post->check()) { /* If the user wants to change the display name */ if ($user->display_name != $post['display_name']) { /* Set new display name if it isn't in use already */ if (Helper_Account::display_name_exists($post['display_name'])) { Message::set(MESSAGE::ERROR, array('Display name already in use!', 'The display name you entered (' . $post['display_name'] . ') is already in use, please choose another one. Reverting to your previous display name (' . $user->display_name . ').')); } else { //$user->display_name = $post['display_name']; //as of 3.0 user may no longer update their display name. } } $user->gender = $post['gender']; $user->vanity_url = $post['vanity_url']; $user->newsletter = $post['newsletter']; $user->save(); $this->add_favorites($original_post); Message::set(Message::SUCCESS, 'Successfully edited!'); Request::instance()->redirect('profile'); } else { Message::set(Message::ERROR, $post->errors('user')); } } }
echo form::select('questions[9]', Helper_Favorite::select_answers($school_subjects), Arr::get($_POST, 'questions[9]', Helper_Favorite::get_answer(9))); ?> <br /><br /> <h3>Favorite Season:</h3> <?php echo form::select('questions[10]', Helper_Favorite::select_answers($seasons), Arr::get($_POST, 'questions[10]', Helper_Favorite::get_answer(10))); ?> <br /><br /> <h3>Favorite App:</h3> <?php echo form::select('questions[11]', Helper_Favorite::select_answers($app), Arr::get($_POST, 'questions[11]', Helper_Favorite::get_answer(11))); ?> <br /><br /> <h3>Favorite Book:</h3> <?php echo form::select('questions[12]', Helper_Favorite::select_answers($book), Arr::get($_POST, 'questions[12]', Helper_Favorite::get_answer(12))); ?> </div> </div> <!-- END: title --> <div class="title_bottom"></div> <div class="submit_container"> <ul class="buttons"> <li><?php echo form::submit('submit', '', array('class' => 'save')); ?> </li> </ul> </div> <?php echo form::close(); ?>