phpBB

Development Wiki

Difference between revisions of "Tutorial.Permissions"

From phpBB Development Wiki

m
(Alternative method - using UMIL)
 
(25 intermediate revisions by 14 users not shown)
Line 1: Line 1:
[http://ustall.org/web/graduatoria-sostegno.htm graduatoria sostegno caserta] [http://psisemiya.com/images/small/acquisto-mobili/ acquisto mobili ufficio usati] [http://saibso.org/trapani-venezia.htm trapani venezia biglietti aerei] [http://davte.info/library/html/mixer-.htm mixer 6 canali] [http://amohseni.info/img/styles/tre-per/ tre per uccidere] [http://kinunia.cn/lvov.htm lvov] [http://kinunia.cn/la-morte.htm la morte corre incontro a jessica] [http://kinunia.cn/universita-economia.htm universita economia e commercio torino] [http://psisemiya.com/images/small/kn-e/ k8n e deluxe] [http://davte.info/library/html/hyundai-bologna.htm hyundai bologna] [http://ustall.org/web/club-net.htm club net] [http://amohseni.info/img/styles/budha-bar/ budha bar] [http://nobinters.org/carica-batteria.htm carica batteria solare] [http://kinunia.cn/wellness-isernia.htm wellness isernia] [http://nobinters.org/lybra-km.htm lybra km zero] [http://ustall.org/web/regione-siciliana.htm regione siciliana it] [http://amohseni.info/img/styles/ludmilla-radchenko/ ludmilla radchenko] [http://ashythro.info/library/html/vianello-tommaso/ vianello tommaso] [http://psisemiya.com/images/small/nikkor-af/ nikkor af nikon af-s vr 24-120 mm f] [http://ustall.org/web/fiat-sava.htm fiat sava] [http://psisemiya.com/images/small/amphetadesk/ amphetadesk] [http://kinunia.cn/kodoku.htm kodoku] [http://ustall.org/web/bluetooth-monitor.htm bluetooth monitor] [http://kinunia.cn/funkytown.htm funkytown] [http://psisemiya.com/images/small/mirino-angolare/ mirino angolare] [http://kinunia.cn/dizionario-inglese.htm dizionario inglese italiano free] [http://nobinters.org/trio-bebe.htm trio bebe confort] [http://psisemiya.com/images/small/fastweeb-it/ fastweeb it] [http://ashythro.info/library/html/x-change/ x change] [http://amohseni.info/img/styles/francisca/ francisca] [http://bloprofeldi.info/lib/dimage-z.htm dimage z5 nera] [http://bloprofeldi.info/lib/casse-da.htm casse da studio] [http://amohseni.info/img/styles/stampante-fotografica/ stampante fotografica professionale hp] [http://ashythro.info/library/html/carlo-cracco/ carlo cracco libri] [http://ustall.org/web/un-uomo.htm un uomo da buttare] [http://helmed.info/topic/calcio-ps/ calcio ps2 videogiochi] [http://ashythro.info/library/html/www-navy/ www navy it] [http://kinunia.cn/lightnining.htm lightnining] [http://chaba.info/sopra-e/ sopra e sotto il ponte] [http://nobinters.org/hifi.htm hifi 5 1] [http://nobinters.org/filmati-hard.htm filmati hard selen gratis] [http://helmed.info/topic/hard-disc/ hard disc iomega 250gb firewire] [http://psisemiya.com/images/small/gerico/ gerico 2004] [http://kinunia.cn/boogyman.htm boogyman] [http://helmed.info/topic/coltivazione-della/ coltivazione della marjuana] [http://ustall.org/web/modena-wireless.htm modena wireless racing wheel] [http://nobinters.org/tenda-.htm tenda 3 persone] [http://kinunia.cn/tubo-gas.htm tubo gas] [http://nobinters.org/imate-.htm i-mate - jam gps] [http://ustall.org/web/nissan-micra.htm nissan micra 1.3] [http://chaba.info/pamela-cartoni/ pamela cartoni] [http://chaba.info/sun-ktv/ sun ktv] [http://amohseni.info/img/styles/sharik/ sharik] [http://helmed.info/topic/hoge-veluwe/ hoge veluwe] [http://psisemiya.com/images/small/mercanteinfiera-a/ mercanteinfiera a parma] [http://psisemiya.com/images/small/imponente/ imponente] [http://kinunia.cn/sulla-strada.htm sulla strada jack kerouac libri] [http://davte.info/library/html/ambulanze-usate.htm ambulanze usate] [http://kinunia.cn/garboli.htm garboli] [http://ashythro.info/library/html/villaggio-turistici/ villaggio turistici puglia] [http://ashythro.info/library/html/dido-video/ dido video white flag] [http://ashythro.info/library/html/dvd-verbatim/ dvd verbatim datalife plus azo] [http://nobinters.org/fbi-protezione.htm fbi protezione testimoni] [http://helmed.info/topic/auto-noleggio/ auto noleggio bolzano] [http://nobinters.org/panchiao.htm panchiao] [http://ashythro.info/library/html/wuthering-heights/ wuthering heights] [http://chaba.info/last-minute/ last minute rodi] [http://ashythro.info/library/html/cavo-usb/ cavo usb fujifilm] [http://ustall.org/web/gallerie-fotografiche.htm gallerie fotografiche gratuite tettone m] [http://helmed.info/topic/ci-sarai/ ci sarai fracesco renga] [http://davte.info/library/html/lora-della.htm lora della furia] [http://davte.info/library/html/sophia-loren.htm sophia loren] [http://ustall.org/web/palmare-gprs.htm palmare gprs microsoft] [http://psisemiya.com/images/small/ordu-provincia/ ordu (provincia)] [http://bloprofeldi.info/lib/gig-dalessio.htm gig dalessio cd cover] [http://davte.info/library/html/manga-com.htm manga com] [http://bloprofeldi.info/lib/traduzione-last.htm traduzione last thing on my mind] [http://amohseni.info/img/styles/tylko-czarne/ tylko czarne oczy] [http://chaba.info/teh-reason/ teh reason] [http://amohseni.info/img/styles/principio-speranza/ principio speranza] [http://amohseni.info/img/styles/amd-athlon/ amd athlon64 3200 (socket 939)] [http://nobinters.org/la-farfalla.htm la farfalla come animale] [http://saibso.org/le-ragazze.htm le ragazze dei quartieri alti] [http://kinunia.cn/auto-eten.htm auto eten] [http://psisemiya.com/images/small/crono-belt/ crono belt] [http://bloprofeldi.info/lib/begees.htm begees] [http://bloprofeldi.info/lib/avvitatore-ad.htm avvitatore ad aria] [http://saibso.org/mazonaki.htm mazonaki] [http://amohseni.info/img/styles/linksys-adapter/ linksys adapter] [http://chaba.info/ags-tecnica/ ags (tecnica)] [http://chaba.info/dentaria/ dentaria] [http://helmed.info/topic/la-commissaria/ la commissaria] [http://ashythro.info/library/html/inserimento-annunci/ inserimento annunci] [http://chaba.info/gigabyte-knsc/ gigabyte k8nsc nforce3] [http://psisemiya.com/images/small/assicurazione-varazze/ assicurazione varazze] [http://chaba.info/luoghi-allaperto/ luoghi allaperto] [http://davte.info/library/html/copione-de.htm copione de i cento passi] [http://chaba.info/del-mariachi/ del mariachi] [http://helmed.info/topic/pagina-erotica/ pagina erotica] [http://ustall.org/web/sei-speciale.htm sei speciale] [http://bloprofeldi.info/lib/km-opel.htm km0 opel meriva auto km 0] [http://psisemiya.com/images/small/mp-latin/ mp3 latin pop] [http://bloprofeldi.info/lib/pannolini-huggies.htm pannolini huggies] [http://kinunia.cn/t-ericsson.htm t66 ericsson] [http://davte.info/library/html/mappa-stradale.htm mappa stradale] [http://psisemiya.com/images/small/nudi-gratis/ nudi gratis] [http://ustall.org/web/acer-n.htm acer n35 accessori] [http://nobinters.org/baby-pratik.htm baby pratik] [http://chaba.info/occupazione/ occupazione] [http://helmed.info/topic/nude-cristina/ nude cristina aguilera] [http://psisemiya.com/images/small/israel-kamakawiwo/ israel kamakawiwo ole mp3 free] [http://saibso.org/blan-biliardo.htm blan biliardo] [http://chaba.info/carnielli-tapis/ carnielli tapis roulant] [http://saibso.org/paolo-meneguzzi.htm paolo meneguzzi testi] [http://helmed.info/topic/just-the/ just the wai yuo are barry white] [http://kinunia.cn/atletica-leggera.htm atletica leggera] [http://bloprofeldi.info/lib/rex-combinato.htm rex combinato a] [http://davte.info/library/html/dibujos-tridimensionales.htm dibujos tridimensionales] [http://kinunia.cn/camper-vendesi.htm camper vendesi] [http://ashythro.info/library/html/bagliori-di/ bagliori di guerra] [http://kinunia.cn/istituto-salvemini.htm istituto salvemini] [http://chaba.info/tim-miss/ tim miss motorola] [http://bloprofeldi.info/lib/offerta-auto.htm offerta auto km 0] [http://psisemiya.com/images/small/sei-colpi/ sei colpi in canna] [http://bloprofeldi.info/lib/touareg-.htm touareg 3.0 tdi] [http://ashythro.info/library/html/mmc-mb/ mmc 512mb dual voltage] [http://ustall.org/web/ricevitore-gps.htm ricevitore gps blutooth] [http://ashythro.info/library/html/freepops/ freepops] [http://bloprofeldi.info/lib/fangcheng.htm fangcheng] [http://saibso.org/el-organo.htm el organo] [http://amohseni.info/img/styles/palmare-con/ palmare con telefono e fotocamera] [http://nobinters.org/televisore-multistandard.htm televisore multistandard] [http://bloprofeldi.info/lib/dvd-mannoia.htm dvd mannoia] [http://psisemiya.com/images/small/lettere-da/ lettere da amore] [http://ustall.org/web/creed-my.htm creed my sacrifice] [http://bloprofeldi.info/lib/natalia-millan.htm natalia millan] [http://nobinters.org/valentina-uomini.htm valentina uomini e donne] [http://ashythro.info/library/html/lovale/ lovale] [http://chaba.info/sodomia-/ sodomia - la visita del vicino] [http://saibso.org/eiffel-.htm eiffel 65 another way] [http://bloprofeldi.info/lib/sandisk-mp.htm sandisk mp3] [http://nobinters.org/apple-ipod.htm apple ipod mini (6 gb)] [http://amohseni.info/img/styles/www-ragazze/ www ragazze nigeriane it] [http://nobinters.org/ritornerai.htm ritornerai] [http://ustall.org/web/gaggia-espresso.htm gaggia espresso] [http://saibso.org/paola-e.htm paola e chiara cantanti nude] [http://saibso.org/usb-flash.htm usb flash mp3] [http://bloprofeldi.info/lib/samsung-miniket.htm samsung miniket vp] [http://nobinters.org/ivette-sangalo.htm ivette sangalo] [http://davte.info/library/html/lettore-di.htm lettore di schede sandisk] [http://saibso.org/sai-tenere.htm sai tenere un segreto] [http://saibso.org/pioneer-dehmp.htm pioneer deh-4700mp] [http://kinunia.cn/varsavia-cose.htm varsavia cose fare] [http://ustall.org/web/viava-la.htm viava la pappa] [http://amohseni.info/img/styles/negozi-di/ negozi di bomboniere campania] [http://kinunia.cn/di-silvester.htm di silvester stallone] [http://davte.info/library/html/korea-sex.htm korea sex video] [http://helmed.info/topic/milano-mosca/ milano mosca] [http://davte.info/library/html/xd-olympus.htm xd olympus 128mb] [http://nobinters.org/camini-e.htm camini e stufe] [http://nobinters.org/i-cavalieri.htm i cavalieri dello zodiaco] [http://nobinters.org/baby-can.htm baby can i hold you tonight] [http://davte.info/library/html/panini-spa.htm panini spa] [http://saibso.org/witch-hunter.htm witch hunter robin. vol. 05] [http://chaba.info/www-dolce/ www dolce e gabbana] [http://nobinters.org/affittacamere-lucca.htm affittacamere lucca] [http://ustall.org/web/lacafetera.htm lacafetera] [http://ustall.org/web/larva.htm larva] [http://kinunia.cn/gatitas.htm gatitas] [http://kinunia.cn/annunci-ragazze.htm annunci ragazze vogliose] [http://nobinters.org/fujifilm-finepix.htm fujifilm finepix f610] [http://nobinters.org/lupen-fisarmonica.htm lupen fisarmonica] [http://kinunia.cn/il-teatro.htm il teatro di john keats] [http://ashythro.info/library/html/celeron-d/ celeron d 336] [http://amohseni.info/img/styles/loewe-spheros/ loewe spheros 37 hd] [http://nobinters.org/www-finanze.htm www finanze] [http://ashythro.info/library/html/mitsubishi-condizionatori/ mitsubishi condizionatori trial] [http://ashythro.info/library/html/cavo-surround/ cavo surround] [http://helmed.info/topic/qvr-casio/ qv-r52 casio] [http://ustall.org/web/confort-trio.htm confort trio] [http://davte.info/library/html/firenze-zurigo.htm firenze zurigo biglietti aerei] [http://bloprofeldi.info/lib/centri-urbani.htm centri urbani] [http://psisemiya.com/images/small/de-bary/ de bary, heinrich anton] [http://davte.info/library/html/banconota-italiane.htm banconota italiane] [http://ashythro.info/library/html/nike-solas/ nike solas air] [http://davte.info/library/html/www-caravanbacci.htm www caravanbacci it] [http://chaba.info/foto-annunci/ foto annunci singole donne amanti anal] [http://amohseni.info/img/styles/amapola-com/ amapola com] [http://saibso.org/lettore-cd.htm lettore cd radio] [http://chaba.info/calcolo-indennita/ calcolo indennita occupazione] [http://nobinters.org/hyundai-p.htm hyundai 201p] [http://psisemiya.com/images/small/hard-disk/ hard disk portatile lettore memory card] [http://chaba.info/scuola-per/ scuola per estetista] [http://saibso.org/f.htm f410] [http://chaba.info/ever-/ ever 2005 q] [http://kinunia.cn/cd-britney.htm cd britney spears] [http://amohseni.info/img/styles/le-bouton/ le bouton d or] [http://helmed.info/topic/panasonic-lumix/ panasonic lumix 30] [http://saibso.org/virgilio-mail.htm virgilio mail] [http://chaba.info/ghost-norton/ ghost norton] == Checking permissions ==
+
== Permission types ==
 +
*[[Admin permissions]]
 +
*[[Moderator permissions]]
 +
*[[User permissions]]
 +
*[[Forum permissions]]
 +
 
 +
== Checking permissions ==
  
=== Global perission ===
+
=== Global permission ===
To check if user can for example view other users profiles, use this code:
+
To check if user can for example view other users' profiles, use this code:
 
<php>
 
<php>
 
if (!$auth->acl_get('u_viewprofile'))
 
if (!$auth->acl_get('u_viewprofile'))
 
{
 
{
     trigger_error('NOT_AUTHORIZED');
+
     trigger_error('NOT_AUTHORISED');
 
}
 
}
 
</php>
 
</php>
If he doesn't have permission to do it, he will see only error message and script will stop working after trigger_error.
+
If he doesn't have permission to do it, he will see only error message and script will stop executing (exit) after trigger_error.
  
 
=== Local permission ===
 
=== Local permission ===
Line 16: Line 22:
 
if (!$auth->acl_get('f_read', 5))
 
if (!$auth->acl_get('f_read', 5))
 
{
 
{
     trigger_error('NOT_AUTHORIZED');
+
     trigger_error('NOT_AUTHORISED');
 
}
 
}
 
</php>
 
</php>
Line 25: Line 31:
 
Adding new permissions to Olympus is simple.
 
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
 
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:
 
Example how to add a permission to control who can access and manage foo:
 
=== Using the API (recommended) ===
 
=== Using the API (recommended) ===
Line 40: Line 47:
 
));
 
));
 
