/**
  * update one phone
  *
  * @param Voipmanager_Model_Snom_Phone $_phone
  * @return Voipmanager_Model_Snom_Phone
  * @throws Voipmanager_Exception_Validation
  * 
  * @todo do not overwrite update() -> use inspectBefore/After functions
  */
 public function update(Tinebase_Record_Interface $_phone)
 {
     // check first if mac address is already used
     if ($_phone->has('macaddress')) {
         try {
             $phoneWithMac = $this->getByMacAddress($_phone->macaddress);
             if ($phoneWithMac->getId() !== $_phone->getId()) {
                 throw new Voipmanager_Exception_Validation('A phone with this mac address already exists.');
             }
         } catch (Voipmanager_Exception_NotFound $venf) {
             // everything ok
         }
     }
     try {
         $db = $this->_backend->getAdapter();
         $transactionId = Tinebase_TransactionManager::getInstance()->startTransaction($db);
         $phone = $this->_backend->update($_phone);
         $_phoneSettings = $_phone->settings;
         if ($_phoneSettings instanceof Voipmanager_Model_Snom_PhoneSettings) {
             // force the right phone_id
             $_phoneSettings->setId($phone->getId());
             // set all settings which are equal to the default settings to NULL
             $template = Voipmanager_Controller_Snom_Template::getInstance()->get($phone->template_id);
             $settingDefaults = Voipmanager_Controller_Snom_Setting::getInstance()->get($template->setting_id);
             foreach ($_phoneSettings->toArray() as $key => $value) {
                 if ($key == 'phone_id') {
                     continue;
                 }
                 if ($settingDefaults->{$key} == $value) {
                     $_phoneSettings->{$key} = NULL;
                 }
             }
             if (Voipmanager_Controller_Snom_PhoneSettings::getInstance()->get($phone->getId())) {
                 $phoneSettings = Voipmanager_Controller_Snom_PhoneSettings::getInstance()->update($_phoneSettings);
             } else {
                 $phoneSettings = Voipmanager_Controller_Snom_PhoneSettings::getInstance()->create($_phoneSettings);
             }
         }
         Voipmanager_Controller_Snom_Line::getInstance()->deletePhoneLines($phone->getId());
         $this->_createLines($phone, $_phone->lines);
         // save phone rights
         if (isset($_phone->rights)) {
             $this->_backend->setPhoneRights($_phone);
         }
         Tinebase_TransactionManager::getInstance()->commitTransaction($transactionId);
     } catch (Exception $e) {
         $this->_handleRecordCreateOrUpdateException($e);
     }
     return $this->get($phone->getId());
 }