Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Resources
  • Code Requests
  • Completed Requests
  • [Completed] [ZB] Appeal Offense Form
Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ;)

Interested in joining? Click here.


If you are already a member of ZBCode, feel free to login right here:

Username:   Password:
Locked Topic
  • Pages:
  • 1
  • 2
  • 3
  • 4
  • 5
[Completed] [ZB] Appeal Offense Form
Tweet Topic Started: Sep 9 2009, 08:30 PM (1,498 Views)
Gorgor Sep 13 2009, 05:41 AM Post #21
Hello

Posts:
1,187
Group:
Former Staff
Member
#2,728
Joined:
Apr 2, 2009
Coding language
PHP
Hmm... the code's just about done, but I'm not sure exactly where to send the data for it. Always gotta send the data some place different than the regular :glare:

Could anyone who knows where to $.post it help please?
Also, did desire just change the title to [Completed]... or did they some how mess up their auto-tool? :P

Current code
Code:
 
forum = "1141882"
if(location.href.match("PAGE URL")){
$("button[name=sendit]").click(function(){
var title = "Appeal for "+$('#top_info strong a').html(), message = "[center][big]Appeal for: "+$('#top_info strong a').html()+"[/big][small]\nDate: "+$('input[name=date]').val()+"[/small][/center]\nOffence commited: "+$('input[name=offence]').val()+"\nWhy it should be removed:\n"+$('textarea[name=reason]').val()+"\n\nAdditional comments:\n"+$('textarea[name=reason]').val()
$.get(main_url + 'post/?type=1&mode=1&f=' + forum, function(e) {
var mode = $('input[name=mode]',e).val(), type = $('input[name=type]',e).val(), ast = $('input[name=ast]', e).val(), f = $('input[name=f]').val(), xc = $('input[name=xc]',e).val(), sd = $('input[name=sd]',e).val();
$.post(main_url + 'post/?type=1&mode=1&f=' + forum + '&send=1', {
mode:mode, type:type, ast:ast, f:f, xc:xc, sd:sd, title:title, post:message },
function(r) {
alert("Appeal sent.");
});
});
});
}
Edited by Gorgor, Sep 13 2009, 05:42 AM.
Offline Profile Goto Top
 
stargazer Sep 13 2009, 09:29 AM Post #22


Posts:
219
Group:
Dedicated
Member
#2,299
Joined:
Feb 11, 2009
Coding language
HTML/CSS
Two Three :D questions,

1. Can you have different forms on different url, without them conflicting each other?
2. Can guest use the forms?

3. How can members/guest post with the form that goes to the staff viewable section of the board?
Edited by stargazer, Sep 13 2009, 09:30 AM.
Offline Profile Goto Top
 
Firestrife2 Sep 13 2009, 10:30 AM Post #23
Member Avatar


Posts:
159
Group:
Dedicated
Member
#2,094
Joined:
Jan 21, 2009
stargazer
Sep 13 2009, 09:29 AM
Two Three :D questions,

1. Can you have different forms on different url, without them conflicting each other?
2. Can guest use the forms?

3. How can members/guest post with the form that goes to the staff viewable section of the board?
I do believe you can. Anyone can use it, you would have to tell it otherwise if you didn't want guests to. This is the function I use:

Code:
 
getuser=document.getElementById('top_info').getElementsByTagName('strong')[0];


With that you can make an IF statement to go around the code, such as this:

Code:
 
