Kaynağa Gözat

Deprecate hunt groups since ring groups now have equivalent features. However keep hunt groups code around in case someone wants to revive it in the future.

Mark Crane 12 yıl önce
ebeveyn
işleme
df935bc160

+ 281 - 0
hunt_groups/app_config.php

@@ -0,0 +1,281 @@
+<?php
+	//application details
+		$apps[$x]['name'] = "Hunt Group";
+		$apps[$x]['uuid'] = '0610f841-2e27-4c5f-7926-08ab3aad02e0';
+		$apps[$x]['category'] = 'Switch';;
+		$apps[$x]['subcategory'] = '';
+		$apps[$x]['version'] = '';
+		$apps[$x]['license'] = 'Mozilla Public License 1.1';
+		$apps[$x]['url'] = 'http://www.fusionpbx.com';
+		$apps[$x]['description']['en-us'] = 'A Hunt Group is a list of destinations that can be called in sequence or simultaneously.';
+		$apps[$x]['description']['es-mx'] = 'Un grupo en caza es una lista de destinos que pueden ser llamados en sequencia o simultáneamente.';
+		$apps[$x]['description']['de'] = '';
+		$apps[$x]['description']['de-ch'] = '';
+		$apps[$x]['description']['de-at'] = '';
+		$apps[$x]['description']['fr'] = "Un groupe chasse est une liste de destinataires qui peuvent être appellés en séquence ou simultanément.";
+		$apps[$x]['description']['fr-ca'] = '';
+		$apps[$x]['description']['fr-ch'] = '';
+		$apps[$x]['description']['pt-pt'] = 'Um grupo de busca é uma lista de destinos que podem ser chamados em sequência ou simultaneamente.';
+		$apps[$x]['description']['pt-br'] = '';
+
+	//menu details
+		$apps[$x]['menu'][0]['title']['en-us'] = 'Hunt Groups';
+		$apps[$x]['menu'][0]['title']['es-mx'] = 'Grupos de Caza';
+		$apps[$x]['menu'][0]['title']['de'] = '';
+		$apps[$x]['menu'][0]['title']['de-ch'] = '';
+		$apps[$x]['menu'][0]['title']['de-at'] = '';
+		$apps[$x]['menu'][0]['title']['fr'] = 'Group chasse';
+		$apps[$x]['menu'][0]['title']['fr-ca'] = '';
+		$apps[$x]['menu'][0]['title']['fr-ch'] = '';
+		$apps[$x]['menu'][0]['title']['pt-pt'] = 'Grupo de Busca';
+		$apps[$x]['menu'][0]['title']['pt-br'] = '';
+		$apps[$x]['menu'][0]['uuid'] = '632f87de-7f86-b68f-c629-4c2d2b3ce545';
+		$apps[$x]['menu'][0]['parent_uuid'] = 'fd29e39c-c936-f5fc-8e2b-611681b266b5';
+		$apps[$x]['menu'][0]['category'] = 'internal';
+		$apps[$x]['menu'][0]['path'] = '/app/hunt_groups/hunt_groups.php';
+		$apps[$x]['menu'][0]['groups'][] = 'admin';
+		$apps[$x]['menu'][0]['groups'][] = 'superadmin';
+
+	//permission details
+		$apps[$x]['permissions'][0]['name'] = 'hunt_group_view';
+		$apps[$x]['permissions'][0]['groups'][] = 'admin';
+		$apps[$x]['permissions'][0]['groups'][] = 'superadmin';
+		
+		$apps[$x]['permissions'][1]['name'] = 'hunt_group_add';
+		$apps[$x]['permissions'][1]['groups'][] = 'admin';
+		$apps[$x]['permissions'][1]['groups'][] = 'superadmin';
+	
+		$apps[$x]['permissions'][2]['name'] = 'hunt_group_edit';
+		$apps[$x]['permissions'][2]['groups'][] = 'admin';
+		$apps[$x]['permissions'][2]['groups'][] = 'superadmin';
+	
+		$apps[$x]['permissions'][3]['name'] = 'hunt_group_delete';
+		$apps[$x]['permissions'][3]['groups'][] = 'admin';
+		$apps[$x]['permissions'][3]['groups'][] = 'superadmin';
+
+		$apps[$x]['permissions'][4]['name'] = 'hunt_group_call_forward';
+
+	//schema details
+		$y = 0; //table array index
+		$z = 0; //field array index
+		$apps[$x]['db'][$y]['table'] = 'v_hunt_groups';
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'hunt_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'] = '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'] = 'dialplan_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_dialplans';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'dialplan_uuid';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'hunt_group_extension';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'huntgroupextension';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'hunt_group_name';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'huntgroupname';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'hunt_group_type';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'huntgrouptype';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'hunt_group_context';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'huntgroupcontext';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'hunt_group_timeout';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'huntgrouptimeout';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'hunt_group_timeout_destination';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'huntgrouptimeoutdestination';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'hunt_group_timeout_type';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'huntgrouptimeouttype';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'hunt_group_ringback';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'huntgroupringback';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'hunt_group_cid_name_prefix';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'huntgroupcidnameprefix';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'hunt_group_pin';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'huntgrouppin';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'hunt_group_caller_announce';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'huntgroupcallerannounce';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'hunt_group_call_prompt';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'hunt_group_user_list';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'hunt_group_enabled';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'hunt_group_description';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'huntgroup_desc';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+
+		$y = 1; //table array index
+		$z = 0; //field array index
+		$apps[$x]['db'][$y]['table'] = 'v_hunt_group_destinations';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'id';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'hunt_group_destination_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'serial';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = 'true';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'hunt_group_destination_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'] = 'hunt_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_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'] = 'v_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = 'true';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'hunt_group_id';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = 'true';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'destination_data';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'destinationdata';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'destination_type';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'destinationtype';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'destination_profile';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'destinationprofile';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'destination_timeout';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'destination_order';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'destinationorder';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'destination_enabled';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'destination_description';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'destinationdescr';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+
+		$y = 2; //table array index
+		$z = 0; //field array index
+		$apps[$x]['db'][$y]['table'] = 'v_hunt_group_users';
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'id';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'serial';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'integer';
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'INT NOT NULL AUTO_INCREMENT';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = 'true';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'hunt_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'] = 'hunt_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_hunt_groups';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'hunt_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'] = '';
+?>

+ 97 - 0
hunt_groups/app_languages.php

@@ -0,0 +1,97 @@
+<?php
+
+//Hunt Groups
+
+$text['title-hunt_groups']['en-us'] = 'Hunt Groups';
+$text['title-hunt_group']['en-us'] = 'Hunt Group';
+$text['title-hunt_group_destination_add']['en-us'] = 'Destination Add';
+$text['title-hunt_group_destination_edit']['en-us'] = 'Destination Edit';
+$text['title-hunt-group_call_forward']['en-us'] = 'Hunt Group Call Forward';
+
+$text['header-hunt_groups']['en-us'] = 'Hunt Groups';
+$text['header-hunt_group']['en-us'] = 'Hunt Group';
+$text['header-hunt_group_destinations']['en-us'] = 'Destinations';
+$text['header-hunt_group_destination_add']['en-us'] = 'Destination Add';
+$text['header-hunt_group_destination_edit']['en-us'] = 'Destination Edit';
+$text['header-hunt-group_call_forward']['en-us'] = 'Hunt Group Call Forward';
+
+$text['description-hunt_groups']['en-us'] = 'A Hunt Group is a list of destinations that can be called in sequence or simultaneously.';
+$text['description-hunt_group']['en-us'] = 'Specify the attributes of your Hunt Group below.';
+$text['description-hunt_group_destinations']['en-us'] = 'The following destinations will be called.';
+$text['description-hunt_group_call_forward']['en-us'] = 'Use the links to configure hunt group call forward. The following hunt groups have been assigned to this user account.';
+$text['description-hunt_group_call_forward_edit']['en-us'] = 'Directs incoming calls for extension';
+
+$text['label-name']['en-us'] = 'Name';
+$text['label-extension']['en-us'] = 'Extension';
+$text['label-strategy']['en-us'] = 'Strategy';
+$text['label-timeout']['en-us'] = 'Timeout';
+$text['label-timeout_destination']['en-us'] = 'Timeout Destination';
+$text['label-timeout_type']['en-us'] = 'Timeout Type';
+$text['label-ring_back']['en-us'] = 'Ring Back';
+$text['label-caller_id_name_prefix']['en-us'] = 'Caller ID Name Prefix';
+$text['label-pin_number']['en-us'] = 'PIN Number';
+$text['label-caller_announce']['en-us'] = 'Caller Announce';
+$text['label-user_list']['en-us'] = 'User List';
+$text['label-enabled']['en-us'] = 'Enabled';
+$text['label-description']['en-us'] = 'Description';
+$text['label-destination']['en-us'] = 'Destination';
+$text['label-type']['en-us'] = 'Type';
+$text['label-profile']['en-us'] = 'Profile';
+$text['label-order']['en-us'] = 'Order';
+$text['label-tools']['en-us'] = 'Tools';
+$text['label-call_forward']['en-us'] = 'Call Forward';
+$text['label-call_prompt']['en-us'] = 'Call Prompt';
+$text['label-number']['en-us'] = 'Number';
+
+$text['description-name']['en-us'] = 'Enter a name for this hunt group.';
+$text['description-extension']['en-us'] = 'Enter an extension for this hunt group. (eg. 7002)';
+$text['description-strategy']['en-us'] = 'Select a ring strategy.';
+$text['description-timeout']['en-us'] = 'The timeout sets the time in seconds to continue to call before timing out.';
+$text['description-timeout_destination']['en-us'] = 'Enter the timeout destination. (eg. 1001)';
+$text['description-timeout_type']['en-us'] = 'Select the timeout destination type.';
+$text['description-ring_back']['en-us'] = 'Select what the caller will hear while the destination is being called.';
+$text['description-caller_id_name_prefix']['en-us'] = 'Set a prefix on the caller ID name.';
+$text['description-pin_number']['en-us'] = 'If this is provided then the caller will be required to enter the PIN number.';
+$text['description-user_list_select']['en-us'] = 'Select users above to add to the user list below. This will assign users to this hunt group extension.';
+$text['description-user_list_textarea']['en-us'] = 'Assign the users that can manage this hunt group extension.';
+$text['description-enabled']['en-us'] = 'Set the status of this hunt group.';
+$text['description-description']['en-us'] = 'Enter a description here, if desired (not parsed).';
+$text['description-destination_timeout']['en-us'] = 'Select the destination timeout in seconds.';
+$text['description-destination_order']['en-us'] = 'The processing of each destination is determined by the order specified above.';
+$text['description-destination_examples']['en-us'] = 'Example Values';
+$text['description-destination_example_extension']['en-us'] = 'Extension';
+$text['description-destination_example_voicemail']['en-us'] = 'Voicemail';
+$text['description-destination_example_sip_uri_voicemail']['en-us'] = 'SIP URI (Voicemail)';
+$text['description-destination_example_sip_uri_external_number']['en-us'] = 'SIP URI (External Number)';
+$text['description-destination_example_sip_uri_auto_attendant']['en-us'] = 'SIP URI (Auto Attendant)';
+$text['description-destination_example_sip_uri_user']['en-us'] = 'SIP URI (User)';
+
+$text['option-true']['en-us'] = 'True';
+$text['option-false']['en-us'] = 'False';
+$text['option-simultaneous']['en-us'] = 'Simultaneous';
+$text['option-sequential']['en-us'] = 'Sequential';
+$text['option-extension']['en-us'] = 'Extension';
+$text['option-voicemail']['en-us'] = 'Voicemail';
+$text['option-sip_uri']['en-us'] = 'SIP URI';
+$text['option-enabled']['en-us'] = 'Enabled';
+$text['option-disabled']['en-us'] = 'Disabled';
+
+$text['button-add']['en-us'] = 'Add';
+$text['button-edit']['en-us'] = 'Edit';
+$text['button-delete']['en-us'] = 'Delete';
+$text['button-advanced']['en-us'] = 'Advanced';
+$text['button-copy']['en-us'] = 'Copy';
+$text['button-back']['en-us'] = 'Back';
+$text['button-save']['en-us'] = 'Save';
+
+$text['confirm-delete']['en-us'] = 'Do you really want to delete this?';
+$text['confirm-copy']['en-us'] = 'Do you really want to copy this?';
+
+$text['message-add']['en-us'] = 'Add Completed';
+$text['message-update']['en-us'] = 'Update Completed';
+$text['message-delete']['en-us'] = 'Delete Completed';
+$text['message-copy']['en-us'] = 'Copy Completed';
+$text['message_extension']['en-us'] = 'Enter the new Extension to use...';
+$text['message-required']['en-us'] = 'Please provide: ';
+
+?>