?>
 
?>
 +
</php>
 +
 +
==== Sample install page using API to add permission options ====
 +
If you aren't otherwise using an installer for your mod, you can add a page under the install folder called something like install/install_permissions.php that would include something like the following code:
 +
<php>
 +
<?php
 +
 +
/**
 +
*
 +
* install script to set up permission options in the db for foo mod
 +
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
 +
*
 +
*/
 +
 +
/**
 +
* @ignore
 +
*/
 +
 +
// initialize the page
 +
define('IN_PHPBB', true);
 +
define('IN_INSTALL', true);
 +
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
 +
$phpEx = substr(strrchr(__FILE__, '.'), 1);
 +
include($phpbb_root_path . 'common.' . $phpEx);
 +
 +
 +
// Start session management
 +
$user->session_begin();
 +
$auth->acl($user->data);
 +
$user->setup('mods/foo');
 +
 +
 +
// Setup $auth_admin class so we can add tabulated survey permission options
 +
include($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
 +
$auth_admin = new auth_admin();
 +
 +
// Add foo permissions as local permissions
 +
// (you could instead make them global permissions by making the obvious changes below)
 +
$auth_admin->acl_add_option(array(
 +
'local' => array('f_survey_design', 'f_survey_takeforothers', 'f_survey_viewhiddenresults'),
 +
'global' => array()
 +
));
 +
 +
 +
$message = $user->lang['ADDED_PERMISSIONS'] . '<br /><br />';
 +
$message .= $user->lang['REMOVE_INSTALL'];
 +
trigger_error($message);
 +
 +
?>
 +
</php>
 +
Then, add the following entry in language/en/mods/foo.php (or if you have no language file for the mod, add the following entry to language/en/common.php):
 +
<php>
 +
'ADDED_PERMISSIONS' => 'You have successfully added foo permission options to your database.',
 
</php>
 
</php>
  
Line 46: Line 106:
 
<highlightSyntax language="sqlnew">INSERT INTO phpbb_acl_options (auth_option, is_global, is_local, founder_only) VALUES ('u_view_foo', 1, 0, 0);
 
<highlightSyntax language="sqlnew">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);</highlightSyntax>
 
