Re: Ridiculous User Management Head Melt

2007-09-05 Thread dardosordi

Consider this differents patterns for mapping inheritance to sql
tables:

http://www.martinfowler.com/eaaCatalog/singleTableInheritance.html
http://www.martinfowler.com/eaaCatalog/classTableInheritance.html
http://www.martinfowler.com/eaaCatalog/concreteTableInheritance.html

On Aug 10, 3:12 pm, Sonic Baker [EMAIL PROTECTED] wrote:
 Hey Geoff,

 Thanks very much for the replies. Think I have it all straightened out in my
 head now.

 Cheers,

 Sonic


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Ridiculous User Management Head Melt

2007-08-10 Thread Sonic Baker
Hey Geoff,

Thanks very much for the replies. Think I have it all straightened out in my
head now.

Cheers,

Sonic

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Ridiculous User Management Head Melt

2007-08-08 Thread Geoff Ford
Hi Sonic,

Glad I could help - see my comments below.

Geoff

On 8/9/07, Sonic Baker [EMAIL PROTECTED] wrote:

 Hey Geoff,

 Thanks for second the reply dude, and thanks even more for your level of
 detail with your thoughts. The profile stuff is clear to me now and I'll be
 adapting my current Models to use an abstract factory on asap. The only
 thing I'm having trouble with now is how to know which account a user
 belongs to when they log in. (please see below)


 On 8/8/07, Geoff Ford [EMAIL PROTECTED] wrote:
 
 
  Customer hasMany Accounts - a customer is a User with a
  CustomerProfile


 Yep, that's what I have.

 Account belongsTo AccountAdmin(admin), AccountManager(manager_id),
  BillingContact(billing_contact_id)  (which are users)



 Aha, we're on the same page here too.

 I would keep the accounts table the way you have it now as I think the
  above associations is more correct than User belongsTo Account.


 Ok, see this is where the trouble comes in. If I just leave the
 'billing_contact_id' and 'account_manager_id' in the `accounts` table and
 don't have an 'account_id' in the User's `external_profiles` table, then how
 will I know what Account a BillingContact is trying to access when they log
 in?
 I'll have to search through the Account's for one who's
 'billing_contact_id' is the same as the 'user_id' who logs on. That seems
 like a bit of a waste when an association could take care of it. Have I
 picked you up wrongly on this point?


Here is where Cake is really flexible - you can create the association in
Profile like ExternalProfile hasOne Account and then specify the foreign key
as billing_contact_id.  If you are using the same profile model for all
three account user types you will have to look into Model::bind() and
Model::unbind() to create this association as needed, and adapt the foreign
key to the user type.


Man I love complex data models and associations.  There are so many
  different ways you can model them and everyone has a different idea as
  to waht is correct.


 I love it too. Unfortunately, I don't have many people who are also into
 it and who I can run my thoughts by. It can get a bit messy inside one head
 :)


I know what you mean :) It can get lonely in your own head sometimes -
especially when you can't quite get it the way you want it :)

Feel free to say that eveything I just wrote is
  crap and wont work in your situation. :)


 I think most of it'll be perfect. I just hope I haven't thrown a spanner
 in the works on the logging in thing. What do you think?

 Cheers,

 Sonic


 



-- 
http://lemoncake.wordpress.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Ridiculous User Management Head Melt

2007-08-07 Thread Sonic Baker
Hi Geoff,

Thanks very much for your response. Just got to view it now. I'll have a
look into your suggestions but they sound good.

On 8/2/07, Geoff Ford [EMAIL PROTECTED] wrote:


 I hope this seems clear enough.


On the permissions and profiles, I think so. Just to clear another part up;
Am I right thinking that the `users` table will have an 'account_id' which
is only set if the user is an account user. This can be used in the factory
method for Account Users and ignored in the factory method for System
Users. Or can you suggest a better way?

The way it is at the moment; the `accounts` table has fields for the Billing
Contact's name, email, and phone number as well as similar fields for the
account owner (admin) and manager. I could still just leave the
'billing_contact_id' and 'manager_id' in the `accounts` table but there
wouldn't be any need if I had the 'account_id' in the users table.
However this setup would imply that it's possible for an Account have Many
BillingContact's and Managers etc.. whereas the current setup is more hasOne
oriented. I suppose I could restrict it to one in my application logic. Any
thoughts?

Thanks again for your help,

Sonic

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Ridiculous User Management Head Melt

2007-08-07 Thread Geoff Ford

Heres what I was thinking:

