* $PHORUM['threaded_list'] = PHORUM_THREADED_DEFAULT; * } elseif ($_COOKIE['list_style'] == 'threaded') { * $PHORUM['threaded_list'] = PHORUM_THREADED_ON; * } elseif ($_COOKIE['list_style'] == 'flat') { * $PHORUM['threaded_list'] = PHORUM_THREADED_OFF; * } elseif ($_COOKIE['list_style'] == 'hybrid') { * $PHORUM['threaded_list'] = PHORUM_THREADED_HYBRID; * } * } * </hookcode> */ $page_hook = 'page_' . phorum_page; if (isset($PHORUM["hooks"][$page_hook])) { phorum_api_hook($page_hook, ""); } $formatted = phorum_api_format_users(array($PHORUM['user'])); $PHORUM['DATA']['USER'] = $formatted[0]; $PHORUM['DATA']['PHORUM_PAGE'] = phorum_page; $PHORUM['DATA']['USERTRACK'] = $PHORUM['track_user_activity']; $PHORUM['DATA']['VROOT'] = $PHORUM['vroot']; $PHORUM['DATA']['POST_VARS'] .= "<input type=\"hidden\" name=\"forum_id\" value=\"{$PHORUM["forum_id"]}\" />\n"; if (!empty($PHORUM['ref_thread_id'])) { $PHORUM['DATA']['POST_VARS'] .= "<input type=\"hidden\" name=\"ref_thread_id\" value=\"{$PHORUM["ref_thread_id"]}\" />\n"; } if (!empty($PHORUM['ref_message_id'])) { $PHORUM['DATA']['POST_VARS'] .= "<input type=\"hidden\" name=\"ref_message_id\" value=\"{$PHORUM["ref_message_id"]}\" />\n"; } if (!empty($PHORUM['use_rss'])) { if ($PHORUM["default_feed"] == "rss") { $PHORUM["DATA"]["FEED"] = $PHORUM["DATA"]["LANG"]["RSS"]; $PHORUM["DATA"]["FEED_CONTENT_TYPE"] = "application/rss+xml";
/** * A common function which is used to save the userdata from the post-data. * @param panel - The panel for which to save data. * @return array - An array containing $error and $okmsg. */ function phorum_controlcenter_user_save($panel) { global $PHORUM; $error = ""; $okmsg = ""; // Setup the default userdata fields that can be changed // from the control panel interface. $userdata = array('signature' => NULL, 'hide_email' => NULL, 'hide_activity' => NULL, 'tz_offset' => NULL, 'is_dst' => NULL, 'user_language' => NULL, 'threaded_list' => NULL, 'threaded_read' => NULL, 'email_notify' => NULL, 'show_signature' => NULL, 'pm_email_notify' => NULL, 'user_template' => NULL, 'moderation_email' => NULL, 'real_name' => NULL); // Password related fields can only be updated from the password panel. if ($panel == 'password') { $userdata['password'] = NULL; $userdata['password_temp'] = NULL; } // E-mail address related fields can only be updated from the email panel. if ($panel == 'email') { $userdata['email'] = NULL; $userdata['email_temp'] = NULL; } // E-mail address related fields can only be updated from the email panel. if ($panel == 'email') { $userdata['email'] = NULL; $userdata['email_temp'] = NULL; } // Add custom profile fields as acceptable fields. foreach ($PHORUM["CUSTOM_FIELDS"][PHORUM_CUSTOM_FIELD_USER] as $id => $field) { if ($id === "num_fields" || !empty($field['deleted'])) { continue; } $userdata[$field["name"]] = NULL; } // Update userdata with $_POST information. foreach ($_POST as $key => $val) { if (array_key_exists($key, $userdata)) { $userdata[$key] = $val; } } // Remove unused profile fields. foreach ($userdata as $key => $val) { if (is_null($val)) { unset($userdata[$key]); } } // Set static userdata. $userdata["user_id"] = $PHORUM["user"]["user_id"]; // Run a hook, so module writers can update and check the userdata. if (isset($PHORUM["hooks"]["cc_save_user"])) { $userdata = phorum_api_hook("cc_save_user", $userdata); } // Set $error, in case the cc_save_user hook did set an error. if (isset($userdata['error'])) { $error = $userdata['error']; unset($userdata['error']); // Try to update the userdata in the database. } elseif (!phorum_api_user_save($userdata)) { // Updating the user failed. $error = $PHORUM["DATA"]["LANG"]["ErrUserAddUpdate"]; } else { // Updating the user was successful. $okmsg = $PHORUM["DATA"]["LANG"]["ProfileUpdatedOk"]; // Let the userdata be reloaded. phorum_api_user_set_active_user(PHORUM_FORUM_SESSION, $userdata["user_id"]); // If a new password was set, then reset all session id(s), so // other computers or browser will lose any active session that // they are running. if (isset($userdata["password"]) && $userdata["password"] != '') { phorum_api_user_session_create(PHORUM_FORUM_SESSION, PHORUM_SESSID_RESET_ALL); } // Copy data from the updated user back into the user template data. $formatted = phorum_api_format_users(array($PHORUM['user'])); foreach ($formatted[0] as $key => $val) { $PHORUM['DATA']['USER'][$key] = $val; } // Copy data from the updated user back into the template data. // Leave PANEL and forum_id alone (these are injected into the // userdata in the template from this script). foreach ($PHORUM["DATA"]["PROFILE"] as $key => $val) { if ($key == "PANEL" || $key == "forum_id") { continue; } if (isset($PHORUM["user"][$key])) { if (is_array($val)) { // array-data would be (most often) broken when html encoded $PHORUM["DATA"]["PROFILE"][$key] = $PHORUM["user"][$key]; } elseif (substr($key, 0, 9) == 'signature') { // the signature needs special care - e.g. for the formatted sig // Fake a message here so we can run the sig through format_message. $fake_messages = array(array("author" => "", "email" => "", "subject" => "", "body" => $PHORUM["user"]["signature"])); $fake_messages = phorum_format_messages($fake_messages); $PHORUM["DATA"]["PROFILE"]["signature_formatted"] = $fake_messages[0]["body"]; // Format the user signature using standard message body formatting // or HTML escape it $PHORUM["DATA"]["PROFILE"]["signature"] = htmlspecialchars($PHORUM["user"]["signature"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]); } else { // same handling as when loading the page for the first time $PHORUM["DATA"]["PROFILE"][$key] = htmlspecialchars($PHORUM["user"][$key], ENT_COMPAT, $PHORUM['DATA']['HCHARSET']); } } else { $PHORUM["DATA"]["PROFILE"][$key] = ""; } } } return array($error, $okmsg); }