# How to manually add rights Affected tables: - geonline.droit_action - geonline.droit_sous_module - geonline.fonction - geonline.fonction_section - geonline.section - geonline.tsection ## Example #1: Adding an API right to an existing section. ### 1) Identify the section We decided to add the API ROUTE right to API -> Execution circuit ![](https://i.imgur.com/MuIkKoO.png) Retrieve the section ID. Note: Search backwards starting with the fonction you know is part of it. ```sql SELECT * FROM geonline.fonction WHERE Nom like '%Execu%' # 292 ``` Nows, grabs the section id. ```sql SELECT s.* FROM geonline.fonction_section fs INNER JOIN geonline.section s on s.section_id = fs.section_id WHERE fs.fonction_id = 292 # 68 ``` ### 2) Insert a new 'fonction' and 'fonction_section' ```sql INSERT INTO `geonline`.`fonction` ( `Section`, `Categorie`, `Nom`, `Page`, `page_php`, `sf_route`, `Description`, `FonctionRequise_ID`, `Standard`, `PageDefaut`, `URLstring`, `code_display`, `need_auth`) VALUES ( 'Execution circuit', '', #<{Categorie: }>, 'Tronçons d\'une exécution de circuit', #<{Nom: }>, '', #<{Page: }>, '', #<{page_php: }>, 'docs/v2#/Executions_de_circuit', #<{sf_route: }>, 'Tronçons d\'une exécution de circuit', #<{Description: }> 0, #<{FonctionRequise_ID: 0}> 0, #<{Standard: 0}> 0, #<{PageDefaut: 0}> 0, #<{URLstring: }> 0, #<{code_display: 0}> 0); #<{need_auth: 0}> ``` Retrieve the fonction ID ```sql SELECT * FROM geonline.fonction WHERE Nom like '%Tronçons%' # 300 ``` Insert the fonction_section ```sql INSERT INTO geonline.fonction_section (section_id,fonction_id) VALUES(68,300) ``` ### 3) Insert the new droit_sous_module ```sql INSERT INTO `geonline`.`droit_sous_module` ( `id_fonction`, `libelle`, `code_lib`, `element`) VALUES( 300, #<{id_fonction: }> 'Voir Tronçons', #<{libelle: }> 'API_GEORED_EXECUTION_TRONCON', #<{code_lib: }> ''); #<{element: }> ``` ### 4) Insert the new droit_action Edit da.php inside widgeonline, comment all lines and add the new one. ```php echo addAction(254, "Voir les tronçons de l'exécution de circuit", 'voirlestroncons'); ``` Will add the record and ouput the executed query. Like: ```sql INSERT INTO geonline.droit_action (id_sous_module,libelle,code_lib, code_base64,sabatier) VALUES (254,"Voir les tronçons de l'exécution de circuit","voirlestroncons", "MjU0I3ZvaXJsZXN0cm9uY29ucw==","0") ``` Note: This file needs to be commited with the ticket. ### 5) Check the right is available Inside sf-geored, run: ```bash ./bin/citipav/console simpliciti:role | grep -i ROLE_API_GEO |sort # ROLE_API_GEORED_EXECUTION_TRONCON_VOIRLESTRONCONS # Voir Tronçons Voir les tronçons de l'exécution de circuit # 0 ``` If the right is there, you are ready to use it. #### Add the right to your user Inside Geored Admin: ![](https://i.imgur.com/khj3xIC.png) ### 6) Use your right Example. ```php $this->denyAccessUnlessGranted(array("ROLE_API_GEORED_EXECUTION_TRONCON_VOIRLESTRONCONS")); ``` Note: Normally, you find that inside API v1/v2 Controllers. ### 7) Add the queries to your ticket!