+ 135 - 0
hunt_groups/hunt_group_call_forward.php

@@ -0,0 +1,135 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+
+//check permissions
+if (permission_exists('hunt_group_call_forward')) {
+
+	require_once "resources/header.php";
+	$page["title"] = $text['title-hunt-group_call_forward'];
+
+	require_once "resources/paging.php";
+
+
+	//add multi-lingual support
+	require_once "app_languages.php";
+	foreach($text as $key => $value) {
+		$text[$key] = $value[$_SESSION['domain']['language']['code']];
+	}
+
+	$order_by = $_GET["order_by"];
+	$order = $_GET["order"];
+
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"center\">\n";
+
+	if ($is_included != "true") {
+		echo "	<br>";
+		echo "	<table width=\"100%\" border=\"0\" cellpadding=\"6\" cellspacing=\"0\">\n";
+		echo "	<tr>\n";
+		echo "	<td align='left'><b>".$text['header-hunt-group_call_forward']."</b><br>\n";
+		echo "		".$text['description-hunt_group_call_forward']."\n";
+		echo "	</td>\n";
+		echo "	</tr>\n";
+		echo "	</table>\n";
+		echo "	<br />";
+	}
+
+	$sql = "select * from v_hunt_groups ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and hunt_group_type <> 'dnd' ";
+	$sql .= "and hunt_group_type <> 'call_forward' ";
+	$sql .= "and hunt_group_type <> 'follow_me_simultaneous' ";
+	$sql .= "and hunt_group_type <> 'follow_me_sequence' ";
+	if (!(permission_exists('hunt_group_add') || permission_exists('hunt_group_edit'))) {
+		$sql .= "and hunt_group_user_list like '%|".$_SESSION["username"]."|%' ";
+	}
+	if (strlen($order_by)> 0) {
+		$sql .= "order by $order_by $order ";
+	}
+	else {
+		$sql .= "order by hunt_group_extension asc ";
+	}
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$result_count = count($result);
+	unset ($prep_statement, $sql);
+
+	$c = 0;
+	$row_style["0"] = "row_style0";
+	$row_style["1"] = "row_style1";
+
+	if ($is_included == "true" && $result_count == 0) {
+		//hide this when there is no result
+	}
+	else {
+		echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+		echo "<tr>\n";
+		echo "<th>".$text['label-extension']."</th>\n";
+		echo "<th>".$text['label-tools']."</th>\n";
+		echo "<th>".$text['label-description']."</th>\n";
+		echo "</tr>\n";
+	}
+
+	if ($result_count > 0) {
+		foreach($result as $row) {
+			echo "<tr >\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['hunt_group_extension']."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>\n";
+			echo "		<a href='".PROJECT_PATH."/app/hunt_group/hunt_group_call_forward_edit.php?id=".$row['hunt_group_uuid']."&a=call_forward' alt='".$text['label-call_forward']."'>".$text['label-call_forward']."</a> \n";
+			echo "	</td>\n";
+			echo "	<td valign='top' class='row_stylebg' width='40%'>".$row['hunt_group_description']."&nbsp;</td>\n";
+			echo "</tr>\n";
+			if ($c==0) { $c=1; } else { $c=0; }
+		}
+		unset($sql, $result, $row_count);
+	} //end if results
+
+	if ($is_included == "true" && $result_count == 0) {
+		//hide this when there is no result
+	}
+	else {
+		echo "</table>";
+
+		echo "<br>";
+		echo "<br>";
+		echo "<br>";
+	}
+
+	echo "</table>";
+	echo "</div>";
+
+	if ($is_included != "true") {
+		require_once "resources/footer.php";
+	}
+}
+
+?>

+ 495 - 0
hunt_groups/hunt_group_call_forward_edit.php

