/**
  * appendPhoneLines
  * 
  * @param Voipmanager_Model_Snom_Phone $_phone
  * @param SimpleXMLElement $_xml
  */
 protected function _appendPhoneLines(Voipmanager_Model_Snom_Phone $_phone, SimpleXMLElement $_xml)
 {
     if (!$_phone->lines) {
         return;
     }
     $asteriskPeer = new Voipmanager_Backend_Asterisk_SipPeer($this->_db);
     $snomLocation = new Voipmanager_Backend_Snom_Location($this->_db);
     $lines = array();
     $location = $snomLocation->get($_phone->location_id);
     foreach ($_phone->lines as $snomLine) {
         $line = array();
         $line['user_active'] = $snomLine->lineactive == 1 ? 'on' : 'off';
         $line['user_idle_text'] = $snomLine->idletext;
         $asteriskLine = $asteriskPeer->get($snomLine->asteriskline_id);
         // remove <some tag> from the end of the line
         $line['user_realname'] = trim(preg_replace('/<\\d+>$/', '', $asteriskLine->callerid));
         $line['user_name'] = $asteriskLine->name;
         $line['user_host'] = $location->registrar;
         $line['user_mailbox'] = $asteriskLine->mailbox;
         $line['user_pass'] = $asteriskLine->secret;
         $line['user_server_type'] = 'asterisk';
         $lines[$snomLine->linenumber] = $line;
     }
     foreach ($lines as $lineId => $line) {
         foreach ($line as $key => $value) {
             $child = $_xml->addChild($key, $value);
             $child->addAttribute('idx', $lineId);
             $child->addAttribute('perm', 'RO');
         }
         // reset old dialplan
         $child = $_xml->addChild('user_dp_str');
         $child->addAttribute('idx', $lineId);
         $child->addAttribute('perm', 'RO');
     }
 }