Example #1
0
 public static function delete($base)
 {
     $xml = Telephony::getDriver()->xml;
     FreeSwitch::setSection('xmlcdr');
     //not sure what to do here
     //        $xml->deleteNode();
 }
Example #2
0
 public static function delete($trunk)
 {
     if ($interfaceId = arr::get($trunk, 'plugins', 'sipinterface', 'sipinterface_id')) {
         $xml = FreeSwitch::setSection('gateway', 'sipinterface_' . $interfaceId, 'trunk_' . $trunk['trunk_id']);
         $xml->deleteNode();
     }
 }
Example #3
0
 public static function delete($base)
 {
     if ($base instanceof Device) {
         $domain = '$${location_' . $base['User']['location_id'] . '}';
         $xml = FreeSwitch::setSection('user', $domain, $base['device_id']);
         $xml->deleteNode('/variables/variable[@name="bypass_media"]');
     }
 }
Example #4
0
 public static function delete($base)
 {
     if (empty($base['plugins']['simpleroute'])) {
         return;
     }
     $simpleroute = $base['plugins']['simpleroute'];
     foreach ($simpleroute['patterns'] as $index => $options) {
         foreach ($simpleroute['contexts'] as $context_id => $enabled) {
             $xml = FreeSwitch::createExtension('trunk_' . $base['trunk_id'] . '_pattern_' . $index, 'main', 'context_' . $context_id);
             $xml->deleteNode();
         }
     }
 }
Example #5
0
 public static function set($base)
 {
     if ($base instanceof Device and $location_id = arr::get($base['User'], 'location_id')) {
         $domain = '$${location_' . $location_id . '}';
         $xml = Telephony::getDriver()->xml;
         FreeSwitch::setSection('user', $domain, $base['device_id']);
         if ($areacode = arr::get($base, 'registry', 'areacode')) {
             $xml->update('/variables/variable[@name="areacode"]{@value="' . $areacode . '"}');
         } else {
             $xml->deleteNode('/variables/variable[@name="areacode"]');
         }
     }
 }
Example #6
0
 public static function set($base)
 {
     if ($base instanceof Device and $location_id = arr::get($base['User'], 'location_id')) {
         $domain = '$${location_' . $location_id . '}';
         $xml = Telephony::getDriver()->xml;
         FreeSwitch::setSection('user', $domain, $base['device_id']);
         if (($outbound_intercept_group = arr::get($base, 'plugins', 'callintercept', 'outbound_intercept_group')) != NULL) {
             $outbound_intercept_group = implode('|', preg_split('/[,\\s\\/\\\\|\\.]/', $outbound_intercept_group, NULL, PREG_SPLIT_NO_EMPTY));
             $xml->update('/variables/variable[@name="interceptgroup"]{@value="' . $outbound_intercept_group . '"}');
         } else {
             $xml->deleteNode('/variables/variable[@name="interceptgroup"]');
         }
     }
 }
Example #7
0
 public static function delete($base)
 {
     if ($base instanceof Voicemail) {
         $xml = FreeSwitch::setSection('user', 'voicemail_' . $base['account_id'], $base['voicemail_id']);
         $xml->deleteNode();
     } else {
         if ($base instanceof Device) {
             $voicemail = $base['plugins']['voicemail'];
             $domain = '$${location_' . $base['User']['location_id'] . '}';
             $xml = FreeSwitch::setSection('user', $domain, $base['device_id']);
             $xml->deleteNode('/variables/variable[@name="mwi-account"]');
             $xml->deleteNode('/params/param[@name="mwi-account"]');
         }
     }
 }
Example #8
0
File: xmpp.php Project: swk/bluebox
 public static function delete($xmppData)
 {
     //Delete dialplans
     foreach ($xmppData['registry']['patterns'] as $simple_route_id => $options) {
         foreach ($xmppData['registry']['contexts'] as $context_id => $enabled) {
             $xml = FreeSwitch::createExtension($xmppData['xmpp_id'] . '_pattern_' . $simple_route_id, 'main', 'context_' . $context_id);
             $xml->deleteNode();
         }
     }
     //Delete jingle profile
     $xml = Telephony::getDriver()->xml;
     $root = '//document/section[@name="configuration"]/configuration[@name="dingaling.conf"]' . '/profile[@name="dingaling_' . $xmppData['xmpp_id'] . '"]';
     $xml->setXmlRoot($root);
     $xml->deleteNode();
 }
