Example #1
0
 public function Save()
 {
     $sXml = $this->ToXml();
     $oUDSearch = new DBObjectSearch('UserDashboard');
     $oUDSearch->AddCondition('user_id', UserRights::GetUserId(), '=');
     $oUDSearch->AddCondition('menu_code', $this->sId, '=');
     $oUDSet = new DBObjectSet($oUDSearch);
     if ($oUDSet->Count() > 0) {
         // Assuming there is at most one couple {user, menu}!
         $oUserDashboard = $oUDSet->Fetch();
         $oUserDashboard->Set('contents', $sXml);
         $oUserDashboard->DBUpdate();
     } else {
         // No such customized dasboard for the current user, let's create a new record
         $oUserDashboard = new UserDashboard();
         $oUserDashboard->Set('user_id', UserRights::GetUserId());
         $oUserDashboard->Set('menu_code', $this->sId);
         $oUserDashboard->Set('contents', $sXml);
         $oUserDashboard->DBInsert();
     }
 }