Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
sulaiman0dawod committed Apr 6, 2023
1 parent c391ca0 commit 4803c2d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 6 deletions.
8 changes: 4 additions & 4 deletions includes/functions.class.php
Expand Up @@ -3764,16 +3764,16 @@ function mention_permissions()
global $PowerBB;

// Get forum id
if (isset($PowerBB->_GET['page']) == "new_topic")
if($PowerBB->_GET['page'] == "new_topic")
{
$exforumid = intval($PowerBB->_GET['id']);
}
elseif (isset($PowerBB->_GET['page']) == "management")
elseif($PowerBB->_GET['page'] == "management")
{
$exforumid = intval($PowerBB->_GET['section']);
}
elseif (isset($PowerBB->_GET['page']) == "new_reply"
or isset($PowerBB->_GET['page']) == "topic")
elseif ($PowerBB->_GET['page'] == "new_reply"
or $PowerBB->_GET['page'] == "topic")
{
$topic_id= intval($PowerBB->_GET['id']);
$TopicArr = $PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['subject'] . " WHERE id = '$topic_id' ");
Expand Down
52 changes: 50 additions & 2 deletions modules/new_topic.module.php
Expand Up @@ -703,7 +703,36 @@ function _Start()
$PowerBB->_POST['text'] = str_replace('target="_blank" ','',$PowerBB->_POST['text']);
$PowerBB->_POST['title'] = $PowerBB->functions->CleanVariable($PowerBB->_POST['title'],'sql');
//$PowerBB->_POST['text'] = $PowerBB->functions->CleanVariable($PowerBB->_POST['text'],'sql');
//

// mention users tag replace
if($PowerBB->functions->mention_permissions())
{
if(preg_match('/\[mention\](.*?)\[\/mention\]/s', $PowerBB->_POST['text'], $tags_w))
{
$username = trim($tags_w[1]);
$MemArr = $PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['member'] . " WHERE username = '$username' ");
$Member_row = $PowerBB->DB->sql_fetch_array($MemArr);
if($Member_row)
{
if ($Member_row['username'] == $PowerBB->_CONF['member_row']['username'])
{
$PowerBB->_POST['text'] = str_replace("[mention]", "@", $PowerBB->_POST['text']);
$PowerBB->_POST['text'] = str_replace("[/mention]", "", $PowerBB->_POST['text']);
$Member_row['username'] = '';
}
if (!empty($Member_row['username']))
{
$forum_url = $PowerBB->functions->GetForumAdress();
$url = $forum_url."index.php?page=profile&show=1&id=".$Member_row['id'];
$PowerBB->_POST['text'] = str_replace("[mention]", "[url=".$PowerBB->functions->rewriterule($url)."]@", $PowerBB->_POST['text']);
$PowerBB->_POST['text'] = str_replace("[/mention]", "[/url]", $PowerBB->_POST['text']);
// insert mention
$insert_mention = true;
}
}
}

}


$SecInfoArr = array();
Expand Down Expand Up @@ -916,7 +945,26 @@ function _Start()
}
}
}
//////////

// insert mention
if($PowerBB->functions->mention_permissions())
{
if ($insert_mention)
{
$InsertArr = array();
$InsertArr['field'] = array();

$InsertArr['field']['user_mention_about_you'] = $PowerBB->_CONF['member_row']['username'];
$InsertArr['field']['you'] = $Member_row['username'];
$InsertArr['field']['topic_id'] = intval($PowerBB->subject->id);
$InsertArr['field']['reply_id'] = 0;
$InsertArr['field']['profile_id'] = $PowerBB->_CONF['member_row']['id'];
$InsertArr['field']['date'] = $PowerBB->_CONF['now'];
$InsertArr['field']['user_read'] = '1';

$insert = $PowerBB->core->Insert($InsertArr,'mention');
}
}

// Upload files
if ($PowerBB->_CONF['member_permission'])
Expand Down

0 comments on commit 4803c2d

Please sign in to comment.