/**
  * appends user settings
  * 
  * @param Voipmanager_Model_Snom_Phone $_phone
  * @param SimpleXMLElement $_xml
  */
 protected function _appendUserSettings(Voipmanager_Model_Snom_Phone $_phone, SimpleXMLElement $_xml)
 {
     $phoneSettinsgBackend = new Voipmanager_Backend_Snom_PhoneSettings($this->_db);
     $phoneSettings = $phoneSettinsgBackend->get($_phone->getId());
     $templateBackend = new Voipmanager_Backend_Snom_Template($this->_db);
     $template = $templateBackend->get($_phone->template_id);
     $defaultPhoneSettingsBackend = new Voipmanager_Backend_Snom_Setting($this->_db);
     $defaultPhoneSettings = $defaultPhoneSettingsBackend->get($template->setting_id);
     $userSettings = array();
     foreach ($phoneSettings as $key => $value) {
         if ($key == 'phone_id') {
             continue;
         }
         $isWritableProperty = $key . '_w';
         if (!$defaultPhoneSettings->has($isWritableProperty)) {
             continue;
         }
         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
             Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Writable property: ' . $key);
         }
         if ($defaultPhoneSettings->{$isWritableProperty} == true && $value !== NULL) {
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Setting ' . $key . ' = ' . $value);
             }
             $userSettings[$key]['value'] = $value;
             $userSettings[$key]['perms'] = 'RW';
         } else {
             if ($defaultPhoneSettings->{$key} !== NULL) {
                 $userSettings[$key]['value'] = $defaultPhoneSettings->{$key};
                 if ($defaultPhoneSettings->{$isWritableProperty} == true) {
                     $userSettings[$key]['perms'] = 'RW';
                 } else {
                     $userSettings[$key]['perms'] = 'RO';
                 }
             }
         }
     }
     foreach ($userSettings as $key => $value) {
         $child = $_xml->addChild($key, $value['value']);
         $child->addAttribute('perm', $value['perms']);
     }
 }
示例#2
0
 protected function _appendUserSettings(Voipmanager_Model_Snom_Phone $_phone, SimpleXMLElement $_xml)
 {
     $phoneSettinsgBackend = new Voipmanager_Backend_Snom_PhoneSettings($this->_db);
     $phoneSettings = $phoneSettinsgBackend->get($_phone->getId());
     $templateBackend = new Voipmanager_Backend_Snom_Template($this->_db);
     $template = $templateBackend->get($_phone->template_id);
     $defaultPhoneSettingsBackend = new Voipmanager_Backend_Snom_Setting($this->_db);
     $defaultPhoneSettings = $defaultPhoneSettingsBackend->get($template->setting_id);
     $userSettings = array();
     foreach ($phoneSettings as $key => $value) {
         if ($key == 'phone_id') {
             continue;
         }
         $isWriteAbleProperty = $key . '_writable';
         if (!$defaultPhoneSettings->has($isWriteAbleProperty)) {
             continue;
         }
         if ($defaultPhoneSettings->{$isWriteAbleProperty} == true && $value !== NULL) {
             $userSettings[$key]['value'] = $value;
             $userSettings[$key]['perms'] = 'RW';
         } elseif ($defaultPhoneSettings->{$key} !== NULL) {
             $userSettings[$key]['value'] = $defaultPhoneSettings->{$key};
             if ($defaultPhoneSettings->{$isWriteAbleProperty} == true) {
                 $userSettings[$key]['perms'] = 'RW';
             } else {
                 $userSettings[$key]['perms'] = 'RO';
             }
         }
     }
     foreach ($userSettings as $key => $value) {
         $child = $_xml->addChild($key, $value['value']);
         $child->addAttribute('perm', $value['perms']);
     }
 }