Selaa lähdekoodia

Add Mobile-Twinning App (#116)

* Create README

* Create app_config.php

* Create app_languages.php

* Create app_menu.php

* Create mobile_twinning.php

* Create mobile_twinning_edit.php

* Create root.php

* Create 390_mobile_twinning.xml

* Create index.lua
konradSC 6 vuotta sitten
vanhempi
commit
5c3bb35fb5

+ 8 - 0
mobile-twinning/390_mobile_twinning.xml

@@ -0,0 +1,8 @@
+<context name="{v_context}">
+	<extension name="mobile-twinning" number="*662" continue="false" app_uuid="21152484-76fb-46ad-9035-ecbd3b5f908a" destination="true">
+		<condition field="destination_number" expression="^\*662$">
+			<action application="answer" data=""/>
+			<action application="lua" data="app.lua mobile_twinning"/>
+		</condition>
+	</extension>
+</context>

+ 40 - 0
mobile-twinning/README

@@ -0,0 +1,40 @@
+This adds the mobile-twinning app.
+
+Works like this:
+
+Go to Apps -> Mobile Twinning. Associate the mobile number with the corresponding extension.
+Go to Dialplan -> Destinations. Map a Destination to the mobile-twinning dialplan number. (*662) (spells MOB for "mobile")
+
+You can now seamlessly move calls back and forth from your deskphone and your mobile.
+If someone calls your extension and you have it forwarded (or follow-me) to your mobile, you can dial *662 from your desk to bring the call back to your desk.
+If you are on your deskphone, you can dial the mobile-twinning destination (step 2), press 1 and the call is transferred to your mobile.
+
+Notes:
+
+This will probably not work across multiple FS servers as it is written.
+This is setup for the mobile to have a 10 digit number.
+
+Install:
+
+On your server.
+	git clone https://github.com/fusionpbx/fusionpbx-apps
+Copy or move the directory 'mobile-twinning' into your main FusionPBX directory.
+	cp -R fusionpbx-apps/mobile-twinning /var/www/fusionpbx/app
+Move the xml dialplan file.
+	cp /var/www/fusionpbx/app/mobile-twinning/390_mobile-twinning.xml /var/www/fusionpbx/app/dialplans/resources/switch/conf/dialplan/390_mobile-twinning.xml
+Create the LUA script directory
+	mkdir /usr/share/freeswitch/scripts/app/mobile_twinning
+Copy the script
+	cp /var/www/fusionpbx/app/mobile-twinning/index.lua /usr/share/freeswitch/scripts/app/mobile_twinning/index.lua
+Set the permissions
+	chown -R www-data:www-data /var/www/fusionpbx/app/mobile-twinning
+	chown -R www-data:www-data /usr/share/freeswitch/scripts/app/mobile_twinning
+	chown -R www-data:www-data /var/www/fusionpbx/app/dialplans/resources/switch/conf/dialplan
+
+
+	
+Log into the FusionPBX webpage
+Advanced -> Upgrade
+Menu Defaults and Permission Defaults.
+Log out and back in
+

+ 83 - 0
mobile-twinning/app_config.php

@@ -0,0 +1,83 @@
+<?php
+
+	//application details
+		$apps[$x]['name'] = "Mobile Twinning";
+		$apps[$x]['uuid'] = "5aa03dfb-f261-4cb5-9693-899fa293c1ba";
+		$apps[$x]['category'] = "Switch";
+		$apps[$x]['subcategory'] = "";
+		$apps[$x]['version'] = "1.0";
+		$apps[$x]['license'] = "Mozilla Public License 1.1";
+		$apps[$x]['url'] = "http://www.fusionpbx.com";
+		$apps[$x]['description']['en-us'] = "A tool to twin an extension with a mobile.";
+		$apps[$x]['description']['ar-eg'] = "";
+		$apps[$x]['description']['de-at'] = "";
+		$apps[$x]['description']['de-ch'] = "";
+		$apps[$x]['description']['de-de'] = "";
+		$apps[$x]['description']['es-cl'] = "";
+		$apps[$x]['description']['es-mx'] = "";
+		$apps[$x]['description']['fr-ca'] = "";
+		$apps[$x]['description']['fr-fr'] = "";
+		$apps[$x]['description']['he-il'] = "";
+		$apps[$x]['description']['it-it'] = "";
+		$apps[$x]['description']['nl-nl'] = "";
+		$apps[$x]['description']['pl-pl'] = "";
+		$apps[$x]['description']['pt-br'] = "";
+		$apps[$x]['description']['pt-pt'] = "";
+		$apps[$x]['description']['ro-ro'] = "";
+		$apps[$x]['description']['ru-ru'] = "";
+		$apps[$x]['description']['sv-se'] = "";
+		$apps[$x]['description']['uk-ua'] = "";
+
+	//permission details
+		$y=0;
+		$apps[$x]['permissions'][$y]['name'] = "mobile_twinning_view";
+		$apps[$x]['permissions'][$y]['menu']['uuid'] = "b30f085f-3ec6-2819-7e62-5aa033fb-f261-43b5-9693-899fa29371ba";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$apps[$x]['permissions'][$y]['groups'][] = "admin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "mobile_twinning_add";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$apps[$x]['permissions'][$y]['groups'][] = "admin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "mobile_twinning_edit";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$apps[$x]['permissions'][$y]['groups'][] = "admin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "mobile_twinning_delete";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$apps[$x]['permissions'][$y]['groups'][] = "admin";
+
+
+	//schema details
+		$y=0;
+		$apps[$x]['db'][$y]['table']['name'] = "v_mobile_twinnings";
+		$apps[$x]['db'][$y]['table']['parent'] = "";
+		$z=0;
+		$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";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "mobile_twinning_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";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "extension_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_extensions";
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "extension_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "mobile_twinning_number";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enable the mobile twinning number.";
+
+?>

+ 266 - 0
mobile-twinning/app_languages.php

@@ -0,0 +1,266 @@
+<?php
+
+$text['description-mobile_twinning']['en-us'] = "Mobile Numbers linked to Extensions";
+$text['description-mobile_twinning']['ar-eg'] = "";
+$text['description-mobile_twinning']['de-at'] = "Mobile Numbers linked to Extensions"; 
+$text['description-mobile_twinning']['de-ch'] = "Mobile Numbers linked to Extensions";
+$text['description-mobile_twinning']['de-de'] = "Mobile Numbers linked to Extensions";
+$text['description-mobile_twinning']['es-cl'] = "Mobile Numbers linked to Extensions";
+$text['description-mobile_twinning']['es-mx'] = "Mobile Numbers linked to Extensions"; 
+$text['description-mobile_twinning']['fr-ca'] = "Mobile Numbers linked to Extensions"; 
+$text['description-mobile_twinning']['fr-fr'] = "Mobile Numbers linked to Extensions";
+$text['description-mobile_twinning']['he-il'] = "";
+$text['description-mobile_twinning']['it-it'] = "Mobile Numbers linked to Extensions";
+$text['description-mobile_twinning']['nl-nl'] = "";
+$text['description-mobile_twinning']['pl-pl'] = "Mobile Numbers linked to Extensions";
+$text['description-mobile_twinning']['pt-br'] = "Mobile Numbers linked to Extensions";
+$text['description-mobile_twinning']['pt-pt'] = "Mobile Numbers linked to Extensions";
+$text['description-mobile_twinning']['ro-ro'] = "";
+$text['description-mobile_twinning']['ru-ru'] = "Mobile Numbers linked to Extensions";
+$text['description-mobile_twinning']['sv-se'] = "Mobile Numbers linked to Extensions";
+$text['description-mobile_twinning']['uk-ua'] = "Mobile Numbers linked to Extensions";
+
+$text['description-mobile_twinning_number']['en-us'] = "Enter the 10 digit mobile mumber.";
+$text['description-mobile_twinning_number']['ar-eg'] = "";
+$text['description-mobile_twinning_number']['de-at'] = "Enter the 10 digit mobile mumber."; 
+$text['description-mobile_twinning_number']['de-ch'] = "Enter the 10 digit mobile mumber.";
+$text['description-mobile_twinning_number']['de-de'] = "Enter the 10 digit mobile mumber.";
+$text['description-mobile_twinning_number']['es-cl'] = "Enter the 10 digit mobile mumber.";
+$text['description-mobile_twinning_number']['es-mx'] = "Enter the 10 digit mobile mumber."; 
+$text['description-mobile_twinning_number']['fr-ca'] = "Enter the 10 digit mobile mumber."; 
+$text['description-mobile_twinning_number']['fr-fr'] = "Enter the 10 digit mobile mumber.";
+$text['description-mobile_twinning_number']['he-il'] = "";
+$text['description-mobile_twinning_number']['it-it'] = "Enter the 10 digit mobile mumber.";
+$text['description-mobile_twinning_number']['nl-nl'] = "";
+$text['description-mobile_twinning_number']['pl-pl'] = "Enter the 10 digit mobile mumber.";
+$text['description-mobile_twinning_number']['pt-br'] = "Enter the 10 digit mobile mumber.";
+$text['description-mobile_twinning_number']['pt-pt'] = "Enter the 10 digit mobile mumber.";
+$text['description-mobile_twinning_number']['ro-ro'] = "";
+$text['description-mobile_twinning_number']['ru-ru'] = "Enter the 10 digit mobile mumber.";
+$text['description-mobile_twinning_number']['sv-se'] = "Enter the 10 digit mobile mumber.";
+$text['description-mobile_twinning_number']['uk-ua'] = "Enter the 10 digit mobile mumber.";
+
+
+$text['header-mobile_twinning']['en-us'] = "Mobile Twinning";
+$text['header-mobile_twinning']['ar-eg'] = "";
+$text['header-mobile_twinning']['de-at'] = "Mobile Twinning"; 
+$text['header-mobile_twinning']['de-ch'] = "Mobile Twinning";
+$text['header-mobile_twinning']['de-de'] = "Mobile Twinning";
+$text['header-mobile_twinning']['es-cl'] = "Mobile Twinning";
+$text['header-mobile_twinning']['es-mx'] = "Mobile Twinning"; 
+$text['header-mobile_twinning']['fr-ca'] = "Mobile Twinning"; 
+$text['header-mobile_twinning']['fr-fr'] = "Mobile Twinning";
+$text['header-mobile_twinning']['he-il'] = "";
+$text['header-mobile_twinning']['it-it'] = "Mobile Twinning";
+$text['header-mobile_twinning']['nl-nl'] = "";
+$text['header-mobile_twinning']['pl-pl'] = "Mobile Twinning";
+$text['header-mobile_twinning']['pt-br'] = "Mobile Twinning";
+$text['header-mobile_twinning']['pt-pt'] = "Mobile Twinning";
+$text['header-mobile_twinning']['ro-ro'] = "";
+$text['header-mobile_twinning']['ru-ru'] = "Mobile Twinning";
+$text['header-mobile_twinning']['sv-se'] = "Mobile Twinning";
+$text['header-mobile_twinning']['uk-ua'] = "Mobile Twinning";
+
+
+$text['label-user_group']['en-us'] = "User Group";
+$text['label-user_group']['ar-eg'] = "";
+$text['label-user_group']['de-at'] = "User Group"; 
+$text['label-user_group']['de-ch'] = "User Group";
+$text['label-user_group']['de-de'] = "User Group";
+$text['label-user_group']['es-cl'] = "User Group";
+$text['label-user_group']['es-mx'] = "User Group"; 
+$text['label-user_group']['fr-ca'] = "User Group"; 
+$text['label-user_group']['fr-fr'] = "User Group";
+$text['label-user_group']['he-il'] = "";
+$text['label-user_group']['it-it'] = "User Group";
+$text['label-user_group']['nl-nl'] = "";
+$text['label-user_group']['pl-pl'] = "User Group";
+$text['label-user_group']['pt-br'] = "User Group";
+$text['label-user_group']['pt-pt'] = "User Group";
+$text['label-user_group']['ro-ro'] = "";
+$text['label-user_group']['ru-ru'] = "User Group";
+$text['label-user_group']['sv-se'] = "User Group";
+$text['label-user_group']['uk-ua'] = "User Group";
+
+$text['label-mobile_twinning_number']['en-us'] = "Mobile Number";
+$text['label-mobile_twinning_number']['ar-eg'] = "";
+$text['label-mobile_twinning_number']['de-at'] = "Mobile Number"; 
+$text['label-mobile_twinning_number']['de-ch'] = "Mobile Number";
+$text['label-mobile_twinning_number']['de-de'] = "Mobile Number";
+$text['label-mobile_twinning_number']['es-cl'] = "Mobile Number";
+$text['label-mobile_twinning_number']['es-mx'] = "Mobile Number"; 
+$text['label-mobile_twinning_number']['fr-ca'] = "Mobile Number"; 
+$text['label-mobile_twinning_number']['fr-fr'] = "Mobile Number";
+$text['label-mobile_twinning_number']['he-il'] = "";
+$text['label-mobile_twinning_number']['it-it'] = "Mobile Number";
+$text['label-mobile_twinning_number']['nl-nl'] = "";
+$text['label-mobile_twinning_number']['pl-pl'] = "Mobile Number";
+$text['label-mobile_twinning_number']['pt-br'] = "Mobile Number";
+$text['label-mobile_twinning_number']['pt-pt'] = "Mobile Number";
+$text['label-mobile_twinning_number']['ro-ro'] = "";
+$text['label-mobile_twinning_number']['ru-ru'] = "Mobile Number";
+$text['label-mobile_twinning_number']['sv-se'] = "Mobile Number";
+$text['label-mobile_twinning_number']['uk-ua'] = "Mobile Number";
+
+$text['message-duplicate_mobile_twinning_number']['en-us'] = " Duplicate Number. Please enter a unique mobile number. ";
+$text['message-duplicate_mobile_twinning_number']['ar-eg'] = "";
+$text['message-duplicate_mobile_twinning_number']['de-at'] = " Duplicate Number. Please enter a unique mobile number. "; 
+$text['message-duplicate_mobile_twinning_number']['de-ch'] = " Duplicate Number. Please enter a unique mobile number. ";
+$text['message-duplicate_mobile_twinning_number']['de-de'] = " Duplicate Number. Please enter a unique mobile number. ";
+$text['message-duplicate_mobile_twinning_number']['es-cl'] = " Duplicate Number. Please enter a unique mobile number. ";
+$text['message-duplicate_mobile_twinning_number']['es-mx'] = " Duplicate Number. Please enter a unique mobile number. "; 
+$text['message-duplicate_mobile_twinning_number']['fr-ca'] = " Duplicate Number. Please enter a unique mobile number. "; 
+$text['message-duplicate_mobile_twinning_number']['fr-fr'] = " Duplicate Number. Please enter a unique mobile number. ";
+$text['message-duplicate_mobile_twinning_number']['he-il'] = "";
+$text['message-duplicate_mobile_twinning_number']['it-it'] = " Duplicate Number. Please enter a unique mobile number. ";
+$text['message-duplicate_mobile_twinning_number']['nl-nl'] = "";
+$text['message-duplicate_mobile_twinning_number']['pl-pl'] = " Duplicate Number. Please enter a unique mobile number. ";
+$text['message-duplicate_mobile_twinning_number']['pt-br'] = " Duplicate Number. Please enter a unique mobile number. ";
+$text['message-duplicate_mobile_twinning_number']['pt-pt'] = " Duplicate Number. Please enter a unique mobile number. ";
+$text['message-duplicate_mobile_twinning_number']['ro-ro'] = "";
+$text['message-duplicate_mobile_twinning_number']['ru-ru'] = " Duplicate Number. Please enter a unique mobile number. ";
+$text['message-duplicate_mobile_twinning_number']['sv-se'] = " Duplicate Number. Please enter a unique mobile number. ";
+$text['message-duplicate_mobile_twinning_number']['uk-ua'] = " Duplicate Number. Please enter a unique mobile number. ";
+
+$text['message-invalid_mobile_twinning_number']['en-us'] = " Invalid Number. Please enter a 10 digit mobile number. ";
+$text['message-invalid_mobile_twinning_number']['ar-eg'] = "";
+$text['message-invalid_mobile_twinning_number']['de-at'] = " Invalid Number. Please enter a 10 digit mobile number. "; 
+$text['message-invalid_mobile_twinning_number']['de-ch'] = " Invalid Number. Please enter a 10 digit mobile number. ";
+$text['message-invalid_mobile_twinning_number']['de-de'] = " Invalid Number. Please enter a 10 digit mobile number. ";
+$text['message-invalid_mobile_twinning_number']['es-cl'] = " Invalid Number. Please enter a 10 digit mobile number. ";
+$text['message-invalid_mobile_twinning_number']['es-mx'] = " Invalid Number. Please enter a 10 digit mobile number. "; 
+$text['message-invalid_mobile_twinning_number']['fr-ca'] = " Invalid Number. Please enter a 10 digit mobile number. "; 
+$text['message-invalid_mobile_twinning_number']['fr-fr'] = " Invalid Number. Please enter a 10 digit mobile number. ";
+$text['message-invalid_mobile_twinning_number']['he-il'] = "";
+$text['message-invalid_mobile_twinning_number']['it-it'] = " Invalid Number. Please enter a 10 digit mobile number. ";
+$text['message-invalid_mobile_twinning_number']['nl-nl'] = "";
+$text['message-invalid_mobile_twinning_number']['pl-pl'] = " Invalid Number. Please enter a 10 digit mobile number. ";
+$text['message-invalid_mobile_twinning_number']['pt-br'] = " Invalid Number. Please enter a 10 digit mobile number. ";
+$text['message-invalid_mobile_twinning_number']['pt-pt'] = " Invalid Number. Please enter a 10 digit mobile number. ";
+$text['message-invalid_mobile_twinning_number']['ro-ro'] = "";
+$text['message-invalid_mobile_twinning_number']['ru-ru'] = " Invalid Number. Please enter a 10 digit mobile number. ";
+$text['message-invalid_mobile_twinning_number']['sv-se'] = " Invalid Number. Please enter a 10 digit mobile number. ";
+$text['message-invalid_mobile_twinning_number']['uk-ua'] = " Invalid Number. Please enter a 10 digit mobile number. ";
+
+$text['message-warning']['en-us'] = "Warning:";
+$text['message-warning']['ar-eg'] = "";
+$text['message-warning']['de-at'] = "Warning:"; 
+$text['message-warning']['de-ch'] = "Warning:";
+$text['message-warning']['de-de'] = "Warning:";
+$text['message-warning']['es-cl'] = "Warning:";
+$text['message-warning']['es-mx'] = "Warning:"; 
+$text['message-warning']['fr-ca'] = "Warning:"; 
+$text['message-warning']['fr-fr'] = "Warning:";
+$text['message-warning']['he-il'] = "";
+$text['message-warning']['it-it'] = "Warning:";
+$text['message-warning']['nl-nl'] = "";
+$text['message-warning']['pl-pl'] = "Warning:";
+$text['message-warning']['pt-br'] = "Warning:";
+$text['message-warning']['pt-pt'] = "Warning:";
+$text['message-warning']['ro-ro'] = "";
+$text['message-warning']['ru-ru'] = "Warning:";
+$text['message-warning']['sv-se'] = "Warning:";
+$text['message-warning']['uk-ua'] = "Warning:";
+
+
+$text['table-description']['en-us'] = "Description";
+$text['table-description']['ar-eg'] = "";
+$text['table-description']['de-at'] = "Description"; 
+$text['table-description']['de-ch'] = "Description";
+$text['table-description']['de-de'] = "Description";
+$text['table-description']['es-cl'] = "Description";
+$text['table-description']['es-mx'] = "Description"; 
+$text['table-description']['fr-ca'] = "Description"; 
+$text['table-description']['fr-fr'] = "Description";
+$text['table-description']['he-il'] = "";
+$text['table-description']['it-it'] = "Description";
+$text['table-description']['nl-nl'] = "";
+$text['table-description']['pl-pl'] = "Description";
+$text['table-description']['pt-br'] = "Description";
+$text['table-description']['pt-pt'] = "Description";
+$text['table-description']['ro-ro'] = "";
+$text['table-description']['ru-ru'] = "Description";
+$text['table-description']['sv-se'] = "Description";
+$text['table-description']['uk-ua'] = "Description";
+
+$text['table-extension']['en-us'] = "Extension";
+$text['table-extension']['ar-eg'] = "";
+$text['table-extension']['de-at'] = "Extension"; 
+$text['table-extension']['de-ch'] = "Extension";
+$text['table-extension']['de-de'] = "Extension";
+$text['table-extension']['es-cl'] = "Extension";
+$text['table-extension']['es-mx'] = "Extension"; 
+$text['table-extension']['fr-ca'] = "Extension"; 
+$text['table-extension']['fr-fr'] = "Extension";
+$text['table-extension']['he-il'] = "";
+$text['table-extension']['it-it'] = "Extension";
+$text['table-extension']['nl-nl'] = "";
+$text['table-extension']['pl-pl'] = "Extension";
+$text['table-extension']['pt-br'] = "Extension";
+$text['table-extension']['pt-pt'] = "Extension";
+$text['table-extension']['ro-ro'] = "";
+$text['table-extension']['ru-ru'] = "Extension";
+$text['table-extension']['sv-se'] = "Extension";
+$text['table-extension']['uk-ua'] = "Extension";
+
+$text['table-twinning_number']['en-us'] = "Mobile Number";
+$text['table-twinning_number']['ar-eg'] = "";
+$text['table-twinning_number']['de-at'] = "Mobile Number"; 
+$text['table-twinning_number']['de-ch'] = "Mobile Number";
+$text['table-twinning_number']['de-de'] = "Mobile Number";
+$text['table-twinning_number']['es-cl'] = "Mobile Number";
+$text['table-twinning_number']['es-mx'] = "Mobile Number"; 
+$text['table-twinning_number']['fr-ca'] = "Mobile Number"; 
+$text['table-twinning_number']['fr-fr'] = "Mobile Number";
+$text['table-twinning_number']['he-il'] = "";
+$text['table-twinning_number']['it-it'] = "Mobile Number";
+$text['table-twinning_number']['nl-nl'] = "";
+$text['table-twinning_number']['pl-pl'] = "Mobile Number";
+$text['table-twinning_number']['pt-br'] = "Mobile Number";
+$text['table-twinning_number']['pt-pt'] = "Mobile Number";
+$text['table-twinning_number']['ro-ro'] = "";
+$text['table-twinning_number']['ru-ru'] = "Mobile Number";
+$text['table-twinning_number']['sv-se'] = "Mobile Number";
+$text['table-twinning_number']['uk-ua'] = "Mobile Number";
+
+$text['table-twinning_enabled']['en-us'] = "Enabled";
+$text['table-twinning_enabled']['ar-eg'] = "";
+$text['table-twinning_enabled']['de-at'] = "Enabled"; 
+$text['table-twinning_enabled']['de-ch'] = "Enabled";
+$text['table-twinning_enabled']['de-de'] = "Enabled";
+$text['table-twinning_enabled']['es-cl'] = "Enabled";
+$text['table-twinning_enabled']['es-mx'] = "Enabled"; 
+$text['table-twinning_enabled']['fr-ca'] = "Enabled"; 
+$text['table-twinning_enabled']['fr-fr'] = "Enabled";
+$text['table-twinning_enabled']['he-il'] = "";
+$text['table-twinning_enabled']['it-it'] = "Enabled";
+$text['table-twinning_enabled']['nl-nl'] = "";
+$text['table-twinning_enabled']['pl-pl'] = "Enabled";
+$text['table-twinning_enabled']['pt-br'] = "Enabled";
+$text['table-twinning_enabled']['pt-pt'] = "Enabled";
+$text['table-twinning_enabled']['ro-ro'] = "";
+$text['table-twinning_enabled']['ru-ru'] = "Enabled";
+$text['table-twinning_enabled']['sv-se'] = "Enabled";
+$text['table-twinning_enabled']['uk-ua'] = "Enabled";
+
+$text['title-mobile_twinning']['en-us'] = "Mobile Twinning";
+$text['title-mobile_twinning']['ar-eg'] = "";
+$text['title-mobile_twinning']['de-at'] = "Mobile Twinning"; 
+$text['title-mobile_twinning']['de-ch'] = "Mobile Twinning";
+$text['title-mobile_twinning']['de-de'] = "Mobile Twinning";
+$text['title-mobile_twinning']['es-cl'] = "Mobile Twinning";
+$text['title-mobile_twinning']['es-mx'] = "Mobile Twinning"; 
+$text['title-mobile_twinning']['fr-ca'] = "Mobile Twinning"; 
+$text['title-mobile_twinning']['fr-fr'] = "Mobile Twinning";
+$text['title-mobile_twinning']['he-il'] = "";
+$text['title-mobile_twinning']['it-it'] = "Mobile Twinning";
+$text['title-mobile_twinning']['nl-nl'] = "";
+$text['title-mobile_twinning']['pl-pl'] = "Mobile Twinning";
+$text['title-mobile_twinning']['pt-br'] = "Mobile Twinning";
+$text['title-mobile_twinning']['pt-pt'] = "Mobile Twinning";
+$text['title-mobile_twinning']['ro-ro'] = "";
+$text['title-mobile_twinning']['ru-ru'] = "Mobile Twinning";
+$text['title-mobile_twinning']['sv-se'] = "Mobile Twinning";
+$text['title-mobile_twinning']['uk-ua'] = "Mobile Twinning";
+
+?>

+ 23 - 0
mobile-twinning/app_menu.php

@@ -0,0 +1,23 @@
+<?php
+
+$apps[$x]['menu'][0]['title']['en-us'] = "Mobile Twinning";
+$apps[$x]['menu'][0]['title']['es-cl'] = "";
+$apps[$x]['menu'][0]['title']['fr-fr'] = "";
+$apps[$x]['menu'][0]['title']['pt-pt'] = "";
+$apps[$x]['menu'][0]['title']['pt-br'] = "";
+$apps[$x]['menu'][0]['title']['pl'] = "";
+$apps[$x]['menu'][0]['title']['he'] = "";
+$apps[$x]['menu'][0]['title']['uk'] = "";
+$apps[$x]['menu'][0]['title']['sv-se'] = "";
+$apps[$x]['menu'][0]['title']['de-at'] = "";
+$apps[$x]['menu'][0]['title']['ro'] = "";
+$apps[$x]['menu'][0]['title']['ar-eg'] = "";
+$apps[$x]['menu'][0]['uuid'] = "65580aed-834f-4eeb-8462-196fbf14144e";
+$apps[$x]['menu'][0]['parent_uuid'] = "fd29e39c-c936-f5fc-8e2b-611681b266b5";
+$apps[$x]['menu'][0]['category'] = "internal";
+$apps[$x]['menu'][0]['path'] = "/app/mobile_twinning/mobile_twinning.php";
+//$apps[$x]['menu'][0]['groups'][] = "user";
+$apps[$x]['menu'][0]['groups'][] = "admin";
+$apps[$x]['menu'][0]['groups'][] = "superadmin";
+
+?>

+ 216 - 0
mobile-twinning/index.lua

@@ -0,0 +1,216 @@
+
+
+--set default variables
+	max_digits = 15;
+	digit_timeout = 5000;
+	--debug["sql"] = true;
+
+--general functions
+	require "resources.functions.trim";
+
+--connect to the database
+	local Database = require "resources.functions.database";
+	dbh = Database.new('system');
+
+--include json library
+	local json
+	if (debug["sql"]) then
+		json = require "resources.functions.lunajson"
+	end
+
+--set the api
+	api = freeswitch.API();
+
+--get the hostname
+	local hostname = trim(api:execute("switchname", ""));
+	
+--Get intercept logger
+	local log = require "resources.functions.log".mobile_twinning
+	
+--get the argv values
+	call_direction = argv[2];
+	call_uuid = "";
+--get the session variables
+	if (session:ready()) then
+		session:answer();
+		session:execute("sleep", "1000");
+	end
+
+--get the session variables
+	if (session:ready()) then
+		--general variables
+			domain_uuid = session:getVariable("domain_uuid");
+			domain_name = session:getVariable("domain_name");
+			context = session:getVariable("context");
+			uuid = session:get_uuid();
+			caller_id_number = session:getVariable("caller_id_number");
+
+
+		--set the sounds path for the language, dialect and voice
+			default_language = session:getVariable("default_language");
+			default_dialect = session:getVariable("default_dialect");
+			default_voice = session:getVariable("default_voice");
+			if (not default_language) then default_language = 'en'; end
+			if (not default_dialect) then default_dialect = 'us'; end
+			if (not default_voice) then default_voice = 'callie'; end
+	end
+
+--define the sounds directory
+	sounds_dir = session:getVariable("sounds_dir");
+	sounds_dir = sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice;
+
+--lookup caller-id to see if it is an associated mobile_number
+	mobile_caller_id_number = string.sub(caller_id_number,-10);
+	local params = {domain_uuid = domain_uuid, caller_id_number = mobile_caller_id_number }
+	local sql = "SELECT m.mobile_twinning_number, m.extension_uuid, m.mobile_twinning_uuid, e.extension ";
+	sql = sql .. "FROM  v_mobile_twinnings as m ";
+	sql = sql .. "LEFT OUTER JOIN v_extensions AS e ON e.extension_uuid = m.extension_uuid ";
+	sql = sql .. "WHERE m.domain_uuid = :domain_uuid ";
+	sql = sql .. "AND m.mobile_twinning_number = :caller_id_number ";
+	if (debug["sql"]) then
+		freeswitch.consoleLog("notice", "[mobile_twinning] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
+	end
+
+	dbh:query(sql, params, function(row)
+		--set the variables
+			mobile_twinning_number = row.mobile_twinning_number;
+			extension_uuid = row.extension_uuid;
+			mobile_twinning_uuid = row.mobile_twinning_uuid;
+			extension = row.extension;
+	end);
+
+--Call is from mobile
+	if (mobile_twinning_uuid ~= nil and caller_id_number ~= nil) then
+		min_digits = 1;
+		max_digits = 1;
+		max_tries = 1;
+		session:streamFile("ivr/ivr-to_accept_press_one.wav");
+		dtmf_digits = session:getDigits(max_digits, "#", 7000);
+
+		if (dtmf_digits == "1") then
+			local dbh = Database.new('switch')
+			--check the database to the uuid of the desk call
+				presence_id = extension.."@"..domain_name;
+				call_hostname = "";
+				sql = "SELECT uuid, call_uuid, direction, hostname FROM channels ";
+				sql = sql .. "WHERE presence_id = '" .. presence_id .. "' ";
+				sql = sql .. "AND call_uuid IS NOT NULL ";
+				sql = sql .. "AND callstate = 'ACTIVE' ";
+			if (debug["sql"]) then
+				log.noticef("SQL: %s; params: %s", sql, json.encode(params));
+			end
+			local is_child
+			dbh:query(sql, params, function(row)
+				is_child = (row.uuid == row.call_uuid)
+				call_uuid = row.call_uuid;
+				call_hostname = row.hostname;
+				direction = row.direction;
+			end);
+			log.notice("call_uuid: "..uuid .. " direction: " .. direction);
+			if (direction == 'inbound') then
+				leg = "bleg"
+			end
+		end
+	end
+
+--if the call is from an extension, lookup the mobile number and try to pull the call off the mobile phone
+	if (mobile_twinning_uuid == nil and caller_id_number ~= nil) then
+		--lookup the extension_uuid
+				local params = {domain_uuid = domain_uuid, caller_id_number = caller_id_number }
+				local sql = "SELECT extension_uuid FROM v_extensions ";
+				sql = sql .. "WHERE domain_uuid = :domain_uuid ";
+				sql = sql .. "AND extension = :caller_id_number ";
+				if (debug["sql"]) then
+					freeswitch.consoleLog("notice", "[mobile_twinning] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
+				end
+
+				dbh:query(sql, params, function(row)
+					--set the variables
+						extension_uuid = row.extension_uuid;
+				end);
+				
+		--lookup the mobile number associated to the extension
+				local params = {domain_uuid = domain_uuid, extension_uuid = extension_uuid }
+				local sql = "SELECT m.mobile_twinning_number, e.extension ";
+				sql = sql .. "FROM  v_mobile_twinnings as m ";
+				sql = sql .. "LEFT OUTER JOIN v_extensions AS e ON e.extension_uuid = m.extension_uuid ";
+				sql = sql .. "WHERE m.domain_uuid = :domain_uuid ";
+				sql = sql .. "AND m.extension_uuid = :extension_uuid ";
+				if (debug["sql"]) then
+					freeswitch.consoleLog("notice", "[mobile_twinning] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
+				end
+			
+				dbh:query(sql, params, function(row)
+					--set the variables
+						mobile_twinning_number = row.mobile_twinning_number;
+						extension = row.extension;
+				end);
+		
+		if (mobile_twinning_number ~= nil) then
+			--lookup active calls to the mobile (for follow-me)
+				--connect to FS database
+					local dbh = Database.new('switch')
+					
+				--check the database for the uuid of the mobile call 
+					presence_id = caller_id_number.."@"..domain_name;
+					call_hostname = "";
+					sql = "SELECT uuid, call_uuid, hostname FROM channels ";
+					sql = sql .. "WHERE callstate = 'ACTIVE' ";
+					sql = sql .. "AND direction = 'outbound' ";
+					sql = sql .. "AND dest = " .. mobile_twinning_number .. " ";
+					sql = sql .. "AND presence_id = '" .. presence_id .. "' ";
+					sql = sql .. "AND call_uuid IS NOT NULL ";
+				if (debug["sql"]) then
+					log.noticef("SQL: %s; params: %s", sql, json.encode(params));
+				end
+				local is_child
+				dbh:query(sql, params, function(row)
+					is_child = (row.uuid == row.call_uuid)
+					call_uuid = row.call_uuid;
+					call_hostname = row.hostname;
+				end);
+				log.notice("call_uuid from follow-me: "..call_uuid);
+			
+			--lookup active calls to the mobile (for instances where the mobile switched the call from the extension)
+				if (call_uuid == nil or call_uuid == '') then
+				--connect to FS database
+					local dbh = Database.new('switch')
+					
+				--check the database for the uuid of the mobile call 
+					call_hostname = "";
+					sql = "SELECT uuid, call_uuid, hostname FROM channels ";
+					sql = sql .. "WHERE callstate = 'ACTIVE' ";
+					sql = sql .. "AND direction = 'inbound' ";
+					sql = sql .. "AND dest = " .. extension .. " ";
+					sql = sql .. "AND call_uuid IS NOT NULL ";
+					if (debug["sql"]) then
+						log.noticef("SQL: %s; params: %s", sql, json.encode(params));
+					end
+					local is_child
+					dbh:query(sql, params, function(row)
+						is_child = (row.uuid == row.call_uuid)
+						call_uuid = row.call_uuid;
+						call_hostname = row.hostname;
+					end);
+					log.notice("call_uuid from other: "..call_uuid);
+					leg = "bleg"
+				end
+		end
+	end
+
+--intercept a call that is on your mobile
+	if (call_uuid ~= nil) then
+		if (hostname == call_hostname) then
+			if (leg == 'bleg') then
+				session:execute("intercept", "-bleg " .. call_uuid);
+			else
+				session:execute("intercept", call_uuid);
+			end	
+
+--		else
+--			session:execute("export", "sip_h_X-intercept_uuid="..uuid);
+--			make_proxy_call(pickup_number, call_hostname)
+		end
+	else
+		log.notice("No active call to transfer.");
+	end

+ 171 - 0
mobile-twinning/mobile_twinning.php

@@ -0,0 +1,171 @@
+<?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-2016
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	KonradSC <[email protected]>
+	Mark J Crane <[email protected]>
+*/
+
+//includes
+	include "root.php";
+	require_once "resources/require.php";
+	require_once "resources/check_auth.php";
+	require_once "resources/paging.php";
+
+//check permissions	
+	if (permission_exists('mobile_twinning_view')) {
+		//access granted
+	}
+	else {
+		echo "access denied";
+		exit;
+	}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+	
+//get the https values and set as variables
+	$order_by = check_str($_GET["order_by"]);
+	$order = check_str($_GET["order"]);
+
+//handle search term
+	$search = check_str($_GET["search"]);
+	if (strlen($search) > 0) {
+		$sql_mod = "and ( ";
+		$sql_mod .= "e.extension ILIKE '%".$search."%' ";
+		$sql_mod .= "or m.mobile_twinning_description ILIKE '%".$search."%' ";
+		$sql_mod .= "or m.mobile_twinning_number ILIKE '%".$search."%' ";
+		$sql_mod .= ") ";
+	}
+	if (strlen($order_by) < 1) {
+		$order_by = "e.extension";
+		$order = "ASC";
+	}
+
+//get total extension count from the database
+	$sql = "select count(*) as num_rows from v_extensions where domain_uuid = '".$_SESSION['domain_uuid']."' ".$sql_mod." ";
+	$prep_statement = $db->prepare($sql);
+	if ($prep_statement) {
+		$prep_statement->execute();
+		$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
+		$total_extensions = $row['num_rows'];
+		if (($db_type == "pgsql") or ($db_type == "mysql")) {
+			$numeric_extensions = $row['num_rows'];
+		}
+	}
+	unset($prep_statement, $row);
+
+//prepare to page the results
+	$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
+	$param = "&search=".$search."&order_by=".$order_by."&order=".$order;
+	if (!isset($_GET['page'])) { $_GET['page'] = 0; }
+	$_GET['page'] = check_str($_GET['page']);
+	list($paging_controls_mini, $rows_per_page, $var_3) = paging($total_extensions, $param, $rows_per_page, true); //top
+	list($paging_controls, $rows_per_page, $var_3) = paging($total_extensions, $param, $rows_per_page); //bottom
+	$offset = $rows_per_page * $_GET['page'];
+
+//get all the extensions from the database
+	$sql = "select e.extension, m.mobile_twinning_number, e.description, m.mobile_twinning_uuid, e.extension_uuid \n";
+	$sql .= "FROM  v_extensions AS e \n ";
+	$sql .= "LEFT OUTER JOIN v_mobile_twinnings AS m ON m.extension_uuid = e.extension_uuid ";
+	$sql .= "where e.domain_uuid = '$domain_uuid' ";
+	$sql .= $sql_mod; //add search mod from above	
+	$sql .= "and e.enabled = 'true' ";
+	if (strlen($order_by)> 0) {
+		$sql .= "order by $order_by $order ";
+	}
+	else {
+		$sql .= "order by 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);
+
+//set the alternating styles
+	$c = 0;
+	$row_style["0"] = "row_style0";
+	$row_style["1"] = "row_style1";
+
+//begin the content
+	require_once "resources/header.php";
+	echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
+	echo "  <tr>\n";
+	echo "	<td align='left' width='100%'>\n";
+	echo "		<b>".$text['header-mobile_twinning']." (".$numeric_extensions.")</b><br>\n";
+	echo "	</td>\n";
+	echo "		<td align='right' width='100%' style='vertical-align: top;'>";
+	if ((if_group("admin") || if_group("superadmin"))) {
+		echo "		<form method='get' action=''>\n";
+		echo "			<td style='vertical-align: top; text-align: right; white-space: nowrap;'>\n";
+		echo "				<input type='text' class='txt' style='width: 150px' name='search' id='search' value='".$search."'>";
+		echo "				<input type='submit' class='btn' name='submit' value='".$text['button-search']."'>";
+		if ($paging_controls_mini != '') {
+			echo 			"<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
+		}
+		echo "			</td>\n";
+		echo "			</td>\n";
+		echo "		</form>\n";	
+	}
+	echo "  </tr>\n";
+
+	echo "	<tr>\n";
+	echo "		<td colspan='2'>\n";
+	echo "			".$text['description-mobile_twinning']."\n";
+	echo "		</td>\n";
+	echo "	</tr>\n";
+	echo "</table>\n";
+	echo "<br>";
+	
+	echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+	echo "<tr>\n";
+	echo th_order_by('extension', $text['table-extension'], $order_by,$order);
+	echo th_order_by('m.mobile_twinning_number', $text['table-twinning_number'], $order_by, $order);
+	echo th_order_by('e.description', $text['table-description'], $order_by, $order);
+	echo "</tr>\n";
+
+	if ($result_count > 0) {
+		foreach($result as $row) {
+			$tr_link = (permission_exists('mobile_twinning_edit')) ? " href='mobile_twinning_edit.php?id=".$row['mobile_twinning_uuid']."&extid=".$row['extension_uuid']."'" : null;
+			echo "<tr ".$tr_link.">\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['extension']."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".format_phone(substr($row['mobile_twinning_number'],-10))."</td>\n";
+			echo "	<td valign='top' class='row_stylebg' width='40%'>".$row['description']."&nbsp;</td>\n";
+			echo "</tr>\n";
+			if ($c==0) { $c=1; } else { $c=0; }
+		} //end foreach
+		unset($sql, $result, $row_count);
+	} //end if results
+
+	echo "</table>";
+	if (strlen($paging_controls) > 0) {
+		echo "<br />";
+		echo $paging_controls."\n";
+	}
+	echo "<br><br>";
+	
+//show the footer
+	require_once "resources/footer.php";
+?>

+ 203 - 0
mobile-twinning/mobile_twinning_edit.php

@@ -0,0 +1,203 @@
+<?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-2016
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	KonradSC <[email protected]>
+	Mark J Crane <[email protected]>
+*/
+
+//includes
+	include "root.php";
+	require_once "resources/require.php";
+	require_once "resources/check_auth.php";
+	require_once "resources/paging.php";
+
+//check permissions	
+	if (permission_exists('mobile_twinning_view')) {
+		//access granted
+	}
+	else {
+		echo "access denied";
+		exit;
+	}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+	
+//get the https values and set as variables
+	$extension_uuid = check_str($_GET["extid"]);
+	$mobile_twinning_uuid = check_str($_GET["id"]);
+
+//action add or update
+	if (isset($_REQUEST["id"])) {
+		$action = "update";
+		$mobile_twinning_uuid = check_str($_GET["id"]);
+	}
+	else {
+		$action = "add";
+	}
+	
+//get the http values and set them as php variables
+	if (count($_POST) > 0 && $_POST["persistform"] != "1") {
+		$mobile_twinning_number = check_str($_POST["mobile_twinning_number"]);
+		if ($action == "update") {
+			$mobile_twinning_uuid = check_str($_POST["mobile_twinning_uuid"]);
+			$extension_uuid = check_str($_POST["extension_uuid"]);
+			$extension = check_str($_POST["extension"]);
+		}
+	}
+
+//process the user data and save it to the database
+	if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
+
+
+		//check for duplicate mobile in database
+			$database = new database;
+			$database->table = "v_mobile_twinnings";
+			$where[0]["name"] = "mobile_twinning_number";
+			$where[0]["operator"] = "=";
+			$where[0]["value"] = "$mobile_twinning_number";
+			$where[1]["name"] = "mobile_twinning_uuid";
+			$where[1]["operator"] = "!=";
+			$where[1]["value"] = "$mobile_twinning_uuid";			
+			$database->where = $where;
+			$result = $database->count();
+			if ($result > 0) {
+					$msg .= $text['message-warning'].$text['message-duplicate_mobile_twinning_number']."<br>\n";
+				}
+			unset($result,$database);	
+
+		//check for a valid 10 digit mobile number
+			if (strlen($mobile_twinning_number) != 10)  {
+				if (strlen($mobile_twinning_number) != 0) {
+					$msg .= $text['message-warning'].$text['message-invalid_mobile_twinning_number']."<br>\n";
+				}
+			}
+			
+		//display error msg if error found			
+			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;
+			}
+
+		//insert into v_mobile_twinnings
+			$i = 0;
+			$array["mobile_twinnings"][$i]["domain_uuid"] = $_SESSION['domain_uuid'];;
+			$array["mobile_twinnings"][$i]["mobile_twinning_uuid"] = $mobile_twinning_uuid;
+			$array["mobile_twinnings"][$i]["extension_uuid"] = $extension_uuid;
+			$array["mobile_twinnings"][$i]["mobile_twinning_number"] = $mobile_twinning_number;
+			
+		//save to the datbase
+			$database = new database;
+			$database->app_name = 'mobile_twinnings';
+			$database->app_uuid = null;
+			$database->save($array);
+			$message = $database->message;
+			//echo "<pre>".print_r($message, true)."<pre>\n";
+			//exit;
+	}
+	
+//pre-populate the form
+	if (is_array($_GET) && $_POST["persistformvar"] != "true") {
+		$sql = "SELECT e.extension, m.mobile_twinning_number, e.description, m.mobile_twinning_uuid, e.extension_uuid \n";
+		$sql .= "FROM  v_extensions AS e \n ";
+		$sql .= "LEFT OUTER JOIN v_mobile_twinnings AS m ON m.extension_uuid = e.extension_uuid \n";
+		$sql .= "WHERE e.domain_uuid = '$domain_uuid' ";
+		if ($mobile_twinning_uuid != null) {
+				$sql .= "AND m.mobile_twinning_uuid = '$mobile_twinning_uuid' \n";
+		}
+		$sql .= "AND e.extension_uuid = '$extension_uuid' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		unset ($prep_statement, $sql);
+	
+	//set the variables
+
+	
+		foreach ($result as $row) {
+			$mobile_twinning_number = $row[mobile_twinning_number];
+			$mobile_twinning_uuid = $row[mobile_twinning_uuid];
+			$extension = $row[extension];
+			$description = $row[description];
+			$extension_uuid = $row[extension_uuid];
+		}
+
+		if (strlen($mobile_twinning_uuid) == 0) {
+			$mobile_twinning_uuid = uuid();
+		}			
+	}
+	
+//show the header
+	require_once "resources/header.php";
+
+//show the content
+	echo "<form name='frm' id='frm' method='post' action=''>\n";
+	echo "<table width='100%'  border='0' cellpadding='0' cellspacing='0'>\n";
+	echo "<input type='hidden' name='extension_uuid' id='extension_uuid' value='".$extension_uuid."'>\n";
+	echo "<input type='hidden' name='mobile_twinning_uuid' id='mobile_twinning_uuid' value='".$mobile_twinning_uuid."'>\n";
+	echo "<input type='hidden' name='extension' id='mobile_twinning_uuid' value='".$extension."'>\n";
+	echo "<tr>\n";
+	echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-mobile_twinning']."</b><br><br></td>\n";
+	echo "<td width='70%' align='right' valign='top'>\n";
+	echo "	<input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='mobile_twinning.php'\" value='".$text['button-back']."'>";
+	echo "	<input type='submit' class='btn' value='".$text['button-save']."'>";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	//Extension
+	echo "<tr>\n";
+	echo "<td class='vncellreq' width='30%' valign='top' align='left' nowrap='nowrap'>\n";
+	echo "    ".$text['label-extension']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'  padding: 5px; >\n";
+	echo     $extension."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td width=\"30%\" class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+	echo "	".$text['label-mobile_twinning_number']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='mobile_twinning_number' maxlength='255' value=\"".escape($mobile_twinning_number)."\">\n";
+	echo "<br />\n";
+	echo $text['description-mobile_twinning_number']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "</table>";	
+	echo "</form>";
+	echo "<br /><br />";
+
+//include the footer
+	require_once "resources/footer.php";
+
+?>

+ 90 - 0
mobile-twinning/root.php

@@ -0,0 +1,90 @@
+<?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
+	umask(2);
+	if (!defined("PATH_SEPARATOR")) {
+		if (strpos($_ENV["OS"], "Win") !== false) {
+			define("PATH_SEPARATOR", ";");
+		} else {
+			define("PATH_SEPARATOR", ":");
+		}
+	}
+
+	if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
+
+	// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
+	if(PHP_SAPI == 'cli'){
+		chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
+		$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
+		$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
+		if (file_exists('/project_root.php')) {
+			$path = '/';
+		} else {
+			$i    = 1;
+			$path = '';
+			while ($i < count($dirs)) {
+				$path .= '/' . $dirs[$i];
+				if (file_exists($path. '/project_root.php')) {
+					break;
+				}
+				$i++;
+			}
+		}
+		$_SERVER["DOCUMENT_ROOT"] = $path;
+	}else{
+		$_SERVER["DOCUMENT_ROOT"]   = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	}
+	$_SERVER["DOCUMENT_ROOT"]   = realpath($_SERVER["DOCUMENT_ROOT"]);
+// try to detect if a project path is being used
+	if (!defined('PROJECT_PATH')) {
+		if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) {
+			define('PROJECT_PATH', '/fusionpbx');
+		} elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) {
+			define('PROJECT_PATH', '');
+		} else {
+			$dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME)));
+			$i    = 1;
+			$path = $_SERVER["DOCUMENT_ROOT"];
+			while ($i < count($dirs)) {
+				$path .= '/' . $dirs[$i];
+				if (file_exists($path. '/project_root.php')) {
+					break;
+				}
+				$i++;
+			}
+			if(!file_exists($path. '/project_root.php')){
+				die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance");
+			}
+			$project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path);
+			define('PROJECT_PATH', $project_path);
+		}
+		$_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH);
+		set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]);
+	}
+
+?>