feat: ability for players with Multihunter rank to see&write MH messages

#398
This commit is contained in:
Martin Ambrus
2017-12-02 11:57:59 +01:00
parent 537a14e4e3
commit 76fdbc6c3e
5 changed files with 76 additions and 13 deletions
+26 -3
View File
@@ -4101,15 +4101,26 @@ References: User ID/Message ID, Mode
global $session;
$mode = (int) $mode;
$mode_updated = false;
// update $id if we should show Support messages for Admins and we are an admin
if (
($session->access == MULTIHUNTER || $session->access == ADMIN)
$session->access == ADMIN
&& ADMIN_RECEIVE_SUPPORT_MESSAGES
&& in_array($mode, [1,2,6,9,10,11])
) {
$id = $id . ', 1';
$mode_updated = true;
}
// update $id if we should show Multihunter messages for the current player
if (
$session->access == MULTIHUNTER
&& in_array($mode, [1,2,6,9,10,11])
) {
$id = $id . ', 5';
$mode_updated = true;
}
if (in_array($mode, [5,7,8])) {
if (!is_array($id)) {
$id = [$id];
@@ -4119,7 +4130,9 @@ References: User ID/Message ID, Mode
}
}
} else {
$id = (int) $id;
if (!$mode_updated) {
$id = (int) $id;
}
}
global $session;
@@ -4134,7 +4147,17 @@ References: User ID/Message ID, Mode
$q = "SELECT * FROM " . TB_PREFIX . "mdata where id = $id";
break;
case 4:
$q = "UPDATE " . TB_PREFIX . "mdata set viewed = 1 where id = $id AND target IN(".((($session->access == MULTIHUNTER || $session->access == ADMIN) && ADMIN_RECEIVE_SUPPORT_MESSAGES) ? $session->uid.',1' : $session->uid).")";
$show_target = $session->uid;
if ($session->access == ADMIN && ADMIN_RECEIVE_SUPPORT_MESSAGES) {
$show_target .= ',1';
}
if ($session->access == MULTIHUNTER) {
$show_target .= ',5';
}
$q = "UPDATE " . TB_PREFIX . "mdata set viewed = 1 where id = $id AND target IN(".$show_target.")";
break;
case 5:
$q = "UPDATE " . TB_PREFIX . "mdata set deltarget = 1,viewed = 1 where id IN(".implode(', ', $id).")";
+15 -3
View File
@@ -582,9 +582,21 @@ class Message {
}
}
// check if we're not sending this as support
$support_from_admin_allowed = ( ( $session->access == MULTIHUNTER || $session->access == ADMIN ) && ADMIN_RECEIVE_SUPPORT_MESSAGES );
$database->sendMessage( $user, ( ( ! empty( $_POST['as_support'] ) && $support_from_admin_allowed ) ? 1 : $session->uid ), htmlspecialchars( addslashes( $topic ) ), htmlspecialchars( addslashes( $text ) ), 0, $alliance, $player, $coor, $report );
// check if we're not sending this as Support or Multihunter
$support_from_admin_allowed = ( $session->access == ADMIN && ADMIN_RECEIVE_SUPPORT_MESSAGES );
$send_as = $session->uid;
// send as Support?
if (( ! empty( $_POST['as_support'] ) && $support_from_admin_allowed )) {
$send_as = 1;
}
// send as Multihunter
if (( ! empty( $_POST['as_multihunter'] ) && $session->access == MULTIHUNTER )) {
$send_as = 5;
}
$database->sendMessage( $user, $send_as, htmlspecialchars( addslashes( $topic ) ), htmlspecialchars( addslashes( $text ) ), 0, $alliance, $player, $coor, $report );
}
}
+14 -2
View File
@@ -55,7 +55,8 @@
$s = 0;
}
$name = 1;
$support_messages = (($session->access == MULTIHUNTER || $session->access == ADMIN) && ADMIN_RECEIVE_SUPPORT_MESSAGES);
$support_messages = ($session->access == ADMIN && ADMIN_RECEIVE_SUPPORT_MESSAGES);
$multihunter_messages = ($session->access == MULTIHUNTER);
for($i=(1+$s);$i<=(10+$s);$i++) {
if(count($message->inbox1) >= $i) {
@@ -67,7 +68,18 @@
else {
echo "<tr>";
}
echo "<td class=\"sel\">".((!$support_messages || ($support_messages && $message->inbox1[$i-1]['target'] != 1)) ? "<input class=\"check\" type=\"checkbox\" name=\"n".$name."\" value=\"".$message->inbox1[$i-1]['id']."\" />" : '<u><b title="Message for Support"><i>S</i></b></u>')."</td>
$message_for_text = '';
if (!$support_messages || ($support_messages && $message->inbox1[$i-1]['target'] != 1) || ($multihunter_messages && $message->inbox1[$i-1]['target'] != 5)) {
$message_for_text = "<input class=\"check\" type=\"checkbox\" name=\"n".$name."\" value=\"".$message->inbox1[$i-1]['id']."\" />";
} else if ($support_messages) {
$message_for_text = '<u><b title="Message for Support"><i>S</i></b></u>';
} else if ($multihunter_messages) {
$message_for_text = '<u><b title="Message for Multihunter"><i>M</i></b></u>';
}
echo "<td class=\"sel\">".$message_for_text."</td>
<td class=\"top\"><a href=\"nachrichten.php?id=".$message->inbox1[$i-1]['id']."\">".$message->inbox1[$i-1]['topic']."</a> ";
if($message->inbox1[$i-1]['viewed'] == 0) {
echo "(new)";
+14 -2
View File
@@ -57,7 +57,8 @@
$s = 0;
}
$name = 1;
$support_messages = (($session->access == MULTIHUNTER || $session->access == ADMIN) && ADMIN_RECEIVE_SUPPORT_MESSAGES);
$support_messages = ($session->access == ADMIN && ADMIN_RECEIVE_SUPPORT_MESSAGES);
$multihunter_messages = ($session->access == MULTIHUNTER);
for($i=(1+$s);$i<=(10+$s);$i++) {
if(count($message->sent1) >= $i) {
@@ -67,7 +68,18 @@
else {
echo "<tr>";
}
echo "<td class=\"sel\">".((!$support_messages || ($support_messages && $message->inbox1[$i-1]['target'] != 1)) ? "<input class=\"check\" type=\"checkbox\" name=\"n".$name."\" value=\"".$message->sent1[$i-1]['id']."\" />" : '<u><b title="Sent as Support"><i>S</i></b></u>')."</td>
$sent_as_text = '';
if (!$support_messages || ($support_messages && $message->inbox1[$i-1]['target'] != 1) || ($multihunter_messages && $message->inbox1[$i-1]['target'] != 5)) {
$sent_as_text = "<input class=\"check\" type=\"checkbox\" name=\"n".$name."\" value=\"".$message->sent1[$i-1]['id']."\" />";
} else if ($support_messages) {
$sent_as_text = '<u><b title="Sent as Support"><i>S</i></b></u>';
} else if ($multihunter_messages) {
$sent_as_text = '<u><b title="Sent as Multihunter"><i>M</i></b></u>';
}
echo "<td class=\"sel\">".$sent_as_text."</td>
<td class=\"top\"><a href=\"nachrichten.php?t=2a&amp;id=".$message->sent1[$i-1]['id']."\">".$message->sent1[$i-1]['topic']."</a> ";
if($message->sent1[$i-1]['viewed'] == 0) {
echo "(unread)";
+7 -3
View File
@@ -98,12 +98,16 @@ Reply: ".$database->getUserField($id,'username',0)."
<input type="hidden" name="ft" value="m2" />
<input type="image" value="" name="s1" id="btn_send" class="dynamic_img" src="img/x.gif" alt="send" onclick="this.disabled=true;this.form.submit();" tabindex=4; />
<?php
if (($session->access == MULTIHUNTER || $session->access == ADMIN) && ADMIN_RECEIVE_SUPPORT_MESSAGES && !empty($_GET['mid'])) {
if ($session->access == ADMIN && ADMIN_RECEIVE_SUPPORT_MESSAGES && !empty($_GET['mid'])) {
?><br />
<input type="checkbox" name="as_support"<?php echo ((!empty($_GET['tid']) && $_GET['tid'] == 1) ? ' checked="checked"' : ''); ?> /> Send as Support
<?php
}
?>
} else if ($session->access == MULTIHUNTER) {
?><br />
<input type="checkbox" name="as_multihunter"<?php echo ((!empty($_GET['tid']) && $_GET['tid'] == 5) ? ' checked="checked"' : ''); ?> /> Send as Multihunter
<?php
}
?>
</p>
</form>
<div id="adressbook" class="hide"><h2>Addressbook</h2>