Adding more than one owner to the record. Please Help!

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
almaqdad
Posts: 13
Joined: 2013-01-23 07:49

Adding more than one owner to the record. Please Help!

Post by almaqdad » 2013-01-23 07:55

Dear Ahmed,
I have asked you this question before. HOW can I add more than one owner
to the record. I tried manually adding two records in membership_userrecords
table with different members but still it did not work. I guess small changes
needed to be done in PHP Coding that we make appgini to recognize multiple
owners.

Your help in this matter is highly appreciated.

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Adding more than one owner to the record. Please Help!

Post by a.gneady » 2013-01-23 09:41

Hi Almaqdad,

Although the structure of the "membership_userrecords" table does allow multiple owners for each record, the generated code is written in a manner to support only one owner per record. I'll try to review the code to see if supporting more than one record owner is possible in all scenarios and if so, I'll make this change in future releases.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

Maevari
Posts: 5
Joined: 2015-06-14 15:26

Re: Adding more than one owner to the record. Please Help!

Post by Maevari » 2015-11-23 16:54

is there any update on this?

udayvatturi
AppGini Super Hero
AppGini Super Hero
Posts: 85
Joined: 2014-06-14 03:08
Location: India
Contact:

Re: Adding more than one owner to the record. Please Help!

Post by udayvatturi » 2015-11-28 11:08

Hi,
This a great feature that would help lot of people.

You can get this working with this few steps.
Step 1. There is a key ''tableName_pkValue" in membership_users table, that will not allow you to insert multiple records for same primary key and table name. So drop that key
DROP index tableName_pkValue on membership_users

Step 2: There is a line in incFunctions.php file that will create the index even if you drop it, So remove that line.

The line will look something like this

Code: Select all

if(!$membership_userrecords['tableName_pkValue'][1] || !$membership_userrecords['tableName_pkValue'][2]) @db_query("ALTER IGNORE TABLE membership_userrecords ADD UNIQUE INDEX tableName_pkValue (tableName, pkValue)");
By Now the user(2nd or 3rd user) who have permission to a record should see the records in table view. 50% Done.

Step 3: You need to do this in every table file. Here my table name is employees. So in employees_dml.php file i modified 2 lines from

Code: Select all

	$ownerGroupID=sqlValue("select groupID from membership_userrecords where tableName='employees' and pkValue='".makeSafe($selected_id)."'");
		$ownerMemberID=sqlValue("select lcase(memberID) from membership_userrecords where tableName='employees' and pkValue='".makeSafe($selected_id)."'");


to

Code: Select all

$ownerGroupID=sqlValue("select groupID from membership_userrecords where tableName='employees' and pkValue='".makeSafe($selected_id)."' and groupID=".getLoggedGroupID());
		$ownerMemberID=sqlValue("select lcase(memberID) from membership_userrecords where tableName='employees' and pkValue='".makeSafe($selected_id)."' and memberID=lcase('".getLoggedMemberID()."')");
		
Done. I hope this helps.
I tried this and got this working, haven't seen any side effects.

May be ahmad can put this into his build if he feels it wont inject any new issues.

globaldrip8
Posts: 27
Joined: 2015-12-19 03:59

Re: Adding more than one owner to the record. Please Help!

Post by globaldrip8 » 2016-08-06 14:49

udayvatturi wrote:Hi,
This a great feature that would help lot of people.

You can get this working with this few steps.
Step 1. There is a key ''tableName_pkValue" in membership_users table, that will not allow you to insert multiple records for same primary key and table name. So drop that key
DROP index tableName_pkValue on membership_users

Step 2: There is a line in incFunctions.php file that will create the index even if you drop it, So remove that line.

The line will look something like this

Code: Select all

if(!$membership_userrecords['tableName_pkValue'][1] || !$membership_userrecords['tableName_pkValue'][2]) @db_query("ALTER IGNORE TABLE membership_userrecords ADD UNIQUE INDEX tableName_pkValue (tableName, pkValue)");
By Now the user(2nd or 3rd user) who have permission to a record should see the records in table view. 50% Done.

Step 3: You need to do this in every table file. Here my table name is employees. So in employees_dml.php file i modified 2 lines from

Code: Select all

	$ownerGroupID=sqlValue("select groupID from membership_userrecords where tableName='employees' and pkValue='".makeSafe($selected_id)."'");
		$ownerMemberID=sqlValue("select lcase(memberID) from membership_userrecords where tableName='employees' and pkValue='".makeSafe($selected_id)."'");