if(!getuser.innerHTML.match("Guest"){
//CODE THAT GUESTS CAN NOT SEE HERE
}


As for 3... Erm can you explain it any better?
Edited by Firestrife2, Sep 13 2009, 10:30 AM.
Posted Image

Posted Image
Offline Profile Goto Top
 
stargazer Sep 13 2009, 10:44 AM Post #24


Posts:
219
Group:
Dedicated
Member
#2,299
Joined:
Feb 11, 2009
Coding language
HTML/CSS
I am sorry, I do not fully understand. What does that code you provided do? Tells guest that you can't use the feature? How you you add that to the code?

.. so guest can use the form as it is?

The last question refer to the code in making, that is.. instead of sending it to admin user through PM, the form content is posted onto a forum that only staff have access to. That way all Staff can review the data and use it how they wish. My question was if you have such a code, members and guest can post it without having to give posting/replying access in the forum preferences (as you do with all forums).
Offline Profile Goto Top
 
Firestrife2 Sep 13 2009, 11:14 AM Post #25
Member Avatar


Posts:
159
Group:
Dedicated
Member
#2,094
Joined:
Jan 21, 2009
Actually, guests will be able to see it but not use it as guests don't have PM permissions. The code basically makes a PM as that user without the whole "Compose Message" process.

The code I provided is for anything that you want to be invisible to guests. If you wanted you could also display an error message such as "Guests can not use this feature." I have to do that with Internet Explorer users all the time(hate that browser :p).

Here's an explanation of what I just provided:

Code
 
getuser=document.getElementById('top_info').getElementsByTagName('strong')[0];


Red - That is the name of the variable, obviously, so you can use it in multiple areas without having to rewrite the code.

Blue - The actual code. document.getElementById('top_info') tells it to look in the area where "top_info" is, which on Zetaboards is where you are greeted your username, logout, or for guests, register and sign in.

The getuser code I just made is specifically for guests, because I used strong. If you want to make another one for Members all you have to change is ('strong') to ('a') and that should work.

The IF statement is really simple.

(I just noticed, I forgot a parenthesis on the IF statement in my last post. There needs to be 2 at the end.)

code
 
if(!getuser.innerHTML.match("Guest")){
//CODE THAT GUESTS CAN NOT SEE HERE
}


Red - In javascript !(exclamation marks) means the opposite, or not. So whatever I put in the IF statement has opposite effect.

Green - Remember the getuser variable we declared earlier? Well it's time to use it. This will have the value of "Guest" if you are logged out.

Blue - This is the inner coding. It wants to know if the inner HTML(inside of the tags) equals Guest.

Pink - This is where the code is going to go. All you simply have to do is put if(!getuser.innerHTML.match("Guest")){ at the very beginning of the code, and put } at the very end.

To sum it all up, it is saying "If getuser has the value of Guest then show the following code". Now you see why the ! is there. If it wasn't, then the code would only be available for guests, and not members. So now the code should only show for members.

Even though this form wouldn't work for guests, it would probably be nice to display a message letting them know that lol. Since guests don't have an inbox it will not work for them.

EDIT: As long as the guest does not have posting/PM permissions, I think you would be fine. I do believe it is possible you just need to make the forum that is going to be posted into etc. If you want me to I'll make it, but otherwise I'll let gorgor.
Edited by Firestrife2, Sep 13 2009, 11:19 AM.
Posted Image

Posted Image
Offline Profile Goto Top
 
stargazer Sep 14 2009, 01:39 AM Post #26


Posts:
219
Group:
Dedicated
Member
#2,299
Joined:
Feb 11, 2009
Coding language
HTML/CSS
But if gorgor manage to arrange a code that goes to the forum instead, would guest be able to use the form?
Offline Profile Goto Top
 
stargazer Sep 14 2009, 04:37 AM Post #27


Posts:
219
Group:
Dedicated
Member
#2,299
Joined:
Feb 11, 2009
Coding language
HTML/CSS
Firestrife2
Sep 13 2009, 11:14 AM
Actually, guests will be able to see it but not use it as guests don't have PM permissions. The code basically makes a PM as that user without the whole "Compose Message" process.

The code I provided is for anything that you want to be invisible to guests. If you wanted you could also display an error message such as "Guests can not use this feature." I have to do that with Internet Explorer users all the time(hate that browser :p).

Here's an explanation of what I just provided:

Code
 
getuser=document.getElementById('top_info').getElementsByTagName('strong')[0];


Red - That is the name of the variable, obviously, so you can use it in multiple areas without having to rewrite the code.

Blue - The actual code. document.getElementById('top_info') tells it to look in the area where "top_info" is, which on Zetaboards is where you are greeted your username, logout, or for guests, register and sign in.

The getuser code I just made is specifically for guests, because I used strong. If you want to make another one for Members all you have to change is ('strong') to ('a') and that should work.

The IF statement is really simple.

(I just noticed, I forgot a parenthesis on the IF statement in my last post. There needs to be 2 at the end.)

code
 
if(!getuser.innerHTML.match("Guest")){
//CODE THAT GUESTS CAN NOT SEE HERE
}


Red - In javascript !(exclamation marks) means the opposite, or not. So whatever I put in the IF statement has opposite effect.

Green - Remember the getuser variable we declared earlier? Well it's time to use it. This will have the value of "Guest" if you are logged out.

Blue - This is the inner coding. It wants to know if the inner HTML(inside of the tags) equals Guest.

Pink - This is where the code is going to go. All you simply have to do is put if(!getuser.innerHTML.match("Guest")){ at the very beginning of the code, and put } at the very end.

To sum it all up, it is saying "If getuser has the value of Guest then show the following code". Now you see why the ! is there. If it wasn't, then the code would only be available for guests, and not members. So now the code should only show for members.

Even though this form wouldn't work for guests, it would probably be nice to display a message letting them know that lol. Since guests don't have an inbox it will not work for them.

EDIT: As long as the guest does not have posting/PM permissions, I think you would be fine. I do believe it is possible you just need to make the forum that is going to be posted into etc. If you want me to I'll make it, but otherwise I'll let gorgor.
I can't make this work..

how should I implement it to the code above and where?
Offline Profile Goto Top
 
Firestrife2 Sep 14 2009, 03:20 PM Post #28
Member Avatar


Posts:
159
Group:
Dedicated
Member
#2,094
Joined:
Jan 21, 2009
Like I said, guests won't have permission to post unless you give them posting permissions for that forum/section.

If you want the page only viewable by members, just so you don't mislead guests or anything, you can restrict it from them with that code. Also make sure you have the getuser variable declared somewhere in your templates.

Example: If I wanted every member to be alerted "Hello Member!" then it would look like this:

code
 
if(!getuser.innerHTML.match("Guest")){
alert("Hello Member!");
}


You could also use an else statement for the people who are guests...for example if I wanted members to see what they saw before, and guests to see a message saying "Log in please!" It would look like this:


Code:
 
if(!getuser.innerHTML.match("Guest")){
alert("Hello Member!");
}else{
alert("Please log in!");
}


:). Just replace alert("Hello Member!"); with your code, and add a curly brace( } ) to the end.

