Hello
I want to allow a user to subscribe to become a member (with or without approval) and then add a record in a table BUT only one.
He creates his register name, first name ... and then we fill the other fields throughout the year (so we have to hide the ADD button)
Is it possible ?
thank you
hide the ADD button after one record
Re: hide the ADD button after one record
Hi,
yes it is possible, you can use the hook to check if you have already one entry in your table (if the user can only view his records), or query the db to see if a record exists, and if it the case, hide the "add" button.
To hide the add button (in the table view) you can use
yes it is possible, you can use the hook to check if you have already one entry in your table (if the user can only view his records), or query the db to see if a record exists, and if it the case, hide the "add" button.
To hide the add button (in the table view) you can use
Code: Select all
$j('#addNew').hide();
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.
Re: hide the ADD button after one record
Thank you for the idea,
I have this code to see if the member has filed a registration:
The SELECT COUNT (*) AS memberID FROM membership_userrecords WHERE memberID =? SelectedID = # ID # works in SQL, but where exactly?
In the HOOK of my table but I do not see too much.
I have this code to see if the member has filed a registration:
Code: Select all
// We count in the membership_userrecords table the row (s) where the memberID field is equal to 1.
$ sql = mysql_query ('SELECT COUNT (*) AS memberID FROM membership_userrecords WHERE memberID =? SelectedID = # ID #);
$ data = mysql_fetch_array ($ sql);
// If there is a line
if (($ data ['memberID'] == '1'))
{
// remove the ADD button
J $ ( '# addNew') hide ().
}
In the HOOK of my table but I do not see too much.
Re: hide the ADD button after one record
Hellopasbonte wrote: ↑2018-09-13 12:12Thank you for the idea,
I have this code to see if the member has filed a registration:The SELECT COUNT (*) AS memberID FROM membership_userrecords WHERE memberID =? SelectedID = # ID # works in SQL, but where exactly?Code: Select all
// We count in the membership_userrecords table the row (s) where the memberID field is equal to 1. $ sql = mysql_query ('SELECT COUNT (*) AS memberID FROM membership_userrecords WHERE memberID =? SelectedID = # ID #); $ data = mysql_fetch_array ($ sql); // If there is a line if (($ data ['memberID'] == '1')) { // remove the ADD button J $ ( '# addNew') hide (). }
In the HOOK of my table but I do not see too much.
I really block, I searched and tried but I do not see.
thanks for the help
Re: hide the ADD button after one record
Hiding the add button on client side only can be hacked in almost any modern browser.
Just in case you need a safer method, you should check if you can solve it using AppGini's "special permissions for user" feature - not from within the admin-area, but by code:
As far as I can see in incCommon.php, AppGini reads the group-permissions first and overwrites them by user-permissions if available. So my idea is the following:
On after insert in TABLENAME create a record in membership_userpermissions-table with...
The existance of this record should disallow another insert in this table by this user.
On after delete remove that record by code. The group-permissions will be used and insert will be possible again.
Hope this helps!
Kind Regards,
Jan
Just in case you need a safer method, you should check if you can solve it using AppGini's "special permissions for user" feature - not from within the admin-area, but by code:
As far as I can see in incCommon.php, AppGini reads the group-permissions first and overwrites them by user-permissions if available. So my idea is the following:
On after insert in TABLENAME create a record in membership_userpermissions-table with...
- memberID = '<MEMBERNAME>'
- tableName = '<TABLENAME>'
- allowInsert = 0 // insert disabled
- allowView = 1 // view own records only
- allowEdit = 1 // edit own records only
- allowDelete = 1 // delete own records only
Code: Select all
INSERT INTO `membership_userpermissions` (`memberID`, `tableName`, `allowInsert`, `allowView`, `allowEdit`, `allowDelete`)
VALUES ('MEMBERNAME', 'TABLENAME', '0', '1', '1', '1');
On after delete remove that record by code. The group-permissions will be used and insert will be possible again.
Hope this helps!
Kind Regards,
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: hide the ADD button after one record
I have just tested this and it should work:
I have inserted a record in membership_userpermissions-table with allowInsert = 0:
Afterwards the Add-Button is gone:
After removing the record from membership_userpermissions-table the Add-button is back again:
It also works on homepage (if you allow adding records from homepage).
Regards,
Jan
I have inserted a record in membership_userpermissions-table with allowInsert = 0:
Afterwards the Add-Button is gone:
After removing the record from membership_userpermissions-table the Add-button is back again:
It also works on homepage (if you allow adding records from homepage).
Regards,
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: hide the ADD button after one record
Bonjour Jan
Merci !
Your idea is original and I think it is good!
I insert this code into the file matable.php in the HOOK folder.
but that does not work ...
the page displays an error
Merci !
Your idea is original and I think it is good!
I insert this code into the file matable.php in the HOOK folder.
Code: Select all
function ORIENTATION_3_after_insert ($ data, $ memberInfo, & $ args) {
INSERT INTO `membership_userpermissions` (` memberID`, `tableName`,` allowInsert`, `allowView`,` allowEdit`, `allowDelete`);
VALUES ('MEMBERNAME', 'TABLENAME', '0', '1', '1', '1');
return TRUE;
}
the page displays an error
Re: hide the ADD button after one record
- Don't mix up SQL code and PHP code.
- If your table name is "ORIENTATION_3" (without the quotes) you'll have to edit the file ./hooks/ORIENTATION_3.php
- You'll have to replace MEMBERNAME and TABLENAME by current values
- When copying and pasting code, please make sure blanks (space-characters) are in the right place
Code: Select all
function ORIENTATION_3_after_insert($data, $memberInfo, &$args){
$table = "ORIENTATION_3";
$sql = "INSERT INTO `membership_userpermissions`(`memberID`, `tableName`, `allowInsert`, `allowView`, `allowEdit`, `allowDelete`) VALUES ('" . $memberInfo['username'] . "', '" . $table . "', '0', '1', '1', '1')";
sql($sql, $eo);
return $eo == null;
}
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools