Ok i have begin coding on a classified module.
But i need some more field in the user profile like streetaddress and phone and so on.
Im not afraid to do some changes in the core code but if there is any simple way to do it?
Im missing som documentation on the api is there some? Link?
Mvh
Patrik
Currently this requires some modifications in the source. If you want to have this kind of loose coupled, you can create a specific member class that inherits from the Cuyahoga user and map that class via a joined-subclass construct. This has worked well for me in the past.
Hmm.. I have done some addition in my system it is now easy to add more info... Thanks for you answer. And a well done framework...
/p
Hi,
I hope you don't mind, but i have a similar requirement but don't feel i have the answer i need yet.
What i want to do is create a newsletter subscription module. My idea was to make it so that when a member subscribes, they effectivley become a user on the system, thus allowing them to login and modify there settings.
As part of this, i require those users to provide specific information that isn't currently stored against the user.
Martijn, could you please expend on the joined-subclass method? And as you mentioned thats it has worked well for you in the past, is there any way you can post an example?
Many thanks
Matt
D3gradeMartijn, could you please expend on the joined-subclass method? And as you mentioned thats it has worked well for you in the past, is there any way you can post an example?
Here's an example: we have a class Participant that extends User. This is the mapping (only relevant parts):
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<joined-subclass
name="MyNamespace.Participant, MyAssembly"
table="Participant"
extends="Cuyahoga.Core.Domain.User, Cuyahoga.Core"
">
<key column="ParId" />
<property name="Guid" column="Guid" type="String" length="40" not-null="true" />
<property name="CompanyName" column="CompanyName" type="String" length="100" not-null="true" />
<property name="CompanyContact" column="CompanyContact" type="String" length="100" not-null="true" />
<property name="Phone" column="Phone" type="String" length="20" not-null="true" />
<property name="PreferedCulture" column="PreferedCulture" type="String" length="8" not-null="true" />
</joined-subclass>
</hibernate-mapping>
One important thing is that the PK of the Participant table (key column="ParId) is also the foreign key to the cuyahoga_user table, so it's not an autonumber type.
From the code, you can do everything with the Participant class like any other class. NHibernate ensures that all updates, inserts, joins, etc. are being done properly on both the cuyahoga_user table and the Participant table.
To recall that users details then, the user would login, and when they use the edit subscription module that would get the custom user object based upon the id of the currently logged in user object?
Good question, I don't know exactly anymore if you get the custom user directly.
If I remember well, there was also an extra httpmodule involved in this scenario that did some extra logic related to the custom user (more or less overruling the standard authenticationmodule).
ok, i think i get what you mean. Dunno if it's in my skillset yet, but will definatley give it ago.
Still have some other questions, but dunno how they apply yet, so i'll do some investigation and see if i can figure them out first.
Cheers martijn
Martijnb
do you have maby a sample i am new to hibernate.
thanks
Marcel
Unfortunately, I have no complete sample of this. What problems are you facing? The mappings of the joined-subclass?
[class name="Cuyahoga.Modules.InterAction.Domain.WebUser, Cuyahoga.Modules.InterAction" table="tablename"]
[id name="Id" column="userid" type="Int32"]
[generator class="foreign"]
[param name="property"]User[/param]
[/generator]
[/id]
[one-to-one name="User" class="Cuyahoga.Core.Domain.User, Cuyahoga.Core" cascade="all"/]
[property name="InfoMailing" column="infomailing" type="Boolean" not-null="false" /]
[/class]
*Replace
[ for
< and
] for
>
martijnbUnfortunately, I have no complete sample of this. What problems are you facing? The mappings of the joined-subclass?
i whant to create a custom registration page and profile page. With more information of the user.
Alright. You can create a new module that does this.
The module needs to have to views: one for registration and one for the profile. In the module controller, you can create the logic for registration and profile. Take the existing ProfileModule.cs as an example (/Modules/User/ProfileModule.cs).
For the extra user information, create a new class (MyUser). Now there two options how you can relate that class to the Cuyahoga user:
- Inherit it from the Cuyahoga user and map it via a joined-subclass construct
- Or do as YKS mentioned: don't inherit from, but add a reference to the Cuyahoga User
With the help of info in this thread and the
module development guide it shouldn't be too hard.
Don't hesitate to ask for more here if you're stuck.
if you use a joined class you must change Cuyahoga.Domain.User mapping and class.If you make this you dont have compatibility with the future versions of cuyahoga.
YKSif you use a joined class you must change Cuyahoga.Domain.User mapping and class.If you make this you dont have compatibility with the future versions of cuyahoga.
You can also define a joined-subclass in a separate file. No need to change the Cuyahoga user.
Please you can write class (.cs) for this joined-subclass?
You can use this joined subclass with User.Participant.Property¿?
YKSPlease you can write class (.cs) for this joined-subclass?
public class Participant : User
{
private string _companyName;
private string _companyContact;
private Address _postalAddress;
private Address _visitingAddress;
private string _phone;
...
You can use this joined subclass with User.Participant.Property¿?
No need for a property because Participant is a User via inheritance.
You can write a hql or criteria example for obtain a participant object from bbdd? How you obtain the current participant¿? Can I use this?
(MyNamespace.Participant)Page.User.Identity;
Thanks for your help and sorry for my poor english
YKSYou can write a hql or criteria example for obtain a participant object from bbdd?
string hql = "from Participant p where p.Id = :userId"
The userId parameter represents Id of the Cuyahoga user.
How you obtain the current participant¿? Can I use this?
(MyNamespace.Participant)Page.User.Identity;
Yes, create a new httpmodule that handles the authenticaterequest event. In that event, load the participant (userId is HttpContext.Current.User.Identity.Name) and replace the HttpContext.Current.User.Identity with the Participant.
Thanks for your help
Yes, create a new httpmodule that handles the authenticaterequest event. In that event, load the participant (userId is HttpContext.Current.User.Identity.Name) and replace the HttpContext.Current.User.Identity with the Participant.
How make it¿? Can you write this code too :-) ?