1<?php 2 class profile_controller extends controller { 3 private function show_profile_form($profile) { 4 $this->output->open_tag("edit"); 5 6 $this->output->add_tag("username", $this->user->username); 7 $this->output->add_tag("email", $profile["email"]); 8 $this->output->add_tag("notification_key", $profile["notification_key"]); 9 $this->output->add_tag("notification_method", $profile["notification_method"]); 10 $this->output->add_tag("daily_report", show_boolean($profile["daily_report"])); 11 if ($this->user->status == USER_STATUS_CHANGEPWD) { 12 $this->output->add_tag("cancel", "Logout", array("page" => LOGOUT_MODULE)); 13 } else { 14 $this->output->add_tag("cancel", "Back", array("page" => $this->settings->start_page)); 15 } 16 17 $notification_methods = config_array(NOTIFICATION_METHODS); 18 $this->output->open_tag("notification"); 19 foreach ($notification_methods as $method => $label) { 20 $this->output->add_tag("method", $method, array("label" => $label)); 21 } 22 $this->output->close_tag(); 23 24 /* Action log 25 */ 26 if (($actionlog = $this->model->last_account_logs()) !== false) { 27 $this->output->open_tag("actionlog"); 28 foreach ($actionlog as $log) { 29 $this->output->record($log, "log"); 30 } 31 $this->output->close_tag(); 32 } 33 34 $this->output->close_tag(); 35 } 36 37 public function execute() { 38 $this->output->description = "Profile"; 39 $this->output->keywords = "profile"; 40 $this->output->title = "Profile"; 41 42 if ($this->user->status == USER_STATUS_CHANGEPWD) { 43 $this->output->add_message("Please, change your password."); 44 } 45 46 if ($_SERVER["REQUEST_METHOD"] == "POST") { 47 /* Update profile 48 */ 49 if ($this->model->profile_oke($_POST) == false) { 50 $this->show_profile_form($_POST); 51 } else if ($this->model->update_profile($_POST) === false) { 52 $this->output->add_tag("result", "Error while updating profile.", array("url" => "profile")); 53 } else { 54 $this->output->add_tag("result", "Profile has been updated.", array("url" => $this->settings->start_page)); 55 $this->user->log_action("profile updated"); 56 } 57 } else { 58 $user = array( 59 "fullname" => $this->user->fullname, 60 "email" => $this->user->email, 61 "notification_key" => $this->user->notification_key, 62 "notification_method" => $this->user->notification_method, 63 "daily_report" => $this->user->daily_report); 64 $this->show_profile_form($user); 65 } 66 } 67 } 68?> 69