Copyright (C) 2010 All Rights Reserved. Contributor(s): Mark J Crane */ include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('fifo_add')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support require_once "app_languages.php"; foreach($text as $key => $value) { $text[$key] = $value[$_SESSION['domain']['language']['code']]; } require_once "resources/header.php"; $page["title"] = $text['title-queue_add']; require_once "resources/paging.php"; //get http values and set them as variables if (count($_POST)>0) { $order_by = $_GET["order_by"]; $order = $_GET["order"]; $extension_name = check_str($_POST["extension_name"]); $queue_extension_number = check_str($_POST["queue_extension_number"]); $agent_queue_extension_number = check_str($_POST["agent_queue_extension_number"]); $agent_login_logout_extension_number = check_str($_POST["agent_login_logout_extension_number"]); $dialplan_order = check_str($_POST["dialplan_order"]); $pin_number = check_str($_POST["pin_number"]); $profile = check_str($_POST["profile"]); $flags = check_str($_POST["flags"]); $dialplan_enabled = check_str($_POST["dialplan_enabled"]); $dialplan_description = check_str($_POST["dialplan_description"]); if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; } //set default to enabled } if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //check for all required data if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid
\n"; } if (strlen($extension_name) == 0) { $msg .= $text['message-required'].$text['label-name']."
\n"; } if (strlen($queue_extension_number) == 0) { $msg .= $text['message-required'].$text['label-extension']."
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } if (strlen($queue_extension_number) > 0) { //-------------------------------------------------------- //Caller Queue [FIFO in] // // // // // // // //-------------------------------------------------------- $queue_name = $extension_name."@\${domain_name}"; $app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7'; $dialplan_uuid = uuid(); $dialplan_context = $_SESSION['context']; dialplan_add($domain_uuid, $dialplan_uuid, $extension_name, $dialplan_order, $dialplan_context, $dialplan_enabled, $dialplan_description, $app_uuid); if (strlen($dialplan_uuid) > 0) { //set the destination number $dialplan_detail_tag = 'condition'; //condition, action, antiaction $dialplan_detail_type = 'destination_number'; $dialplan_detail_data = '^'.$queue_extension_number.'$'; $dialplan_detail_order = '000'; $dialplan_detail_group = '1'; dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); //set the hold music //if (strlen($hold_music) > 0) { $dialplan_detail_tag = 'action'; //condition, action, antiaction $dialplan_detail_type = 'set'; $dialplan_detail_data = 'fifo_music=$${hold_music}'; $dialplan_detail_order = '001'; $dialplan_detail_group = '1'; dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); //} //action answer $dialplan_detail_tag = 'action'; //condition, action, antiaction $dialplan_detail_type = 'answer'; $dialplan_detail_data = ''; $dialplan_detail_order = '002'; $dialplan_detail_group = '1'; dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); //action fifo //if (strlen($pin_number) > 0) { $pin_number = "+".$pin_number; } //if (strlen($flags) > 0) { $flags = "+{".$flags."}"; } //$queue_action_data = $extension_name."@\${domain_name}".$profile.$flags.$pin_number; $queue_action_data = $queue_name." in"; $dialplan_detail_tag = 'action'; //condition, action, antiaction $dialplan_detail_type = 'fifo'; $dialplan_detail_data = $queue_action_data; $dialplan_detail_order = '003'; $dialplan_detail_group = '1'; dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); } } //end if queue_extension_number // Caller Queue / Agent Queue if (strlen($agent_queue_extension_number) > 0) { //-------------------------------------------------------- // Agent Queue [FIFO out] // // // // // // // //-------------------------------------------------------- $queue_name = $extension_name."_agent@\${domain_name}"; if (strlen($dialplan_uuid) > 0) { //set the destination number $dialplan_detail_tag = 'condition'; //condition, action, antiaction $dialplan_detail_type = 'destination_number'; $dialplan_detail_data = '^'.$agent_queue_extension_number.'$'; $dialplan_detail_order = '000'; $dialplan_detail_group = '2'; dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); //set the hold music //if (strlen($hold_music) > 0) { $dialplan_detail_tag = 'action'; //condition, action, antiaction $dialplan_detail_type = 'set'; $dialplan_detail_data = 'fifo_music=$${hold_music}'; $dialplan_detail_order = '001'; $dialplan_detail_group = '2'; dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); //} //action answer $dialplan_detail_tag = 'action'; //condition, action, antiaction $dialplan_detail_type = 'answer'; $dialplan_detail_data = ''; $dialplan_detail_order = '002'; $dialplan_detail_group = '2'; dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); //action fifo //if (strlen($pin_number) > 0) { $pin_number = "+".$pin_number; } //if (strlen($flags) > 0) { $flags = "+{".$flags."}"; } //$queue_action_data = $extension_name."@\${domain_name}".$profile.$flags.$pin_number; $queue_action_data = $queue_name." out wait"; $dialplan_detail_tag = 'action'; //condition, action, antiaction $dialplan_detail_type = 'fifo'; $dialplan_detail_data = $queue_action_data; $dialplan_detail_order = '003'; $dialplan_detail_group = '2'; dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); } } // agent or member login / logout if (strlen($agent_login_logout_extension_number) > 0) { //-------------------------------------------------------- // Agent Queue [FIFO out] // // // // // // // //-------------------------------------------------------- $queue_name = $extension_name."@\${domain_name}"; if (strlen($dialplan_uuid) > 0) { //set the destination number $dialplan_detail_tag = 'condition'; //condition, action, antiaction $dialplan_detail_type = 'destination_number'; $dialplan_detail_data = '^'.$agent_login_logout_extension_number.'$'; $dialplan_detail_order = '000'; $dialplan_detail_group = '3'; dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); //set the queue_name $dialplan_detail_tag = 'action'; //condition, action, antiaction $dialplan_detail_type = 'set'; $dialplan_detail_data = 'queue_name='.$queue_name; $dialplan_detail_order = '001'; $dialplan_detail_group = '3'; dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); //set the fifo_simo $dialplan_detail_tag = 'action'; //condition, action, antiaction $dialplan_detail_type = 'set'; $dialplan_detail_data = 'fifo_simo=1'; $dialplan_detail_order = '002'; $dialplan_detail_group = '3'; dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); //set the fifo_timeout $dialplan_detail_tag = 'action'; //condition, action, antiaction $dialplan_detail_type = 'set'; $dialplan_detail_data = 'fifo_timeout=10'; $dialplan_detail_order = '003'; $dialplan_detail_group = '3'; dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); //set the fifo_lag $dialplan_detail_tag = 'action'; //condition, action, antiaction $dialplan_detail_type = 'set'; $dialplan_detail_data = 'fifo_lag=10'; $dialplan_detail_order = '004'; $dialplan_detail_group = '3'; dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); //set the pin_number $dialplan_detail_tag = 'action'; //condition, action, antiaction $dialplan_detail_type = 'set'; $dialplan_detail_data = 'pin_number='; $dialplan_detail_order = '005'; $dialplan_detail_group = '3'; dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); //action lua $dialplan_detail_tag = 'action'; //condition, action, antiaction $dialplan_detail_type = 'lua'; $dialplan_detail_data = 'fifo_member.lua'; $dialplan_detail_order = '006'; $dialplan_detail_group = '3'; dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); } } //synchronize the xml config save_dialplan_xml(); //delete the dialplan context from memcache $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if ($fp) { $switch_cmd = "memcache delete dialplan:".$_SESSION["context"]; $switch_result = event_socket_request($fp, 'api '.$switch_cmd); } //redirect the user require_once "resources/header.php"; echo "\n"; echo "
\n"; echo $text['message-update']."\n"; echo "
\n"; require_once "resources/footer.php"; return; } //end if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //show the content echo "
"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; echo "
\n"; echo "
"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
".$text['header-queue_add']."\n"; echo " \n"; echo "
\n"; echo " \n"; echo " ".$text['description-queue_add']."\n"; echo " \n"; echo "
"; echo "
\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo " ".$text['label-name'].":\n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['description-name']."\n"; echo "
\n"; echo " ".$text['label-extension'].":\n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['description-extension']."\n"; echo "
\n"; echo " ".$text['label-order'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo " ".$text['label-enabled'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo " ".$text['label-description'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo "

\n"; echo " ".$text['header-agent_details']."\n"; echo "
\n"; echo "  \n"; echo "
\n"; echo " ".$text['label-agent_queue_extension'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-agent_queue_extension']."\n"; echo "
\n"; echo " ".$text['label-agent_loginout_extension'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-agent_loginout_extension']."\n"; echo "
\n"; echo "\n"; echo "\n"; echo " \n"; echo ""; echo "
\n"; if ($action == "update") { echo " \n"; } echo " \n"; echo "
"; echo "
"; echo "
\n"; echo "
"; echo "

"; //show the footer require_once "resources/footer.php"; ?>