Permalink
Browse files

Fully implemented read only mode

  • Loading branch information...
1 parent 86a9245 commit 5415390a99d5689379b8e141065991d262219bfa brian committed Apr 25, 2007
Showing with 88 additions and 72 deletions.
  1. +24 −17 common.php
  2. +7 −0 include/constants.php
  3. +1 −1 include/lang/english.php
  4. +54 −54 read.php
  5. +2 −0 templates/emerald/header.tpl
View
@@ -214,7 +214,7 @@
if ( !defined( "PHORUM_ADMIN" ) ) {
// if the Phorum is disabled, display a message.
- if(isset($PHORUM["status"]) && $PHORUM["status"]=="disabled"){
+ if(isset($PHORUM["status"]) && $PHORUM["status"]==PHORUM_MASTER_STATUS_DISABLED){
if(!empty($PHORUM["disabled_url"])){
header("Location: ".$PHORUM["disabled_url"]);
exit();
@@ -288,6 +288,7 @@
// check the user session
include_once( "./include/users.php" );
+
if ( phorum_user_check_session() ) {
$PHORUM["DATA"]["LOGGEDIN"] = true;
@@ -392,18 +393,24 @@
$PHORUM["DATA"]["HTML_TITLE"] = htmlentities(strip_tags($PHORUM["DATA"]["HTML_TITLE"]), ENT_COMPAT, $PHORUM["DATA"]["CHARSET"]);
// if the Phorum is disabled, display a message.
- if(isset($PHORUM["status"]) && $PHORUM["status"]=="admin-only" && !$PHORUM["user"]["admin"]){
- // set all our URL's
- phorum_build_common_urls();
-
- $PHORUM["DATA"]["OKMSG"]=$PHORUM["DATA"]["LANG"]["AdminOnlyMessage"];
- include phorum_get_template("header");
- phorum_hook("after_header");
- include phorum_get_template("message");
- phorum_hook("before_footer");
- include phorum_get_template("footer");
- exit();
+ if( !$PHORUM["user"]["admin"] ) {
+ if(isset($PHORUM["status"]) && $PHORUM["status"]==PHORUM_MASTER_STATUS_ADMIN_ONLY ){
+ // set all our URL's
+ phorum_build_common_urls();
+
+ $PHORUM["DATA"]["OKMSG"]=$PHORUM["DATA"]["LANG"]["AdminOnlyMessage"];
+ include phorum_get_template("header");
+ phorum_hook("after_header");
+ include phorum_get_template("message");
+ phorum_hook("before_footer");
+ include phorum_get_template("footer");
+ exit();
+ } elseif($PHORUM["status"]==PHORUM_MASTER_STATUS_READ_ONLY){
+ $PHORUM["DATA"]["GLOBAL_ERROR"]=$PHORUM["DATA"]["LANG"]["ReadOnlyMessage"];
+ $PHORUM["user"] = array( "user_id" => 0, "username" => "", "admin" => false, "newinfo" => array() );
+ $PHORUM["DATA"]["LOGGEDIN"] = false;
+ }
}
// If moderator notifications are on and the person is a mod,
@@ -1083,7 +1090,7 @@ function phorum_check_data_signature($data, $signature)
}
/**
- * Generate a debug back trace.
+ * Generate a debug back trace.
*
* @param $skip - The amount of back trace levels to skip. The call
* to this function is skipped by default, so you don't
@@ -1114,7 +1121,7 @@ function phorum_generate_backtrace($skip = 0, $hidepath = "{path to Phorum}")
// Don't include the call to this function.
if ($id == 0) continue;
- // Skip the required number of steps.
+ // Skip the required number of steps.
if ($id <= $skip) continue;
if ($hidepath !== NULL && isset($step["file"])) {
@@ -1153,9 +1160,9 @@ function phorum_database_error($error)
: 'screen';
// Create a backtrace report, so it's easier to find out where a problem
- // is coming from.
+ // is coming from.
$backtrace = phorum_generate_backtrace(1);
-
+
// Start the error page.
?>
<html>
@@ -1198,7 +1205,7 @@ function phorum_database_error($error)
case "screen":
$htmlbacktrace = $backtrace === NULL
- ? NULLL
+ ? NULLL
: nl2br(htmlspecialchars($backtrace));
print "Please try again later!" .
@@ -179,6 +179,13 @@
define("PHORUM_CC_GROUP_MODERATION", "groupmod");
define("PHORUM_CC_GROUP_MEMBERSHIP", "groups");
+ // Phorum up/down status
+ define("PHORUM_MASTER_STATUS_NORMAL", "normal");
+ define("PHORUM_MASTER_STATUS_READ_ONLY", "read-only");
+ define("PHORUM_MASTER_STATUS_ADMIN_ONLY", "admin-only");
+ define("PHORUM_MASTER_STATUS_DISABLED", "disabled");
+
+
// constants below here do not have to have a constant value,
// as long as each is unique. They are used for enumeration.
// Add to them as you wish knowing that.
@@ -414,7 +414,7 @@
"QuoteMessage" => "Quote",
"read" => "read",
- "ReadOnlyMessage" => "This forum is currently read only. This is a temporary situation. Please check back later.",
+ "ReadOnlyMessage" => "This forum is currently read only. You can not log in or make any changes. This is a temporary situation.",
"ReadPrivateMessages" => "Read Private Messages",
"RealName" => "Real Name",
"Received" => "Received",
View
@@ -64,7 +64,7 @@
// Find out how many forums this user can moderate.
// If the user can moderate more than one forum, then
-// present the move message moderation link.
+// present the move message moderation link.
if ($PHORUM["DATA"]["MODERATOR"]) {
$build_move_url=false;
$forums=phorum_db_get_forums(0, NULL, $PHORUM['vroot']);
@@ -225,7 +225,7 @@
}
$message_index=phorum_cache_get('message_index',$PHORUM['forum_id']."-$thread-$approved");
-
+
$skip_cache = 0;
if($message_index == null) {
@@ -238,17 +238,17 @@
} else {
$message_index=$data[$thread]['meta']['message_ids'];
}
-
+
if(is_array($data[$thread])) {
- // sort it as expected
- sort($message_index);
+ // sort it as expected
+ sort($message_index);
- // put it in the cache now
- phorum_cache_put('message_index',$PHORUM['forum_id']."-$thread-$approved",$message_index);
+ // put it in the cache now
+ phorum_cache_put('message_index',$PHORUM['forum_id']."-$thread-$approved",$message_index);
} else {
- $skip_cache = 1;
+ $skip_cache = 1;
}
}
@@ -257,67 +257,67 @@
if(!$skip_cache) {
- // we expect this message_index to be ordered by message-id already!
+ // we expect this message_index to be ordered by message-id already!
- // in this case we need the reversed order
- if($PHORUM['threaded_read'] && isset($PHORUM["reverse_threading"]) && $PHORUM["reverse_threading"]) {
- $message_index=array_reverse($message_index);
- }
+ // in this case we need the reversed order
+ if($PHORUM['threaded_read'] && isset($PHORUM["reverse_threading"]) && $PHORUM["reverse_threading"]) {
+ $message_index=array_reverse($message_index);
+ }
- $start=$PHORUM["read_length"]*($page-1);
+ $start=$PHORUM["read_length"]*($page-1);
- if(!$PHORUM['threaded_read']) {
- // get the message-ids from this page (only in flat mode)
- $message_ids_page = array_slice($message_index, $start,$PHORUM["read_length"]);
- } else {
- // we need all message in threaded read ...
- $message_ids_page = $message_index;
- }
+ if(!$PHORUM['threaded_read']) {
+ // get the message-ids from this page (only in flat mode)
+ $message_ids_page = array_slice($message_index, $start,$PHORUM["read_length"]);
+ } else {
+ // we need all message in threaded read ...
+ $message_ids_page = $message_index;
+ }
- // we need the threadstarter too but its not available in the additional pages
- if($page > 1) {
- array_unshift($message_ids_page,$thread);
- }
+ // we need the threadstarter too but its not available in the additional pages
+ if($page > 1) {
+ array_unshift($message_ids_page,$thread);
+ }
- $cache_messages = phorum_cache_get('message',$message_ids_page);
+ $cache_messages = phorum_cache_get('message',$message_ids_page);
- // check the returned messages if they were found in the cache
- $db_messages=array();
+ // check the returned messages if they were found in the cache
+ $db_messages=array();
- $msg_not_in_cache=0;
+ $msg_not_in_cache=0;
- foreach($message_ids_page as $mid) {
- if(!isset($cache_messages[$mid])) {
- $db_messages[]=$mid;
- $msg_not_in_cache++;
- } else {
- $data[$mid]=$cache_messages[$mid];
- $data['users'][] = $data[$mid]['user_id'];
- }
- }
+ foreach($message_ids_page as $mid) {
+ if(!isset($cache_messages[$mid])) {
+ $db_messages[]=$mid;
+ $msg_not_in_cache++;
+ } else {
+ $data[$mid]=$cache_messages[$mid];
+ $data['users'][] = $data[$mid]['user_id'];
+ }
+ }
- if($msg_not_in_cache) {
+ if($msg_not_in_cache) {
- $db_messages = phorum_db_get_message($db_messages,'message_id');
- // store the found messages in the cache
+ $db_messages = phorum_db_get_message($db_messages,'message_id');
+ // store the found messages in the cache
- foreach($db_messages as $mid => $message) {
- phorum_cache_put('message',$mid,$message);
- $data[$mid]=$message;
- $data['users'][] = $data[$mid]['user_id'];
- }
+ foreach($db_messages as $mid => $message) {
+ phorum_cache_put('message',$mid,$message);
+ $data[$mid]=$message;
+ $data['users'][] = $data[$mid]['user_id'];
+ }
- if($PHORUM['threaded_read'] && isset($PHORUM["reverse_threading"]) && $PHORUM["reverse_threading"]) {
- krsort($data);
- } else {
- ksort($data);
- }
- }
+ if($PHORUM['threaded_read'] && isset($PHORUM["reverse_threading"]) && $PHORUM["reverse_threading"]) {
+ krsort($data);
+ } else {
+ ksort($data);
+ }
+ }
} else {
- $data = array('users'=>array());
+ $data = array('users'=>array());
}
} else {
@@ -644,7 +644,7 @@
$messages = phorum_hook("read", $messages);
// increment viewcount if enabled
- if($PHORUM['count_views']) {
+ if($PHORUM['count_views'] && $PHORUM["status"]==PHORUM_MASTER_STATUS_NORMAL) {
phorum_db_viewcount_inc($message_id);
}
@@ -133,6 +133,8 @@ Some Icons courtesy of:
</div>
+{IF GLOBAL_ERROR}<div class="attention">{GLOBAL_ERROR}</div>{/IF}
+
{IF USER->NOTICE->SHOW}
<div class="attention">
<h4>{LANG->NeedsAttention}</h4>

0 comments on commit 5415390

Please sign in to comment.