Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Transaction Patterns » VPD - PopUp (changing IN clause)
VPD - PopUp [message #5799] Wed, 03 August 2016 06:28 Go to next message
htManager is currently offline  htManager
Messages: 179
Registered: May 2014
Senior Member
Hi Tony,

is it possible to see in a popup screen more than the allowed records as defined in the IN clause of the generated SQL query ('1', 'x')?

The system with VPD works fine but I want to release records from other account 'channels'.

I have a table where I can release the channel for other VPD accounts with the following structure:

channel_id (pk), account_id (pk), release start, ... where account_id is the system rdcaccount_id.

The popup should include the records from channel_id. I tried to change the SQL query in the (popup1).php but I didn't succeed because of the automatic generated IN clause which only allows shared accounts and the logged in account.

The 'channel' contains records which I want to release for a certain time.
Re: VPD - PopUp [message #5800 is a reply to message #5799] Thu, 04 August 2016 04:55 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2055
Registered: April 2006
Location: Surrey, UK
Senior Member
I do not understand what you want to do. When you are using the rdcaccount_id facility the rules are quite clear:
1) Any entry with rdcaccount_id=1 is shared and can be viewed (but not updated) by a user whose rdcaccount_id>1
2) Any entry with rdcaccount_id>1 is private to that account and can only be viewed/modified by users in that account.

It is not possible to make accounts other than #1 sharable.


Re: VPD - PopUp [message #5801 is a reply to message #5800] Thu, 04 August 2016 09:12 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 179
Registered: May 2014
Senior Member
I know that only accounts with #1 are sharable. But I want the account owner to temporarily (start date, end date) grant access (view rights only) to an account > 1. This account functions as a 'lookup' account. So data has to be stored only once.

I read your article about Virtual private database and how you described in #5 how you altered the code for reading from the database:

else {
// read the user's account and the shared account
$account_id_string = "$this->tablename.rdcaccount_id IN ('1', '$account_id')";
}

My problem would be solved if there would be a possibility to select records from more than one account > 1.

i.e.: if ($pattern_id = 'popup'){
$account_id_string = "$this->tablename.rdcaccount_id IN ('1', '$account_id', '$account_id_additional'')";
}

where $account_id_additional would be some other selected accounts like ('8', '15', 'nnn')

The account owner can grant these (reading) access rights via a table. It would then be possible with a popup to choose data from that account.
Re: VPD - PopUp [message #5803 is a reply to message #5801] Fri, 05 August 2016 04:28 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2055
Registered: April 2006
Location: Surrey, UK
Senior Member
Only account #1 is sharable among other account holders. Anything with an account > 1 can only be viewed and used by members of that account. To change this would open up a huge can of worms, so it will never happen. To make something sharable you add it to account #1.

Re: VPD - PopUp [message #5808 is a reply to message #5803] Fri, 05 August 2016 06:19 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 179
Registered: May 2014
Senior Member
Do you have an idea how I could solve this problem? Would it be possible to query these records outside the framework and add it to the fieldarray before opening the popup screen? Or is there a mechanism that will prevent this?
Re: VPD - PopUp [message #5810 is a reply to message #5808] Fri, 05 August 2016 09:36 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2055
Registered: April 2006
Location: Surrey, UK
Senior Member
I have already told you that if you want records with rdcaccount_id > 1 to become sharable among other accounts then the only way to achieve it is to set their rdcaccount_id's to 1. If you attempt any other mechanism it will be unsupported.

Re: VPD - PopUp [message #5821 is a reply to message #5810] Fri, 12 August 2016 10:48 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 179
Registered: May 2014
Senior Member
Sorry for replying once again but I want to tell you how I solved my problem - at least I think that this is a solution. I had to do this because the temporary release of (part of) accounts is a main feature of my application. Without this feature I had to store data more than once and this would be very unconvenient.
I do know that this is unsupported and outside the framework.

I created two functions in a htm.general.inc file in my includes_htm directory. One for setting an entry in $_SESSION($additional_accounts) and one for unset this entry.
I changed code in _sqlAssembleWhere() and _sqlAssembleWhereLink() with the following:

if (!empty($_SESSION['account_additional_id'])){
$account_additional_id = $_SESSION['account_additional_id'];
$account_id_string = "$this->tablename.rdcaccount_id IN ('1', $account_additional_id, '$account_id')";
} else {
$account_id_string = "$this->tablename.rdcaccount_id IN ('1', '$account_id')";
}

Thus each user can decide for himself if he want to share his (account) channel with others and how long. I did notice that it isn't easy to get the problem solved. I also experienced that I could solve this problem only with 'hard coding' in my functions and that this would be very very difficult for you (as you mentioned) to solve this in Radicore. At the moment it works fine for me but I do not know if there are situations which I do not know and where users can have access to accounts where they shouldn't. But at the moment I am happy that I got it running. If you have an advice for me, please let me know.
Re: VPD - PopUp [message #5823 is a reply to message #5821] Sat, 13 August 2016 05:27 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2055
Registered: April 2006
Location: Surrey, UK
Senior Member
You are bending the system to work outside of its design parameters, which is never a good thing. If you want to take set on "unshared" records and make them "shared" then you should implement a mechanism to copy them to the "shared" account. This would NOT require any changes to any framework code and therefore would not cause unexpected problems down the line.

Re: VPD - PopUp [message #5824 is a reply to message #5823] Sat, 13 August 2016 06:31 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 179
Registered: May 2014
Senior Member
Thank you for the advice. I thought of it but I have no experience in implementing such a mechanism. Do you have an example where I could see how it works? If I could implement such a mechanism I would immediately change my code.
Re: VPD - PopUp [message #5825 is a reply to message #5824] Sun, 14 August 2016 12:31 Go to previous message
AJM is currently offline  AJM
Messages: 2055
Registered: April 2006
Location: Surrey, UK
Senior Member
That to me is just simple programming. You read in a bunch of records, change some values, then update them in the database.

Previous Topic: Filepicker
Next Topic: Introduction to Transaction Patterns within Radicore
Goto Forum:
  


Current Time: Fri Aug 18 02:54:07 EDT 2017

Total time taken to generate the page: 0.04299 seconds