change for punbb
+2
SLGray
Rafa1804
6 posters
Page 1 of 1
change for punbb
I found this code for phpbb3 to hide messages, tested it and it worked in phpbb3.
However, I use PunBB, can you help me to change the variables here to work in PunBB?
Thanks
However, I use PunBB, can you help me to change the variables here to work in PunBB?
- Code:
"use strict";
$(function() {
var title = $('h2.topic-title');
var isAdmin = function() {
var level = _userdata["user_level"];
if (level === 1 || level === 2) return true;
};
title.each(function() {
if (this.textContent == ' > only_admin') {
$(this).children('a').text('This post is only visible for moderation.');
$(this).parents('.post').addClass('admin_only');
}
});
var admin_only = $('.post.admin_only');
if (isAdmin()) {
$('ul.profile-icons').prepend(
'<li><a href="#hide" class="hide-post">Hide post</a></li>'
);
if (admin_only.length) {
admin_only.css({
'opacity': '.5'
});
}
$('.hide-post').click(function() {
var post = $(this).parents('div.post').attr('id').split('p')[1],
content = $(this).parents('.postbody').find('.content').html();
$.post("/post", {
p: post,
mode: 'editpost',
subject: '> only_admin',
message: content,
edit_reason: '',
attach_sig: '0',
notify: "0",
post: 1
}).done(function() {
location.reload();
}).fail(function() {
alert('[Erro]: Something went wrong when editing the post');
});
});
} else {
if (admin_only.length) admin_only.remove();
};
});
Thanks
Re: change for punbb
Where did you found the code?
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Re: change for punbb
SLGray wrote:Where did you found the code?
I found the code on a forum but I can't remember which one, I went back to Forumotion now and had it saved.
Can you help me?
Re: change for punbb
skouliki wrote:we need the forum to be viewable to guests in order to be able to help
Sorry, here is the link
https://ob-forum.forumeiros.com/t6-forumotion#10
Re: change for punbb
Rafa1804 wrote:skouliki wrote:we need the forum to be viewable to guests in order to be able to help
Sorry, here is the link
https://ob-forum.forumeiros.com/t6-forumotion#10
what exactly is this code used for ? are you trying to hide messages from members and is only viewable by admins?
Graphic Design Section Rules || Becoming a Designer || Graphic Requests
Graphics Request Form
Make sure to check out our FREE Graphic's Gallery
No support provided via PM!
Re: change for punbb
BlackScorpion wrote:Rafa1804 wrote:skouliki wrote:we need the forum to be viewable to guests in order to be able to help
Sorry, here is the link
https://ob-forum.forumeiros.com/t6-forumotion#10
what exactly is this code used for ? are you trying to hide messages from members and is only viewable by admins?
Yes, exactly, the problem is that this version is in phpbb3 and it's working which I've already tested, however, I wanted it to work in punbb, it shouldn't be too difficult but I don't understand anything about Javascript, can you help me?
Re: change for punbb
Just to let you know not all Codes can be changed that easy as #punbb has a lot of codes that have the same fields.
Re: change for punbb
The script works perfectly to adapt, I tried to make some changes and it already showed results, but it was still buggy.
If you understand Javascript and reformulate the code, you will be able to put it in the PunBB version for sure.
If you understand Javascript and reformulate the code, you will be able to put it in the PunBB version for sure.
Re: change for punbb
Hello @Rafa1804,
Change your code to:
Demonstration
Members
Admin or Mod
Change your code to:
- Code:
(function($) {
'use strict';
$(function() {
if (! /^\/t(\d+)(p\d+-|-).*$/i.test(location.pathname)) {
return;
}
$('.post').each(function() {
var $post = $(this);
var config = {
link: $post.find('a[href^="/post?p="][href$="&mode=editpost"]'),
message: (_userdata.user_level ? $post.find('a[href^="/post?p="][href$="&mode=editpost"]').attr('href').split('p=')[1].split('&')[0] : $post.attr('class').split('--')[1]),
title: $post.find('.posthead a[href^="/t"]'),
content: $post.find('.entry-content').html()
};
if (/> only_admin/.test(config.title.text())) {
config.title
.html('This post is <b>only visible for moderation</b>.')
;
$post
.attr('id', 'only_admin-' + config.message)
.css('opacity', '.5')
.find('.entry-content')
.html((_userdata.user_level ? config.content : '<span style="font-weight: 700; color: red;">[ You cannot see this message ]</span>'))
;
}
if (_userdata.user_level !== 1 && _userdata.user_level !== 2) {
return;
}
if (!config.link.length) {
return;
}
$.get(config.link.attr('href'))
.done(function(context) {
var $textarea = $('#text_editor_textarea', context);
if (!$textarea.length) return;
if ($('#only_admin-' + config.message).length) return;
$('<button>', {
'class': 'button1 rep-button',
'role': 'button',
'title': 'Hide this post',
'text': 'Hide post'
})
.appendTo(config.title.parent().parent().parent().find('.post-options'))
.on('click', function(event) {
event.preventDefault();
$.post("/post", {
p: config.message,
mode: 'editpost',
subject: '> only_admin',
message: $textarea.val(),
edit_reason: '',
attach_sig: 0,
notify: 0,
post: 1
}).done(function() {
location.reload(true);
}).fail(function() {
alert('[Erro]: Something went wrong when editing the post');
});
});
});
});
});
}(jQuery));
Demonstration
Members
Admin or Mod
Sir Chivas™, SarkZKalie and TonnyKamper like this post
Similar topics
» Chat box text color change/shadow change
» How do i change an admins setting to change their own password pls
» announcement for punbb
» Categories forums color change with css code on a PunBB forum?
» Split Upon Request PunBB Design
» How do i change an admins setting to change their own password pls
» announcement for punbb
» Categories forums color change with css code on a PunBB forum?
» Split Upon Request PunBB Design
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum