/**
  * Loads the preferences for the current user, creating the record in the database
  * if needed
  */
 protected static function Load()
 {
     if (self::$oUserPrefs != null) {
         return;
     }
     $oSearch = new DBObjectSearch('appUserPreferences');
     $oSearch->AddCondition('userid', UserRights::GetUserId(), '=');
     $oSet = new DBObjectSet($oSearch);
     $oObj = $oSet->Fetch();
     if ($oObj == null) {
         // No prefs (yet) for this user, create the object
         $oObj = new appUserPreferences();
         $oObj->Set('userid', UserRights::GetUserId());
         $oObj->Set('preferences', array());
         // Default preferences: an empty array
         try {
             $oObj->DBInsert();
         } catch (Exception $e) {
             // Ignore errors
         }
     }
     self::$oUserPrefs = $oObj;
 }