Example #9
0
 public static function delete($base)
 {
     // Reference to our XML document
     $xml = Telephony::getDriver()->xml;
     if ($base instanceof Conference) {
         FreeSwitch::section('conference_profile', $base['conference_id']);
         $xml->deleteNode('/param[@name="caller-id-number"]');
     } elseif ($base instanceof Device) {
         $domain = '$${location_' . $base['User']['location_id'] . '}';
         FreeSwitch::setSection('user', $domain, $base['device_id']);
         $xml->deleteNode('/variables/variable[@name="outbound_caller_id_name"]');
         $xml->deleteNode('/variables/variable[@name="outbound_caller_id_number"]');
         $xml->deleteNode('/variables/variable[@name="internal_caller_id_name"]');
         $xml->deleteNode('/variables/variable[@name="internal_caller_id_number"]');
     }
 }
Example #10
0
 public static function delete($base)
 {
     $xml = Telephony::getDriver()->xml;
     if ($base instanceof Device) {
         if (empty($base['plugins']['timezone'])) {
             return;
         }
         $timezone = $base['plugins']['timezone'];
         $domain = '$${location_' . $base['User']['location_id'] . '}';
         $xml = FreeSwitch::setSection('user', $domain, $base['device_id']);
         $xml->deleteNode('/variables/variable[@name="timezone"]');
     } else {
         if ($base instanceof Voicemail) {
             if (empty($base['plugins']['timezone'])) {
                 return;
             }
             $timezone = $base['plugins']['timezone'];
             $xml = FreeSwitch::setSection('user', 'voicemail_' . $base['account_id'], $base['voicemail_id']);
             $xml->deleteNode('/variables/variable[@name="timezone"]');
         }
     }
 }
Example #11
0
 public static function set($base)
 {
     if ($base instanceof SipInterface) {
         $xml = FreeSwitch::setSection('sofia', 'sipinterface_' . $base['sipinterface_id']);
         $xml->update('/settings/param[@name="tls"]{@value="' . (isset($base['plugins']['sipencryption']['enable']) && $base['plugins']['sipencryption']['enable'] == 'TRUE' ? 'TRUE' : 'FALSE') . '"}');
         if ($base['plugins']['sipencryption']['type'] == 'tlsv1') {
             $xml->update('/settings/param[@name="tls-bind-params"]{@value="transport=tls"}');
         } else {
             $xml->update('/settings/param[@name="tls-bind-params"]{@value=""}');
         }
         if (isset($base['plugins']['sipencryption']['port'])) {
             $xml->update('/settings/param[@name="tls-sip-port"]{@value="' . $base['plugins']['sipencryption']['port'] . '"}');
         } else {
             $xml->update('/settings/param[@name="tls-sip-port"]{@value="' . ($base['port'] + 1) . '"}');
         }
         if (isset($base['plugins']['sipencryption']['certdir'])) {
             $xml->update('/settings/param[@name="tls-cert-dir"]{@value="' . str_replace('/', '\\/', $base['plugins']['sipencryption']['certdir']) . '"}');
         } else {
             $xml->update('/settings/param[@name="tls-cert-dir"]{@value="$${base_dir}\\/conf\\/ssl"}');
         }
         $xml->update('/settings/param[@name="tls-version"]{@value="' . $base['plugins']['sipencryption']['type'] . '"}');
     }
 }
Example #12
0
File: odbc.php Project: swk/bluebox
 public static function delete($base)
 {
     if ($base instanceof Odbc) {
         $xml = FreeSwitch::setSection('odbc');
         $xml->deleteNode('/X-PRE-PROCESS[@cmd="set"][@bluebox="odbc_' . $base['odbc_id'] . '"]');
         if (class_exists('SipInterface')) {
             $interfaces = Doctrine::getTable('SipInterface')->findAll();
             foreach ($interfaces as $interface) {
                 if (empty($interface['plugins']['odbc']['odbc_id'])) {
                     continue;
                 }
                 if ($interface['plugins']['odbc']['odbc_id'] != $base['odbc_id']) {
                     continue;
                 }
                 $plugins = $interface['plugins'];
                 unset($plugins['odbc']);
                 $interface['plugins'] = $plugins;
                 $interface->save();
                 $xml = FreeSwitch::setSection('sofia', 'sipinterface_' . $interface['sipinterface_id']);
                 $xml->deleteNode('/settings/param[@name="odbc-dsn"]');
             }
         }
     }
 }
