diff --git a/app/ring_groups/app_config.php b/app/ring_groups/app_config.php index 47276a770d..40fbf84533 100644 --- a/app/ring_groups/app_config.php +++ b/app/ring_groups/app_config.php @@ -55,6 +55,13 @@ $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; $apps[$x]['permissions'][$y]['groups'][] = 'admin'; $y++; + $apps[$x]['permissions'][$y]['name'] = 'ring_group_forward'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $apps[$x]['permissions'][$y]['groups'][] = 'user'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'ring_group_prompt'; + $y++; //schema details $y = 0; //table array index @@ -170,4 +177,41 @@ $apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric'; //confirm,announce $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ''; $z++; + + $y = 2; //table array index + $z = 0; //field array index + $apps[$x]['db'][$y]['table'] = 'v_ring_group_users'; + $apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'ring_group_user_uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text'; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)'; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary'; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ''; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text'; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)'; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign'; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_domains'; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'domain_uuid'; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ''; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'ring_group_uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text'; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)'; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign'; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_ring_groups'; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'ring_group_uuid'; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ''; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'user_uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text'; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)'; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign'; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_users'; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'user_uuid'; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ''; ?> \ No newline at end of file diff --git a/app/ring_groups/app_languages.php b/app/ring_groups/app_languages.php index 802d1edbd2..2208b40de3 100644 --- a/app/ring_groups/app_languages.php +++ b/app/ring_groups/app_languages.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2013 the Initial Developer. All Rights Reserved. Contributor(s): @@ -46,6 +46,9 @@ $text['description-ring-group-forward']['en-us'] = 'Forwards calls to an alternate destination for extension '; $text['description-ring-group-forward']['pt-pt'] = ''; + $text['link-call-forward']['en-us'] = 'Call Forward'; + $text['link-call-forward']['pt-pt'] = ''; + $text['label-call-forward']['en-us'] = 'Call Forward:'; $text['label-call-forward']['pt-pt'] = ''; diff --git a/app/ring_groups/ring_group_destination_edit.php b/app/ring_groups/ring_group_destination_edit.php index 68c5fe2c56..084cfdebcd 100644 --- a/app/ring_groups/ring_group_destination_edit.php +++ b/app/ring_groups/ring_group_destination_edit.php @@ -68,7 +68,6 @@ else { if (strlen($select_value) == 0) { $select_value = $select_default; } echo " \n"; - echo " \n"; - if ($destination_prompt == "1") { - echo " \n"; + if (permission_exists('ring_group_prompt')) { + echo "\n"; + echo "\n"; + echo " ".$text['label-destination_prompt'].":\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-destination_prompt']."\n"; + echo "\n"; + echo "\n"; } - else { - echo " \n"; - } - //if ($destination_prompt == "2") { - //echo " \n"; - //} - //else { - //echo " \n"; - //} - echo " \n"; - echo "
\n"; - echo $text['description-destination_prompt']."\n"; - echo "\n"; - echo "\n"; echo " \n"; echo " \n"; echo " \n"; diff --git a/app/ring_groups/ring_group_edit.php b/app/ring_groups/ring_group_edit.php index a7ea0fc362..ddeaf785ea 100644 --- a/app/ring_groups/ring_group_edit.php +++ b/app/ring_groups/ring_group_edit.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2010-2013 the Initial Developer. All Rights Reserved. Contributor(s): @@ -41,21 +41,21 @@ else { $text[$key] = $value[$_SESSION['domain']['language']['code']]; } -//delete the user from the v_extension_users - if ($_GET["a"] == "delete" && permission_exists("user_delete")) { +//delete the user from v_ring_group_users + if ($_GET["a"] == "delete" && strlen($_REQUEST["user_uuid"]) > 0 && permission_exists("ring_group_edit")) { //set the variables - $ring_group_destination_uuid = check_str($_REQUEST["id"]); - $ring_group_uuid = check_str($_REQUEST["ring_group_uuid"]); - //delete the extension from the ring_group - $sql = "delete from v_ring_group_destinations "; - $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and ring_group_destination_uuid = '$ring_group_destination_uuid' "; + $user_uuid = check_str($_REQUEST["user_uuid"]); + $ring_group_uuid = check_str($_REQUEST["id"]); + //delete the group from the users + $sql = "delete from v_ring_group_users "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and ring_group_uuid = '".$ring_group_uuid."' "; + $sql .= "and user_uuid = '".$user_uuid."' "; $db->exec(check_sql($sql)); - unset($sql); //redirect the browser require_once "resources/header.php"; echo "\n"; - echo "
Delete Complete
"; + echo "
".$text['message-delete']."
"; require_once "resources/footer.php"; return; } @@ -122,232 +122,262 @@ else { } } -if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { - - $msg = ''; - if ($action == "update") { - $ring_group_uuid = check_str($_POST["ring_group_uuid"]); - } - - //check for all required data - if (strlen($ring_group_name) == 0) { $msg .= $text['message-name']."
\n"; } - if (strlen($ring_group_extension) == 0) { $msg .= $text['message-extension']."
\n"; } - if (strlen($ring_group_strategy) == 0) { $msg .= $text['message-strategy']."
\n"; } - if (strlen($ring_group_timeout_sec) == 0) { $msg .= $text['message-strategy']."
\n"; } - if (strlen($ring_group_timeout_app) == 0) { $msg .= $text['message-timeout-action']."
\n"; } - //if (strlen($ring_group_cid_name_prefix) == 0) { $msg .= "Please provide: Caller ID Prefix
\n"; } - //if (strlen($ring_group_ringback) == 0) { $msg .= "Please provide: Ringback
\n"; } - if (strlen($ring_group_enabled) == 0) { $msg .= $text['message-enabled']."
\n"; } - //if (strlen($ring_group_description) == 0) { $msg .= "Please provide: Description
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { +//assign the extension to the user + if (strlen($_REQUEST["user_uuid"]) > 0 && strlen($_REQUEST["id"]) > 0 && $_GET["a"] != "delete") { + //set the variables + $user_uuid = check_str($_REQUEST["user_uuid"]); + $extension_uuid = check_str($_REQUEST["id"]); + //assign the user to the extension + $sql_insert = "insert into v_ring_group_users "; + $sql_insert .= "("; + $sql_insert .= "ring_group_user_uuid, "; + $sql_insert .= "domain_uuid, "; + $sql_insert .= "ring_group_uuid, "; + $sql_insert .= "user_uuid "; + $sql_insert .= ")"; + $sql_insert .= "values "; + $sql_insert .= "("; + $sql_insert .= "'".uuid()."', "; + $sql_insert .= "'$domain_uuid', "; + $sql_insert .= "'".$ring_group_uuid."', "; + $sql_insert .= "'".$user_uuid."' "; + $sql_insert .= ")"; + $db->exec($sql_insert); + //redirect the browser require_once "resources/header.php"; - require_once "resources/persist_form_var.php"; - echo "
\n"; - echo "
\n"; - echo $msg."
"; - echo "
\n"; - persistformvar($_POST); - echo "
\n"; + echo "\n"; + echo "
".$text['message-add']."
"; require_once "resources/footer.php"; return; + } + +//process the HTTP POST + if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $ring_group_uuid = check_str($_POST["ring_group_uuid"]); } - //add or update the database - if ($_POST["persistformvar"] != "true") { - if ($action == "add") { - //prepare the uuids - $ring_group_uuid = uuid(); - $dialplan_uuid = uuid(); - //add the ring group - $sql = "insert into v_ring_groups "; - $sql .= "("; - $sql .= "domain_uuid, "; - $sql .= "ring_group_uuid, "; - $sql .= "ring_group_name, "; - $sql .= "ring_group_extension, "; - $sql .= "ring_group_context, "; - $sql .= "ring_group_strategy, "; - $sql .= "ring_group_timeout_sec, "; - $sql .= "ring_group_timeout_app, "; - $sql .= "ring_group_timeout_data, "; - $sql .= "ring_group_cid_name_prefix, "; - $sql .= "ring_group_ringback, "; - $sql .= "ring_group_enabled, "; - $sql .= "ring_group_description, "; - $sql .= "dialplan_uuid "; - $sql .= ")"; - $sql .= "values "; - $sql .= "("; - $sql .= "'".$_SESSION['domain_uuid']."', "; - $sql .= "'".$ring_group_uuid."', "; - $sql .= "'$ring_group_name', "; - $sql .= "'$ring_group_extension', "; - $sql .= "'$ring_group_context', "; - $sql .= "'$ring_group_strategy', "; - $sql .= "'$ring_group_timeout_sec', "; - $sql .= "'$ring_group_timeout_app', "; - $sql .= "'$ring_group_timeout_data', "; - $sql .= "'$ring_group_cid_name_prefix', "; - $sql .= "'$ring_group_ringback', "; - $sql .= "'$ring_group_enabled', "; - $sql .= "'$ring_group_description', "; - $sql .= "'$dialplan_uuid' "; - $sql .= ")"; - $db->exec(check_sql($sql)); - unset($sql); - } //if ($action == "add") - - if ($action == "update") { - $sql = "update v_ring_groups set "; - $sql .= "ring_group_name = '$ring_group_name', "; - $sql .= "ring_group_extension = '$ring_group_extension', "; - if (if_group("superadmin")) { - $sql .= "ring_group_context = '$ring_group_context', "; - } - $sql .= "ring_group_strategy = '$ring_group_strategy', "; - $sql .= "ring_group_timeout_sec = '$ring_group_timeout_sec', "; - $sql .= "ring_group_timeout_app = '$ring_group_timeout_app', "; - $sql .= "ring_group_timeout_data = '$ring_group_timeout_data', "; - $sql .= "ring_group_cid_name_prefix = '$ring_group_cid_name_prefix', "; - $sql .= "ring_group_ringback = '$ring_group_ringback', "; - $sql .= "ring_group_enabled = '$ring_group_enabled', "; - $sql .= "ring_group_description = '$ring_group_description' "; - //$sql .= "dialplan_uuid = '$dialplan_uuid' "; - $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and ring_group_uuid = '$ring_group_uuid' "; - $db->exec(check_sql($sql)); - unset($sql); + //check for all required data + if (strlen($ring_group_name) == 0) { $msg .= $text['message-name']."
\n"; } + if (strlen($ring_group_extension) == 0) { $msg .= $text['message-extension']."
\n"; } + if (strlen($ring_group_strategy) == 0) { $msg .= $text['message-strategy']."
\n"; } + if (strlen($ring_group_timeout_sec) == 0) { $msg .= $text['message-strategy']."
\n"; } + if (strlen($ring_group_timeout_app) == 0) { $msg .= $text['message-timeout-action']."
\n"; } + //if (strlen($ring_group_cid_name_prefix) == 0) { $msg .= "Please provide: Caller ID Prefix
\n"; } + //if (strlen($ring_group_ringback) == 0) { $msg .= "Please provide: Ringback
\n"; } + if (strlen($ring_group_enabled) == 0) { $msg .= $text['message-enabled']."
\n"; } + //if (strlen($ring_group_description) == 0) { $msg .= "Please provide: Description
\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 ($action == "update" || $action == "add") { - //if destination then add it to ring group destinations - if (strlen($destination_number) > 0) { - $ring_group_destination_uuid = uuid(); - $sql = "insert into v_ring_group_destinations "; + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + //prepare the uuids + $ring_group_uuid = uuid(); + $dialplan_uuid = uuid(); + //add the ring group + $sql = "insert into v_ring_groups "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "ring_group_uuid, "; - $sql .= "ring_group_destination_uuid, "; - $sql .= "destination_delay, "; - $sql .= "destination_timeout, "; - $sql .= "destination_prompt, "; - $sql .= "destination_number "; - $sql .= ") "; + $sql .= "ring_group_name, "; + $sql .= "ring_group_extension, "; + $sql .= "ring_group_context, "; + $sql .= "ring_group_strategy, "; + $sql .= "ring_group_timeout_sec, "; + $sql .= "ring_group_timeout_app, "; + $sql .= "ring_group_timeout_data, "; + $sql .= "ring_group_cid_name_prefix, "; + $sql .= "ring_group_ringback, "; + $sql .= "ring_group_enabled, "; + $sql .= "ring_group_description, "; + $sql .= "dialplan_uuid "; + $sql .= ")"; $sql .= "values "; $sql .= "("; $sql .= "'".$_SESSION['domain_uuid']."', "; - $sql .= "'$ring_group_uuid', "; - $sql .= "'$ring_group_destination_uuid', "; - $sql .= "'$destination_delay', "; - if (strlen($destination_timeout) > 0) { - $sql .= "'$destination_timeout', "; - } - else { - $sql .= "'30', "; - } - if (strlen($destination_prompt) > 0) { - $sql .= "'$destination_prompt', "; - } - else { - $sql .= "null, "; - } - $sql .= "'$destination_number' "; + $sql .= "'".$ring_group_uuid."', "; + $sql .= "'$ring_group_name', "; + $sql .= "'$ring_group_extension', "; + $sql .= "'$ring_group_context', "; + $sql .= "'$ring_group_strategy', "; + $sql .= "'$ring_group_timeout_sec', "; + $sql .= "'$ring_group_timeout_app', "; + $sql .= "'$ring_group_timeout_data', "; + $sql .= "'$ring_group_cid_name_prefix', "; + $sql .= "'$ring_group_ringback', "; + $sql .= "'$ring_group_enabled', "; + $sql .= "'$ring_group_description', "; + $sql .= "'$dialplan_uuid' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); - } + } //if ($action == "add") - //delete from the dialplan details - $sql = "delete from v_dialplan_details "; + if ($action == "update") { + $sql = "update v_ring_groups set "; + $sql .= "ring_group_name = '$ring_group_name', "; + $sql .= "ring_group_extension = '$ring_group_extension', "; + if (if_group("superadmin")) { + $sql .= "ring_group_context = '$ring_group_context', "; + } + $sql .= "ring_group_strategy = '$ring_group_strategy', "; + $sql .= "ring_group_timeout_sec = '$ring_group_timeout_sec', "; + $sql .= "ring_group_timeout_app = '$ring_group_timeout_app', "; + $sql .= "ring_group_timeout_data = '$ring_group_timeout_data', "; + $sql .= "ring_group_cid_name_prefix = '$ring_group_cid_name_prefix', "; + $sql .= "ring_group_ringback = '$ring_group_ringback', "; + $sql .= "ring_group_enabled = '$ring_group_enabled', "; + $sql .= "ring_group_description = '$ring_group_description' "; + //$sql .= "dialplan_uuid = '$dialplan_uuid' "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and dialplan_uuid = '".$dialplan_uuid."' "; + $sql .= "and ring_group_uuid = '$ring_group_uuid' "; $db->exec(check_sql($sql)); unset($sql); + } - //delete from the dialplan - $sql = "delete from v_dialplans "; - $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and dialplan_uuid = '".$dialplan_uuid."' "; - $db->exec(check_sql($sql)); - unset($sql); + if ($action == "update" || $action == "add") { + //if destination then add it to ring group destinations + if (strlen($destination_number) > 0) { + $ring_group_destination_uuid = uuid(); + $sql = "insert into v_ring_group_destinations "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "ring_group_uuid, "; + $sql .= "ring_group_destination_uuid, "; + $sql .= "destination_delay, "; + $sql .= "destination_timeout, "; + $sql .= "destination_prompt, "; + $sql .= "destination_number "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$_SESSION['domain_uuid']."', "; + $sql .= "'$ring_group_uuid', "; + $sql .= "'$ring_group_destination_uuid', "; + $sql .= "'$destination_delay', "; + if (strlen($destination_timeout) > 0) { + $sql .= "'$destination_timeout', "; + } + else { + $sql .= "'30', "; + } + if (strlen($destination_prompt) > 0) { + $sql .= "'$destination_prompt', "; + } + else { + $sql .= "null, "; + } + $sql .= "'$destination_number' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } - //add the dialplan - require_once "resources/classes/database.php"; - $database = new database; - $database->db = $db; - $database->table = "v_dialplans"; - $database->fields['domain_uuid'] = $_SESSION['domain_uuid']; - $database->fields['dialplan_uuid'] = $dialplan_uuid; - $database->fields['dialplan_name'] = $ring_group_name; - $database->fields['dialplan_order'] = '333'; - $database->fields['dialplan_context'] = $ring_group_context; - $database->fields['dialplan_enabled'] = 'true'; - $database->fields['dialplan_description'] = $ring_group_description; - $database->fields['app_uuid'] = '1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2'; - $database->add(); + //delete from the dialplan details + $sql = "delete from v_dialplan_details "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '".$dialplan_uuid."' "; + $db->exec(check_sql($sql)); + unset($sql); - //add the dialplan details - $database->table = "v_dialplan_details"; - $database->fields['domain_uuid'] = $_SESSION['domain_uuid']; - $database->fields['dialplan_uuid'] = $dialplan_uuid; - $database->fields['dialplan_detail_uuid'] = uuid(); - $database->fields['dialplan_detail_tag'] = 'condition'; //condition, action, antiaction - $database->fields['dialplan_detail_type'] = 'destination_number'; - $database->fields['dialplan_detail_data'] = '^'.$ring_group_extension.'$'; - $database->fields['dialplan_detail_order'] = '000'; - $database->add(); + //delete from the dialplan + $sql = "delete from v_dialplans "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '".$dialplan_uuid."' "; + $db->exec(check_sql($sql)); + unset($sql); - //add the dialplan details - $database->table = "v_dialplan_details"; - $database->fields['domain_uuid'] = $_SESSION['domain_uuid']; - $database->fields['dialplan_uuid'] = $dialplan_uuid; - $database->fields['dialplan_detail_uuid'] = uuid(); - $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction - $database->fields['dialplan_detail_type'] = 'set'; - $database->fields['dialplan_detail_data'] = 'ring_group_uuid='.$ring_group_uuid; - $database->fields['dialplan_detail_order'] = '025'; - $database->add(); + //add the dialplan + require_once "resources/classes/database.php"; + $database = new database; + $database->db = $db; + $database->table = "v_dialplans"; + $database->fields['domain_uuid'] = $_SESSION['domain_uuid']; + $database->fields['dialplan_uuid'] = $dialplan_uuid; + $database->fields['dialplan_name'] = $ring_group_name; + $database->fields['dialplan_order'] = '333'; + $database->fields['dialplan_context'] = $ring_group_context; + $database->fields['dialplan_enabled'] = 'true'; + $database->fields['dialplan_description'] = $ring_group_description; + $database->fields['app_uuid'] = '1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2'; + $database->add(); - //add the dialplan details - $database->table = "v_dialplan_details"; - $database->fields['domain_uuid'] = $_SESSION['domain_uuid']; - $database->fields['dialplan_uuid'] = $dialplan_uuid; - $database->fields['dialplan_detail_uuid'] = uuid(); - $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction - $database->fields['dialplan_detail_type'] = 'lua'; - $database->fields['dialplan_detail_data'] = 'app.lua ring_groups'; - $database->fields['dialplan_detail_order'] = '030'; - $database->add(); + //add the dialplan details + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $_SESSION['domain_uuid']; + $database->fields['dialplan_uuid'] = $dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'condition'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'destination_number'; + $database->fields['dialplan_detail_data'] = '^'.$ring_group_extension.'$'; + $database->fields['dialplan_detail_order'] = '000'; + $database->add(); - //save the xml - save_dialplan_xml(); + //add the dialplan details + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $_SESSION['domain_uuid']; + $database->fields['dialplan_uuid'] = $dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'set'; + $database->fields['dialplan_detail_data'] = 'ring_group_uuid='.$ring_group_uuid; + $database->fields['dialplan_detail_order'] = '025'; + $database->add(); - //apply settings reminder - $_SESSION["reload_xml"] = true; + //add the dialplan details + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $_SESSION['domain_uuid']; + $database->fields['dialplan_uuid'] = $dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'lua'; + $database->fields['dialplan_detail_data'] = 'app.lua ring_groups'; + $database->fields['dialplan_detail_order'] = '030'; + $database->add(); - //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:".$ring_group_context; - $switch_result = event_socket_request($fp, 'api '.$switch_cmd); - } + //save the xml + save_dialplan_xml(); - //redirect the browser - require_once "resources/header.php"; - echo "\n"; - echo "
\n"; - if ($action == "add") { - echo $text['message-add']."\n"; - } - if ($action == "update") { - echo $text['message-update']."\n"; - } - echo "
\n"; - require_once "resources/footer.php"; - exit; - } - } //if ($_POST["persistformvar"] != "true") -} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //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:".$ring_group_context; + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + } + + //redirect the browser + require_once "resources/header.php"; + echo "\n"; + echo "
\n"; + if ($action == "add") { + echo $text['message-add']."\n"; + } + if ($action == "update") { + echo $text['message-update']."\n"; + } + echo "
\n"; + require_once "resources/footer.php"; + exit; + } + } //if ($_POST["persistformvar"] != "true") + } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { @@ -489,7 +519,9 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " ".$text['label-destination_number']."\n"; echo " ".$text['label-destination_delay']."\n"; echo " ".$text['label-destination_timeout']."\n"; - echo " ".$text['label-destination_prompt']."\n"; + if (permission_exists('ring_group_prompt')) { + echo " ".$text['label-destination_prompt']."\n"; + } echo " \n"; echo " \n"; if ($action == "update") { @@ -514,17 +546,19 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " \n"; echo " ".$field['destination_timeout']." \n"; echo " \n"; - echo " \n"; - if ($field['destination_prompt'] == "1") { - echo " ".$text['label-destination_prompt_confirm']." \n"; + if (permission_exists('ring_group_prompt')) { + echo " \n"; + if ($field['destination_prompt'] == "1") { + echo " ".$text['label-destination_prompt_confirm']." \n"; + } + elseif ($field['destination_prompt'] == "2") { + echo " ".$text['label-destination_prompt_announce']." \n"; + } + else { + echo "  \n"; + } + echo " \n"; } - elseif ($field['destination_prompt'] == "2") { - echo " ".$text['label-destination_prompt_announce']." \n"; - } - else { - echo "  \n"; - } - echo " \n"; echo " \n"; echo " $v_link_label_edit\n"; echo " $v_link_label_delete\n"; @@ -545,13 +579,15 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { destination_select('destination_timeout', $destination_timeout, '30'); echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; + if (permission_exists('ring_group_prompt')) { + echo " \n"; + echo " \n"; + echo " \n"; + } echo " \n"; echo " \n"; echo " \n"; @@ -640,6 +676,51 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; + echo " "; + echo " ".$text['label-user_list'].":"; + echo " "; + echo " \n"; + $sql = "SELECT u.username, r.user_uuid, r.ring_group_uuid FROM v_ring_group_users as r, v_users as u "; + $sql .= "where r.user_uuid = u.user_uuid "; + $sql .= "and u.user_enabled = 'true' "; + $sql .= "and r.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and r.ring_group_uuid = '".$ring_group_uuid."' "; + $sql .= "order by u.username asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + foreach($result as $field) { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + echo "
".$field['username']."\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + echo "
\n"; + $sql = "SELECT * FROM v_users "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and user_enabled = 'true' "; + $sql .= "order by username asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + echo " "; + echo " \n"; + unset($sql, $result); + echo "
\n"; + echo " ".$text['description-user_list']."\n"; + echo "
\n"; + echo " "; + echo " "; + echo "\n"; echo "\n"; echo " ".$text['label-enabled'].":\n"; diff --git a/app/ring_groups/ring_group_forward.php b/app/ring_groups/ring_group_forward.php index 31ea6e4193..0e46bfba46 100644 --- a/app/ring_groups/ring_group_forward.php +++ b/app/ring_groups/ring_group_forward.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2013 the Initial Developer. All Rights Reserved. Contributor(s): @@ -27,7 +27,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('ring_group_view')) { +if (permission_exists('ring_group_forward')) { //access granted } else { @@ -69,8 +69,18 @@ require_once "resources/paging.php"; //echo "\n"; //prepare to page the results - $sql = "select count(*) as num_rows from v_ring_groups "; - $sql .= "where domain_uuid = '$domain_uuid' "; + if (permission_exists('ring_group_add') || permission_exists('ring_group_edit')) { + //show all ring groups + $sql = "select count(*) as num_rows from v_ring_groups "; + $sql .= "where domain_uuid = '$domain_uuid' "; + } + else { + //show only assigned fax extensions + $sql = "select count(*) as num_rows from v_ring_groups as r, v_ring_group_users as u "; + $sql .= "where r.ring_group_uuid = u.ring_group_uuid "; + $sql .= "and r.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and u.user_uuid = '".$_SESSION['user_uuid']."' "; + } if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } $prep_statement = $db->prepare($sql); if ($prep_statement) { @@ -93,9 +103,24 @@ require_once "resources/paging.php"; $offset = $rows_per_page * $page; //get the list - $sql = " select * from v_ring_groups "; - $sql .= " where domain_uuid = '$domain_uuid' "; - if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + if (permission_exists('ring_group_add') || permission_exists('ring_group_edit')) { + //show all ring groups + $sql = "select * from v_ring_groups "; + $sql .= "where domain_uuid = '$domain_uuid' "; + } + else { + //show only assigned fax extensions + $sql = "select r.ring_group_uuid, r.ring_group_extension, r.ring_group_description from v_ring_groups as r, v_ring_group_users as u "; + $sql .= "where r.ring_group_uuid = u.ring_group_uuid "; + $sql .= "and r.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and u.user_uuid = '".$_SESSION['user_uuid']."' "; + } + if (strlen($order_by) == 0) { + $sql .= "order by ring_group_extension asc "; + } + else { + $sql .= "order by $order_by $order "; + } $sql .= " limit $rows_per_page offset $offset "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); @@ -133,7 +158,7 @@ require_once "resources/paging.php"; //echo " ".$row['ring_group_timeout_app']." \n"; //echo " ".$row['ring_group_timeout_data']." \n"; //echo " ".$row['ring_group_enabled']." \n"; - echo " ".$text['label-call-forward']."\n"; + echo " ".$text['link-call-forward']."\n"; echo " ".$row['ring_group_description']." \n"; echo "\n"; if ($c==0) { $c=1; } else { $c=0; } diff --git a/app/ring_groups/ring_group_forward_edit.php b/app/ring_groups/ring_group_forward_edit.php index 9146394199..f270c36b18 100644 --- a/app/ring_groups/ring_group_forward_edit.php +++ b/app/ring_groups/ring_group_forward_edit.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2013 the Initial Developer. All Rights Reserved. Contributor(s): @@ -28,7 +28,7 @@ require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions - if (permission_exists('ring_group_add') || permission_exists('ring_group_edit') || permission_exists('ring_call_forward')) { + if (permission_exists('ring_group_add') || permission_exists('ring_group_edit') || permission_exists('ring_group_forward')) { //access granted } else { diff --git a/app/ring_groups/ring_groups.php b/app/ring_groups/ring_groups.php index e9c144782d..3b9f58e41b 100644 --- a/app/ring_groups/ring_groups.php +++ b/app/ring_groups/ring_groups.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2010-2013 the Initial Developer. All Rights Reserved. Contributor(s):