• 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 Command in Whois box.

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

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

Post a reply
1 post • Page 1 of 1

Postby Troubadix » Wed Jan 10, 2007 4:26 pm

I added the commands kick and ban to the WhoisBox.
They are included in the if{} for the Private message Link and show only op if an admin opens the WhoisBox.

Maybe somebody likes to have this feature in the chat.

This Script is not Language compatibleyet!

Just save this script into your theme as customize.js

Code: Select all
pfcClient.prototype.updateNickWhoisBox = function(nickid)
  {
    var div  = document.createElement('div');
    div.setAttribute('class',     'pfc_nickwhois');
    div.setAttribute('className', 'pfc_nickwhois'); // for IE6

    var ul = document.createElement('ul');
    div.appendChild(ul);

    // add the close button
    var li = document.createElement('li');
    li.setAttribute('class',     'pfc_nickwhois_close');
    li.setAttribute('className', 'pfc_nickwhois_close'); // for IE6
    ul.appendChild(li);
    var a = document.createElement('a');
    a.setAttribute('href', '');
    a.pfc_parent = div;
    a.onclick = function(evt){
      this.pfc_parent.style.display = 'none';
      return false;
    }
    var img = document.createElement('img');
    img.setAttribute('src', this.res.getFileUrl('images/close-whoisbox.gif'));
    img.alt = document.createTextNode(this.res.getLabel('Close'));
    a.appendChild(img);
    li.appendChild(a);

    // add the privmsg link (do not add it if this button is yourself)
    if (pfc.getUserMeta(nickid,'nick') != this.nickname)
    {
      var li = document.createElement('li');
      li.setAttribute('class',     'pfc_nickwhois_pv');
      li.setAttribute('className', 'pfc_nickwhois_pv'); // for IE6
      ul.appendChild(li);
      var a = document.createElement('a');
      a.setAttribute('href', '');
      a.pfc_nickid = nickid;
      a.pfc_parent = div;
      a.onclick = function(evt){
        var nick = pfc.getUserMeta(this.pfc_nickid,'nick');
        pfc.sendRequest('/privmsg "'+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 = document.createTextNode(this.res.getLabel('Private message'));
      a.appendChild(img);
      a.appendChild(document.createTextNode(this.res.getLabel('Private message')));
      li.appendChild(a);

     // add Kick button only for admins
     if (pfc.getUserMeta(this.nickid,'isadmin') == true)
     {
         var li = document.createElement('li');
         li.setAttribute('class',     'pfc_nickwhois_pv');
         li.setAttribute('className', 'pfc_nickwhois_pv'); // for IE6
         ul.appendChild(li);
         var a = document.createElement('a');
         a.setAttribute('href', '');
         a.pfc_nickid = nickid;
         a.pfc_parent = div;
         a.onclick = function(evt){
           var nick = pfc.getUserMeta(this.pfc_nickid,'nick');
           pfc.sendRequest('/kick "'+nick+'"');
           this.pfc_parent.style.display = 'none';
           return false;
         }
         a.appendChild(document.createTextNode('Kick'));
         li.appendChild(a);
   
      // add Ban button only for admins
         var li = document.createElement('li');
         li.setAttribute('class',     'pfc_nickwhois_pv');
         li.setAttribute('className', 'pfc_nickwhois_pv'); // for IE6
         ul.appendChild(li);
         var a = document.createElement('a');
         a.setAttribute('href', '');
         a.pfc_nickid = nickid;
         a.pfc_parent = div;
         a.onclick = function(evt){
           var nick = pfc.getUserMeta(this.pfc_nickid,'nick');
           pfc.sendRequest('/ban "'+nick+'"');
           this.pfc_parent.style.display = 'none';
           return false;
         }
         a.appendChild(document.createTextNode('Ban'));
         li.appendChild(a);
       }
    }
 
    // add the whois information table
    var table = document.createElement('table');
//    table.setAttribute('cellspacing',0);
//    table.setAttribute('cellpadding',0);
//    table.setAttribute('border',0);
    var tbody = document.createElement('tbody');
    table.appendChild(tbody);
    var um = this.getAllUserMeta(nickid);
    var um_keys = um.keys();
    var msg = '';
    for (var i=0; i<um_keys.length; i++)
    {
      var k = um_keys[i];
      var v = um[k];
      if (v && k != 'nickid'
            && k != 'floodtime'
            && k != 'flood_nbmsg'
            && k != 'flood_nbchar'
            && k != 'avatar'
         )
      {
        var tr = document.createElement('tr');
        var td1 = document.createElement('td');
        td1.setAttribute('class',     'pfc_nickwhois_c1');
        td1.setAttribute('className', 'pfc_nickwhois_c1'); // for IE6
        var td2 = document.createElement('td');
        td2.setAttribute('class',     'pfc_nickwhois_c2');
        td2.setAttribute('className', 'pfc_nickwhois_c2'); // for IE6
        td1.appendChild(document.createTextNode(k));
        td2.appendChild(document.createTextNode(v));
        tr.appendChild(td1);
        tr.appendChild(td2);
        tbody.appendChild(tr);
      }
    }
    div.appendChild(table);

    this.nickwhoisbox[nickid] = div;
  }

Greetings
Thomas
Troubadix
Member
 
Posts: 25
Joined: Thu Jan 04, 2007 10:42 am
Location: Germany
  • Website
Top

Post a reply
1 post • Page 1 of 1

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 13 guests

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