@@ -0,0 +1,495 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+
+//check permissions
+	if (permission_exists('hunt_group_add') || permission_exists('hunt_group_edit') || permission_exists('hunt_group_call_forward')) {
+		//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']];
+	}
+
+function destination_select($select_name, $select_value, $select_default) {
+	if (strlen($select_value) == 0) { $select_value = $select_default; }
+	echo "	<select class='formfld' style='width: 40px;' name='$select_name'>\n";
+	echo "	<option value=''></option>\n";
+
+	$i=5;
+	while($i<=100) {
+		if ($select_value == $i) {
+			echo "	<option value='$i' selected='selected'>$i</option>\n";
+		}
+		else {
+			echo "	<option value='$i'>$i</option>\n";
+		}
+		$i=$i+5;
+	}
+	echo "</select>\n";
+}
+
+//show the header
+	require_once "resources/header.php";
+	$page["title"] = $text['title-hunt-group_call_forward'];
+
+//get the hunt_group_uuid
+	$hunt_group_uuid = $_REQUEST["id"];
+
+//hunt_group information used to determine if this is an add or an update
+	$sql = "select * from v_hunt_groups ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and hunt_group_uuid = '$hunt_group_uuid' ";
+	if (!(permission_exists('hunt_group_add') || permission_exists('hunt_group_edit'))) {
+		$sql .= "and hunt_group_user_list like '%|".$_SESSION["username"]."|%' ";
+	}
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	foreach ($result as &$row) {
+		$hunt_group_uuid = $row["hunt_group_uuid"];
+		$hunt_group_extension = $row["hunt_group_extension"];
+	}
+	unset ($prep_statement);
+
+if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+
+	//get http post variables and set them to php variables
+		if (count($_POST)>0) {
+			$call_forward_enabled = check_str($_POST["call_forward_enabled"]);
+			$call_forward_number = check_str($_POST["call_forward_number"]);
+			$hunt_group_call_prompt = check_str($_POST["hunt_group_call_prompt"]);
+
+			if (strlen($call_forward_number) > 0) {
+				$call_forward_number = preg_replace("~[^0-9]~", "",$call_forward_number);
+			}
+
+			//set the default
+				if (strlen($hunt_group_call_prompt) == 0) {
+					$hunt_group_call_prompt = 'false';
+				}
+		}
+
+	//check for all required data
+		//if (strlen($call_forward_enabled) == 0) { $msg .= $text['message-required'].$text['label-call_forward']."<br>\n"; }
+		//if (strlen($call_forward_number) == 0) { $msg .= $text['message-required'].$text['label-number']."<br>\n"; }
+		//if (strlen($hunt_group_call_prompt) == 0) { $msg .= $text['message-required'].$text['label-call_prompt']."<br>\n"; }
+		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			require_once "resources/header.php";
+			require_once "resources/persist_form_var.php";
+			echo "<div align='center'>\n";
+			echo "<table><tr><td>\n";
+			echo $msg."<br />";
+			echo "</td></tr></table>\n";
+			persistformvar($_POST);
+			echo "</div>\n";
+			require_once "resources/footer.php";
+			return;
+		}
+
+	//call forward is enabled so disable the hunt group
+		if ($call_forward_enabled == "true") {
+			$sql = "update v_hunt_groups set hunt_group_enabled = 'false' ";
+			$sql .= "where hunt_group_extension = '$hunt_group_extension' ";
+			$sql .= "and (hunt_group_type = 'simultaneous' or hunt_group_type = 'sequentially') ";
+			$db->exec(check_sql($sql));
+		}
+
+	//call forward is disabled so enable the hunt group
+		if ($call_forward_enabled == "false" || $call_forward_enabled == "") {
+			$sql = "update v_hunt_groups set hunt_group_enabled = 'true' ";
+			$sql .= "where hunt_group_extension = '$hunt_group_extension' ";
+			$sql .= "and (hunt_group_type = 'simultaneous' or hunt_group_type = 'sequentially') ";
+			$db->exec(check_sql($sql));
+		}
+
+	//set the default action to add
+		$call_forward_action = "add";
+
+	//hunt_group information used to determine if this is an add or an update
+		$sql = "select * from v_hunt_groups ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and hunt_group_type = 'call_forward' ";
+		$sql .= "and hunt_group_extension in ( ";
+		$sql .= "select hunt_group_extension from v_hunt_groups ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and hunt_group_uuid = '$hunt_group_uuid' ";
+		if (!(permission_exists('hunt_group_add') || permission_exists('hunt_group_edit'))) {
+			$sql .= "and hunt_group_user_list like '%|".$_SESSION["username"]."|%' ";
+		}
+		$sql .= ") ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach ($result as &$row) {
+			if ($row["hunt_group_type"] == 'call_forward') {
+				$call_forward_action = "update";
+				$call_forward_uuid = $row["hunt_group_uuid"];
+			}
+		}
+		unset ($prep_statement);
+
+	//call forward config
+		$huntgroup_name = 'call_forward_'.$hunt_group_extension;
+		$hunt_group_type = 'call_forward';
+		$hunt_group_context = $_SESSION['context'];
+		$hunt_group_timeout = '3600';
+		$hunt_group_timeout_destination = $hunt_group_extension;
+		$hunt_group_timeout_type = 'voicemail';
+		$hunt_group_ring_back = 'us-ring';
+		$hunt_group_cid_name_prefix = '';
+		$hunt_group_pin = '';
+		$huntgroup_caller_announce = 'false';
+		$hunt_group_user_list = '';
+		$hunt_group_enabled = $call_forward_enabled;
+		$hunt_group_description = 'call forward '.$hunt_group_extension;
+
+		if ($call_forward_action == "add" && permission_exists('hunt_group_add')) {
+			$call_forward_uuid = uuid();
+			$sql = "insert into v_hunt_groups ";
+			$sql .= "(";
+			$sql .= "domain_uuid, ";
+			$sql .= "hunt_group_uuid, ";
+			$sql .= "hunt_group_extension, ";
+			$sql .= "hunt_group_name, ";
+			$sql .= "hunt_group_type, ";
+			$sql .= "hunt_group_context, ";
+			$sql .= "hunt_group_timeout, ";
+			$sql .= "hunt_group_timeout_destination, ";
+			$sql .= "hunt_group_timeout_type, ";
+			$sql .= "hunt_group_ringback, ";
+			$sql .= "hunt_group_cid_name_prefix, ";
+			$sql .= "hunt_group_pin, ";
+			$sql .= "hunt_group_call_prompt, ";
+			$sql .= "hunt_group_caller_announce, ";
+			$sql .= "hunt_group_user_list, ";
+			$sql .= "hunt_group_enabled, ";
+			$sql .= "hunt_group_description ";
+			$sql .= ")";
+			$sql .= "values ";
+			$sql .= "(";
+			$sql .= "'$domain_uuid', ";
+			$sql .= "'$call_forward_uuid', ";
+			$sql .= "'$hunt_group_extension', ";
+			$sql .= "'$huntgroup_name', ";
+			$sql .= "'$hunt_group_type', ";
+			$sql .= "'$hunt_group_context', ";
+			$sql .= "'$hunt_group_timeout', ";
+			$sql .= "'$hunt_group_timeout_destination', ";
+			$sql .= "'$hunt_group_timeout_type', ";
+			$sql .= "'$hunt_group_ring_back', ";
+			$sql .= "'$hunt_group_cid_name_prefix', ";
+			$sql .= "'$hunt_group_pin', ";
+			$sql .= "'$hunt_group_call_prompt', ";
+			$sql .= "'$huntgroup_caller_announce', ";
+			$sql .= "'$hunt_group_user_list', ";
+			$sql .= "'$hunt_group_enabled', ";
+			$sql .= "'$hunt_group_description' ";
+			$sql .= ")";
+			if ($v_debug) {
+				echo $sql."<br />";
+			}
+			$db->exec(check_sql($sql));
+			unset($sql);
+
+		//delete related v_hunt_group_destinations
+			$sql = "delete from v_hunt_group_destinations where hunt_group_uuid = '$call_forward_uuid' ";
+			$db->exec(check_sql($sql));
+
+		if (extension_exists($call_forward_number)) {
+			$destination_data = $call_forward_number;
+			$destination_type = 'extension';
+		}
+		$destination_profile = 'internal';
+		$destination_timeout = '';
+		$destination_order = '1';
+		$destination_enabled = 'true';
+		$destination_description = 'call forward';
+
+		$hunt_group_destination_uuid = uuid();
+		$sql = "insert into v_hunt_group_destinations ";
+		$sql .= "(";
+		$sql .= "domain_uuid, ";
+		$sql .= "hunt_group_uuid, ";
+		$sql .= "hunt_group_destination_uuid, ";
+		$sql .= "destination_data, ";
+		$sql .= "destination_type, ";
+		$sql .= "destination_profile, ";
+		$sql .= "destination_timeout, ";
+		$sql .= "destination_order, ";
+		$sql .= "destination_enabled, ";
+		$sql .= "destination_description ";
+		$sql .= ")";
+		$sql .= "values ";
+		$sql .= "(";
+		$sql .= "'$domain_uuid', ";
+		$sql .= "'$call_forward_uuid', ";
+		$sql .= "'$hunt_group_destination_uuid', ";
+		$sql .= "'$destination_data', ";
+		$sql .= "'$destination_type', ";
+		$sql .= "'$destination_profile', ";
+		$sql .= "'$destination_timeout', ";
+		$sql .= "'$destination_order', ";
+		$sql .= "'$destination_enabled', ";
+		$sql .= "'$destination_description' ";
+		$sql .= ")";
+		$db->exec(check_sql($sql));
+		unset($sql);
+	} //if ($call_forward_action == "add")
+
+	if ($call_forward_action == "update" && permission_exists('hunt_group_call_forward')) {
+		$sql = "update v_hunt_groups set ";
+		$sql .= "hunt_group_extension = '$hunt_group_extension', ";
+		$sql .= "hunt_group_name = '$huntgroup_name', ";
+		$sql .= "hunt_group_type = '$hunt_group_type', ";
+		$sql .= "hunt_group_context = '$hunt_group_context', ";
+		$sql .= "hunt_group_timeout = '$hunt_group_timeout', ";
+		$sql .= "hunt_group_timeout_destination = '$hunt_group_timeout_destination', ";
+		$sql .= "hunt_group_timeout_type = '$hunt_group_timeout_type', ";
+		$sql .= "hunt_group_ringback = '$hunt_group_ring_back', ";
+		$sql .= "hunt_group_cid_name_prefix = '$hunt_group_cid_name_prefix', ";
+		$sql .= "hunt_group_pin = '$hunt_group_pin', ";
+		$sql .= "hunt_group_call_prompt = '$hunt_group_call_prompt', ";
+		$sql .= "hunt_group_caller_announce = '$huntgroup_caller_announce', ";
+		$sql .= "hunt_group_user_list = '$hunt_group_user_list', ";
+		$sql .= "hunt_group_enabled = '$hunt_group_enabled', ";
+		$sql .= "hunt_group_description = '$hunt_group_description' ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and hunt_group_uuid = '$call_forward_uuid'";
+		$db->exec(check_sql($sql));
+		unset($sql);
+
+		//set the variables
+			$destination_data = $call_forward_number;
+			if (extension_exists($call_forward_number)) {
+				$destination_type = 'extension';
+			}
+			else {
+				$destination_type = 'sip uri';
+			}
+			$destination_profile = 'internal';
+			$destination_timeout = '';
+			$destination_order = '1';
+			$destination_enabled = 'true';
+			$destination_description = 'call forward';
+
+		//delete related v_hunt_group_destinations
+			$sql = "delete from v_hunt_group_destinations where hunt_group_uuid = '$call_forward_uuid' ";
+			$db->exec(check_sql($sql));
+
+		//insert the v_hunt_group_destinations
+			$hunt_group_destination_uuid = uuid();
+			$sql = "insert into v_hunt_group_destinations ";
+			$sql .= "(";
+			$sql .= "hunt_group_destination_uuid, ";
+			$sql .= "domain_uuid, ";
+			$sql .= "hunt_group_uuid, ";
+			$sql .= "destination_data, ";
+			$sql .= "destination_type, ";
+			$sql .= "destination_profile, ";
+			$sql .= "destination_timeout, ";
+			$sql .= "destination_order, ";
+			$sql .= "destination_enabled, ";
+			$sql .= "destination_description ";
+			$sql .= ")";
+			$sql .= "values ";
+			$sql .= "(";
+			$sql .= "'$hunt_group_destination_uuid', ";
+			$sql .= "'$domain_uuid', ";
+			$sql .= "'$call_forward_uuid', ";
+			$sql .= "'$destination_data', ";
+			$sql .= "'$destination_type', ";
+			$sql .= "'$destination_profile', ";
+			$sql .= "'$destination_timeout', ";
+			$sql .= "'$destination_order', ";
+			$sql .= "'$destination_enabled', ";
+			$sql .= "'$destination_description' ";
+			$sql .= ")";
+			$db->exec(check_sql($sql));
+			unset($sql);
+	} //if ($call_forward_action == "update")
+
+	//synchronize the xml config
+		save_hunt_group_xml();
+
+	//synchronize the xml config
+		save_dialplan_xml();
+
+	//redirect the user
+		require_once "resources/header.php";
+		echo "<meta http-equiv=\"refresh\" content=\"3;url=".PROJECT_PATH."/app/hunt_group/hunt_group_call_forward.php\">\n";
+		echo "<div align='center'>\n";
+		echo $text['message-update']."<br />\n";
+		echo "</div>\n";
+		require_once "resources/footer.php";
+		return;
+} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+
+
+
+//pre-populate the form
+	$sql = "select * from v_hunt_groups ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and hunt_group_type = 'call_forward' ";
+	$sql .= "and hunt_group_extension = '$hunt_group_extension' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	foreach ($result as &$row) {
+		$hunt_group_uuid = $row["hunt_group_uuid"];
+		$hunt_group_extension = $row["hunt_group_extension"];
+		$huntgroup_name = $row["hunt_group_name"];
+		$hunt_group_type = $row["hunt_group_type"];
+		$hunt_group_context = $row["hunt_group_context"];
+		$hunt_group_timeout = $row["hunt_group_timeout"];
+		$hunt_group_timeout_destination = $row["hunt_group_timeout_destination"];
+		$hunt_group_timeout_type = $row["hunt_group_timeout_type"];
+		$hunt_group_ring_back = $row["hunt_group_ringback"];
+		$hunt_group_cid_name_prefix = $row["hunt_group_cid_name_prefix"];
+		$hunt_group_pin = $row["hunt_group_pin"];
+		$hunt_group_call_prompt = $row["hunt_group_call_prompt"];
+		$huntgroup_caller_announce = $row["hunt_group_caller_announce"];
+		$hunt_group_user_list = $row["hunt_group_user_list"];
+		$hunt_group_enabled = $row["hunt_group_enabled"];
+		$hunt_group_description = $row["hunt_group_description"];
+
+		if ($row["hunt_group_type"] == 'call_forward') {
+			$call_forward_enabled = $hunt_group_enabled;
+		}
+
+		if ($row["hunt_group_type"] == 'call_forward') {
+			$sql = "select * from v_hunt_group_destinations ";
+			$sql .= "where hunt_group_uuid = '$hunt_group_uuid' ";
+			$prep_statement_2 = $db->prepare(check_sql($sql));
+			$prep_statement_2->execute();
+			$result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED);
+			$x=1;
+			foreach ($result2 as &$row2) {
+				if ($row["hunt_group_type"] == 'call_forward') {
+					if (strlen($row2["destination_data"]) > 0) {
+						$call_forward_number = $row2["destination_data"];
+					}
+				}
+			}
+			unset ($prep_statement_2);
+		}
+	}
+	unset ($prep_statement);
+
+//show the content
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n";
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"center\">\n";
+	echo "		<br>";
+
+	echo "<form method='post' name='frm' action=''>\n";
+	echo "<table width='100%'  border='0' cellpadding='6' cellspacing='0'>\n";
+	echo "<tr>\n";
+	echo "<td align='left' width='30%' nowrap>\n";
+	echo "	<b>".$text['header-hunt-group_call_forward']."</b>\n";
+	echo "</td>\n";
+	echo "<td width='70%' align='right'>\n";
+	echo "	<input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='hunt_group_call_forward.php'\" value='".$text['button-back']."'>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td colspan='2'>\n";
+	echo "	".$text['description-hunt_group_call_forward_edit']." ".$hunt_group_extension."<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	<strong>".$text['label-call_forward'].":</strong>\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	if ($call_forward_enabled == "true") {
+		echo "	<input type='radio' name='call_forward_enabled' value='true' checked='checked'/> ".$text['option-enabled']." \n";
+	}
+	else {
+		echo "	<input type='radio' name='call_forward_enabled' value='true' /> ".$text['option-enabled']." \n";
+	}
+	if ($call_forward_enabled == "false" || $call_forward_enabled == "") {
+		echo "	<input type='radio' name='call_forward_enabled' value='false' checked='checked' /> ".$text['option-disabled']." \n";
+	}
+	else {
+		echo "	<input type='radio' name='call_forward_enabled' value='false' /> ".$text['option-disabled']." \n";
+	}
+	echo "<br />\n";
+	echo "<br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	".$text['label-number'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='call_forward_number' maxlength='255' value=\"$call_forward_number\">\n";
+	echo "<br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td colspan='2'>\n";
+	echo "	<br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td colspan='2'>\n";
+	echo "	<br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "	<tr>\n";
+	echo "		<td colspan='2' align='right'>\n";
+	if ($action == "update") {
+		echo "				<input type='hidden' name='id' value='$call_forward_uuid'>\n";
+	}
+	echo "				<input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
+	echo "		</td>\n";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</form>";
+
+	echo "	</td>";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</div>";
+
+//show the footer
+	require_once "resources/footer.php";
+?>

+ 184 - 0
hunt_groups/hunt_group_copy.php

@@ -0,0 +1,184 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+require_once "resources/paging.php";
+
+//check permissions
+	if (permission_exists('hunt_group_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']];
+	}
+
+//set the http get/post variable(s) to a php variable
+	if (isset($_REQUEST["id"])) {
+		$hunt_group_uuid = check_str($_REQUEST["id"]);
+		$hunt_group_extension_new = check_str($_REQUEST["ext"]);
+	}
+
+//get the v_hunt_group data
+	$sql = "select * from v_hunt_groups ";
+	$sql .= "where hunt_group_uuid = '$hunt_group_uuid' ";
+	$sql .= "and domain_uuid = '$domain_uuid' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	foreach ($result as &$row) {
+		$hunt_group_extension = $row["hunt_group_extension"];
+		$hunt_group_name = $row["hunt_group_name"]."_copy";
+		$hunt_group_type = $row["hunt_group_type"];
+		$hunt_group_context = $row["hunt_group_context"];
+		$hunt_group_timeout = $row["hunt_group_timeout"];
+		$hunt_group_timeout_destination = $row["hunt_group_timeout_destination"];
+		$hunt_group_timeout_type = $row["hunt_group_timeout_type"];
+		$hunt_group_ringback = $row["hunt_group_ringback"];
+		$hunt_group_cid_name_prefix = $row["hunt_group_cid_name_prefix"];
+		$hunt_group_pin = $row["hunt_group_pin"];
+		$hunt_group_caller_announce = $row["hunt_group_caller_announce"];
+		$hunt_group_user_list = $row["hunt_group_user_list"];
+		$hunt_group_enabled = $row["hunt_group_enabled"];
+		$hunt_group_description = "copy: ".$row["hunt_group_description"];
+		break; //limit to 1 row
+	}
+	unset ($prep_statement);
+
+	//copy the hunt group
+		$hunt_group_uuid_new = uuid();
+		$sql = "insert into v_hunt_groups ";
+		$sql .= "(";
+		$sql .= "hunt_group_uuid, ";
+		$sql .= "domain_uuid, ";
+		$sql .= "hunt_group_extension, ";
+		$sql .= "hunt_group_name, ";
+		$sql .= "hunt_group_type, ";
+		$sql .= "hunt_group_context, ";
+		$sql .= "hunt_group_timeout, ";
+		$sql .= "hunt_group_timeout_destination, ";
+		$sql .= "hunt_group_timeout_type, ";
+		$sql .= "hunt_group_ringback, ";
+		$sql .= "hunt_group_cid_name_prefix, ";
+		$sql .= "hunt_group_pin, ";
+		$sql .= "hunt_group_caller_announce, ";
+		$sql .= "hunt_group_user_list, ";
+		$sql .= "hunt_group_enabled, ";
+		$sql .= "hunt_group_description ";
+		$sql .= ")";
+		$sql .= "values ";
+		$sql .= "(";
+		$sql .= "'$hunt_group_uuid_new', ";
+		$sql .= "'$domain_uuid', ";
+		$sql .= "'$hunt_group_extension_new', ";
+		$sql .= "'$hunt_group_name', ";
+		$sql .= "'$hunt_group_type', ";
+		$sql .= "'$hunt_group_context', ";
+		$sql .= "'$hunt_group_timeout', ";
+		$sql .= "'$hunt_group_timeout_destination', ";
+		$sql .= "'$hunt_group_timeout_type', ";
+		$sql .= "'$hunt_group_ringback', ";
+		$sql .= "'$hunt_group_cid_name_prefix', ";
+		$sql .= "'$hunt_group_pin', ";
+		$sql .= "'$hunt_group_caller_announce', ";
+		$sql .= "'$hunt_group_user_list', ";
+		$sql .= "'$hunt_group_enabled', ";
+		$sql .= "'$hunt_group_description' ";
+		$sql .= ")";
+		$db->exec(check_sql($sql));
+		unset($sql);
+
+	//get the the hunt group destinations
+		$sql = "select * from v_hunt_group_destinations ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and hunt_group_uuid = '$hunt_group_uuid' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach ($result as &$row) {
+			$destination_data = $row["destination_data"];
+			$destination_type = $row["destination_type"];
+			$destination_profile = $row["destination_profile"];
+			$destination_timeout = $row["destination_timeout"];
+			$destination_order = $row["destination_order"];
+			$destination_enabled = $row["destination_enabled"];
+			$destination_description = $row["destination_description"];
+
+			//copy the hunt group destinations
+				$hunt_group_destination_uuid = uuid();
+				$sql = "insert into v_hunt_group_destinations ";
+				$sql .= "(";
+				$sql .= "domain_uuid, ";
+				$sql .= "hunt_group_uuid, ";
+				$sql .= "hunt_group_destination_uuid, ";
+				$sql .= "destination_data, ";
+				$sql .= "destination_type, ";
+				$sql .= "destination_profile, ";
+				$sql .= "destination_timeout, ";
+				$sql .= "destination_order, ";
+				$sql .= "destination_enabled, ";
+				$sql .= "destination_description ";
+				$sql .= ")";
+				$sql .= "values ";
+				$sql .= "(";
+				$sql .= "'$domain_uuid', ";
+				$sql .= "'$hunt_group_uuid_new', ";
+				$sql .= "'$hunt_group_destination_uuid', ";
+				$sql .= "'$destination_data', ";
+				$sql .= "'$destination_type', ";
+				$sql .= "'$destination_profile', ";
+				$sql .= "'$destination_timeout', ";
+				$sql .= "'$destination_order', ";
+				$sql .= "'$destination_enabled', ";
+				$sql .= "'$destination_description' ";
+				$sql .= ")";
+				$db->exec(check_sql($sql));
+				//echo $sql."<br><br>";
+				//exit();
+				unset($sql);
+		}
+		unset ($prep_statement);
+
+	//synchronize the xml config
+		save_hunt_group_xml();
+
+	//redirect the user
+		require_once "resources/header.php";
+		echo "<meta http-equiv=\"refresh\" content=\"2;url=hunt_groups.php\">\n";
+		echo "<div align='center'>\n";
+		echo $text['message-copy']."\n";
+		echo "</div>\n";
+		require_once "resources/footer.php";
+		return;
+
+?>

