Page 1 of 1

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

Posted: 2013-01-23 07:55
by almaqdad
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.

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

Posted: 2013-01-23 09:41
by a.gneady
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.

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

Posted: 2015-11-23 16:54
by Maevari
is there any update on this?

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

Posted: 2015-11-28 11:08
by udayvatturi
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.

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

Posted: 2016-08-06 14:49
by globaldrip8
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?

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

Posted: 2016-08-07 13:25
by grimblefritz
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.

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

Posted: 2016-08-27 16:47
by globaldrip8
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?

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

Posted: 2019-11-07 23:08
by mysh_eireannach
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.

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

Posted: 2023-11-22 12:49
by charmed_ones
has there been a development on this? I have a very big need for different users to have access to the same records.