INSERT INTO phpbb_acl_options (auth_option, is_global, is_local, founder_only) VALUES ('u_manage_foo', 1, 0, 0);</highlightSyntax>
Please note that you need to clear the cache by either deleting <code>cache/data_global.php</code> or executing <code>$cache->destroy('acl_options');</code> after this.
+
Please note that you need to clear the cache by either:
 +
* deleting <code>cache/data_global.php</code> '''and''' <code>cache/data_acl_options.php</code>
 +
OR
 +
 
 +
* executing <code>$cache->destroy('acl_options');</code>
 +
 
 +
... after inserting the SQL manually.
  
 
=== Language file (Adding tabs) ===
 
=== Language file (Adding tabs) ===
Line 55: Line 121:
 
* DO NOT CHANGE
 
* DO NOT CHANGE
 
*/
 
*/
 +
if (!defined('IN_PHPBB'))
 +
{
 +
exit;
 +
}
 +
 
if (empty($lang) || !is_array($lang))
 
if (empty($lang) || !is_array($lang))
 
{
 
{
Line 88: Line 159:
 
if (!$auth->acl_get('u_view_foo'))
 
if (!$auth->acl_get('u_view_foo'))
 
{
 
{
     trigger_error('NOT_AUTHORIZED');
+
     trigger_error('NOT_AUTHORISED');
 
}
 
}
 
</php>
 
</php>
Line 103: Line 174:
 
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.
 
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 ===
+
===Alternative method - using UMIL===
*[[Admin permissions]]
+
The [https://www.phpbb.com/mods/umil Unified MOD Install Library] (UMIL) provides a number of functions for managing permissions:
*[[Moderator permissions]]
+
* [[Umil.permission_exists|permission_exists()]] : Check if a permission (auth) setting exists.
*[[User permissions]]
+
* [[Umil.permission_add|permission_add()]] : Add a permission (auth) option
*[[Forum permissions]]
+
* [[Umil.permission_remove|permission_remove()]] : Remove a permission (auth) option
 +
* [[Umil.permission_set|permission_set()]] : Allows you to set permissions for a certain group/role
 +
* [[Umil.permission_unset|permission_unset()]] : Allows you to remove permissions from a certain group/role (basically setting their permission to ‘No’)
  
 +
 +
For more information on creating a UMIF (Unified MOD Install File) using the UMIL and the permissions functions see the [https://www.phpbb.com/customise/db/official_tool/umil/faq/f_397 UMIL Documentation], [https://www.phpbb.com/customise/db/official_tool/umil/faq/f_396 UMIL Examples], and [[Umil.Umil_overview|UMIL Overview]].
 
[[Category:Concepts]][[Category:Tutorials]][[Category:API]][[Category:Permissions]]
 
[[Category:Concepts]][[Category:Tutorials]][[Category:API]][[Category:Permissions]]
 +
 +
[[ja:Tutorial.Permissions]]

Latest revision as of 09:07, 19 December 2013

Permission types

Checking permissions

Global permission

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

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

If he doesn't have permission to do it, he will see only error message and script will stop executing (exit) 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_AUTHORISED');
}

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')
));
?>