+ 118 - 0
hunt_groups/hunt_group_delete.php

@@ -0,0 +1,118 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+
+//check permissions
+if (permission_exists('hunt_group_delete')) {
+	//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']];
+	}
+
+if (count($_GET)>0) {
+	$id = $_GET["id"];
+}
+
+if (strlen($id)>0) {
+
+	//start the atomic transaction
+		$count = $db->exec("BEGIN;");
+
+	//get the dialplan uuid
+		$sql = "select * from v_hunt_groups ";
+		$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
+		$sql .= "and hunt_group_uuid = '$id' ";
+		$prep_statement = $db->prepare($sql);
+		$prep_statement->execute();
+		while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) {
+			$dialplan_uuid = $row['dialplan_uuid'];
+		}
+
+	//delete child data
+		$sql = "delete from v_hunt_group_destinations ";
+		$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
+		$sql .= "and hunt_group_uuid = '$id' ";
+		$db->query($sql);
+		unset($sql);
+
+	//delete parent data
+		$sql = "delete from v_hunt_groups ";
+		$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
+		$sql .= "and hunt_group_uuid = '$id' ";
+		$db->query($sql);
+		unset($sql);
+
+	//delete the dialplan entry
+		$sql = "delete from v_dialplans ";
+		$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
+		$sql .= "and dialplan_uuid = '$dialplan_uuid' ";
+		//echo $sql."<br>\n";
+		$db->query($sql);
+		unset($sql);
+
+	//delete the dialplan details
+		$sql = "delete from v_dialplan_details ";
+		$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
+		$sql .= "and dialplan_uuid = '$dialplan_uuid' ";
+		//echo $sql."<br>\n";
+		$db->query($sql);
+		unset($sql);
+
+	//commit the atomic transaction
+		$count = $db->exec("COMMIT;");
+
+	//synchronize the xml config
+		save_hunt_group_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"]."@".$_SESSION['domain_name'];
+			$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
+		}
+
+}
+
+//redirect the user
+	require_once "resources/header.php";
+	echo "<meta http-equiv=\"refresh\" content=\"2;url=hunt_groups.php\">\n";
+	echo "<div align='center'>\n";
+	echo $text['message-delete']."\n";
+	echo "</div>\n";
+	require_once "resources/footer.php";
+	return;
+
+?>

+ 72 - 0
hunt_groups/hunt_group_destination_delete.php

@@ -0,0 +1,72 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+
+//check permissions
+	if (permission_exists('hunt_group_delete')) {
+		//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']];
+	}
+
+if (count($_GET)>0) {
+	$id = $_GET["id"];
+	$hunt_group_uuid = check_str($_REQUEST["id2"]);
+}
+
+if (strlen($id)>0) {
+	//delete the data
+		$sql = "delete from v_hunt_group_destinations ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and hunt_group_destination_uuid = '$id' ";
+		$sql .= "and hunt_group_uuid = '$hunt_group_uuid' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		unset($sql);
+	//synchronize the xml config
+		save_hunt_group_xml();
+}
+
+//redirect the user
+	require_once "resources/header.php";
+	echo "<meta http-equiv=\"refresh\" content=\"2;url=hunt_group_edit.php?id=".$hunt_group_uuid."\">\n";
+	echo "<div align='center'>\n";
+	echo $text['message-delete']."\n";
+	echo "</div>\n";
+	require_once "resources/footer.php";
+	return;
+
+?>

+ 376 - 0
hunt_groups/hunt_group_destination_edit.php

