Some new stuff on my path

Several new stuff has come on my path the last weeks. Starting last week with 2 new colleagues…. from Minsk, Belarus. Together with another 2 guys they are about to start LECTRIC Minsk. Welcome Aliaskei Uladzimir(hope I spelled both names well)! The most important task this weeks is to get ‘m familiar with us, the LECTRIC culture, the colleagues and let them work with Sitecore. Yesterday they passed the Level 1 exam, hopefully tomorrow the Level 2.
Speaking about Level 2, I’ve to finish that one finally too. And tomorrow will also be that day! Guess I’ll be able to pass the exam, but hopefully my score will be sufficient enough ;-). As we’ve got lot of people who had to pass the exam, we’ve decided to do another course which was today. The members form the Sitecore team, who participated, Max, Ben & Martijn, passed the exam. Congratz! Hopefully we can add Castor(a new guy), Sjoerd, Aliaksei, Uladzimir and myself to that list tomorrow.

But as the training days have started today, Paul, one of our managers, decided to take us out for dinner. Kerry Bellerose, the trainer from Sitecore also participated. He’s a nice guy and he’s also really funny. I guess everybody had a good time :). Thank you Kerry for your time to share with us. I really appreciate it :).
The struggling thing about the trainings is that I’ve arranged ‘m. Not everything went that easy, but most of it did. I’ve got a checklist now for next time. Some other stuff to arrange is LECTRIC 10yr. Yes we’re celebrating. In November we went to Berlin, and now we’ve to arrange a final party. And yes who’s in charge? Exactly. It takes a lot of time….

As that isn’t good enoug I’ve started my last year @ school which means I’ve to do some final big project and hopefully at around January next year or, in worst case, June, I’ve graduated. I’ve to provide a final project to the university which is valuable enough for my personal employment. Don’t know what to select. I’m thinking about creating a Sitecore based ‘something'(DSL’s?), or select a project @ LECTRIC or…. Well I do not know yet. Any suggestions are definitelly welcome! It can be both practical or research so share your thoughts and ideas… please?

Then, I want to announce, I’m going to leave Team Sitecore @ LECTRIC for a while. I’m going to join the team who creates excellent solution with the system SmartSite. SmartSite is still VB6, which is very ugly poor old technology, but the reason for me to do that is to get a better view about Content Management which is becoming more and more a main process in the daily business world. Don’t worry, I’ll continue blogging about Sitecore. I even received 2 week returning in our Project Schedule! So I’ll spread the word inside LECTRIC, on the blog, etc. I might will change my look a little, but that can only improve the product, don’t you think?
I’ll take some time for more CMS’s such as Umbraco, Typo3, SmartSite, GX, MediaSurface, Reddot and Tridion as well(all before the summer ofcourse…). And thinking about creating my own matrix. Till now, Sitecore always has the best scores, but this might change? I will not doubt about that looking at the current development, plans and public roadmaps….

That’s again way enough about my daily adventures. The last 2 things I want to share with you before I go to sleep:

  • Read this incredible funny and wise article about programmers who can’t read. Sometimes I’m really like that…
  • Sorry Jacqueline, we’ve been talking about Document Management en Security Management last week and this monday, I’m going to finsih the article… I promise! But not before friday… Sorry again! It’s worth sharing but the article should be at least at the same quality our discussion/conversation was!

Software how software shouldn’t be: Acrobat Reader

Since last thursday I’ve got a brilliant new notebook. It’s incredible fast and even quite good looking. Till today I was pretty happy with all the stuff I’d to install. Starting with the regular developer tools till stuff to make it possible for me to blog. But just 10 minutes ago I became very sad… I had to install Acrobat Reader.