Example #13
0
 public static function delete($base)
 {
     if (empty($base['plugins']['simpleroute'])) {
         return;
     }
     $simpleroute = $base['plugins']['simpleroute'];
     $routenumber == 0;
     $xml = FreeSwitch::createExtension("route_{$routenumber}", 'main', 'context_' . $base->context_id);
     while ($xml !== FALSE) {
         $xml->deleteNode();
         $routenumber++;
         $xml = FreeSwitch::createExtension("route_{$routenumber}", 'main', 'context_' . $base->context_id, array("existing"));
     }
 }
Example #14
0
 public static function delete($autoattendant)
 {
     FreeSwitch::setSection('autoattendant', $autoattendant['auto_attendant_id'])->deleteNode();
 }
Example #15
0
 public static function delete($netList)
 {
     // Reference to our XML document & context
     $xml = FreeSwitch::setSection('netlist', $netList['net_list_id']);
     $xml->deleteNode();
 }
Example #16
0
 /**
  * Set the prefix for all upcoming set()/update() requests, based on a friendly section name (like 'dialplan' or 'directory')
  * Use this helper method to set the section the subsequent set()/update() requests should go to. This does two things:
  *   1) Prevents having to add a big long xpath to every set/update request
  *   2) Hides some of the uglyness in deeply nested XML elements within the FreeSWITCH config, so that we closer resemble
  *      the stock samples that come with FreeSWITCH so people are more comfortable using our helper methods
  *
  * Usage is:
  *   FreeSwitch::setSection('dialplan');
  *   FreeSwitch::getInstance()->xml->set('/mysetting');
  *
  * Note that sprintf is utilized to populate any additional variables you pass into the section XPath (if the xpath supports it).
  * So an alternate usage for users:
  *   FreeSwitch::setSection('users', 'mysystem.com', 'bob');
  *
  * Would allow for setting/getting variables for the domain 'mysystem.com' and user named bob in our users directory.
  *
  * @param string $sectionName Shortname of the section we want to work with
  * @return FsDomDocument Return the FsDomDocument element with the prefix now set for us (normally you ignore this returned var)
  */
 public static function setSection($sectionName)
 {
     $args = func_get_args();
     array_shift($args);
     if ($args) {
         self::$instance->xml->setXmlRoot(vsprintf(self::$sectionPaths[$sectionName], $args));
     } else {
         self::$instance->xml->setXmlRoot(self::$sectionPaths[$sectionName]);
     }
     if ($sectionName == 'netlist') {
         self::$aclDirty = TRUE;
     }
     if ($sectionName == 'sofia' or $sectionName == 'gateway') {
         self::$sofiaDirty = TRUE;
     }
     if ($sectionName == 'xmlcdr') {
         self::$xmlcdrDirty = TRUE;
     }
     // This probably isn't necessary. Could just return nothing.
     return self::$instance->xml;
 }
Example #17
0
 public static function delete($sipinterface)
 {
     if (!$sipinterface instanceof SipInterface) {
         return TRUE;
     }
     // Reference to our XML document
     $xml = Telephony::getDriver()->xml;
     // The section we are working with is <document><section name="configuration"><configuration name="conference.conf">
     FreeSwitch::setSection('sofia', 'sipinterface_' . $sipinterface['sipinterface_id']);
     $xml->deleteNode();
 }
Example #18
0
        </div>

    <?php 
}
?>

    <?php 
echo form::close_section();
?>

    <?php 
echo form::open_section('Add XML Sections');
?>

    <?php 
