phpBB

Development Wiki

Difference between revisions of "Tutorial.Permissions"

From phpBB Development Wiki

m
m (Reverted edits by ZgwCuu (Talk); changed back to last version by Naderman)
Line 1: Line 1:
[http://lordsander.ifrance.com/topic/riassunti-verga.htm riassunti verga] [http://tat-ooin.ifrance.com/resources/articles/bellenden-william.htm bellenden, william] [http://toofarfrommaybe.ifrance.com/view/new/ufficio-vercelli/ ufficio vercelli] [http://girlwho-is.ifrance.com/img/styles/scarica-suonerie.htm scarica suonerie ommitel it] [http://girlwho-is.ifrance.com/img/styles/ospedale-rizzoli.htm ospedale rizzoli bologna] [http://noxuhax.ifrance.com/content/view/googfle.htm googfle] [http://voltia.ifrance.com/content/view/fidanzata-amico.htm fidanzata amico] [http://broadwaylili.ifrance.com/content/view/grosseto-trans.htm grosseto trans] [http://deviantrus.ifrance.com/topic/poliziotto-solitudine/ poliziotto, solitudine e rabbia] [http://toofarfrommaybe.ifrance.com/view/new/barbie-magico/ barbie magico salone di bellezza] [http://kalian42.ifrance.com/text/directory/ad-ware/ ad ware] [http://igaros.ifrance.com/lib/how-deep/ how deep is] [http://jdawsona.ifrance.com/data/yakumo-x/ yakumo 67x] [http://lordsander.ifrance.com/topic/aeg.htm aeg 48380] [http://tizolaa.ifrance.com/web/domenica-bestiale/ domenica bestiale di fabio concato] [http://noxuhax.ifrance.com/content/view/driver-for.htm driver for motorola v220] [http://kalian42.ifrance.com/text/directory/classrooms/ classrooms] [http://singaporepets.ifrance.com/library/html/head-radical.htm head radical liquidmetal] [http://deviantrus.ifrance.com/topic/melissa/ melissa 18] [http://broadwaylili.ifrance.com/content/view/dlt-backup.htm dlt back-up e accessori] [http://tizolaa.ifrance.com/web/w-w/ w w w cameracafe it] [http://girlwho-is.ifrance.com/img/styles/microsoft-digital.htm microsoft digital media pro keyboard] [http://tizolaa.ifrance.com/web/roba-che/ roba che scotta] [http://deviantrus.ifrance.com/topic/la-perla/ la perla store] [http://girlwho-is.ifrance.com/img/styles/marmisti.htm marmisti] [http://voltia.ifrance.com/content/view/bruce-springsteen.htm bruce springsteen. video anthology 1978-88] [http://kalian42.ifrance.com/text/directory/pentium-/ pentium 4 socket 478 3 2 ghz] [http://noxuhax.ifrance.com/content/view/torino-roma.htm torino roma] [http://lordsander.ifrance.com/topic/ragazza.htm ragazza] [http://kalian42.ifrance.com/text/directory/vita-segreta/ vita segreta di una diciottenne] [http://highbulp.ifrance.com/images/small/football-manager/ football manager] [http://noxuhax.ifrance.com/content/view/gli-ultimi.htm gli ultimi giorni] [http://tizolaa.ifrance.com/web/max-speziali/ max speziali] [http://speedofsoun.ifrance.com/text/directory/code-keys.htm code keys viaccess seca nagravision] [http://tat-ooin.ifrance.com/resources/articles/real-book.htm real book] [http://demurediablo.ifrance.com/library/html/nuova-officine/ nuova officine tessili] [http://jdawsona.ifrance.com/data/san-sperate/ san sperate] [http://yeeden.ifrance.com/img/styles/hp-scanjet/ hp scanjet 5530c usb] [http://girlwho-is.ifrance.com/img/styles/livorno.htm livorno] [http://toofarfrommaybe.ifrance.com/view/new/il-simbolo/ il simbolo del sesso] [http://kalian42.ifrance.com/text/directory/fashion-show/ fashion show clip] [http://jdawsona.ifrance.com/data/printer-dock/ printer dock 6000] [http://tizolaa.ifrance.com/web/bon-jovi/ bon jovi in these arms] [http://lovereceier.ifrance.com/lib/battle.htm battle2] [http://jdawsona.ifrance.com/data/antenna-dsail/ antenna d-sail] [http://highbulp.ifrance.com/images/small/marica-yo/ marica yo marica tu marica quien marica] [http://tizolaa.ifrance.com/web/libreria-ibis/ libreria ibis] [http://igaros.ifrance.com/lib/www-biancaluna/ www biancaluna com] [http://lordsander.ifrance.com/topic/crociera-nilo.htm crociera nilo vacanze] [http://tat-ooin.ifrance.com/resources/articles/ram-cisco.htm ram cisco 1700] [http://tat-ooin.ifrance.com/resources/articles/volo-basso.htm volo basso costo] [http://singaporepets.ifrance.com/library/html/mariah-carey.htm mariah carey porno foto] [http://lordsander.ifrance.com/topic/mina-don.htm mina don t] [http://deviantrus.ifrance.com/topic/tim-sms/ tim sms gratis] [http://tat-ooin.ifrance.com/resources/articles/daniela-mercury.htm daniela mercury] [http://tizolaa.ifrance.com/web/foppapedretti-mary/ foppapedretti mary naturale] [http://speedofsoun.ifrance.com/text/directory/golf.htm golf 3.2] [http://kalian42.ifrance.com/text/directory/luci-a/ luci a sa siro] [http://akmokanzen.ifrance.com/images/small/moto-recapiti.htm moto recapiti] [http://oiyaoi.ifrance.com/images/small/liquido-campeggio/ liquido campeggio] [http://kalian42.ifrance.com/text/directory/come-si/ come si installa] [http://broadwaylili.ifrance.com/content/view/dezful.htm dezful] [http://tizolaa.ifrance.com/web/sborra-negli/ sborra negli slip] [http://jdawsona.ifrance.com/data/oubritenga/ oubritenga] [http://highbulp.ifrance.com/images/small/sito-ufficiale/ sito ufficiale italiano per wolverine] [http://yeeden.ifrance.com/img/styles/cassino/ cassino] [http://voltia.ifrance.com/content/view/ram-full.htm ram full brand] [http://akmokanzen.ifrance.com/images/small/michael-j.htm michael j fox] [http://girlwho-is.ifrance.com/img/styles/enciende-mi.htm enciende mi fuego] [http://lordsander.ifrance.com/topic/balla-diy.htm balla diy] [http://tizolaa.ifrance.com/web/surf-casting/ surf casting] [http://tat-ooin.ifrance.com/resources/articles/grande-punto.htm grande punto 1 3] [http://tizolaa.ifrance.com/web/le-fate/ le fate dei fiori] [http://broadwaylili.ifrance.com/content/view/la-stanza.htm la stanza del fliglio] [http://voltia.ifrance.com/content/view/monitor-plasma.htm monitor plasma hitachi] [http://noxuhax.ifrance.com/content/view/olivetti-ofx.htm olivetti ofx] [http://yeeden.ifrance.com/img/styles/courtney/ courtney] [http://voltia.ifrance.com/content/view/dive-calendario.htm dive calendario] [http://demurediablo.ifrance.com/library/html/sisley-eau/ sisley eau de campagne] [http://demurediablo.ifrance.com/library/html/unico/ unico 2004] [http://demurediablo.ifrance.com/library/html/stoccaggio-rifiuti/ stoccaggio rifiuti] [http://girlwho-is.ifrance.com/img/styles/carros.htm carros] [http://yeeden.ifrance.com/img/styles/instint/ instint] [http://girlwho-is.ifrance.com/img/styles/indeo-video.htm indeo video play back] [http://lordsander.ifrance.com/topic/bass-tab.htm bass tab raffaella carra] [http://toofarfrommaybe.ifrance.com/view/new/bobble-ice/ bobble ice age] [http://toofarfrommaybe.ifrance.com/view/new/cucine-classiche/ cucine classiche] [http://girlwho-is.ifrance.com/img/styles/soluzione-shadow.htm soluzione shadow of the colossus] [http://tat-ooin.ifrance.com/resources/articles/la-.htm la 2 gurra mondiale] [http://singaporepets.ifrance.com/library/html/malawi.htm malawi] [http://highbulp.ifrance.com/images/small/peugeot-sw/ peugeot sw] [http://tizolaa.ifrance.com/web/creative-zen/ creative zen micro arancione] [http://noxuhax.ifrance.com/content/view/amstrad-tv.htm amstrad tv 5] [http://oiyaoi.ifrance.com/images/small/qui-a/ qui a le droit] [http://highbulp.ifrance.com/images/small/dub-optika/ dub optika] [http://noxuhax.ifrance.com/content/view/www-portobello.htm www portobello it] [http://deviantrus.ifrance.com/topic/cavo-usb/ cavo usb stampanti] [http://demurediablo.ifrance.com/library/html/pino-daniele/ pino daniele -project] [http://igaros.ifrance.com/lib/dimmi-di/ dimmi di no] [http://yeeden.ifrance.com/img/styles/optin-email/ optin email marketing] [http://voltia.ifrance.com/content/view/mezzoforte.htm mezzoforte] [http://tizolaa.ifrance.com/web/quotazioni-multipla/ quotazioni multipla] [http://yeeden.ifrance.com/img/styles/motori-graupner/ motori graupner] [http://singaporepets.ifrance.com/library/html/bmw-.htm bmw 4 serie] [http://speedofsoun.ifrance.com/text/directory/batterie-z.htm batterie z300] [http://toofarfrommaybe.ifrance.com/view/new/autoradio-mp/ autoradio mp3 slot] [http://deviantrus.ifrance.com/topic/il-dito/ il dito nella piaga] [http://oiyaoi.ifrance.com/images/small/crane-hart/ crane, hart] [http://demurediablo.ifrance.com/library/html/franco-simone/ franco simone] [http://akmokanzen.ifrance.com/images/small/mike-buongiorno.htm mike buongiorno] [http://broadwaylili.ifrance.com/content/view/sorelline.htm sorelline] [http://yeeden.ifrance.com/img/styles/ricettario-bertolini/ ricettario bertolini] [http://highbulp.ifrance.com/images/small/calendario-ilary/ calendario ilary blasi] [http://yeeden.ifrance.com/img/styles/stampanti-laser/ stampanti laser colore a4 samsung] [http://igaros.ifrance.com/lib/pellicola-vetri/ pellicola vetri] [http://deviantrus.ifrance.com/topic/duncan-i/ duncan i believe my heart] [http://toofarfrommaybe.ifrance.com/view/new/keys-viaaccess/ keys viaaccess 007c00] [http://girlwho-is.ifrance.com/img/styles/putas-borrachas.htm putas borrachas] [http://tizolaa.ifrance.com/web/plasma-philips/ plasma philips 42] [http://lovereceier.ifrance.com/lib/roberta-giarusso.htm roberta giarusso nuda] [http://voltia.ifrance.com/content/view/ventole-pc.htm ventole pc] [http://jdawsona.ifrance.com/data/malevil/ malevil] [http://tizolaa.ifrance.com/web/tommasini-hotel/ tommasini hotel] [http://speedofsoun.ifrance.com/text/directory/tamil-songs.htm tamil songs] [http://voltia.ifrance.com/content/view/monitor-benq.htm monitor benq 937] [http://deviantrus.ifrance.com/topic/legacoopbund/ legacoopbund] [http://broadwaylili.ifrance.com/content/view/lorna-papi.htm lorna papi chulo] [http://oiyaoi.ifrance.com/images/small/nikon/ nikon 70 200 2 8] [http://tat-ooin.ifrance.com/resources/articles/aria-mesh.htm aria mesh puma] [http://lovereceier.ifrance.com/lib/calciatore-stranieri.htm calciatore stranieri] [http://girlwho-is.ifrance.com/img/styles/torna-backyard.htm torna backyard wrestling] [http://highbulp.ifrance.com/images/small/c-dragonball/ c18 dragonball x] [http://igaros.ifrance.com/lib/videoclip-eifel/ videoclip eifel 65] [http://toofarfrommaybe.ifrance.com/view/new/barry-white/ barry white cd] [http://girlwho-is.ifrance.com/img/styles/storia-festa.htm storia festa donna] [http://lordsander.ifrance.com/topic/batteria-cordless.htm batteria cordless sagem] [http://toofarfrommaybe.ifrance.com/view/new/harry-potter/ harry potter soundtrack] [http://noxuhax.ifrance.com/content/view/kit-auto.htm kit auto altoparlanti] [http://highbulp.ifrance.com/images/small/canon-fotografia/ canon fotografia] [http://igaros.ifrance.com/lib/aquatica-online/ aquatica online] [http://girlwho-is.ifrance.com/img/styles/castrazione.htm castrazione] [http://tat-ooin.ifrance.com/resources/articles/some-girl.htm some girl] [http://tizolaa.ifrance.com/web/fattoria-maremmana/ fattoria maremmana] [http://deviantrus.ifrance.com/topic/acqua-fredda/ acqua fredda] [http://igaros.ifrance.com/lib/www-provini/ www provini it] [http://girlwho-is.ifrance.com/img/styles/donne-inculate.htm donne inculate da cani] [http://speedofsoun.ifrance.com/text/directory/trucchi-per.htm trucchi per spyro 3] [http://akmokanzen.ifrance.com/images/small/www-sillyrabbit.htm www sillyrabbit com] [http://oiyaoi.ifrance.com/images/small/djv/ dj600v] [http://igaros.ifrance.com/lib/album-foto/ album foto matrimonio] [http://akmokanzen.ifrance.com/images/small/vietnam-hotel.htm vietnam hotel] [http://broadwaylili.ifrance.com/content/view/telegiornale-filmati.htm telegiornale filmati iraq] [http://voltia.ifrance.com/content/view/www-concessionario.htm www concessionario usato it] [http://deviantrus.ifrance.com/topic/djerba-last/ djerba last minute] [http://toofarfrommaybe.ifrance.com/view/new/rex-rd/ rex rd 1871 da] [http://noxuhax.ifrance.com/content/view/isacco-newton.htm isacco newton] [http://demurediablo.ifrance.com/library/html/lacie-/ lacie 50 gb] [http://lordsander.ifrance.com/topic/polski-hip.htm polski hip hop] [http://akmokanzen.ifrance.com/images/small/lego-studios.htm lego studios] [http://yeeden.ifrance.com/img/styles/harley-davidson/ harley davidson] [http://tizolaa.ifrance.com/web/agriturismo-asiago/ agriturismo asiago] [http://girlwho-is.ifrance.com/img/styles/belvedere-amalfi.htm belvedere amalfi] [http://lovereceier.ifrance.com/lib/tanti-giochi.htm tanti giochi  sexy] [http://voltia.ifrance.com/content/view/penelope-miller.htm penelope miller] [http://kalian42.ifrance.com/text/directory/elementari-nude/ elementari nude foto] [http://tat-ooin.ifrance.com/resources/articles/gps-portatile.htm gps portatile] [http://tat-ooin.ifrance.com/resources/articles/dainese-jet.htm dainese jet] [http://yeeden.ifrance.com/img/styles/moto-club/ moto club lucca] [http://demurediablo.ifrance.com/library/html/data-bank/ data bank] [http://deviantrus.ifrance.com/topic/lettore-multimedia/ lettore multimedia] [http://oiyaoi.ifrance.com/images/small/luomo-che/ luomo che uccise il suo carnefice] [http://tizolaa.ifrance.com/web/tomi/ tomi] [http://igaros.ifrance.com/lib/valvonauta-verdena/ valvonauta verdena] [http://demurediablo.ifrance.com/library/html/manuale-maya/ manuale maya] [http://singaporepets.ifrance.com/library/html/drops-of.htm drops of jupiter train] [http://noxuhax.ifrance.com/content/view/quattro-foto.htm quattro foto e un sondaggio per far cry] [http://highbulp.ifrance.com/images/small/grazie-di/ grazie di esistere] [http://speedofsoun.ifrance.com/text/directory/ilguerriero.htm ilguerriero] [http://tat-ooin.ifrance.com/resources/articles/immagini-e.htm immagini e nuovi dettagli per motogp 3] [http://tizolaa.ifrance.com/web/le-isole/ le isole canarie] [http://igaros.ifrance.com/lib/w-netsky/ w32 netsky p] [http://girlwho-is.ifrance.com/img/styles/agricoltura-.htm agricoltura - servizi] [http://speedofsoun.ifrance.com/text/directory/www-milano.htm www milano it] [http://jdawsona.ifrance.com/data/soulseek/ soulseek] [http://toofarfrommaybe.ifrance.com/view/new/ca/ ca] [http://yeeden.ifrance.com/img/styles/kendall-henry/ kendall, henry way] [http://singaporepets.ifrance.com/library/html/cerco-lavoro.htm cerco lavoro a catania] [http://toofarfrommaybe.ifrance.com/view/new/oroscopo-capricorno/ oroscopo capricorno] [http://broadwaylili.ifrance.com/content/view/www-bradford.htm www bradford it] [http://demurediablo.ifrance.com/library/html/packard-bell/ packard bell - store play hard disk] [http://girlwho-is.ifrance.com/img/styles/di-salto.htm di salto] [http://deviantrus.ifrance.com/topic/legend-garmin/ legend garmin] [http://lordsander.ifrance.com/topic/dolce-gabbana.htm dolce gabbana uomo abbigliamento] [http://tizolaa.ifrance.com/web/pooh-la/ pooh la donna del mio amico] [http://lordsander.ifrance.com/topic/hosting-dedicato.htm hosting dedicato] [http://jdawsona.ifrance.com/data/key-crack/ key crack password hotmail] [http://kalian42.ifrance.com/text/directory/luce-lettura/ luce lettura] [http://oiyaoi.ifrance.com/images/small/fax-xerox/ fax xerox] [http://igaros.ifrance.com/lib/dolce-attesa/ dolce attesa] [http://akmokanzen.ifrance.com/images/small/progettazione-consulenza.htm progettazione consulenza vendite aziendali] == Checking permissions ==
+
== Checking permissions ==
  
 
=== Global perission ===
 
=== Global perission ===

Revision as of 22:44, 19 August 2007

Checking permissions

Global perission

To check if user can for example view other users profiles, use this code:

if (!$auth->acl_get('u_viewprofile'))
{
     
trigger_error('NOT_AUTHORIZED');
}

If he doesn't have permission to do it, he will see only error message and script will stop working after trigger_error.

Local permission

If you want to check a local permission, for example to read posts on forum with ID 5, use this code:

if (!$auth->acl_get('f_read'5))
{
     
trigger_error('NOT_AUTHORIZED');
}

Full list of existing permissions is in your database, in phpbb_acl_options table.

Adding a permission

Adding new permissions to Olympus is simple. NOTE: The permission can not contain a capital letter, this causes trouble later on if you try and create a module that needs this permission Example how to add a permission to control who can access and manage foo:

Using the API (recommended)

  • Run this code in the installer:
<?php
// Setup $auth_admin class so we can add permission options
include($phpbb_root_path 'includes/acp/auth.' $phpEx);
$auth_admin = new auth_admin();

// Add permissions
$auth_admin->acl_add_option(array(
    
'local'      => array(),
    
'global'   => array('u_view_foo''u_manage_foo')
));
?>

Using SQL

You can also directly insert new rows into the phpbb_acl_options table:

INSERT INTO phpbb_acl_options (auth_option, is_global, is_local, founder_only) VALUES ('u_view_foo', 1, 0, 0);
INSERT INTO phpbb_acl_options (auth_option, is_global, is_local, founder_only) VALUES ('u_manage_foo', 1, 0, 0);

Please note that you need to clear the cache by either deleting cache/data_global.php or executing $cache->destroy('acl_options'); after this.

Language file (Adding tabs)

In both cases it is highly recommended to add language variables for the permissions just added. To do this, simply create a file named permissions_foo.php in language/xx/mods. It will automatically be included, don't worry about how.

<?php
/**
* DO NOT CHANGE
*/
if (empty($lang) || !is_array($lang))
{
    
$lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine

// Adding new category
$lang['permission_cat']['foo'] = 'Foo management';

// Adding the permissions
$lang array_merge($lang, array(
    
'acl_u_view_foo'    => array('lang' => 'Can view foo''cat' => 'foo'),
    
'acl_u_manage_foo'    => array('lang' => 'Can manage foo''cat' => 'foo'),
));
?>

In this code they added the category "foo" (will be displayed as a new tab). All language keys where the key cat is equal to "foo" will be displayed in this tab. So you have created an new tab if you use that code.

The permission should be ready to assign to users/groups in the acp now. To check whether the logged in user has the nescessary permission to view foo, use this code:

if (!$auth->acl_get('u_view_foo'))
{
     
trigger_error('NOT_AUTHORIZED');
}

Panels (in the ACP)

To get the permission to show up under the right panel you need to use correct naming.

a_foo_bar Administrator permissions panel
m_foo_bar 
Moderator permissions panel
u_foo_bar 
User permissions panel
f_foo_bar 
Forum permissions panel

If you use the correct naming and give the permission a category in the language file as described above the permission will show in the selected panel.

Permission types