What a terrible piece of software! You have to download 20 Mb for a Reader? The past versions maked my machines always crash and  navigating trough PDF-files is always horrible and slow. Adobe, please tell me why? Why not create a tiny and fast viewer such as the Visio 2007 Viewer is? Or even better Irfanview for PSDs. And I don’t have to talk about the plugin in Acrobat Reader, have I? And the past, 7 version, didn’t stop its process when you opened a file from the internet and moved away from it.
Well, a small light at the end of the tunnel: poort version 7 is replaced by version 8. Hopefully, they have realized they should improve a lot, but that would be the first time for Adobe…

Security issue in the client

In this topic on SDN forum, we came to the conslusion that every use who can access the User Manager, also canmake himself and any other user Administrator.
This problems is caused by the User Editor where all fields, the user contains, are readen and displayed. This allows you add additional fields which are aditable, really quickly(you can do in the file ‘Security Templates.xml’ located in /Website/sitecore/shell).

But the problem is, the Administrator checkbox is also a field… As this is a quite heavy exploit for some users, I’ve decided to create a patch. Ofcourse this isn’t an official patch, but it works at least.

So how did I solve it? Well… first of all I’ve located the XAML file:
/sitecore/shell/applications/security/Edit user/Edit user.xml
Inside this file, I found the following CodeBeside tag:
<CodeBeside Type=”Sitecore.Shell.Applications.Security.EditUser.EditUserForm,Sitecore.Client”/>
At that moment I edpho that I would be able to override a single method, to change the behaviour of the control. So I opened the EditUserForm using the cool 5.0 version of Lutz Roedder Reflector. And looked at the  following Disassembled code in the OnLoad method:

After running trough this code I decided it would be way to much work te rewrite it. I should have to rewrite anything which is a lot of work as copying disassembled code is not done as it onle results in not readible code => bugs.
The resolution for this problem was quite easy. First I want to do the original method do it’s work and later on, in an overriden method, I just had to disable the Checkbox when the user isn’t an Administrator. This resulted in the following code:

    1 using Sitecore;

    2 using SCU = Sitecore.Shell.Applications.Security.EditUser;

    3 using MSUI = System.Web.UI;

    4 using Sitecore.Web.UI.HtmlControls;

    5 

    6 namespace Sitecore.ShellExtensions.Applications.Security.EditUser

    7 {

    8     class EditUserForm : SCU.EditUserForm

    9     {

   10         private static bool EnableAdminToggle

   11         {

   12             get { return Context.User.IsAdministrator; }

   13         }

   14         protected override void OnLoad(System.EventArgs e)

   15         {

   16             base.OnLoad(e);

   17             if(!Context.ClientPage.IsEvent && !EnableAdminToggle)

   18             {

   19                 MSUI.Control adminControl = Fields.FindControl(“Administrator”);

   20                 Checkbox checkbox = adminControl as Checkbox;

   21                 if (checkbox != null)

   22                 {

   23                     checkbox.Disabled = true;

   24                 }

   25             }

   26         }

   27     }

   28 }

 As you can see, because of the duplicate classes in the used namespaces, I had to make ‘m unique. This is done using aliases(using [alias] = [namespace]).
So now the code is written, I’ve to add it to the control. Actually, I don’t want to edit the control at all as in the following version of Sitecore it can be way changed. So I’ve decided to copy the XAML file to the override-folder of Sitecore which is located in /sitecore/shell/override/. After copying, I change the CodeBeside tag so it reffers my newly created class:
<CodeBeside Type=”Sitecore.ShellExtensions.Applications.Security.EditUser.EditUserForm,Sitecore.ShellExtensions”/>

Afterwards, I’ve created a package and released version 0.1 of my Extensions, but wile writing, I realised the New User wizard has the same problem. Therefor, I’ve created the following overriding code:

    1 using SCU = Sitecore.Shell.Applications.Security.CreateNewUser;

    2 using MSUI = System.Web.UI;

    3 

    4 namespace Sitecore.ShellExtensions.Applications.Security.CreateNewUser

    5 {

    6     class CreateNewUserForm  : SCU.CreateNewUserForm

    7     {

    8         private static bool EnableAdminToggle

    9         {

   10             get { return Context.User.IsAdministrator; }

   11         }

   12         protected override void OnLoad(System.EventArgs e)

   13         {

   14             base.OnLoad(e);

   15             if (!EnableAdminToggle && Administrator != null)

   16             {

   17                 Administrator.Disabled = true;

   18             }

   19         }

   20     }

   21 }

