• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ Contributions (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

kick and ban in user\'s menu

Post a bug fix, a new feature, a theme ...

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
14 posts • Page 1 of 1

Postby white_devil » Wed Jun 13, 2007 6:25 pm

Hi, first at all my english is no so good, so let me know if there's anything that cant be understandable...

Is my first contribution so i dont know exactly how to explain the modifications but i'll do my best, thanks...

This is a mod for displaying "Kick" and "Ban" options in the menu that is displayed when you click a user, but this options only appears after being identifyied as a chat admin, if you get disconnected the options will hide, etc. etc. Is the same that /kick and /ban, but in a menu, so you just have to click the user you want to kick or ban.

Hope you like it..

/i18n/en_US/main.php, line 383

Code: Select all
// line 480 in phpfreechat.class.php
$GLOBALS["i18n"]["Kick"] = "Kick";

// line 481 in phpfreechat.class.php
$GLOBALS["i18n"]["Are you sure you want to kick this user?"] = "Are you sure you want to kick this user?";

// line 482 in phpfreechat.class.php
$GLOBALS["i18n"]["Ban"] = "Ban";

// line 483 in phpfreechat.class.php
$GLOBALS["i18n"]["Are you sure you want to ban this user?"] = "Are you sure you want to ban this user?";

/src/phpfreechat.class.php, line 481, replace ");" with:

Code: Select all
"Kick",
 "Are you sure you want to kick this user?",
 "Ban",
 "Are you sure you want to ban this user?",
);

/data/public/js/pfcclient.js, various lines:

Code: Select all
//-------------------------
//line 27

this.imadmin = false;
//-------------------------

//------------------------
//line 1037, add this functions, the kick and ban options builder

    var isadmin = this.getUserMeta(nickid, 'isadmin');
    if (isadmin == '') isadmin = false;

    if (this.imadmin && (pfc.getUserMeta(nickid,'nick') != this.nickname) && !isadmin)
    { //the kick option
     lblKckRuSr = this.res.getLabel('Are you sure you want to kick this user?');
      var p = document.createElement('p');
      p.setAttribute('class',     'pfc_nickwhois_pv');
      p.setAttribute('className', 'pfc_nickwhois_pv'); // for IE6
      var a = document.createElement('a');
      a.setAttribute('href', '');
      a.pfc_nickid = nickid;
      a.pfc_parent = div;
      a.onclick = function(evt){
      if(confirm(lblKckRuSr)){
         var nick = pfc.getUserMeta(this.pfc_nickid,'nick');
         pfc.sendRequest('/kick "'+nick+'"');
         this.pfc_parent.style.display = 'none';
         return false;
      }
      }
      var img = document.createElement('img');
      img.setAttribute('src', this.res.getFileUrl('images/openpv.gif'));
      img.alt = this.res.getLabel('Kick');
      a.appendChild(img);
      a.appendChild(document.createTextNode(this.res.getLabel('Kick')));
      p.appendChild(a);
      div.appendChild(p);
    
     //the ban option
     lblBnRuSr = this.res.getLabel('Are you sure you want to ban this user?');
      var p = document.createElement('p');
      p.setAttribute('class',     'pfc_nickwhois_pv');
      p.setAttribute('className', 'pfc_nickwhois_pv'); // for IE6
      var a = document.createElement('a');
      a.setAttribute('href', '');
      a.pfc_nickid = nickid;
      a.pfc_parent = div;
      a.onclick = function(evt){
      if(confirm(lblBnRuSr)){
         var nick = pfc.getUserMeta(this.pfc_nickid,'nick');
         pfc.sendRequest('/ban "'+nick+'"');
         this.pfc_parent.style.display = 'none';
         return false;
      }
      }
      var img = document.createElement('img');
      img.setAttribute('src', this.res.getFileUrl('images/openpv.gif'));
      img.alt = this.res.getLabel('Ban');
      a.appendChild(img);
      a.appendChild(document.createTextNode(this.res.getLabel('Ban')));
      p.appendChild(a);
      div.appendChild(p);

    }

//---------------------------

//----------------------------
//line 1054, replace this:

var d = pfc.getNickWhoisBox(this.pfc_nickid);

//with this:

pfc.updateNickWhoisBox(this.pfc_nickid);
var d = pfc.getNickWhoisBox(this.pfc_nickid);

//------------------------------


//-----------------------------
//line 1067 to 1070, replace this:

    if (isadmin)
      img.setAttribute('src', this.res.getFileUrl('images/user-admin.gif'));
    else
      img.setAttribute('src', this.res.getFileUrl('images/user.gif'));

// with this:
     
    if (isadmin)
    {
     if(pfc.getUserMeta(nickid,'nick') == this.nickname)
        this.imadmin = true;
     img.setAttribute('src', this.res.getFileUrl('images/user-admin.gif'));
     }
    else
      img.setAttribute('src', this.res.getFileUrl('images/user.gif'));

//--------------------------

