Hi
My english is no good.
2Moons 1.8 to 2.0 available.
Register the username you want to block messages from.
You can delete and add in settings.
I made it easy to use and it is very easy.
A screenshot is attached.
I hope this helps a lot.
1. Add to sql
ALTER TABLE `uni1_users` ADD `message_x` text DEFAULT NULL;
2. Create a php file.
includes/game/ShowMessagesxxPage.class.php
Display All
3. Create a tpl file.
templates/game/page.messagesxx.tpl
Display All
4. Add php content.
includes/game/ShowMessagesPage.class.php
Find line
function send()
.
.
Find line
if (empty($receiverID) empty($text) !isset($session->messageToken) $session->messageToken != md5($USER['id'].'|'.$receiverID))
{
$this->sendJSON($LNG['mg_error']);
}
Add code
Display All
Find line
function show()
.
.
Find line
foreach($TitleColor as $CategoryID => $CategoryColor) {
$CategoryList[$CategoryID] = array(
'color'=> $CategoryColor,
'unread' => $UnRead[$CategoryID],
'total'=> $Total[$CategoryID],
);
}
Add code
Display All
5. Add tpl content..
templates/game/page.messages.default.tpl
Just add it wherever you want.
Display All
Thanks.
My english is no good.
2Moons 1.8 to 2.0 available.
Register the username you want to block messages from.
You can delete and add in settings.
I made it easy to use and it is very easy.
A screenshot is attached.
I hope this helps a lot.
1. Add to sql
ALTER TABLE `uni1_users` ADD `message_x` text DEFAULT NULL;
2. Create a php file.
includes/game/ShowMessagesxxPage.class.php
PHP Source Code: ShowMessagesxxPage.class.php
- <?php
- class ShowMessagesxxPage extends AbstractGamePage
- {
- public static $requireModule = 0;
- function __construct()
- {
- parent::__construct();
- $this->setWindow('popup');
- $this->initTemplate();
- }
- function show()
- {
- global $LNG, $USER;
- $db = Database::get();
- $scarray = explode("\r\n", $USER['message_x']);
- $MessageS_L = array();
- foreach($scarray as $b)
- {
- if(empty($b))
- continue;
- $c = explode(',', $b);
- $MessageS_L[] = array(
- 'name' => $c[0],
- 'username' => $c[1],
- 'userid' => $USER['authlevel'] >= 3 ? '('.$c[2].')' : '',
- );
- }
- $this->assign(array(
- 'MessageS_L' => $MessageS_L,
- ));
- $this->display('page.messagesxx.tpl');
- }
- function add()
- {
- global $LNG, $USER;
- $name = HTTP::_GP('n', '', UTF8_SUPPORT);
- $username = HTTP::_GP('username', '', UTF8_SUPPORT);
- $name = 'Delete ';
- $db = Database::get();
- $sql = "SELECT id FROM %%USERS%% WHERE username = :userID AND universe = :uni ;" ;
- $exists = $db->selectSingle($sql, array(
- ':userID' => $username,
- ':uni' => Universe::current()
- ));
- if(empty($exists['id']) || empty($username) || empty($name))
- {
- $this->printMessage("<span style=font-size:1.2em;color:red>Username does not exist !!!</font>", array(array(
- 'label' => $LNG['sys_back'],
- 'url' => 'game.php?page=messagesxx'
- )));
- }else{
- $USER['message_x'] .= $name.','.$username.','.$exists['id']."\r\n";
- $sql = "UPDATE %%USERS%% SET message_x = :messx WHERE id = :userID;" ;
- $db->update($sql, array(
- ':messx' => $USER['message_x'],
- ':userID' => $USER['id'],
- ));
- }
- $this->redirectTo('game.php?page=messagesxx');
- }
- function delete()
- {
- global $LNG, $USER;
- $a = HTTP::_GP('n', '');
- $db = Database::get();
- if(!is_numeric($a)) {
- $this->printMessage("<span style=font-size:1.2em;color:red>input error!!</font>", array(array(
- 'label' => $LNG['sys_back'],
- 'url' => 'game.php?page=messagesxx'
- )));
- }
- $scarray = explode("\r\n", $USER['message_x']);
- $r = explode(",", $scarray[$a]);
- unset($scarray[$a]);
- $USER['message_x'] = implode("\r\n", $scarray);
- $sql = "UPDATE %%USERS%% SET message_x = :messx WHERE id = :userID;" ;
- $db->update($sql, array(
- ':messx' => $USER['message_x'],
- ':userID' => $USER['id'],
- ));
- $this->redirectTo('game.php?page=messagesxx');
- }
- }
3. Create a tpl file.
templates/game/page.messagesxx.tpl
HTML Source Code: page.messagesxx.tpl
- {block name="title" prepend}{$LNG.lm_notes}{/block}
- {block name="content"}
- <style>
- td{
- font-size:1.3em;
- }
- th{
- font-size:1.3em;
- }
- </style>
- <div class="content_page" style="width: 690px;margin-left:8px">
- <div class="title">
- Messages Block
- </div>
- <form action="game.php?page=messagesxx&mode=add" method="post">
- <table style="width:100%;">
- <tr style="height: 20px;">
- <td>
- Block username: <input type="text" name="username" value="" size="17" maxlength="30" placeholder="username" required> <input type="submit" value="SAVE">
- </td>
- </tr>
- <tr>
- <td></td>
- </tr>
- </table>
- </form>
- <table style="width:100%;">
- {foreach name=MessageS_L key=id item=short from=$MessageS_L}
- {if $smarty.foreach.MessageS_L.iteration is odd}<tr style="height:20px;">{/if}
- <td><a style="color:#6995B9" href="?page=messagesxx&mode=delete&n={$id}">{$short.name}</a>
- <a style="color:#00B6FF"> [ {$short.username} ]</a>
- </td>
- {if $smarty.foreach.MessageS_L.last && $smarty.foreach.MessageS_L.total is odd && $smarty.foreach.MessageS_L.total != 1}<td> </td>{/if}
- {if $smarty.foreach.MessageS_L.iteration is even}</tr>{/if}
- {foreachelse}
- <td colspan="2">There are no blocked users.</td>
- {/foreach}
- <tr><th colspan="2"></th></tr>
- </table>
- </div>
- {/block}
4. Add php content.
includes/game/ShowMessagesPage.class.php
Find line
function send()
.
.
Find line
if (empty($receiverID) empty($text) !isset($session->messageToken) $session->messageToken != md5($USER['id'].'|'.$receiverID))
{
$this->sendJSON($LNG['mg_error']);
}
Add code
PHP Source Code
- # [SRTART] Block messages when receiving is rejected
- $sql = "SELECT message_x FROM %%USERS%% WHERE id = :userID AND universe = :uni;";
- $Ownercheck = Database::get()->selectSingle($sql, array(
- ':userID' => $receiverID,
- ':uni' => Universe::current()
- ));
- $scarray = explode("\r\n", $Ownercheck['message_x']);
- foreach($scarray as $b)
- {
- if(empty($b))
- continue;
- $c = explode(',', $b);
- if($c[2] == $USER['id']){
- $this->sendJSON("Message blocked.");
- }
- }
- # [END] Block messages when receiving is rejected
Find line
function show()
.
.
Find line
foreach($TitleColor as $CategoryID => $CategoryColor) {
$CategoryList[$CategoryID] = array(
'color'=> $CategoryColor,
'unread' => $UnRead[$CategoryID],
'total'=> $Total[$CategoryID],
);
}
Add code
PHP Source Code
- ## [START] Show Message Blocked Users
- $scarray = explode("\r\n", $USER['message_x']);
- $MessageS_L = array();
- foreach($scarray as $b)
- {
- if(empty($b))
- continue;
- $c = explode(',', $b);
- $MessageS_L[] = array(
- 'name' => $c[0],
- 'username' => $c[1],
- );
- }
- ## [END] Show Message Blocked Users
- ## Add code
- $this->assign(array(
- 'MessageS_L' => $MessageS_L, //Add code
- ));
5. Add tpl content..
templates/game/page.messages.default.tpl
Just add it wherever you want.
HTML Source Code
- <div class="title fontsize12" style="margin: 0 -5px 0 -5px;" >
- Users who blocks to receive messages
- </div>
- <table style="width:100%;">
- <tr><th colspan="2"><a href="game.php?page=messagesxx"onclick="return Dialog.open(this.href, 720, 400);" data-toggle="dropdown" href="#" role="button" style="background:#004F79;border-radius:3px;padding: 4px 20px;">Settings</a></th></tr>
- {foreach name=MessageS_L key=id item=short from=$MessageS_L}
- {if $smarty.foreach.MessageS_L.iteration is odd}<tr style="height:20px;">{/if}
- <td><a style="color:#6995B9;font-size:1.2em">Block</a>
- <a style="color:#00B6FF;font-size:1.2em"> [ {$short.username} ]</a>
- </td>
- {if $smarty.foreach.MessageS_L.last && $smarty.foreach.MessageS_L.total is odd && $smarty.foreach.MessageS_L.total != 1}<td> </td>{/if}
- {if $smarty.foreach.MessageS_L.iteration is even}</tr>{/if}
- {foreachelse}
- <td colspan="2">There are no blocked users.</td>
- {/foreach}
- <tr><th colspan="2"> </th></tr>
- </table>
Thanks.
--------------------------------------------------------------------------------------
The post was edited 1 time, last by noonn ().