Again I’ve copied the original XAML file to the override folder and here are the (visual) results. You can click on the image to see the images in the original size:

As you could see this wasn’t rocket-sience. I wouldn’t even say it was sience at all. These enhancement can be easily made by anyone who is able to create a .NET Class Library project.
As mentioned in the topic, this is also submitted to the Core team. Hopefully, they will changing this behaviour in the upcoming version. Until this version is released, you can:

Have fun :).

Btw: Neither LECTRIC, Sitecore or myself is responsible for any harm caused by this fix/extension. You are responsible for testing everything on your development environment and for installing it in a right way. Hope that’s clear 🙂

Joe White’s ReSharper tips

As I know a lot of you guys use ReSharper, at least the whole Sitecore team does. From Core development to the Support team to the Trainers/Solutions Architects, all of them think it’s a really valuable product. And so do I. I’m even going to recommend it to the Teamlead’s @ LECTRIC, to buy a license for all .NET developer although the quote of $249 is a bit to high in my opinion.

But ReSharper is only usefull when you take so time to get used to the advanced shortcuts it’s offering. Joe White gives, during a whole month(=31 days), every day a set of tips how to use ReSharper. He’s already reaching the end of the month(last friday was day 23), but all posts remain ofcourse online. You can find the full updated list of tips and hints here. Have fun reading!

Typo3 : Finally the right way?

The last weeks I’ve been struggling with Typo 3. It’s a PHP CMS which has a big community and lots of fans over the world. And as Umbraco and Sitecore are, Typo3 is originally from Denmark.

During the last weeks I’ve had several problems with the system. It’s not that it isn’t working, but I’m missing the amount of control I’m used to with other systems. Such as Umbraco and of course my favorite ;). It takes to long to describe all my problems now, but what Ithe positive words I want to share is way more important: The Typo3 core-team is redesigning their solution! Last weekend, they’ve had a core-team meet from which the results can be found here.

Typo3 5.0 Layered Architecture draft

They have talked about all kinds of developing a product, from the code base to architecture, from maintenance to infrastructure, all parts are discussed and I’ve to say: I’m impressed! During the last days they’ve also updated the roadmap. Some of the most interesting topics on it:

  • Milestone 1: The core system will be redesigned, the full content structure is going to change and becomes platform/database indepentdant en very puggable.
  • Milestone 1: All the core parts will be developed using a Test Driven Developement approach.
  • Milestone 2: The full security model will be recreated
  • And finally in milestone 3: Recreation of the ugly unflexible, inbelievable horrible template engine ;). Also a redesign of TypoScript.
  • Milestone 4: Rebirth of the client. Some people compare the current client to a ugly beast.

I’m pretty happy they have realized this really has to be done, And as I take myself way to serious, I’m going to write the developers a white paper including all my problems, suggestions, etc. The letter will include some highly remommendations for TypoScript, Template engine and the way Extensions are built and defined. Hopefully they will take the time to read it. You can expect the white paper by the end of next week.

The Typo3 teamhttp://news.typo3.org/news/article/results-of-typo3-50-meeting-in-berlin/

Last but not least… Why??? You supposed to write Sitecore modules! Yep yep, you’re right and there are some upcoming, but the reason to do this is quite simple:
First of all, I like the way those guys work, they meet each other on a weekend off in Berlin, discuss, go home with some excellent ideas, work ‘m out and present ‘m to the world. That’s the way I like open source!
And second as a reward for the platform they deliver for the solution I’m implemention in my spare time as a volunteer for a Jazz Festival.