//--------------------------
// line 1439 to 1441, replace this:

      loginlogout_icon.src   = this.res.getFileUrl('images/logout.gif');
      loginlogout_icon.alt   = this.res.getLabel('Disconnect');
      loginlogout_icon.title = loginlogout_icon.alt;

//with this:

      this.imadmin = false;
      loginlogout_icon.src   = this.res.getFileUrl('images/logout.gif');
      loginlogout_icon.alt   = this.res.getLabel('Disconnect');
      loginlogout_icon.title = loginlogout_icon.alt;

//-------------------------

and that's it :), let me know if i didnt explain very well
white_devil
Member
 
Posts: 12
Joined: Wed Jun 13, 2007 5:06 am
Location: Dominican Republic
  • Website
Top

Postby white_devil » Wed Jun 13, 2007 6:27 pm

Oh an btw, if somebody is using the spanish translation i have the modifications in spanish too, so it will display "Está seguro de que desea patear a este usuario?", instead of "Are you sure you want to kick this user?", so just let me know.

:)
white_devil
Member
 
Posts: 12
Joined: Wed Jun 13, 2007 5:06 am
Location: Dominican Republic
  • Website
Top

Postby phpfreechat » Wed Jun 13, 2007 9:00 pm

Nice contribution.
I will look at your code in details when I have some time and I will certainly give you some feedback and integrate it after 1.0-final is released.
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby nassausky » Fri Jul 06, 2007 6:40 am

That is the best idea ever. The code doesn't seem to match with the line numbers in the latest beta 11 release of version 1 ..

Anyone know of how I can add the kick and ban to the user menu

M
nassausky
New member
 
Posts: 5
Joined: Fri Jul 06, 2007 6:38 am
Top

Postby bbguy » Sat Aug 23, 2008 6:33 am

This script isn't working... please remove non working scripts?
bbguy
New member
 
Posts: 1
Joined: Sat Aug 23, 2008 6:30 am
Top

Postby OldWolf » Sat Aug 23, 2008 8:31 am

I'm sorry, we don't have the resources to constantly check and recheck code for function. This code is as is, with no warranty of correctness or usefulness.
Signature:
Read before Posting: Forum Rules
Note: I am unable to offer support through PM/e-mail at this time.
OldWolf
Site Admin
 
Posts: 1918
Joined: Sun Sep 23, 2007 5:48 am
Top

Postby alain57 » Mon Oct 06, 2008 6:23 pm

kerphi wrote:Nice contribution.
I will look at your code in details when I have some time and I will certainly give you some feedback and integrate it after 1.0-final is released.

will it be included in version 1.3, or was the idea not retain ?

just in case i check the code, it work, but the line numerbers are no more correct, so i decided to change a little the tutorial

here we go :