@@ -0,0 +1,376 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+
+//check permissions
+	if (permission_exists('hunt_group_add') || permission_exists('hunt_group_edit')) {
+		//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']];
+	}
+
+//set the action as an add or an update
+	if (isset($_REQUEST["id"])) {
+		$action = "update";
+		$hunt_group_destination_uuid = check_str($_REQUEST["id"]);
+	}
+	else {
+		$action = "add";
+	}
+
+	if (isset($_REQUEST["id2"])) {
+		$hunt_group_uuid = check_str($_REQUEST["id2"]);
+	}
+
+//get the http values and set them as variables
+	if (count($_POST)>0) {
+		if (isset($_POST["hunt_group_uuid"])) {
+			$hunt_group_uuid = check_str($_POST["hunt_group_uuid"]);
+		}
+		$destination_data = check_str($_POST["destination_data"]);
+		$destination_type = check_str($_POST["destination_type"]);
+		$destination_timeout = check_str($_POST["destination_timeout"]);
+		$destination_order = check_str($_POST["destination_order"]);
+		$destination_enabled = check_str($_POST["destination_enabled"]);
+		$destination_description = check_str($_POST["destination_description"]);
+	}
+
+if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+
+	$msg = '';
+	if ($action == "update") {
+		$hunt_group_destination_uuid = check_str($_POST["hunt_group_destination_uuid"]);
+	}
+
+	//check for all required data
+		if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid<br>\n"; }
+		if (strlen($destination_data) == 0) { $msg .= $text['message-required'].$text['label-destination']."<br>\n"; }
+		if (strlen($destination_type) == 0) { $msg .= $text['message-required'].$text['label-type']."<br>\n"; }
+		//if (strlen($destination_timeout) == 0) { $msg .= $text['message-required'].$text['label-timeout']."<br>\n"; }
+		//if (strlen($destination_order) == 0) { $msg .= $text['message-required'].$text['label-order']."<br>\n"; }
+		//if (strlen($destination_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
+		//if (strlen($destination_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
+		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			require_once "resources/header.php";
+			require_once "resources/persist_form_var.php";
+			echo "<div align='center'>\n";
+			echo "<table><tr><td>\n";
+			echo $msg."<br />";
+			echo "</td></tr></table>\n";
+			persistformvar($_POST);
+			echo "</div>\n";
+			require_once "resources/footer.php";
+			return;
+		}
+
+	//add or update the database
+		if ($_POST["persistformvar"] != "true") {
+			if ($action == "add" && permission_exists('hunt_group_add')) {
+				$hunt_group_destination_uuid = uuid();
+				$sql = "insert into v_hunt_group_destinations ";
+				$sql .= "(";
+				$sql .= "domain_uuid, ";
+				$sql .= "hunt_group_uuid, ";
+				$sql .= "hunt_group_destination_uuid, ";
+				$sql .= "destination_data, ";
+				$sql .= "destination_type, ";
+				$sql .= "destination_timeout, ";
+				$sql .= "destination_order, ";
+				$sql .= "destination_enabled, ";
+				$sql .= "destination_description ";
+				$sql .= ")";
+				$sql .= "values ";
+				$sql .= "(";
+				$sql .= "'$domain_uuid', ";
+				$sql .= "'$hunt_group_uuid', ";
+				$sql .= "'$hunt_group_destination_uuid', ";
+				$sql .= "'$destination_data', ";
+				$sql .= "'$destination_type', ";
+				$sql .= "'$destination_timeout', ";
+				$sql .= "'$destination_order', ";
+				$sql .= "'$destination_enabled', ";
+				$sql .= "'$destination_description' ";
+				$sql .= ")";
+				$db->exec(check_sql($sql));
+				unset($sql);
+
+				//synchronize the xml config
+				save_hunt_group_xml();
+
+				require_once "resources/header.php";
+				echo "<meta http-equiv=\"refresh\" content=\"2;url=hunt_group_edit.php?id=".$hunt_group_uuid."\">\n";
+				echo "<div align='center'>\n";
+				echo $text['message-add']."\n";
+				echo "</div>\n";
+				require_once "resources/footer.php";
+				return;
+			} //if ($action == "add")
+
+			if ($action == "update" && permission_exists('hunt_group_edit')) {
+				$sql = "update v_hunt_group_destinations set ";
+				$sql .= "domain_uuid = '$domain_uuid', ";
+				$sql .= "hunt_group_uuid = '$hunt_group_uuid', ";
+				$sql .= "destination_data = '$destination_data', ";
+				$sql .= "destination_type = '$destination_type', ";
+				$sql .= "destination_timeout = '$destination_timeout', ";
+				$sql .= "destination_order = '$destination_order', ";
+				$sql .= "destination_enabled = '$destination_enabled', ";
+				$sql .= "destination_description = '$destination_description' ";
+				$sql .= "where domain_uuid = '$domain_uuid' ";
+				$sql .= "and hunt_group_destination_uuid = '$hunt_group_destination_uuid'";
+				$db->exec(check_sql($sql));
+
+				//synchronize the xml config
+				save_hunt_group_xml();
+
+				require_once "resources/header.php";
+				echo "<meta http-equiv=\"refresh\" content=\"2;url=hunt_group_edit.php?id=".$hunt_group_uuid."\">\n";
+				echo "<div align='center'>\n";
+				echo $text['message-update']."\n";
+				echo "</div>\n";
+				require_once "resources/footer.php";
+				return;
+			} //if ($action == "update")
+		} //if ($_POST["persistformvar"] != "true")
+} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+
+//pre-populate the form
+	if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
+		$hunt_group_destination_uuid = $_GET["id"];
+		$sql = "select * from v_hunt_group_destinations ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and hunt_group_destination_uuid = '$hunt_group_destination_uuid' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach ($result as &$row) {
+			$hunt_group_uuid = $row["hunt_group_uuid"];
+			$destination_data = $row["destination_data"];
+			$destination_type = $row["destination_type"];
+			$destination_timeout = $row["destination_timeout"];
+			$destination_order = $row["destination_order"];
+			$destination_enabled = $row["destination_enabled"];
+			$destination_description = $row["destination_description"];
+			break; //limit to 1 row
+		}
+		unset ($prep_statement);
+	}
+
+//show the header
+	require_once "resources/header.php";
+	if ($action == "add") {
+		$page["title"] = $text['title-hunt_group_destination_add'];
+	}
+	if ($action == "update") {
+		$page["title"] = $text['title-hunt_group_destination_edit'];
+	}
+
+//show the content
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
+
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"left\">\n";
+	echo "      <br>";
+
+	echo "<form method='post' name='frm' action=''>\n";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%'  border='0' cellpadding='6' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	if ($action == "add") {
+		echo "<td align='left' width='30%' nowrap><b>".$text['header-hunt_group_destination_add']."</b></td>\n";
+	}
+	if ($action == "update") {
+		echo "<td align='left' width='30%' nowrap><b>".$text['header-hunt_group_destination_edit']."</b></td>\n";
+	}
+	echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='hunt_group_edit.php?id=".$hunt_group_uuid."'\" value='".$text['button-back']."'></td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "    ".$text['label-destination'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "    <input class='formfld' type='text' name='destination_data' maxlength='255' value=\"$destination_data\">\n";
+	echo "<br />\n";
+	echo "<b>".$text['description-destination_examples']."</b>...<br>\n";
+	echo $text['description-destination_example_extension'].": 1001<br />\n";
+	echo $text['description-destination_example_voicemail'].": 1001<br />\n";
+	echo $text['description-destination_example_sip_uri_voicemail'].": sofia/internal/*98@\${domain}<br />\n";
+	echo $text['description-destination_example_sip_uri_external_number'].": sofia/gateway/gatewayname/12081231234<br />\n";
+	echo $text['description-destination_example_sip_uri_auto_attendant'].": sofia/internal/5002@\${domain}<br />\n";
+	echo $text['description-destination_example_sip_uri_user'].": /user/1001@\${domain}\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "    ".$text['label-type'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "                <select name='destination_type' class='formfld'>\n";
+	echo "                <option></option>\n";
+	if ($destination_type == "extension") {
+		echo "                <option selected='yes' value='extension'>".$text['option-extension']."</option>\n";
+	}
+	else {
+		echo "                <option value='extension'>".$text['option-extension']."</option>\n";
+	}
+	if ($destination_type == "voicemail") {
+		echo "                <option selected='yes' value='voicemail'>".$text['option-voicemail']."</option>\n";
+	}
+	else {
+		echo "                <option value='voicemail'>".$text['option-voicemail']."</option>\n";
+	}
+	if ($destination_type == "sip uri") {
+		echo "                <option selected='yes' value='sip uri'>".$text['option-sip_uri']."</option>\n";
+	}
+	else {
+		echo "                <option value='sip uri'>".$text['option-sip_uri']."</option>\n";
+	}
+	echo "                </select>\n";
+	echo "<br />\n";
+	echo "\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "    ".$text['label-timeout'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "              <select name='destination_timeout' class='formfld'>\n";
+	echo "              <option></option>\n";
+	if (strlen($destination_timeout)> 0) {
+		echo "              <option selected='yes' value='".htmlspecialchars($destination_timeout)."'>".htmlspecialchars($destination_timeout)."</option>\n";
+	}
+	$i=0;
+	while($i<=301) {
+		echo "              <option value='$i'>$i</option>\n";
+		$i++;
+	}
+	echo "              </select>\n";
+	echo "<br />\n";
+	echo $text['description-destination_timeout']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "    ".$text['label-order'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "              <select name='destination_order' class='formfld'>\n";
+	if (strlen($destination_order)> 0) {
+		echo "              <option selected='yes' value='".htmlspecialchars($destination_order)."'>".htmlspecialchars($destination_order)."</option>\n";
+	}
+	$i=0;
+	while($i<=301) {
+		if (strlen($i) == 1) {
+			echo "              <option value='00$i'>00$i</option>\n";
+		}
+		if (strlen($i) == 2) {
+			echo "              <option value='0$i'>0$i</option>\n";
+		}
+		if (strlen($i) == 3) {
+			echo "              <option value='$i'>$i</option>\n";
+		}
+		$i++;
+	}
+	echo "              </select>\n";
+	echo "<br />\n";
+	echo $text['description-destination_order']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "    ".$text['label-enabled'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "    <select class='formfld' name='destination_enabled'>\n";
+	echo "    <option value=''></option>\n";
+	if ($destination_enabled == "true" || strlen($destination_enabled) == 0) {
+		echo "    <option value='true' selected >".$text['option-true']."</option>\n";
+	}
+	else {
+		echo "    <option value='true'>".$text['option-true']."</option>\n";
+	}
+	if ($destination_enabled == "false") {
+		echo "    <option value='false' selected >".$text['option-false']."</option>\n";
+	}
+	else {
+		echo "    <option value='false'>".$text['option-false']."</option>\n";
+	}
+	echo "    </select>\n";
+	echo "<br />\n";
+	echo "\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "    ".$text['label-description'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "    <input class='formfld' type='text' name='destination_description' maxlength='255' value=\"$destination_description\">\n";
+	echo "<br />\n";
+	echo $text['description-description']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "	<tr>\n";
+	echo "		<td colspan='2' align='right'>\n";
+	echo "				<input type='hidden' name='hunt_group_uuid' value='$hunt_group_uuid'>\n";
+	if ($action == "update") {
+		echo "				<input type='hidden' name='hunt_group_destination_uuid' value='$hunt_group_destination_uuid'>\n";
+	}
+	echo "				<input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
+	echo "		</td>\n";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</form>";
+
+	echo "	</td>";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</div>";
+
+//show the footer
+	require_once "resources/footer.php";
+?>

+ 739 - 0
hunt_groups/hunt_group_edit.php

@@ -0,0 +1,739 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+require_once "resources/paging.php";
+
+//check permissions
+	if (permission_exists('hunt_group_add') || permission_exists('hunt_group_edit')) {
+		//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']];
+	}
+
+//action add or update
+	if (isset($_REQUEST["id"])) {
+		$action = "update";
+		$hunt_group_uuid = check_str($_REQUEST["id"]);
+		$dialplan_uuid = check_str($_REQUEST["dialplan_uuid"]);
+	}
+	else {
+		$action = "add";
+	}
+
+//get the http values and set them as variables
+	if (count($_POST)>0) {
+		$hunt_group_extension = check_str($_POST["hunt_group_extension"]);
+		$hunt_group_name = check_str($_POST["hunt_group_name"]);
+		$hunt_group_type = check_str($_POST["hunt_group_type"]);
+		$hunt_group_timeout = check_str($_POST["hunt_group_timeout"]);
+		$hunt_group_timeout_destination = check_str($_POST["hunt_group_timeout_destination"]);
+		$hunt_group_timeout_type = check_str($_POST["hunt_group_timeout_type"]);
+		$hunt_group_ringback = check_str($_POST["hunt_group_ringback"]);
+		$hunt_group_cid_name_prefix = check_str($_POST["hunt_group_cid_name_prefix"]);
+		$hunt_group_pin = check_str($_POST["hunt_group_pin"]);
+		$hunt_group_caller_announce = check_str($_POST["hunt_group_caller_announce"]);
+
+		//prepare the user list for the database
+		$hunt_group_user_list = $_POST["hunt_group_user_list"];
+		if (strlen($hunt_group_user_list) > 0) {
+			$hunt_group_user_list_array = explode("\n", $hunt_group_user_list);
+			if (count($hunt_group_user_list_array) == 0) {
+				$hunt_group_user_list = '';
+			}
+			else {
+				$hunt_group_user_list = '|';
+				foreach($hunt_group_user_list_array as $user){
+					if(strlen(trim($user)) > 0) {
+						$hunt_group_user_list .= check_str(trim($user))."|";
+					}
+				}
+			}
+		}
+
+		$hunt_group_enabled = check_str($_POST["hunt_group_enabled"]);
+		$hunt_group_description = check_str($_POST["hunt_group_description"]);
+
+		//remove invalid characters
+		$hunt_group_cid_name_prefix = str_replace(":", "-", $hunt_group_cid_name_prefix);
+		$hunt_group_cid_name_prefix = str_replace("\"", "", $hunt_group_cid_name_prefix);
+		$hunt_group_cid_name_prefix = str_replace("@", "", $hunt_group_cid_name_prefix);
+		$hunt_group_cid_name_prefix = str_replace("\\", "", $hunt_group_cid_name_prefix);
+		$hunt_group_cid_name_prefix = str_replace("/", "", $hunt_group_cid_name_prefix);
+
+		//set default
+		if (strlen($hunt_group_caller_announce) == 0) { $hunt_group_caller_announce = "false"; }
+	}
+
+if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+
+	$msg = '';
+	if ($action == "update") {
+		$hunt_group_uuid = check_str($_POST["hunt_group_uuid"]);
+	}
+
+	//check for all required data
+		if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid<br>\n"; }
+		if (strlen($hunt_group_extension) == 0) { $msg .= $text['message-required'].$text['label-extension']."<br>\n"; }
+		if (strlen($hunt_group_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
+		if (strlen($hunt_group_type) == 0) { $msg .= $text['message-required'].$text['label-strategy']."<br>\n"; }
+		if (strlen($hunt_group_timeout) == 0) { $msg .= $text['message-required'].$text['label-timeout']."<br>\n"; }
+		if (strlen($hunt_group_timeout_destination) == 0) { $msg .= $text['message-required'].$text['label-timeout_destination']."<br>\n"; }
+		if (strlen($hunt_group_timeout_type) == 0) { $msg .= $text['message-required'].$text['label-timeout_type']."<br>\n"; }
+		//if (strlen($hunt_group_ringback) == 0) { $msg .= $text['message-required'].$text['label-ring_back']."<br>\n"; }
+		//if (strlen($hunt_group_cid_name_prefix) == 0) { $msg .= $text['message-required'].$text['label-caller_id_name_prefix']."<br>\n"; }
+		//if (strlen($hunt_group_pin) == 0) { $msg .= $text['message-required'].$text['label-pin_number']."<br>\n"; }
+		if (strlen($hunt_group_caller_announce) == 0) { $msg .= $text['message-required'].$text['label-caller_announce']."<br>\n"; }
+		//if (strlen($hunt_group_user_list) == 0) { $msg .= $text['message-required'].$text['label-user_list']."<br>\n"; }
+		//if (strlen($hunt_group_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
+		//if (strlen($hunt_group_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
+		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			require_once "resources/header.php";
+			require_once "resources/persist_form_var.php";
+			echo "<div align='center'>\n";
+			echo "<table><tr><td>\n";
+			echo $msg."<br />";
+			echo "</td></tr></table>\n";
+			persistformvar($_POST);
+			echo "</div>\n";
+			require_once "resources/footer.php";
+			return;
+		}
+
+	//add or update the database
+		if ($_POST["persistformvar"] != "true") {
+			if ($action == "add" && permission_exists('hunt_group_add')) {
+				//add to the table
+					$dialplan_uuid = uuid();
+					$hunt_group_uuid = uuid();
+					$sql = "insert into v_hunt_groups ";
+					$sql .= "(";
+					$sql .= "domain_uuid, ";
+					$sql .= "dialplan_uuid, ";
+					$sql .= "hunt_group_uuid, ";
+					$sql .= "hunt_group_extension, ";
+					$sql .= "hunt_group_name, ";
+					$sql .= "hunt_group_type, ";
+					$sql .= "hunt_group_context, ";
+					$sql .= "hunt_group_timeout, ";
+					$sql .= "hunt_group_timeout_destination, ";
+					$sql .= "hunt_group_timeout_type, ";
+					$sql .= "hunt_group_ringback, ";
+					$sql .= "hunt_group_cid_name_prefix, ";
+					$sql .= "hunt_group_pin, ";
+					$sql .= "hunt_group_caller_announce, ";
+					$sql .= "hunt_group_user_list, ";
+					$sql .= "hunt_group_enabled, ";
+					$sql .= "hunt_group_description ";
+					$sql .= ")";
+					$sql .= "values ";
+					$sql .= "(";
+					$sql .= "'$domain_uuid', ";
+					$sql .= "'$dialplan_uuid', ";
+					$sql .= "'$hunt_group_uuid', ";
+					$sql .= "'$hunt_group_extension', ";
+					$sql .= "'$hunt_group_name', ";
+					$sql .= "'$hunt_group_type', ";
+					$sql .= "'".$_SESSION['context']."', ";
+					$sql .= "'$hunt_group_timeout', ";
+					$sql .= "'$hunt_group_timeout_destination', ";
+					$sql .= "'$hunt_group_timeout_type', ";
+					$sql .= "'$hunt_group_ringback', ";
+					$sql .= "'$hunt_group_cid_name_prefix', ";
+					$sql .= "'$hunt_group_pin', ";
+					$sql .= "'$hunt_group_caller_announce', ";
+					$sql .= "'$hunt_group_user_list', ";
+					$sql .= "'$hunt_group_enabled', ";
+					$sql .= "'$hunt_group_description' ";
+					$sql .= ")";
+					$db->exec(check_sql($sql));
+					unset($sql);
+
+				//synchronize the xml config
+					save_hunt_group_xml();
+
+				//redirect the user
+					require_once "resources/header.php";
+					echo "<meta http-equiv=\"refresh\" content=\"2;url=hunt_groups.php\">\n";
+					echo "<div align='center'>\n";
+					echo $text['message-add']."\n";
+					echo "</div>\n";
+					require_once "resources/footer.php";
+					return;
+			} //if ($action == "add")
+
+			if ($action == "update" && permission_exists('hunt_group_edit')) {
+				//update the table
+					$sql = "update v_hunt_groups set ";
+					$sql .= "hunt_group_extension = '$hunt_group_extension', ";
+					$sql .= "hunt_group_name = '$hunt_group_name', ";
+					$sql .= "hunt_group_type = '$hunt_group_type', ";
+					$sql .= "hunt_group_context = '".$_SESSION['context']."', ";
+					$sql .= "hunt_group_timeout = '$hunt_group_timeout', ";
+					$sql .= "hunt_group_timeout_destination = '$hunt_group_timeout_destination', ";
+					$sql .= "hunt_group_timeout_type = '$hunt_group_timeout_type', ";
+					$sql .= "hunt_group_ringback = '$hunt_group_ringback', ";
+					$sql .= "hunt_group_cid_name_prefix = '$hunt_group_cid_name_prefix', ";
+					$sql .= "hunt_group_pin = '$hunt_group_pin', ";
+					$sql .= "hunt_group_caller_announce = '$hunt_group_caller_announce', ";
+					if (if_group("admin") || if_group("superadmin")) {
+						$sql .= "hunt_group_user_list = '$hunt_group_user_list', ";
+					}
+					$sql .= "hunt_group_enabled = '$hunt_group_enabled', ";
+					$sql .= "hunt_group_description = '$hunt_group_description' ";
+					$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
+					$sql .= "and hunt_group_uuid = '$hunt_group_uuid'";
+					$db->exec(check_sql($sql));
+					unset($sql);
+
+				//update the dialplan entry
+					require_once "resources/classes/dialplan.php";
+					$dialplan = new dialplan;
+					$dialplan->domain_uuid = $_SESSION['domain_uuid'];
+					$dialplan->app_uuid = $app_uuid;
+					$dialplan->dialplan_uuid = $dialplan_uuid;
+					$dialplan->dialplan_name = $hunt_group_name;
+					//$dialplan->dialplan_continue = $dialplan_continue;
+					//$dialplan->dialplan_order = '330';
+					$dialplan->dialplan_context = $_SESSION['context'];
+					$dialplan->dialplan_enabled = $hunt_group_enabled;
+					$dialplan->dialplan_description = $hunt_group_description;
+					$dialplan->dialplan_update();
+					unset($dialplan);
+
+					//update the condition
+					$sql = "update v_dialplan_details set ";
+					$sql .= "dialplan_detail_data = '^".$hunt_group_extension."$' ";
+					$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
+					$sql .= "and dialplan_detail_tag = 'condition' ";
+					$sql .= "and dialplan_detail_type = 'destination_number' ";
+					$sql .= "and dialplan_uuid = '$dialplan_uuid' ";
+					$sql .= "and dialplan_detail_group = '1' ";
+					$db->query($sql);
+					unset($sql);
+
+					//update the action
+					$sql = "update v_dialplan_details set ";
+					$sql .= "dialplan_detail_data = 'v_huntgroup_".$_SESSION['domain_name']."_".$hunt_group_extension.".lua', ";
+					$sql .= "dialplan_detail_type = 'lua' ";
+					$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
+					$sql .= "and dialplan_detail_tag = 'action' ";
+					$sql .= "and dialplan_uuid = '$dialplan_uuid' ";
+					$sql .= "and dialplan_detail_type = 'lua' ";
+					$sql .= "and dialplan_detail_group = '1' ";
+					$db->query($sql);
+
+				//synchronize the xml config
+					save_hunt_group_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"]."@".$_SESSION['domain_name'];
+						$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
+					}
+
+				//rediret the user
+					require_once "resources/header.php";
+					echo "<meta http-equiv=\"refresh\" content=\"2;url=hunt_groups.php\">\n";
+					echo "<div align='center'>\n";
+					echo $text['message-update']."\n";
+					echo "</div>\n";
+					require_once "resources/footer.php";
+					return;
+			} //if ($action == "update")
+		} //if ($_POST["persistformvar"] != "true")
+} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+
+//pre-populate the form
+	if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
+		$hunt_group_uuid = $_GET["id"];
+		$sql = "select * from v_hunt_groups ";
+		$sql .= "where hunt_group_uuid = '$hunt_group_uuid' ";
+		$sql .= "and domain_uuid = '$domain_uuid' ";
+		$sql .- "hunt_group_enabled = 'true' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach ($result as &$row) {
+			$dialplan_uuid = $row["dialplan_uuid"];
+			$hunt_group_extension = $row["hunt_group_extension"];
+			$hunt_group_name = $row["hunt_group_name"];
+			$hunt_group_type = $row["hunt_group_type"];
+			$hunt_group_timeout = $row["hunt_group_timeout"];
+			$hunt_group_timeout_destination = $row["hunt_group_timeout_destination"];
+			$hunt_group_timeout_type = $row["hunt_group_timeout_type"];
+			$hunt_group_ringback = $row["hunt_group_ringback"];
+			$hunt_group_cid_name_prefix = $row["hunt_group_cid_name_prefix"];
+			$hunt_group_pin = $row["hunt_group_pin"];
+			$hunt_group_caller_announce = $row["hunt_group_caller_announce"];
+			$hunt_group_user_list = $row["hunt_group_user_list"];
+			$hunt_group_enabled = $row["hunt_group_enabled"];
+			$hunt_group_description = $row["hunt_group_description"];
+			break; //limit to 1 row
+		}
+		unset ($prep_statement);
+	}
+
+//show the header
+	require_once "resources/header.php";
+	$page["title"] = $text['title-hunt_group'];
+
+
+//show the content
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
+	echo "<tr class='border'>\n";
+	echo "<td align=\"left\">\n";
+	echo "<br>";
+
+	echo "<form method='post' name='frm' action=''>\n";
+	echo "<div align='center'>\n";
+	echo "<table width='100%'  border='0' cellpadding='6' cellspacing='0'>\n";
+	echo "<tr>\n";
+	echo "<td align='left' colspan='2'>\n";
+
+	echo "<table width='100%'>\n";
+	echo "<tr>\n";
+	echo "<td align='left' width='30%' nowrap>\n";
+	echo "	<span class='vexpl'>\n";
+	echo "		<strong>".$text['header-hunt_group']."</strong><br>\n";
+	echo "	</span>\n";
+	echo "</td>\n";
+	echo "<td width='70%' align='right'>\n";
+	if ($action != "add") {
+		echo "	<input type='button' class='btn' name='' alt='".$text['button-copy']."' onclick=\"var new_ext = prompt('".$text['message_extension']."'); if (new_ext != null) { window.location='hunt_group_copy.php?id=".$hunt_group_uuid."&ext=' + new_ext; }\" value='".$text['button-copy']."'>\n";
+	}
+	echo "	<input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='hunt_groups.php'\" value='".$text['button-back']."'>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td align='left' colspan='2'>\n";
+	echo "		  ".$text['description-hunt_group']."\n";
+	echo "		  </span><br />\n";
+	echo "<br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "</table>\n";
+
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "	 ".$text['label-name'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	 <input class='formfld' type='text' name='hunt_group_name' maxlength='255' value=\"$hunt_group_name\">\n";
+	echo "<br />\n";
+	echo $text['description-name']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "	 ".$text['label-extension'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	 <input class='formfld' type='text' name='hunt_group_extension' maxlength='255' value=\"$hunt_group_extension\">\n";
+	echo "<br />\n";
+	echo $text['description-extension']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "	 ".$text['label-strategy'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	 <select class='formfld' name='hunt_group_type'>\n";
+	echo "	 <option value=''></option>\n";
+	if ($hunt_group_type == "simultaneous") {
+		echo "	 <option value='simultaneous' selected='selected'>".$text['option-simultaneous']."</option>\n";
+	}
+	else {
+		echo "	 <option value='simultaneous'>".$text['option-simultaneous']."</option>\n";
+	}
+	if ($hunt_group_type == "sequentially") {
+		echo "	 <option value='sequentially' selected='selected'>".$text['option-sequential']."</option>\n";
+	}
+	else {
+		echo "	 <option value='sequentially'>".$text['option-sequential']."</option>\n";
+	}
+	echo "	 </select>\n";
+	echo "<br />\n";
+	echo "\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "	 ".$text['label-timeout'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	 <input class='formfld' type='text' name='hunt_group_timeout' maxlength='255' value=\"$hunt_group_timeout\">\n";
+	echo "<br />\n";
+	echo $text['description-timeout']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "	 ".$text['label-timeout_destination'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	 <input class='formfld' type='text' name='hunt_group_timeout_destination' maxlength='255' value=\"$hunt_group_timeout_destination\">\n";
+	echo "<br />\n";
+	echo $text['description-timeout_destination']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "	 ".$text['label-timeout_type'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	 <select class='formfld' name='hunt_group_timeout_type'>\n";
+	echo "	 <option value=''></option>\n";
+	if ($hunt_group_timeout_type == "extension") {
+		echo "	 <option value='extension' SELECTED >".$text['option-extension']."</option>\n";
+	}
+	else {
+		echo "	 <option value='extension'>".$text['option-extension']."</option>\n";
+	}
+	if ($hunt_group_timeout_type == "voicemail") {
+		echo "	 <option value='voicemail' SELECTED >".$text['option-voicemail']."</option>\n";
+	}
+	else {
+		echo "	 <option value='voicemail'>".$text['option-voicemail']."</option>\n";
+	}
+	if ($hunt_group_timeout_type == "sip uri") {
+		echo "	 <option value='sip uri' SELECTED >".$text['option-sip_uri']."</option>\n";
+	}
+	else {
+		echo "	 <option value='sip uri'>".$text['option-sip_uri']."</option>\n";
+	}
+	echo "	 </select>\n";
+	echo "<br />\n";
+	echo $text['description-timeout_type']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "	 ".$text['label-ring_back'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+
+	$select_options = "";
+	if ($hunt_group_ringback == "\${us-ring}" || $hunt_group_ringback == "us-ring") {
+		$select_options .= "		<option value='\${us-ring}' selected='selected'>us-ring</option>\n";
+	}
+	else {
+		$select_options .= "		<option value='\${us-ring}'>us-ring</option>\n";
+	}
+	if ($hunt_group_ringback == "\${fr-ring}" || $hunt_group_ringback == "fr-ring") {
+		$select_options .= "		<option value='\${fr-ring}' selected='selected'>fr-ring</option>\n";
+	}
+	else {
+		$select_options .= "		<option value='\${fr-ring}'>fr-ring</option>\n";
+	}
+	if ($hunt_group_ringback == "\${uk-ring}" || $hunt_group_ringback == "uk-ring") {
+		$select_options .= "		<option value='\${uk-ring}' selected='selected'>uk-ring</option>\n";
+	}
+	else {
+		$select_options .= "		<option value='\${uk-ring}'>uk-ring</option>\n";
+	}
+	if ($hunt_group_ringback == "\${rs-ring}" || $hunt_group_ringback == "rs-ring") {
+		$select_options .= "		<option value='\${rs-ring}' selected='selected'>rs-ring</option>\n";
+	}
+	else {
+		$select_options .= "		<option value='\${rs-ring}'>rs-ring</option>\n";
+	}
+	require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php";
+	$moh = new switch_music_on_hold;
+	$moh->select_name = "hunt_group_ringback";
+	$moh->select_value = $hunt_group_ringback;
+	$moh->select_options = $select_options;
+	echo $moh->select();
+
+	echo "<br />\n";
+	echo $text['description-ring_back']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	 ".$text['label-caller_id_name_prefix'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	 <input class='formfld' type='text' name='hunt_group_cid_name_prefix' maxlength='255' value=\"$hunt_group_cid_name_prefix\">\n";
+	echo "<br />\n";
+	echo $text['description-caller_id_name_prefix']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	 ".$text['label-pin_number'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	 <input class='formfld' type='text' name='hunt_group_pin' maxlength='255' value=\"$hunt_group_pin\">\n";
+	echo "<br />\n";
+	echo $text['description-pin_number']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	if (!$fp) {
+		$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
+	}
+	if (switch_module_is_running($fp, 'mod_spidermonkey')) {
+		echo "<tr>\n";
+		echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+		echo "	 ".$text['label-caller_announce'].":\n";
+		echo "</td>\n";
+		echo "<td class='vtable' align='left'>\n";
+		echo "	 <select class='formfld' name='hunt_group_caller_announce'>\n";
+		echo "	 <option value=''></option>\n";
+		if ($hunt_group_caller_announce == "true") {
+			echo "	 <option value='true' selected='selected'>".$text['option-true']."</option>\n";
+		}
+		else {
+			echo "	 <option value='true'>".$text['option-true']."</option>\n";
+		}
+		if ($hunt_group_caller_announce == "false") {
+			echo "	 <option value='false' selected='selected'>".$text['option-false']."</option>\n";
+		}
+		else {
+			echo "	 <option value='false'>".$text['option-false']."</option>\n";
+		}
+		echo "	 </select>\n";
+		echo "<br />\n";
+		echo "\n";
+		echo "</td>\n";
+		echo "</tr>\n";
+	}
+
+	if (if_group("admin") || if_group("superadmin")) {
+		echo "<tr>\n";
+		echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+		echo "		".$text['label-user_list'].":\n";
+		echo "</td>\n";
+		echo "<td class='vtable' align='left'>\n";
+		$onchange = "document.getElementById('hunt_group_user_list').value += document.getElementById('username').value + '\\n';";
+		$table_name = 'v_users'; $field_name = 'username'; $field_current_value = ''; $sql_where_optional = "where domain_uuid = '$domain_uuid' and user_enabled = 'true' ";
+		echo html_select_on_change($db, $table_name, $field_name, $sql_where_optional, $field_current_value, $onchange);
+		echo "<br />\n";
+		echo $text['description-user_list_select']."\n";
+		echo "<br />\n";
+		echo "<br />\n";
+		//replace the vertical bar with a line feed to display in the textarea
+		$hunt_group_user_list = trim($hunt_group_user_list, "|");
+		$hunt_group_user_list_array = explode("|", $hunt_group_user_list);
+		$hunt_group_user_list = '';
+		foreach($hunt_group_user_list_array as $user){
+			$hunt_group_user_list .= trim($user)."\n";
+		}
+		echo "		<textarea name=\"hunt_group_user_list\" id=\"hunt_group_user_list\" class=\"formfld\" cols=\"30\" rows=\"3\" wrap=\"off\">$hunt_group_user_list</textarea>\n";
+		echo "		<br>\n";
+		echo $text['description-user_list_textarea']."\n";
+		echo "<br />\n";
+		echo "</td>\n";
+		echo "</tr>\n";
+	}
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "	 ".$text['label-enabled'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	 <select class='formfld' name='hunt_group_enabled'>\n";
+	echo "	 <option value=''></option>\n";
+	if ($hunt_group_enabled == "true" || strlen($hunt_group_enabled) == 0) {
+		echo "	 <option value='true' selected >".$text['option-true']."</option>\n";
+	}
+	else {
+		echo "	 <option value='true'>".$text['option-true']."</option>\n";
+	}
+	if ($hunt_group_enabled == "false") {
+		echo "	 <option value='false' selected >".$text['option-false']."</option>\n";
+	}
+	else {
+		echo "	 <option value='false'>".$text['option-false']."</option>\n";
+	}
+	echo "	 </select>\n";
+	echo "<br />\n";
+	echo $text['description-enabled']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	 ".$text['label-description'].":\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	 <input class='formfld' type='text' name='hunt_group_description' maxlength='255' value=\"$hunt_group_description\">\n";
+	echo "<br />\n";
+	echo $text['description-description']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "	<tr>\n";
+	echo "		<td colspan='2' align='right'>\n";
+	if ($action == "update") {
+		echo "				<input type='hidden' name='dialplan_uuid' value='$dialplan_uuid'>\n";
+		echo "				<input type='hidden' name='hunt_group_uuid' value='$hunt_group_uuid'>\n";
+	}
+	echo "				<input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
+	echo "		</td>\n";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</form>";
+
+	echo "	</td>";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</div>";
+
+//list hunt group destinations
+	if ($action == "update") {
+
+		echo "<div align='center'>";
+		echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
+
+		echo "<tr class='border'>\n";
+		echo "	<td align=\"center\">\n";
+		echo "		<br>";
+
+		echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
+		echo "	<tr>\n";
+		echo "	<td align='left'><p><span class='vexpl'>\n";
+		echo "		<span class='red'><strong>".$text['header-hunt_group_destinations']."</strong></span><br>\n";
+		echo "			".$text['description-hunt_group_destinations']."\n";
+		echo "		</span></p></td>\n";
+		echo "	</tr>\n";
+		echo "</table>\n";
+		echo "<br />\n";
+
+		$sql = " select * from v_hunt_group_destinations ";
+		$sql .= " where domain_uuid = '$domain_uuid' ";
+		$sql .= " and hunt_group_uuid = '$hunt_group_uuid' ";
+		$sql .= " order by destination_order, destination_data asc";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		$result_count = count($result);
+		unset ($prep_statement, $sql);
+
+
+		$c = 0;
+		$row_style["0"] = "row_style0";
+		$row_style["1"] = "row_style1";
+
+		echo "<div align='center'>\n";
+		echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+
+		echo "<tr>\n";
+		echo "<th align='center'>".$text['label-destination']."</th>\n";
+		echo "<th align='center'>".$text['label-type']."</th>\n";
+		echo "<th align='center'>".$text['label-profile']."</th>\n";
+		echo "<th align='center'>".$text['label-order']."</th>\n";
+		echo "<th align='center'>".$text['label-description']."</th>\n";
+		echo "<td align='right' width='42'>\n";
+		if (permission_exists('hunt_group_add')) {
+			echo "	<a href='hunt_group_destination_edit.php?id2=".$hunt_group_uuid."' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
+		}
+		echo "</td>\n";
+		echo "<tr>\n";
+
+		if ($result_count > 0) {
+			foreach($result as $row) {
+				echo "<tr >\n";
+				echo "	<td valign='top' class='".$row_style[$c]."'>&nbsp;&nbsp;".$row['destination_data']."</td>\n";
+				echo "	<td valign='top' class='".$row_style[$c]."'>&nbsp;&nbsp;";
+				switch($row['destination_type']) {
+					case "extension" : echo $text['option-extension']; break;
+					case "voicemail" : echo $text['option-voicemail']; break;
+					case "sip uri" : echo $text['option-sip_uri']; break;
+				}
+				echo "</td>\n";
+				echo "	<td valign='top' class='".$row_style[$c]."'>&nbsp;&nbsp;".$row['destination_profile']."</td>\n";
+				echo "	<td valign='top' class='".$row_style[$c]."'>&nbsp;&nbsp;".$row['destination_order']."</td>\n";
+				echo "	<td valign='top' class='row_stylebg' width='30%'>".$row['destination_description']."&nbsp;</td>\n";
+				echo "	<td valign='top' align='right'>\n";
+				if (permission_exists('hunt_group_edit')) {
+					echo "		<a href='hunt_group_destination_edit.php?id=".$row['hunt_group_destination_uuid']."&id2=".$hunt_group_uuid."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
+				}
+				if (permission_exists('hunt_group_delete')) {
+					echo "		<a href='hunt_group_destination_delete.php?id=".$row['hunt_group_destination_uuid']."&id2=".$hunt_group_uuid."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
+				}
+				echo "	</td>\n";
+				echo "</tr>\n";
+				if ($c==0) { $c=1; } else { $c=0; }
+			} //end foreach
+			unset($sql, $result, $row_count);
+		} //end if results
+
+		echo "<tr>\n";
+		echo "<td colspan='6'>\n";
+		echo "	<table width='100%' cellpadding='0' cellspacing='0'>\n";
+		echo "	<tr>\n";
+		echo "		<td width='33.3%' nowrap>&nbsp;</td>\n";
+		echo "		<td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
+		echo "		<td width='33.3%' align='right'>\n";
+		if (permission_exists('hunt_group_add')) {
+			echo "			<a href='hunt_group_destination_edit.php?id2=".$hunt_group_uuid."' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
+		}
+		echo "		</td>\n";
+		echo "	</tr>\n";
+		echo "	</table>\n";
+		echo "</td>\n";
+		echo "</tr>\n";
+
+		echo "</table>";
+		echo "</div>";
+		echo "<br><br>";
+		echo "<br><br>";
+
+		echo "</td>";
+		echo "</tr>";
+		echo "</table>";
+		echo "</div>";
+		echo "<br><br>";
+	} //end if update
+
+//show the footer
+	require_once "resources/footer.php";
+?>

+ 195 - 0
hunt_groups/hunt_groups.php

@@ -0,0 +1,195 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+
+//check permissions
+	if (permission_exists('hunt_group_view')) {
+		//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-hunt_groups'];
+
+require_once "resources/paging.php";
+
+$order_by = $_GET["order_by"];
+$order = $_GET["order"];
+
+echo "<div align='center'>";
+echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+echo "<tr class='border'>\n";
+echo "	<td align=\"center\">\n";
+echo "      <br />";
+
+echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+echo "<tr>\n";
+echo "    <td align='left'><p><span class='vexpl'><span class='red'><strong>".$text['header-hunt_groups']."<br />\n";
+echo "        </strong></span>".$text['description-hunt_groups']."</span></p></td>\n";
+echo "</tr>\n";
+echo "</table>\n";
+echo "<br />\n";
+
+//get the number of rows in v_hunt_groups
+$sql = "select count(*) as num_rows from v_hunt_groups ";
+$sql .= "where domain_uuid = '$domain_uuid' ";
+$prep_statement = $db->prepare(check_sql($sql));
+if ($prep_statement) {
+	$prep_statement->execute();
+	$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
+	if ($row['num_rows'] > 0) {
+		$num_rows = $row['num_rows'];
+	}
+	else {
+		$num_rows = '0';
+	}
+}
+unset($prep_statement, $result);
+
+//prepare to page the results
+$rows_per_page = 150;
+$param = "";
+$page = $_GET['page'];
+if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
+list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
+$offset = $rows_per_page * $page;
+
+//get the hunt group list
+$sql = "select * from v_hunt_groups ";
+$sql .= "where domain_uuid = '$domain_uuid' ";
+if (strlen($order_by)> 0) {
+	$sql .= "order by $order_by $order ";
+}
+else {
+	$sql .= "order by hunt_group_extension asc ";
+}
+$sql .= " limit $rows_per_page offset $offset ";
+$prep_statement = $db->prepare(check_sql($sql));
+$prep_statement->execute();
+$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+$result_count = count($result);
+unset ($prep_statement, $sql);
+
+$c = 0;
+$row_style["0"] = "row_style0";
+$row_style["1"] = "row_style1";
+
+echo "<div align='center'>\n";
+echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+echo "<tr>\n";
+echo th_order_by('hunt_group_extension', $text['label-extension'], $order_by, $order);
+echo th_order_by('hunt_group_name', $text['label-name'], $order_by, $order);
+echo th_order_by('hunt_group_name', $text['label-enabled'], $order_by, $order);
+echo th_order_by('hunt_group_description', $text['label-description'], $order_by, $order);
+echo "<td align='right' width='42'>\n";
+if (permission_exists('hunt_group_add')) {
+	echo "	<a href='hunt_group_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
+}
+echo "</td>\n";
+echo "<tr>\n";
+
+if ($result_count > 0) {
+	foreach($result as $row) {
+		echo "<tr >\n";
+		echo "   <td valign='top' class='".$row_style[$c]."'>".$row['hunt_group_extension']."</td>\n";
+		echo "   <td valign='top' class='".$row_style[$c]."'>".$row['hunt_group_name']."</td>\n";
+		echo "   <td valign='top' class='".$row_style[$c]."'>";
+		if ($row['hunt_group_enabled'] == "true") {
+			echo $text['option-true'];
+		}
+		else if ($row['hunt_group_enabled'] == "false") {
+			echo $text['option-false'];
+		}
+		echo "</td>\n";
+		echo "   <td valign='top' class='row_stylebg' width='40%'>".$row['hunt_group_description']."&nbsp;</td>\n";
+		echo "   <td valign='top' align='right'>\n";
+		if (permission_exists('hunt_group_edit')) {
+			echo "		<a href='hunt_group_edit.php?id=".$row['hunt_group_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
+		}
+		if (permission_exists('hunt_group_delete')) {
+			echo "		<a href='hunt_group_delete.php?id=".$row['hunt_group_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
+		}
+		echo "   </td>\n";
+		echo "</tr>\n";
+		if ($c==0) { $c=1; } else { $c=0; }
+	} //end foreach
+	unset($sql, $result, $row_count);
+} //end if results
+
+echo "<tr>\n";
+echo "<td colspan='5'>\n";
+echo "	<table width='100%' cellpadding='0' cellspacing='0'>\n";
+echo "	<tr>\n";
+echo "		<td width='33.3%' nowrap>&nbsp;</td>\n";
+echo "		<td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
+echo "		<td width='33.3%' align='right'>\n";
+if (permission_exists('hunt_group_add')) {
+	echo "			<a href='hunt_group_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
+}
+echo "		</td>\n";
+echo "	</tr>\n";
+echo "	</table>\n";
+echo "</td>\n";
+echo "</tr>\n";
+
+if ($v_path_show) {
+	echo "<tr>\n";
+	echo "<td align='left' colspan='4'>\n";
+	echo "<br />\n";
+	echo $_SESSION['switch']['scripts']['dir']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+}
+
+echo "</table>";
+echo "</div>";
+echo "<br><br>";
+echo "<br><br>";
+
+echo "</td>";
+echo "</tr>";
+echo "</table>";
+echo "</div>";
+echo "<br><br>";
+
+require_once "resources/footer.php";
+unset ($result_count);
+unset ($result);
+unset ($key);
+unset ($val);
+unset ($c);
+?>

+ 50 - 0
hunt_groups/root.php

@@ -0,0 +1,50 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
+?>