I think this would work well:
getuser=document.getElementById('top_info').getElementsByTagName('strong')[0];
code
 

getuser=document.getElementById('top_info').getElementsByTagName('strong')[0];
if(!getuser.innerHTML.match("Guest")){
if(location.href.match("PAGE URL")){
$("button[name=sendit]").click(function(){
message = "Username: "+$('#top_info strong a').html()+"\nDate: "+$('input[name=date]').val()+"\nOffence commited: "+$('input[name=offence]').val()+"\nWhy it should be removed:\n"+$('textarea[name=reason]').val()+"\n\nAdditional comments:\n"+$('textarea[name=reason]').val()
$.get(main_url + 'msg/?c=2', function(e) {
var xc = $('input[name=xc]',e).val(), msg = $('input[name=msg]',e).val(), secure = $('input[name=secure]', e).val(), fwd = $('input[name=fwd]').val(), convo = $('input[name=convo]',e).val(), draft_edit = $('input[name=draft_edit]',e).val(), name = "Brandt", title = "Offence appeal";
$.post(main_url + 'msg/?c=3&sd=1', {
xc:xc, msg:msg, secure:secure, fwd:fwd, convo:convo, draft_edit:draft_edit, name:name, title:title, post:message },
function(r) {
alert("Appeal sent.");
});
});
});
}
}else{
if(location.href.match("PAGE URL")){
$("button[name=sendit]").click(function(){
alert("Guests may not use the Appeal Offense system. Please log in.");
}
}


I didn't test it but it should work fine.[/quote]
Edited by Firestrife2, Sep 16 2009, 02:38 PM.
Posted Image

Posted Image
Offline Profile Goto Top
 
stargazer Sep 15 2009, 03:03 AM Post #29


Posts:
219
Group:
Dedicated
Member
#2,299
Joined:
Feb 11, 2009
Coding language
HTML/CSS
I tried your code but it does not work for me. The button does not react and I do not get any message as guest when adding the code above, ...
Offline Profile Goto Top
 
Firestrife2 Sep 16 2009, 11:34 AM Post #30
Member Avatar


Posts:
159
Group:
Dedicated
Member
#2,094
Joined:
Jan 21, 2009
That means it's my turn to work with this code on an actual board. I'll reply later with the best code I can get :D.
Posted Image

Posted Image
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Completed Requests · Next Topic »
Locked Topic
  • Pages:
  • 1
  • 2
  • 3
  • 4
  • 5

Track Topic · E-mail Topic Time: 2:27 PM Jul 11
Hosted for free by ZetaBoards · Privacy Policy