$message['subscription'] = ""; if (isset($PHORUM["user"]["email_notify"]) && $PHORUM["user"]["email_notify"] > 0) { if ($PHORUM["user"]["email_notify"] == 2) { $message["subscription"] = "message"; } elseif ($PHORUM["user"]["email_notify"] == 1) { $message["subscription"] = "bookmark"; } else { $message["subscription"] = ""; } } } // When replying, the user might already be subscribed to the thread, // in which case the follow mode needs to be initializated to not // lose the follow mode on posting the reply. if (($mode == "reply" || $mode == "quote") && $PHORUM["DATA"]["LOGGEDIN"]) { $type = phorum_api_user_get_subscription($PHORUM["user"]["user_id"], $message["forum_id"], $message["thread"]); switch ($type) { case NULL: if ($PHORUM["user"]["email_notify"] == 2) { $message["subscription"] = "message"; } elseif ($PHORUM["user"]["email_notify"] == 1) { $message["subscription"] = "bookmark"; } else { $message["subscription"] = ""; } break; case PHORUM_SUBSCRIPTION_BOOKMARK: $message["subscription"] = "bookmark"; break; case PHORUM_SUBSCRIPTION_MESSAGE: $message["subscription"] = "message";
function phorum_posting_merge_db2form($form, $db, $apply_readonly = false) { global $PHORUM; // If we have a user linked to the current message, then get the // user data from the database, if it has to be applied as // read-only data. We fetch the data here, so later on we // can apply it to the message. if (($PHORUM["post_fields"]["email"][pf_READONLY] || $PHORUM["post_fields"]["author"][pf_READONLY]) && !empty($db["user_id"])) { $user_info = phorum_api_user_get($db["user_id"]); $user_info["author"] = $user_info["display_name"]; } foreach ($PHORUM["post_fields"] as $key => $info) { // Skip writeable fields if we only have to apply read-only ones. if ($apply_readonly && !$info[pf_READONLY]) { continue; } switch ($key) { case "show_signature": $form[$key] = !empty($db["meta"]["show_signature"]); break; case "allow_reply": $form[$key] = !$db["closed"]; break; case "subscription": $type = phorum_api_user_get_subscription($db["user_id"], $db["forum_id"], $db["thread"]); switch ($type) { case NULL: $form[$key] = ""; break; case PHORUM_SUBSCRIPTION_BOOKMARK: $form[$key] = "bookmark"; break; case PHORUM_SUBSCRIPTION_MESSAGE: $form[$key] = "message"; break; default: $form[$key] = ""; break; } break; case "forum_id": $form["forum_id"] = $db["forum_id"] ? $db["forum_id"] : $PHORUM["forum_id"]; break; case "attachments": $form[$key] = array(); if (isset($db["meta"]["attachments"])) { foreach ($db["meta"]["attachments"] as $data) { $data["keep"] = true; $data["linked"] = true; $form["attachments"][] = $data; } } break; case "author": case "email": if ($db["user_id"] && $PHORUM["post_fields"][$key][pf_READONLY]) { $form[$key] = $user_info[$key]; } else { $form[$key] = $db[$key]; } break; case "special": if ($db["sort"] == PHORUM_SORT_STICKY) { $form["special"] = "sticky"; } else { $form["special"] = ""; } break; case "mode": // NOOP break; default: $form[$key] = $db[$key]; } } return $form; }