/**
  * 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)
 {
     $oldRecord = $this->get($_phone->getId());
     $rights = $this->_backend->getPhoneRights($_phone->getId());
     $currentAccountId = Tinebase_Core::getUser()->getId();
     $hasRight = false;
     foreach ($rights as $right) {
         if ($right->account_id == $currentAccountId) {
             // if  user has the right to dial and read the phone, he or she may edit the lines
             if ($right->dial_right && $right->read_right) {
                 $hasRight = true;
             }
         }
     }
     if (!$hasRight) {
         throw new Tinebase_Exception_AccessDenied('You are not allowed to edit this phone!');
     }
     // user is not allowed to add or remove lines
     $diff = $oldRecord->lines->diff($_phone->lines);
     if (count($diff->added) > 0 || count($diff->removed) > 0) {
         throw new Tinebase_Exception_AccessDenied('You are not allowed to add or remove lines of this phone!');
     }
     // user may just edit the lines and settings of the phone
     $oldRecord->lines = $_phone->lines;
     $oldRecord->settings = $_phone->settings;
     return parent::update($oldRecord);
 }