Wica,
I was getting the same error message in the Contacts module when trying the unset($layout_defs[etc...] technique. After a little digging around, I discovered that the problem was only happening with one particular user. When I switched to another user, there was no error and the subpanel I had unset was not there.
After looking through the code, I discovered the problem for the one user was a user preference (stored in the user_preferences table) with an array containing a list of subpanels for the contacts module. This user preference gets written whenever you change the order of the subpanels by dragging and dropping them. One of the subpanels stored in this array was the one I had unset.
When Sugar displays the view, before it renders the subpanels it checks to see if the user has a 'custom' subpanel order set in their user preferences. If so it tries to display the subpanels in that custom order. The problem I was running into is that the custom order included the subpanel I had 'unset' and Sugar was failing to display the subpanel since it no longer had any properties.
In my case I solved the problem by deleting that preference record from the user_preferences table. After that, it worked fine. To do this, you will need to know the user_id for your current user and the category name of the preference. You can find the category name by putting this debugging line after line 98 in the file modules/UserPreferences/UserPreference.php:
PHP Code:
if ($name == 'subpanelLayout') print "<span style='background-color:yellow'>User preference category is: $category</style>";
A better way to avoid this problem would be to check whether a subpanel is actually defined in $layout_defs before trying to render it. This example seems to work for me. Keep in mind that I haven't tested it much and it isn't an upgrade-safe change. Add the following at line 229 of include/SubPanel/SubPanelTiles.php:
PHP Code:
//Skip to the next subpanel if this one is not defined
if ($this->subpanel_definitions->layout_defs['subpanel_setup'][$tab] == NULL) continue;
The end result of this change is that Sugar will just skip over that subpanel if it isn't defined, rather than trying to display it and failing.
--Greg Watson
Bookmarks