to

Code: Select all

$ownerGroupID=sqlValue("select groupID from membership_userrecords where tableName='employees' and pkValue='".makeSafe($selected_id)."' and groupID=".getLoggedGroupID());
		$ownerMemberID=sqlValue("select lcase(memberID) from membership_userrecords where tableName='employees' and pkValue='".makeSafe($selected_id)."' and memberID=lcase('".getLoggedMemberID()."')");
		
Done. I hope this helps.
I tried this and got this working, haven't seen any side effects.

May be ahmad can put this into his build if he feels it wont inject any new issues.
I tried and its work for stamdard or parent table, but the problem still exist in child table,can anyone help please?

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Adding more than one owner to the record. Please Help!

Post by grimblefritz » 2016-08-07 13:25

Conceptually, record ownership by more than one user is awkward, and usually attempts to render awkward concepts in code result in awkward software.

How does a record gain more than one owner? For example, if it is created by John, how do Paul, George and Ringo also become owners? Does John grant it? Do they find the record themselves and then lay claim to it? Does an admin have to be petitioned to do everything? How does the system know if a request to own a record is exclusive or shared? Who removes a co-owner? Etc.

It might be easy to hack something together, but to make a robust system that is understandable to everyone (as AppGini must do), and have it work reliably in whatever unique scenario it's used in (as AppGini must do) -- that's much more challenging.

I think the entire security model needs to be reworked. Better Ahmad to do that than to spend his limited time whacking out individual hacks.

globaldrip8
Posts: 27
Joined: 2015-12-19 03:59

Re: Adding more than one owner to the record. Please Help!

Post by globaldrip8 » 2016-08-27 16:47

latest update about this what i got is when you add data from child table it will broke a membership_userrecords table (its awkward just like grimblefritz say
any idea about this?

mysh_eireannach
Veteran Member
Posts: 35
Joined: 2016-02-16 22:31

Re: Adding more than one owner to the record. Please Help!

Post by mysh_eireannach » 2019-11-07 23:08

Hi

I tried adding more than one owner to the record using Udayvatturi method, my AppGini Version 5.81, but looks like code incFunctions.php was change.

Using keywords tableName_pkValue and membership_userrecords I find:

Code: Select all

########################################################################
	function update_membership_userrecords() {
		$tn = 'membership_userrecords';
		$eo = array('silentErrors' => true);

		sql(
			"CREATE TABLE IF NOT EXISTS `{$tn}` (
				`recID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 
				`tableName` VARCHAR(100), 
				`pkValue` VARCHAR(255), 
				`memberID` VARCHAR(100), 
				`dateAdded` BIGINT UNSIGNED, 
				`dateUpdated` BIGINT UNSIGNED, 
				`groupID` INT UNSIGNED, 
				PRIMARY KEY (`recID`),
				UNIQUE INDEX `tableName_pkValue` (`tableName`, `pkValue`(150)),
				INDEX `pkValue` (`pkValue`),
				INDEX `tableName` (`tableName`),
				INDEX `memberID` (`memberID`),
				INDEX `groupID` (`groupID`)
			) CHARSET " . mysql_charset,
		$eo);

		sql("ALTER TABLE `{$tn}` ADD UNIQUE INDEX `tableName_pkValue` (`tableName`, `pkValue`(150))", $eo);
		sql("ALTER TABLE `{$tn}` ADD INDEX `pkValue` (`pkValue`)", $eo);
		sql("ALTER TABLE `{$tn}` ADD INDEX `tableName` (`tableName`)", $eo);
		sql("ALTER TABLE `{$tn}` ADD INDEX `memberID` (`memberID`)", $eo);
		sql("ALTER TABLE `{$tn}` ADD INDEX `groupID` (`groupID`)", $eo);
		sql("ALTER TABLE `{$tn}` CHANGE COLUMN `memberID` `memberID` VARCHAR(100)", $eo);
	}
I need adding more than one owner to record table: projects_dml.php

Please help, what I need to change at incFunctions.php file to have more than one owner for one record.

charmed_ones
Veteran Member
Posts: 32
Joined: 2013-03-22 13:31

Re: Adding more than one owner to the record. Please Help!

Post by charmed_ones » 2023-11-22 12:49

has there been a development on this? I have a very big need for different users to have access to the same records.

Post Reply