foreach (FreeSwitch::getDialplanSections() as $section) {
    ?>

        <div id="<?php 
    echo $section;
    ?>
-empty" class="unused section-<?php 
    echo isset($registry[$section]) ? '' : 'un';
    ?>
used">

          <span style="font-weight: bold">+</span>

          <span><?php 
    echo ucfirst($section);
    ?>
Example #19
0
File: sip.php Project: swk/bluebox
 public static function delete($base)
 {
     if ($base instanceof Device) {
         $domain = '$${location_' . $base['User']['location_id'] . '}';
         $xml = FreeSwitch::setSection('user', $domain, $base['device_id']);
         $xml->deleteNode();
     } else {
         if ($base instanceof Trunk) {
             $plugins = $base['plugins'];
             if (!empty($plugins['sipinterface']['sipinterface_id'])) {
                 $xml = FreeSwitch::setSection('gateway', 'sipinterface_' . $plugins['sipinterface']['sipinterface_id'], 'trunk_' . $base['trunk_id']);
                 $xml->deleteNode();
             }
         }
     }
 }
Example #20
0
 public static function delete($base)
 {
     $xml = FreeSwitch::setSection('location');
     $xml->deleteNode('/X-PRE-PROCSS[@cmd="set"][@bluebox="location_' . $base['location_id'] . '"]');
 }
Example #21
0
 /**
  * Indicate we support FreeSWITCH with this SIP Device and provide code to save SIP device specific settings
  */
 public static function set($base)
 {
     $xml = Telephony::getDriver()->xml;
     // Reference to our XML document, context and extension. Creates the extension & context if does not already exist
     $xml = FreeSwitch::createExtension('number_' . $base['Number']['number_id'], 'main', 'context_' . $base['context_id']);
     // Does this number go anywhere?
     if ($base['Number']['class_type']) {
         kohana::log('debug', 'FreeSWITCH -> ADDING NUMBER ' . $base['Number']['number'] . ' (' . $base['Number']['number_id'] . ') TO CONTEXT ' . $base['context_id']);
         // Dialplans are a bit different - we don't want to keep anything that is currently in an extension, in the event it's totally changed
         $xml->deleteChildren();
         // Check what number they dialed
         $xml->update('/condition[@field="destination_number"]{@expression="^' . $base['Number']['number'] . '$"}');
         // Now that the extension and condition fields are created for this number, set our root to inside the condition
         $xml->setXmlRoot($xml->getXmlRoot() . '/condition[@field="destination_number"][@expression="^' . $base['Number']['number'] . '$"]');
         $dialplan = $base['Number']['dialplan'];
         // Add an extension-specific prenumber items
         // Note that unlike other dialplan adds, this one assumes you're already in the right spot in the XML document for the add
         dialplan::preNumber($base['Number']);
         if (!empty($dialplan['terminate']['action'])) {
             switch ($dialplan['terminate']['action']) {
                 case 'transfer':
                     $xml->update('/action[@application="set"][@bluebox="settingEndBridge"][@data="hangup_after_bridge=true"]');
                     $xml->update('/action[@application="set"][@bluebox="settingFail"][@data="continue_on_fail=true"]');
                     break;
             }
         }
         // Add related final destination XML
         $destinationDriverName = Telephony::getDriverName() . '_' . substr($base['Number']['class_type'], 0, strlen($base['Number']['class_type']) - 6) . '_Driver';
         Kohana::log('debug', 'FreeSWITCH -> Looking for destination driver ' . $destinationDriverName);
         // Is there a driver?
         if (class_exists($destinationDriverName, TRUE)) {
             // Logging
             Kohana::log('debug', 'FreeSWITCH -> Adding information for destination ' . $base['Number']['number_id'] . ' from model "' . get_class($base['Number']) . '" to our telephony configuration...');
             // Drivers are always singletons, and are responsible for persistenting data for their own config generation via static vars
             // TODO: Change this for PHP 5.3, which doesn't require eval(). Don't change this until all the cool kids are on PHP 5.3*/
             kohana::log('debug', 'FreeSWITCH -> EVAL ' . $destinationDriverName . '::dialplan($base->Number);');
             $success = eval('return ' . $destinationDriverName . '::dialplan($base->Number);');
         }
         // Add an anti-action / failure route for this dialplan
         // Note that unlike other dialplan adds, this one assumes you're already in the right spot in the XML document for the add
         dialplan::postNumber($base['Number']);
         if (!empty($dialplan['terminate']['action'])) {
             switch ($dialplan['terminate']['action']) {
                 case 'transfer':
                     if ($transfer = fs::getTransferToNumber($dialplan['terminate']['transfer'])) {
                         $xml->update('/action[@application="transfer"][@data="' . $transfer . '"]');
                     } else {
                         $xml->update('/action[@application="hangup"]');
                     }
                     break;
                 case 'continue':
                     break;
                 case 'hangup':
                 default:
                     $xml->update('/action[@application="hangup"]');
                     break;
             }
         } else {
             $xml->update('/action[@application="hangup"]');
         }
     } else {
         kohana::log('debug', 'FreeSWITCH -> REMOVING NUMBER ID ' . $base['Number']['number_id'] . ' FROM CONTEXT ' . $base['context_id']);
         $xml->deleteNode();
     }
 }
Example #22
0
    public static function delete($conference)
    {
        $xml = FreeSwitch::setSection('conference_profile', $conference['conference_id']);

        $xml->deleteNode();
    }
Example #23
0
 public static function set($dbnData)
 {
     if ($dbnData instanceof Dbndir) {
         $xml = Telephony::getDriver()->xml;
         $root = '//document/section[@name="configuration"]/configuration[@name="directory.conf"][@description="Directory"]';
         $xml->setXmlRoot($root);
         $updatestr = '/settings';
         $xml->update($updatestr);
         $root = '//document/section[@name="configuration"]/configuration[@name="directory.conf"][@description="Directory"]/profiles/profile[@name="dbnprofile_' . $dbnData->dbn_id . '"]';
         $xml->setXmlRoot($root);
         if (isset($dbnData->dbn_max_menu_attempts) && !empty($dbnData->dbn_max_menu_attempts) && $dbnData->dbn_max_menu_attempts != '') {
             $updatestr = '/param[@name="max-menu-attempts"]{@value="' . $dbnData->dbn_max_menu_attempts . '"}';
         } else {
             $updatestr = '/param[@name="max-menu-attempts"]{@value="3"}';
         }
         Kohana::log('debug', $updatestr);
         $xml->update($updatestr);
         if (isset($dbnData->dbn_min_search_digits) && !empty($dbnData->dbn_min_search_digits) && $dbnData->dbn_min_search_digits != '') {
             $updatestr = '/param[@name="min-search-digits"]{@value="' . $dbnData->dbn_min_search_digits . '"}';
         } else {
             $updatestr = '/param[@name="min-search-digits"]{@value="3"}';
         }
         $xml->update($updatestr);
         if (isset($dbnData->dbn_terminator_key) && !empty($dbnData->dbn_terminator_key) && $dbnData->dbn_terminator_key != '') {
             $updatestr = '/param[@name="terminator-key"]{@value="' . $dbnData->dbn_terminator_key . '"}';
         } else {
             $updatestr = '/param[@name="terminator-key"]{@value="#"}';
         }
         $xml->update($updatestr);
         if (isset($dbnData->dbn_digit_timeout) && !empty($dbnData->dbn_digit_timeout) && $dbnData->dbn_digit_timeout != '') {
             $updatestr = '/param[@name="digit-timeout"]{@value="' . $dbnData->dbn_digit_timeout . '"}';
         } else {
             $updatestr = '/param[@name="digit-timeout"]{@value="3000"}';
         }
         $xml->update($updatestr);
         if (isset($dbnData->dbn_max_result) && !empty($dbnData->dbn_max_result) && $dbnData->dbn_max_result != '') {
             $updatestr = '/param[@name="max-result"]{@value="' . $dbnData->dbn_max_result . '"}';
         } else {
             $updatestr = '/param[@name="max-result"]{@value="5"}';
         }
         $xml->update($updatestr);
         if (isset($dbnData->dbn_next_key) && !empty($dbnData->dbn_next_key) && $dbnData->dbn_next_key != '') {
             $updatestr = '/param[@name="next-key"]{@value="' . $dbnData->dbn_next_key . '"}';
         } else {
             $updatestr = '/param[@name="next-key"]{@value="6"}';
         }
         $xml->update($updatestr);
         if (isset($dbnData->dbn_prev_key) && !empty($dbnData->dbn_prev_key) && $dbnData->dbn_prev_key != '') {
             $updatestr = '/param[@name="prev-key"]{@value="' . $dbnData->dbn_prev_key . '"}';
         } else {
             $updatestr = '/param[@name="prev-key"]{@value="4"}';
         }
         $xml->update($updatestr);
         if (isset($dbnData->dbn_switch_order_key) && !empty($dbnData->dbn_switch_order_key) && $dbnData->dbn_switch_order_key != '') {
             $updatestr = '/param[@name="switch-order-key"]{@value="' . $dbnData->dbn_switch_order_key . '"}';
         } else {
             $updatestr = '/param[@name="switch-order-key"]{@value="*"}';
         }
         $xml->update($updatestr);
         if (isset($dbnData->dbn_select_name_key) && !empty($dbnData->dbn_select_name_key) && $dbnData->dbn_select_name_key != '') {
             $updatestr = '/param[@name="select-name-key"]{@value="' . $dbnData->dbn_select_name_key . '"}';
         } else {
             $updatestr = '/param[@name="select-name-key"]{@value="1"}';
         }
         $xml->update($updatestr);
         if (isset($dbnData->dbn_new_search_key) && !empty($dbnData->dbn_new_search_key) && $dbnData->dbn_new_search_key != '') {
             $updatestr = '/param[@name="new-search-key"]{@value="' . $dbnData->dbn_new_search_key . '"}';
         } else {
             $updatestr = '/param[@name="new-search-key"]{@value="3"}';
         }
         $xml->update($updatestr);
         if (isset($dbnData->dbn_search_order) && !empty($dbnData->dbn_search_order) && $dbnData->dbn_search_order != '') {
             $updatestr = '/param[@name="search-order"]{@value="' . $dbnData->dbn_search_order . '"}';
         } else {
             $updatestr = '/param[@name="search-order"]{@value="last_name"}';
         }
         $xml->update($updatestr);
     } else {
         if ($dbnData instanceof Device) {
             $dbndir = $dbnData['plugins']['dbndir'];
             $domain = '$${location_' . $dbnData['User']['location_id'] . '}';
             $xml = FreeSwitch::setSection('user', $domain, $dbnData['device_id']);
             if (isset($dbndir['full_name']) && !empty($dbndir['full_name']) && $dbndir['full_name'] != '') {
                 $xml->update('/variables/variable[@name="directory_full_name"]{@value="' . $dbndir['full_name'] . '"}');
             } else {
                 $username = $dbnData->User->first_name . ' ' . $dbnData->User->last_name;
                 $xml->update('/variables/variable[@name="directory_full_name"]{@value="' . $username . '"}');
             }
             if (isset($dbndir['visible']) && !empty($dbndir['visible']) && $dbndir['visible'] != '') {
                 $xml->update('/params/param[@name="directory-visible"]{@value="True"}');
             } else {
                 $xml->update('/params/param[@name="directory-visible"]{@value="False"}');
             }
             if (isset($dbndir['announce_ext']) && !empty($dbndir['announce_ext']) && $dbndir['announce_ext'] != '') {
                 $xml->update('/params/param[@name="directory-exten-visible"]{@value="True"}');
             } else {
                 $xml->update('/params/param[@name="directory-exten-visible"]{@value="False"}');
             }
         }
     }
 }
Example #24
0
 public static function delete($base)
 {
     $xml = Telephony::getDriver()->xml;
     FreeSwitch::setSection('cdr_csv');
     $xml->deleteNode('/settings/template[@name="account_' . $base->account_id . '"]');
 }
Example #25
0
 public static function update_aliases($location_id, $alias_sipinterface_id = NULL)
 {
     $location_name = '$${location_' . $location_id . '}';
     $sipinterfaces = Doctrine::getTable('SipInterface')->findAll();
     foreach ($sipinterfaces as $sipinterface) {
         $sipinterface_id = $sipinterface['sipinterface_id'];
         $xml = FreeSwitch::setSection('sofia_aliases', 'sipinterface_' . $sipinterface_id);
         if ($sipinterface_id == $alias_sipinterface_id) {
             $xml->update('/alias[@name="' . $location_name . '"]');
         } else {
             $xml->deleteNode('/alias[@name="' . $location_name . '"]');
         }
     }
 }