apply a custom quey in lookup field only if groups is not admin or superuser

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

apply a custom quey in lookup field only if groups is not admin or superuser

Post by fgazza » 2020-04-21 08:55

Hi.

I set this custom query in appgini lookup field advanced settings:

-----------my advanced setting ---------------
SELECT `appuntamenti`.`pri_key`, IF(CHAR_LENGTH(if(`appuntamenti`.`data_appuntamento`,date_format(`appuntamenti`.`data_appuntamento`,'%d/%m/%Y'),'')) || CHAR_LENGTH(`appuntamenti`.`titolo`), CONCAT_WS('', if(`appuntamenti`.`data_appuntamento`,date_format(`appuntamenti`.`data_appuntamento`,'%d/%m/%Y'),''), ': ', `appuntamenti`.`titolo`), '') FROM `appuntamenti` LEFT JOIN `azioni_progetto` as azioni_progetto1 ON `azioni_progetto1`.`prikey`=`appuntamenti`.`azione_di_progetto` LEFT JOIN `schede_tratt_dati` as schede_tratt_dati1 ON `schede_tratt_dati1`.`pri_key`=`appuntamenti`.`nome_sch_inf_tratt_dati` WHERE `appuntamenti`.`accesso_op_enti_partner` = '1' AND `appuntamenti`.`attivo`= '1' ORDER BY `data_appuntamento` DESC
---------end of advance setting----------------

I need to apply the specific clause `appuntamenti`.`attivo` = '1' only if user-groups is not Admins or Superuser.

Any help please?

Thank you!

Fabiano

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: apply a custom quey in lookup field only if groups is not admin or superuser

Post by onoehring » 2020-04-21 18:00

Hi,

just from memory:
The query is saved in some file (just search all files for part of your querystring) and exists in a JS variable. You might be able to overwrite this variable in the /hooks/tablename-php _init function according to your needs. Just check in the init for the usergroup and set the variable accordingly.

Olaf

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: apply a custom quey in lookup field only if groups is not admin or superuser

Post by fgazza » 2020-04-21 19:52

Thanks for the reply. I'm sorry but I can't understand what I can do.
Can't change the custom query in appgini to get my purpose?
Thanks and sorry for my incompetence!

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: apply a custom quey in lookup field only if groups is not admin or superuser

Post by pbottcher » 2020-04-21 20:21

Hi,

AppGini does not support that feature out of the box right now. And for your specific case I guess it will take some time if at all this will be supported.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

kerelov
Veteran Member
Posts: 42
Joined: 2020-04-17 21:20
Location: Bulgaria

Re: apply a custom quey in lookup field only if groups is not admin or superuser

Post by kerelov » 2020-04-23 19:10

Hi,
Why don’t you try the following strategy:
Create 2 lookup fields. In the first one place the original SQL you posted and in the second one place the SQL with the additional `appuntamenti`.`attivo` = '1' .
Now you can add in footer-extras.php a php code that checks for session variable of the user group and inside it a JS script that hides one or the other field if a certain user group is presented.

Post Reply