Howto Clone core features?

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
1/5/2011 1:43:08 AM
Gravatar
Total Posts 92
Нет, я не изменил. До старости глубокой...

Howto Clone core features?

Dear Joe,
In Mojo documentation, where you explained how to clone some Mojo features, but you did not explain how to modify some core features and here I have a question:


http://www.mojoportal.com/user-registered-event-handlers.aspx
http://www.mojoportal.com/user-sign-in-event-handlers.aspx
http://www.mojoportal.com/cloning-an-existing-feature.aspx
 

If I need to force the user after he logged on to go to some x page if he did not apply some features, I put my code in the SiteLogin.cs at Controls in the Core, but I did not know how to clone it, here is my code:
I also may need to change the user administration so I will give this user rights to add “his users or seats to start working on his project”
//check if he bought a package or not?
//if no, keep redirecting him to products page

if (siteUser.UserId > -1)
{
if (siteUser.AdminDelegate == true && !siteUser.HasBoughtPackage)
{
this.DestinationPageUrl = siteRoot + "/WebStore/ProductList.aspx";
}
}
Please note that I added new 2 properties to the user account (AdminDelegate and HasBoughtPackage)
The question:
Where to put this code so I can later modify the mojoPortal, also if I want to change a feature in the core, should I separate it in a standalone project and disable mojo feature or how?

Thanks
 

1/5/2011 11:17:42 AM
Gravatar
Total Posts 18439

Re: Howto Clone core features?

Hi,

Cloning features only applies to features that plug into the content system and is a way to modify them without losing the ability to upgrade.

I don't recommend making any modifications at all to mojoPortal code, if you do that you have created a fork and it will be difficult for you to ever upgrade. All of your custom code should be in your own projects.

You could implement redirect logic upon login in a user sign in event handler.

You should not be adding properties on siteUser nor adding columns to the table or modifying any mojoPortal code. Instead you should create your own table for those custom fields and create your own object like userExtensions and add your custom properties to your own object and populate it with your own code from your own table. You can keep your extensions associated to the mojo SiteUser by the userid or userguid which you store in your own table. In your custom sign in handler you get a reference to the siteUser then you could use the user id to lookup your own custom object.

If you really need to customize the login page (which you don't in this case in my opinion), you could create your own custom page in your own project then use a post build event to copy it up and replace the mojo version of the page. This would mean that you always have to deploy your own custom build but it keeps you from modifying mojoPortal code so you are able to always pull the latest change sets from the mojoportal source code repository.

Any time you find yourself about to make changes in mojoPortal code you should stop and try to think of a creative way to accomplish your goal without doing that. The solution will vary from case to case depending on what you are trying to accomplish and you are free to ask here and explain what you are trying to do and we "may" be able to help you come up with an idea.

Hope it helps,

Joe

1/5/2011 12:06:08 PM
Gravatar
Total Posts 19

Re: Howto Clone core features?

Maybe a small module that does the job somewhere on front page without visible controls? If the user is logged in and has not bought a package yet,the code will redirect him to the products list (Although i admit that i would find it disturbing as a visitor).

It's not a good idea to mess with the core since you do not want to extend anything existing. Imagine having to rewrite things when updates come out. Modules are portable and upgrade-friendly. 

Even if you decide to do changes to the core , my opinion is to keep the core classes intact. I am trying to make a small extension to the profiles and i create my own classes separately from the core, following how the rest is written. Try to add, not to modify. 

1/5/2011 1:27:56 PM
Gravatar
Total Posts 92
Нет, я не изменил. До старости глубокой...

Re: Howto Clone core features?

Ok, understood, thank you.

Griever, I need this feature, and the visitor will not suffer from it, only the users who need to work on projects will need this feature (I am creating a small Administrator User who will work o his projects and create his users for that project.. etc  and so, he must buy a package to complete his job) and they have to check a box while they are registering, other users will leave this check box unchecked.

 

Thank you a lot for your reply, you are the best

You must sign in to post in the forums. This thread is closed to new posts.