If anyone want to contribute, feel free to drop a comment or sent me an e-mail.

Restoring your Sitecore databases using SQL2005

Everytime I receive databases from customers, (support-)team members, etc, it’s always the same story… Restoring… Grrr… Sitecore has the incredible cool tool called MS SQL Database Restore Tool, but sometimes you just have to run a simple SQL script because you haven’t got any right to run a program, or don’t want to. So I’ve created a simple restore script:

RESTORE DATABASE [sc53Archive] FROM DISK = N’D:\Backup\sql\SC53ARCHIVE_DATA.bak’ WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10
RESTORE DATABASE [sc53Core] FROM DISK = N’D:\Backup\sql\SC53CORE_DATA.bak’ WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10
RESTORE DATABASE [sc53Extranet] FROM DISK = N’D:\Backup\sql\SC53EXTRANET_DATA.bak’ WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10
RESTORE DATABASE [sc53Master] FROM DISK = N’D:\Backup\sql\SC53MASTER_DATA.bak’ WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10
RESTORE DATABASE [sc53RecycleBin] FROM DISK = N’D:\Backup\sql\SC53RECYCLEBIN_DATA.bak’ WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10
RESTORE DATABASE [sc53Security] FROM DISK = N’D:\Backup\sql\SC53SECURITY_DATA.bak’ WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10
RESTORE DATABASE [sc53Web] FROM DISK = N’D:\Backup\sql\SC53WEB_DATA.bak’ WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10

GO

Just find-and-replace ‘sc53’ with the prefix you like and the same goed out to the backupfilepaths. Using this script you should be able to restore in 10 minutes instead of the hour it would cost otherwise. Have fun 🙂

Creating items and edit them afterwards in all languages

Today my dear colleague Max had the problem he wasn’t able to edit his newly created item in another language then the default one. So I helped poor old Max a little out by taking the creation of the item from him and supplying the item in all different languages to his delegate:

    1         public delegate void ItemByLanguageEditor(Item item);

    2 

    3         public void CreateItemFromMaster(string itemName, ID masterId, Item destination, ItemByLanguageEditor ible)

    4         {

    5             Assert.IsNotNullOrEmpty(itemName, “The parameter with the name ‘itemName’ cannot be null or empty”);

    6             Assert.IsNotNull(masterId, “The parameter with the name ‘masterId’ cannot be null”);

    7             Assert.IsNotNull(masterId, “The parameter with the name ‘destination’ cannot be null”);

    8 

    9             Item newCreatedItem = Sitecore.Data.Managers.ItemManager.AddFromMaster(itemName, masterId, destination);

   10             if(newCreatedItem != null)

   11             {

   12                 foreach (Sitecore.Globalization.Language l in newCreatedItem.Languages)

   13                 {

   14 

   15                     Item langVersionOfItem = Sitecore.Context.ContentDatabase.GetItem(newCreatedItem.ID, l);

   16                     ible.Invoke(langVersionOfItem);

   17 

   18                 }

   19             }

   20         }

When you use this method make sure you are/have:

  1. in the right security context
  2. selectected the right active site(Sitecore.Context.SetActiveSite….)
  3. the destination item(his upcoming parent) is in the right database

A small improvement to think about, for my friends in Denmark, would be a method with the following stub ;):

Item.GetByLanguage(Sitecore.Globalisation.Language lang):Item

WPF/E Expired? Download the February CTP

Some guys noticed me that WPF/E seemed to be expired… And indeed I had the same problem. For example try the Channel 9 example and look if you get the same dialog:

I guess so, or you haven’t installed the December CTP at all. Anyways, Microsoft was aware of this and has published the new CTP. It’s again just 1,09 Megabyte and you even don’t have to uninstall the last CTP.

http://www.microsoft.com/downloads/details.aspx?FamilyId=E63992D3-CCF5-40B9-B98A-D16BCA57467C&displaylang=en