User hasOne Profile - Profile is a factory model that loads
StaffProfile, ManagementProfile or CustomerProfile,
AccountAdminProfile, AccountManagerProfile, BillingContactProfile.
The profile model can hold all the common data (address, phone etc)
and the specific profile holds all the extra data, but doing this will
require some extra associations e.g. XXXProfile belongsTo Profile.  If
the profile_id in the user table is not set then you obviously won't
be loading any Profile data.  This is very close to what you have with
the staff_members and managment_members tables. Just call a Profile a
Member and I think you have the db structure.  YOu do not need a
profile for every user type if you don't want - you could get away
with InternalProfile and ExternalProfile or whatever you think is
appropriate.

Customer hasMany Accounts - a customer is a User with a
CustomerProfile

Account belongsTo AccountAdmin(admin), AccountManager(manager_id),
BillingContact(billing_contact_id)  (which are users)

I would keep the accounts table the way you have it now as I think the
above associations is more correct than User belongsTo Account.

Man I love complex data models and associations.  There are so many
different ways you can model them and everyone has a different idea as
to waht is correct.  Feel free to say that eveything I just wrote is
crap and wont work in your situation. :)

Geoff
--
http://lemoncake.wordpress.com



On Aug 8, 6:20 am, Sonic Baker [EMAIL PROTECTED] wrote:
 Hi Geoff,

 Thanks very much for your response. Just got to view it now. I'll have a
 look into your suggestions but they sound good.

 On 8/2/07, Geoff Ford [EMAIL PROTECTED] wrote:

  I hope this seems clear enough.

 On the permissions and profiles, I think so. Just to clear another part up;
 Am I right thinking that the `users` table will have an 'account_id' which
 is only set if the user is an account user. This can be used in the factory
 method for Account Users and ignored in the factory method for System
 Users. Or can you suggest a better way?

 The way it is at the moment; the `accounts` table has fields for the Billing
 Contact's name, email, and phone number as well as similar fields for the
 account owner (admin) and manager. I could still just leave the
 'billing_contact_id' and 'manager_id' in the `accounts` table but there
 wouldn't be any need if I had the 'account_id' in the users table.
 However this setup would imply that it's possible for an Account have Many
 BillingContact's and Managers etc.. whereas the current setup is more hasOne
 oriented. I suppose I could restrict it to one in my application logic. Any
 thoughts?

 Thanks again for your help,

 Sonic


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Ridiculous User Management Head Melt

2007-08-01 Thread Sonic Baker
   !-- @page { size: 21cm 29.7cm; margin: 2cm } P { margin-bottom: 0.21cm }
--

Hi Bakers,
I have a problem and I could really use some advice.
Apart from having multiple types of groups defined in my ACL's I want
certain users to have extra associated information.

For example:

  General Staff:

Staff members have a home addresses and a Tax number


  Management:

Management will have a home addresses, a Tax number and a Vehicle


  Customers:

When a customer registers they will be the administrator of their
accounts. A Customer can register many Accounts. Once registered, they will
be allowed to (or required to) register 3 different types of users for each
account. Each Account user will have different permissions for accessing
areas of the account back-end and each account user will also have different
types of additional information associated with them.


The 3 types of account user are:
  admins - have access to all functionality
  managers - can view stats and use basic functionality
  billing contacts - can view invoices


Account Admins will have a phone number, fax and email
Account Managers will have a phone number, alternative phone number, fax and
email
Account Billing Contacts will have a phone number, and email

There is a table for `customers` and a table for `accounts`.

  Customer hasMany Account


So far the `accounts` table holds the info about the all three types of
account user.


There is a separate table for `staff_members`.

  StaffMember hasOne Address


There is a separate table for `management_members`

  ManagementMember hasOne Address

  ManagementMember hasOne Vehicle


Now I'm trying to implement the Auth and ACL stuff. I left this till I had
some base functionality down as I was going for most business value first.
I'm trying a few different types of CakePHP Auth and ACL systems to see
which will be the most suitable. I see now that a single  `users` table is
required.

So when a user logs in, I'll want to check what group they belong to. If
they are of type:

  Staff:

I'll want to access their extra information from the Staff and
associated Address models.


  Management:

 I'll want to access their extra information from the Management and
associated Address and Vehicle models.


  Account Admin, Manager or Billing Contact:

 I'll probably want an 'account_id' in the User model and look in the
relevant Account to get their extra information like phone numbers etc. This
will mean having the account_id set to '0' for StaffMember and
ManagementMember because they will not have accounts in the sense a Customer
can.

It all seems a bit ridiculous to me now. It's starting to melt my head to be
honest. Can anyone see an alternative arrangement which would take care of
my requirements. I was considering the Subtype/Supertype method on the User
model but this could bet messy also.

I'd really appreciate any help of suggestions.

Cheers,

Sonic

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---