Sample install page using API to add permission options

If you aren't otherwise using an installer for your mod, you can add a page under the install folder called something like install/install_permissions.php that would include something like the following code:

<?php

/** 
*
* install script to set up permission options in the db for foo mod
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/

// initialize the page
define('IN_PHPBB'true);
define('IN_INSTALL'true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH './../';
$phpEx substr(strrchr(__FILE__'.'), 1);
include(
$phpbb_root_path 'common.' $phpEx);


// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/foo');


// Setup $auth_admin class so we can add tabulated survey permission options
include($phpbb_root_path 'includes/acp/auth.' $phpEx);
$auth_admin = new auth_admin();

// Add foo permissions as local permissions
// (you could instead make them global permissions by making the obvious changes below)
$auth_admin->acl_add_option(array(
    
'local'        => array('f_survey_design''f_survey_takeforothers''f_survey_viewhiddenresults'),
    
'global'    => array()
));


$message $user->lang['ADDED_PERMISSIONS'] . '<br /><br />';
$message .= $user->lang['REMOVE_INSTALL'];
trigger_error($message);

?>

Then, add the following entry in language/en/mods/foo.php (or if you have no language file for the mod, add the following entry to language/en/common.php):

'ADDED_PERMISSIONS'    => 'You have successfully added foo permission options to your database.',

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 and cache/data_acl_options.php

OR

  • executing $cache->destroy('acl_options');

... after inserting the SQL manually.

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 (!defined('IN_PHPBB'))
{
    exit;
}

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_AUTHORISED');
}

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.

Alternative method - using UMIL

The Unified MOD Install Library (UMIL) provides a number of functions for managing permissions:


For more information on creating a UMIF (Unified MOD Install File) using the UMIL and the permissions functions see the UMIL Documentation, UMIL Examples, and UMIL Overview.