Verzeichnisstruktur phpBB-3.0.0


Veröffentlicht
12.12.2007

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

permissions.js

Zuletzt modifiziert: 09.10.2024, 12:51 - Dateigröße: 6.67 KiB


 001  /**
 002  * Hide and show all checkboxes
 003  * status = true (show boxes), false (hide boxes)
 004  */
 005  function display_checkboxes(status) 
 006  {
 007      var form = document.getElementById('set-permissions');
 008      var cb = document.getElementsByTagName('input');
 009      var display;
 010   
 011      //show
 012      if (status)
 013      {
 014          display = 'inline';
 015      }
 016      //hide
 017      else
 018      {
 019          display = 'none';
 020      }
 021      
 022      for (var i = 0; i < cb.length; i++ )
 023      {
 024          if (cb[i].className == 'permissions-checkbox')
 025          {
 026              cb[i].style.display = display;
 027          }
 028          
 029      }    
 030      
 031  }
 032   
 033   
 034  /**
 035  * Change opacity of element
 036  * e = element
 037  * value = 0 (hidden) till 10 (fully visible)
 038  */
 039  function set_opacity(e, value) {
 040      e.style.opacity = value/10;
 041      
 042      //IE opacity currently turned off, because of its astronomical stupidity
 043      //e.style.filter = 'alpha(opacity=' + value*10 + ')';
 044  }
 045   
 046  /**
 047  * Reset the opacity and checkboxes
 048  * block_id = id of the element that needs to be toggled
 049  */
 050  function toggle_opacity(block_id) {
 051      var cb = document.getElementById('checkbox' + block_id);
 052      var fs = document.getElementById('perm' + block_id);
 053      
 054      if (cb.checked) 
 055      {
 056          set_opacity(fs, 5);
 057      } 
 058      else 
 059      {
 060          set_opacity(fs, 10);
 061      }
 062  }
 063   
 064  /**
 065  * Reset the opacity and checkboxes
 066  * value = 0 (checked) and 1 (unchecked)
 067  * except_id = id of the element not to hide
 068  */
 069  function reset_opacity(status, except_id) {
 070      var perm = document.getElementById('set-permissions');
 071      var fs = perm.getElementsByTagName('fieldset');
 072      var opacity = 5;
 073   
 074      if (status)
 075      {
 076          opacity = 10;    
 077      }
 078      
 079      for (var i = 0; i < fs.length; i++ )
 080      {
 081          if (fs[i].className != 'quick')
 082          {
 083              set_opacity(fs[i], opacity);
 084          }
 085      }
 086   
 087      if (typeof(except_id) != 'undefined')
 088      {
 089          set_opacity(document.getElementById('perm' + except_id), 10);
 090      }
 091   
 092      //reset checkboxes too
 093      marklist('set-permissions', 'inherit', !status);
 094  }
 095   
 096   
 097  /**
 098  * Check whether we have a full radiobutton row of true
 099  * index = offset for the row of inputs (0 == first row, 1 == second, 2 == third),
 100  * rb = array of radiobuttons
 101  */
 102  function get_radio_status(index, rb) 
 103  {
 104      for (var i = index; i < rb.length; i = i + 3 )
 105      {
 106          if (rb[i].checked != true)
 107          {
 108              if (i > index)
 109              {
 110                  //at least one is true, but not all (custom)
 111                  return 2;
 112              }
 113              //first one is not true
 114              return 0;
 115          }
 116      }
 117   
 118      // all radiobuttons true
 119      return 1;
 120  }
 121   
 122  /**
 123  * Set tab colours
 124  * id = panel the tab needs to be set for, 
 125  * init = initialising on open, 
 126  * quick = If no calculation needed, this contains the colour
 127  */
 128  function set_colours(id, init, quick)
 129  {
 130      var table = document.getElementById('table' + id);
 131      var tab = document.getElementById('tab' + id);
 132   
 133      if (typeof(quick) != 'undefined') 
 134      {
 135          tab.className = 'permissions-preset-' + quick + ' activetab';
 136          return;
 137      }
 138   
 139      var rb = table.getElementsByTagName('input');
 140      var colour = 'custom';
 141   
 142      var status = get_radio_status(0, rb);
 143   
 144      if (status == 1)
 145      {
 146          colour = 'yes';
 147      }
 148      else if (status == 0) 
 149      {
 150          // We move on to No
 151          status = get_radio_status(1, rb);
 152   
 153          if (status == 1)
 154          {
 155              colour = 'no';
 156          }
 157          else if (status == 0) 
 158          {
 159              // We move on to Never
 160              status = get_radio_status(2, rb);
 161   
 162              if (status == 1)
 163              {
 164                  colour = 'never';
 165              }
 166          }
 167      }
 168   
 169      if (init)
 170      {
 171          tab.className = 'permissions-preset-' + colour;
 172      }
 173      else
 174      {
 175          tab.className = 'permissions-preset-' + colour + ' activetab';
 176      }
 177  }
 178   
 179  /**
 180  * Initialise advanced tab colours on first load
 181  * block_id = block that is opened
 182  */
 183  function init_colours(block_id)
 184  {    
 185      var block = document.getElementById('advanced' + block_id);
 186      var panels = block.getElementsByTagName('div');
 187      var tab = document.getElementById('tab' + id);
 188   
 189      for (var i = 0; i < panels.length; i++)
 190      {
 191          if(panels[i].className == 'permissions-panel')
 192          {
 193              set_colours(panels[i].id.replace(/options/, ''), true);
 194          }
 195      }
 196   
 197      tab.className = tab.className + ' activetab';
 198  }
 199   
 200  /**
 201  * Show/hide option panels
 202  * value = suffix for ID to show
 203  * adv = we are opening advanced permissions
 204  * view = called from view permissions
 205  */
 206  function swap_options(pmask, fmask, cat, adv, view)
 207  {
 208      id = pmask + fmask + cat;
 209      active_option = active_pmask + active_fmask + active_cat;
 210   
 211      var    old_tab = document.getElementById('tab' + active_option);    
 212      var new_tab = document.getElementById('tab' + id);
 213      var adv_block = document.getElementById('advanced' + pmask + fmask);
 214   
 215      if (adv_block.style.display == 'block' && adv == true)
 216      {
 217          dE('advanced' + pmask + fmask, -1);
 218          reset_opacity(1);
 219          display_checkboxes(false);
 220          return;
 221      }
 222   
 223      // no need to set anything if we are clicking on the same tab again
 224      if (new_tab == old_tab && !adv)
 225      {
 226          return;
 227      }
 228   
 229      // init colours
 230      if (adv && (pmask + fmask) != (active_pmask + active_fmask))
 231      {
 232          init_colours(pmask + fmask);
 233          display_checkboxes(true);
 234          reset_opacity(1);
 235      } 
 236      else if (adv) 
 237      {
 238          //Checkbox might have been clicked, but we need full visibility
 239          display_checkboxes(true);
 240          reset_opacity(1);
 241      }
 242   
 243      // set active tab
 244      old_tab.className = old_tab.className.replace(/\ activetab/g, '');
 245      new_tab.className = new_tab.className + ' activetab';
 246   
 247      if (id == active_option && adv != true)
 248      {
 249          return;
 250      }
 251   
 252      dE('options' + active_option, -1);
 253      
 254      //hiding and showing the checkbox
 255      if (document.getElementById('checkbox' + active_pmask + active_fmask))
 256      {
 257          dE('checkbox' + pmask + fmask, -1);    
 258          
 259          if ((pmask + fmask) != (active_pmask + active_fmask))
 260          {
 261              document.getElementById('checkbox' + active_pmask + active_fmask).style.display = 'inline';
 262          }
 263      }
 264   
 265      if (!view)
 266      {
 267          dE('advanced' + active_pmask + active_fmask, -1);
 268      }
 269   
 270      if (!view)
 271      {
 272          dE('advanced' + pmask + fmask, 1);
 273      }
 274      dE('options' + id, 1);
 275   
 276      active_pmask = pmask;
 277      active_fmask = fmask;
 278      active_cat = cat;
 279  }
 280   
 281  /**
 282  * Mark all radio buttons in one panel
 283  * id = table ID container, s = status ['y'/'u'/'n']
 284  */
 285  function mark_options(id, s)
 286  {
 287      var t = document.getElementById(id);
 288   
 289      if (!t)
 290      {
 291          return;
 292      }
 293   
 294      var rb = t.getElementsByTagName('input');
 295   
 296      for (var r = 0; r < rb.length; r++)
 297      {
 298          if (rb[r].id.substr(rb[r].id.length-1) == s)
 299          {
 300              rb[r].checked = true;
 301          }
 302      }
 303  }
 304   
 305  function mark_one_option(id, field_name, s)
 306  {
 307      var t = document.getElementById(id);
 308   
 309      if (!t)
 310      {
 311          return;
 312      }
 313   
 314      var rb = t.getElementsByTagName('input');
 315   
 316      for (var r = 0; r < rb.length; r++)
 317      {
 318          if (rb[r].id.substr(rb[r].id.length-field_name.length-3, field_name.length) == field_name && rb[r].id.substr(rb[r].id.length-1) == s)
 319          {
 320              rb[r].checked = true;
 321          }
 322      }
 323  }
 324   
 325  /**
 326  * Reset role dropdown field to Select role... if an option gets changed
 327  */
 328  function reset_role(id)
 329  {
 330      var t = document.getElementById(id);
 331   
 332      if (!t)
 333      {
 334          return;
 335      }
 336   
 337      t.options[0].selected = true;
 338  }
 339   
 340  /**
 341  * Load role and set options accordingly
 342  */
 343  function set_role_settings(role_id, target_id)
 344  {
 345      settings = role_options[role_id];
 346   
 347      if (!settings)
 348      {
 349          return;
 350      }
 351   
 352      // Mark all options to no (unset) first...
 353      mark_options(target_id, 'u');
 354   
 355      for (var r in settings)
 356      {
 357          mark_one_option(target_id, r, (settings[r] == 1) ? 'y' : 'n');
 358      }
 359  }
 360