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(); } } }
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(); }
/** * 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(); } }
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")); } }