Page 1 of 1

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

Posted: 2020-04-21 08:55
by fgazza
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

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

Posted: 2020-04-21 18:00
by onoehring
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

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

Posted: 2020-04-21 19:52
by fgazza
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!

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

Posted: 2020-04-21 20:21
by pbottcher
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.

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

Posted: 2020-04-23 19:10
by kerelov
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.