1 : in file i18n/your language/main.php
add this at the end (you can change the text after the = sign, but not the one in the [] !
Code: Select all
$GLOBALS["i18n"]["Kick"] = "Kick";
$GLOBALS["i18n"]["Are you sure you want to kick this user?"] = "Are you sure you want to kick this user?";
$GLOBALS["i18n"]["Ban"] = "Ban";
$GLOBALS["i18n"]["Are you sure you want to ban this user?"] = "Are you sure you want to ban this user?";

2: in the file /src/phpfreechat.class.php
search
Code: Select all
"Hide smiley box",

replace with
Code: Select all
"Hide smiley box",
"Kick",
 "Are you sure you want to kick this user?",
 "Ban",
 "Are you sure you want to ban this user?",

3: in the file /data/public/js/pfcclient.js


search
Code: Select all
this.nickid   = pfc_nickid;

replace with
Code: Select all
this.nickid   = pfc_nickid;
this.imadmin = false;

search
Code: Select all
this.nickwhoisbox.set(nickid, div);

replace with
Code: Select all
var isadmin = this.getUserMeta(nickid, 'isadmin');
    if (isadmin == '') isadmin = false;

    if (this.imadmin && (pfc.getUserMeta(nickid,'nick') != this.nickname) && !isadmin)
    { //the kick option
      lblKckRuSr = this.res.getLabel('Are you sure you want to kick this user?');
      var p = document.createElement('p');
      p.setAttribute('class',     'pfc_nickwhois_pv');
      p.setAttribute('className', 'pfc_nickwhois_pv'); // for IE6
      var a = document.createElement('a');
      a.setAttribute('href', '');
      a.pfc_nickid = nickid;
      a.pfc_parent = div;
      a.onclick = function(evt){
        if(confirm(lblKckRuSr)){
            var nick = pfc.getUserMeta(this.pfc_nickid,'nick');
            pfc.sendRequest('/kick "'+nick+'"');
            this.pfc_parent.style.display = 'none';
            return false;
        }
      }
      var img = document.createElement('img');
      img.setAttribute('src', this.res.getFileUrl('images/openpv.gif'));
      img.alt = this.res.getLabel('Kick');
      a.appendChild(img);
      a.appendChild(document.createTextNode(this.res.getLabel('Kick')));
      p.appendChild(a);
      div.appendChild(p);
     
      //the ban option
      lblBnRuSr = this.res.getLabel('Are you sure you want to ban this user?');
      var p = document.createElement('p');
      p.setAttribute('class',     'pfc_nickwhois_pv');
      p.setAttribute('className', 'pfc_nickwhois_pv'); // for IE6
      var a = document.createElement('a');
      a.setAttribute('href', '');
      a.pfc_nickid = nickid;
      a.pfc_parent = div;
      a.onclick = function(evt){
        if(confirm(lblBnRuSr)){
            var nick = pfc.getUserMeta(this.pfc_nickid,'nick');
            pfc.sendRequest('/ban "'+nick+'"');
            this.pfc_parent.style.display = 'none';
            return false;
        }
      }
      var img = document.createElement('img');
      img.setAttribute('src', this.res.getFileUrl('images/openpv.gif'));
      img.alt = this.res.getLabel('Ban');
      a.appendChild(img);
      a.appendChild(document.createTextNode(this.res.getLabel('Ban')));
      p.appendChild(a);
      div.appendChild(p);

    }



    this.nickwhoisbox.set(nickid, div);

search
Code: Select all
var d = pfc.getNickWhoisBox(this.pfc_nickid);

replace with
Code: Select all
pfc.updateNickWhoisBox(this.pfc_nickid);
var d = pfc.getNickWhoisBox(this.pfc_nickid);

search
Code: Select all
if (isadmin)
      img.setAttribute('src', this.res.getFileUrl('images/user-admin.gif'));
    else
      img.setAttribute('src', this.res.getFileUrl('images/user.gif'));

replace with
Code: Select all
    if (isadmin)
    {
      if(pfc.getUserMeta(nickid,'nick') == this.nickname)
          this.imadmin = true;
      img.setAttribute('src', this.res.getFileUrl('images/user-admin.gif'));
     }
    else
      img.setAttribute('src', this.res.getFileUrl('images/user.gif'));

search
Code: Select all
loginlogout_icon.src   = this.res.getFileUrl('images/logout.gif');

replace with
Code: Select all
this.imadmin = false;
loginlogout_icon.src   = this.res.getFileUrl('images/logout.gif');

oh and i forgot : i found a bug, when you kick someone who does private chat... he will be kicked, but is not going to disapear from member list until he close the private channel tab or leave....
Last edited by alain57 on Mon Oct 06, 2008 7:39 pm, edited 1 time in total.
alain57
New member
 
Posts: 7
Joined: Mon Oct 06, 2008 6:10 pm
Top

Postby AJBarnesy » Thu Jan 08, 2009 5:33 am

yay it worked nicely with the search and replace

thank you very much
AJBarnesy
Member
 
Posts: 11
Joined: Thu Jan 08, 2009 3:54 am
Top

Postby phpfreechat » Thu Jan 08, 2009 8:59 am

alain57 wrote:will it be included in version 1.3, or was the idea not retain ?

I personally don't have the time to integrate this contribution in the official code source. However I can give you (or someone else) svn write access to commit this contribution. If you are interested to to it, please create a sourceforge account and contact me by email.
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby re*s.t.a.r.s.*2 » Wed Nov 04, 2009 9:21 pm

Well i want to say that this also works in 1.2 v pfc , worked like champp..
Free Singles Chat Rooms No Registration Required
Text and Chat Singles no need to register or app required
Sala De Bate Papo Online Grátis E Sem Cadastro
re*s.t.a.r.s.*2
Support Team
 
Posts: 612
Joined: Wed Sep 24, 2008 4:04 pm
Location: los angeles CA
  • Website
Top

Postby MaleXachi » Thu Jul 29, 2010 1:08 am

Nice!! Thanks!
MaleXachi
Member
 
Posts: 11
Joined: Tue Jul 27, 2010 1:04 am
Top

Postby re*s.t.a.r.s.*2 » Thu Jul 29, 2010 4:35 am

1.3 v pfc also works.
Free Singles Chat Rooms No Registration Required
Text and Chat Singles no need to register or app required
Sala De Bate Papo Online Grátis E Sem Cadastro
re*s.t.a.r.s.*2
Support Team
 
Posts: 612
Joined: Wed Sep 24, 2008 4:04 pm
Location: los angeles CA
  • Website
Top

Postby CodezStar » Tue Mar 01, 2011 3:48 pm

it dont work for me and i have 1.3
CodezStar
New member
 
Posts: 6
Joined: Tue Mar 01, 2011 3:25 pm
Top

Postby Dangerous » Wed Sep 14, 2011 5:26 pm

Hi,

it don't work if you are installed the /away command.. I had test it and without script in the customize.js.php for the function /away it work.

Well, now we how to does for work it ?

See u
Dangerous
New member
 
Posts: 5
Joined: Tue Sep 13, 2011 2:42 pm
Top


Post a reply
14 posts • Page 1 of 1

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 14 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub