Add conference controls.

This commit is contained in:
markjcrane
2016-07-17 15:12:15 -06:00
parent 4d7818a043
commit 6b5bf1cb82
11 changed files with 1355 additions and 0 deletions

View File

@@ -0,0 +1,107 @@
<?php
//application details
$apps[$x]['name'] = 'Conference Controls';
$apps[$x]['uuid'] = 'e1ad84a2-79e1-450c-a5b1-7507a043e048';
$apps[$x]['category'] = '';
$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'] = '';
//permission details
$y = 0;
$apps[$x]['permissions'][$y]['name'] = 'conference_control_view';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'user';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'conference_control_add';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'conference_control_edit';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
//$apps[$x]['permissions'][$y]['groups'][] = 'user';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'conference_control_delete';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'conference_control_detail_view';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'user';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'conference_control_detail_add';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'conference_control_detail_edit';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
//$apps[$x]['permissions'][$y]['groups'][] = 'user';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'conference_control_detail_delete';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
//schema details
$y = 0; //table array index
$z = 0; //field array index
$apps[$x]['db'][$y]['table'] = 'v_conference_controls';
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'conference_control_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'] = 'control_name';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the conference control name.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'control_enabled';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Set the statsu of the control.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'control_description';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the description.';
$y = 1; //table array index
$z = 0; //field array index
$apps[$x]['db'][$y]['table'] = 'v_conference_control_details';
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'conference_control_detail_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'] = 'conference_control_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_conference_control';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'conference_control_uuid';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'control_digits';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the digits.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'control_action';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the action.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'control_data';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the data.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'control_enabled';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Set the status of the control.';
$z++;
?>

View File

@@ -0,0 +1,131 @@
<?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 <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
if ($domains_processed == 1) {
//add the conference controls list to the database
$sql = "select count(*) as num_rows from v_conference_controls; ";
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] == 0) {
//set the directory
$xml_dir = $_SESSION["switch"]["conf"]["dir"].'/autoload_configs';
$xml_file = $xml_dir."/conference.conf";
$xml_file_alt = $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH.'/resources/templates/conf/autoload_configs/conference.conf';
//rename the file
if (file_exists($xml_dir.'/conference.conf.xml.noload')) {
rename($xml_dir.'/conference.conf.xml.noload', $xml_dir.'/conference.conf');
}
//load the xml and save it into an array
if (file_exists($xml_file)) {
$xml_string = file_get_contents($xml_file);
}
elseif (file_exists($xml_file_alt)) {
$xml_string = file_get_contents(xml_file_alt);
}
$xml_object = simplexml_load_string($xml_string);
$json = json_encode($xml_object);
$conf_array = json_decode($json, true);
//process the array
foreach ($conf_array['caller-controls']['group'] as $row) {
//get the data from the array
$control_name = $row['@attributes']['name'];
//echo $profile_name."<br />\n";
//insert the data into the database
$conference_control_uuid = uuid();
$sql = "insert into v_conference_controls ";
$sql .= "(";
//$sql .= "domain_uuid, ";
$sql .= "conference_control_uuid, ";
$sql .= "control_name, ";
$sql .= "control_enabled ";
$sql .= ") ";
$sql .= "values ";
$sql .= "( ";
//$sql .= "'".$domain_uuid."', ";
$sql .= "'".$conference_control_uuid."', ";
$sql .= "'".check_str($control_name)."', ";
$sql .= "'true' ";
$sql .= ");";
//echo $sql."\n";
$db->exec(check_sql($sql));
unset($sql);
//insert the profile params
foreach ($row['control'] as $p) {
//get the name
//print_r($p);
$control_action = $p['@attributes']['action'];
$control_digits = $p['@attributes']['digits'];
$control_data = $p['@attributes']['data'];
$control_enabled = 'true';
//add the coference profile params
$conference_control_detail_uuid = uuid();
$sql = "insert into v_conference_control_details ";
$sql .= "(";
$sql .= "conference_control_uuid, ";
$sql .= "conference_control_detail_uuid, ";
$sql .= "control_digits, ";
$sql .= "control_action, ";
if (strlen($control_data) > 0) {
$sql .= "control_data, ";
}
$sql .= "control_enabled ";
$sql .= ") ";
$sql .= "values ";
$sql .= "( ";
$sql .= "'".$conference_control_uuid."', ";
$sql .= "'".$conference_control_detail_uuid."', ";
$sql .= "'".$control_digits."', ";
$sql .= "'".$control_action."', ";
if (strlen($control_data) > 0) {
$sql .= "'".$control_data."', ";
}
$sql .= "'".$control_enabled."' ";
$sql .= ");";
//echo $sql."\n";
$db->exec(check_sql($sql));
unset($sql);
}
}
} //if num_rows
} //if prep_statement
}
?>

View File

@@ -0,0 +1,170 @@
<?php
//Conference Controls
$text['title-conference_controls']['en-us'] = 'Conference Controls';
$text['title-conference_controls']['es-cl'] = '';
$text['title-conference_controls']['pt-pt'] = '';
$text['title-conference_controls']['fr-fr'] = '';
$text['title-conference_control']['en-us'] = 'Conference Control';
$text['title-conference_control']['es-cl'] = '';
$text['title-conference_control']['pt-pt'] = '';
$text['title-conference_control']['fr-fr'] = '';
$text['title_description-conference_control']['en-us'] = 'Call controls enable ability to assign digits to actions. They can be used to mute, unmute, or other actions during the conference call.';
$text['title_description-conference_control']['es-cl'] = '';
$text['title_description-conference_control']['pt-pt'] = '';
$text['title_description-conference_control']['fr-fr'] = '';
$text['label-control_name']['en-us'] = 'Name';
$text['label-control_name']['es-cl'] = '';
$text['label-control_name']['pt-pt'] = '';
$text['label-control_name']['fr-fr'] = '';
$text['description-control_name']['en-us'] = 'Enter the conference control name.';
$text['description-control_name']['es-cl'] = '';
$text['description-control_name']['pt-pt'] = '';
$text['description-control_name']['fr-fr'] = '';
$text['label-control_enabled']['en-us'] = 'Enabled';
$text['label-control_enabled']['es-cl'] = '';
$text['label-control_enabled']['pt-pt'] = '';
$text['label-control_enabled']['fr-fr'] = '';
$text['description-control_enabled']['en-us'] = 'Set the statsu of the control.';
$text['description-control_enabled']['es-cl'] = '';
$text['description-control_enabled']['pt-pt'] = '';
$text['description-control_enabled']['fr-fr'] = '';
$text['label-control_description']['en-us'] = 'Description';
$text['label-control_description']['es-cl'] = '';
$text['label-control_description']['pt-pt'] = '';
$text['label-control_description']['fr-fr'] = '';
$text['description-control_description']['en-us'] = 'Enter the description.';
$text['description-control_description']['es-cl'] = '';
$text['description-control_description']['pt-pt'] = '';
$text['description-control_description']['fr-fr'] = '';
$text['label-true']['en-us'] = 'true';
$text['label-true']['es-cl'] = '';
$text['label-true']['pt-pt'] = '';
$text['label-true']['fr-fr'] = '';
$text['label-false']['en-us'] = 'false';
$text['label-false']['es-cl'] = 'falso';
$text['label-false']['pt-pt'] = 'falso';
$text['label-false']['fr-fr'] = 'falso';
$text['button-add']['en-us'] = 'Add';
$text['button-add']['es-cl'] = '';
$text['button-add']['pt-pt'] = '';
$text['button-add']['fr-fr'] = '';
$text['button-edit']['en-us'] = 'Edit';
$text['button-edit']['es-cl'] = '';
$text['button-edit']['pt-pt'] = '';
$text['button-edit']['fr-fr'] = '';
$text['button-delete']['en-us'] = 'Delete';
$text['button-delete']['es-cl'] = '';
$text['button-delete']['pt-pt'] = '';
$text['button-delete']['fr-fr'] = '';
$text['button-save']['en-us'] = 'Save';
$text['button-save']['es-cl'] = '';
$text['button-save']['pt-pt'] = 'Guardar';
$text['button-save']['fr-fr'] = '';
$text['button-view']['en-us'] = 'View';
$text['button-view']['es-cl'] = '';
$text['button-view']['pt-pt'] = '';
$text['button-view']['fr-fr'] = '';
$text['button-back']['en-us'] = 'Back';
$text['button-back']['es-cl'] = '';
$text['button-back']['pt-pt'] = 'Voltar';
$text['button-back']['fr-fr'] = '';
$text['confirm-delete']['en-us'] = 'Do you really want to delete this?';
$text['confirm-delete']['es-cl'] = '';
$text['confirm-delete']['pt-pt'] = '';
$text['confirm-delete']['fr-fr'] = '';
$text['message-add']['en-us'] = 'Add Completed';
$text['message-add']['es-cl'] = '';
$text['message-add']['pt-pt'] = '';
$text['message-add']['fr-fr'] = '';
$text['message-update']['en-us'] = 'Update Completed';
$text['message-update']['es-cl'] = '';
$text['message-update']['pt-pt'] = '';
$text['message-update']['fr-fr'] = '';
$text['message-delete']['en-us'] = 'Delete Completed';
$text['message-delete']['es-cl'] = '';
$text['message-delete']['pt-pt'] = '';
$text['message-delete']['fr-fr'] = '';
$text['message-required']['en-us'] = 'Please provide: ';
$text['message-required']['es-cl'] = '';
$text['message-required']['pt-pt'] = '';
$text['message-required']['fr-fr'] = '';
//Controls
$text['title-conference_control_details']['en-us'] = 'Controls';
$text['title-conference_control_details']['es-cl'] = '';
$text['title-conference_control_details']['pt-pt'] = '';
$text['title-conference_control_details']['fr-fr'] = '';
$text['title-conference_control_detail']['en-us'] = 'Control';
$text['title-conference_control_detail']['es-cl'] = '';
$text['title-conference_control_detail']['pt-pt'] = '';
$text['title-conference_control_detail']['fr-fr'] = '';
$text['title_description-conference_control_detail']['en-us'] = '';
$text['title_description-conference_control_detail']['es-cl'] = '';
$text['title_description-conference_control_detail']['pt-pt'] = '';
$text['title_description-conference_control_detail']['fr-fr'] = '';
$text['label-control_digits']['en-us'] = 'Digits';
$text['label-control_digits']['es-cl'] = '';
$text['label-control_digits']['pt-pt'] = '';
$text['label-control_digits']['fr-fr'] = '';
$text['description-control_digits']['en-us'] = 'Enter the digits.';
$text['description-control_digits']['es-cl'] = '';
$text['description-control_digits']['pt-pt'] = '';
$text['description-control_digits']['fr-fr'] = '';
$text['label-control_action']['en-us'] = 'Action';
$text['label-control_action']['es-cl'] = '';
$text['label-control_action']['pt-pt'] = '';
$text['label-control_action']['fr-fr'] = '';
$text['description-control_action']['en-us'] = 'Enter the action.';
$text['description-control_action']['es-cl'] = '';
$text['description-control_action']['pt-pt'] = '';
$text['description-control_action']['fr-fr'] = '';
$text['label-control_data']['en-us'] = 'Data';
$text['label-control_data']['es-cl'] = '';
$text['label-control_data']['pt-pt'] = '';
$text['label-control_data']['fr-fr'] = '';
$text['description-control_data']['en-us'] = 'Enter the data.';
$text['description-control_data']['es-cl'] = '';
$text['description-control_data']['pt-pt'] = '';
$text['description-control_data']['fr-fr'] = '';
$text['label-control_enabled']['en-us'] = 'Enabled';
$text['label-control_enabled']['es-cl'] = '';
$text['label-control_enabled']['pt-pt'] = '';
$text['label-control_enabled']['fr-fr'] = '';
$text['description-control_enabled']['en-us'] = 'Set the status of the control.';
$text['description-control_enabled']['es-cl'] = '';
$text['description-control_enabled']['pt-pt'] = '';
$text['description-control_enabled']['fr-fr'] = '';
?>

View File

@@ -0,0 +1,19 @@
<?php
$apps[$x]['menu'][0]['title']['en-us'] = 'Conference Controls';
$apps[$x]['menu'][0]['title']['es-cl'] = '';
$apps[$x]['menu'][0]['title']['fr-fr'] = '';
$apps[$x]['menu'][0]['title']['fr-ca'] = '';
$apps[$x]['menu'][0]['title']['pl'] = '';
$apps[$x]['menu'][0]['title']['sv-se'] = '';
$apps[$x]['menu'][0]['title']['uk'] = '';
$apps[$x]['menu'][0]['title']['de-at'] = '';
$apps[$x]['menu'][0]['uuid'] = '9896d4b5-507f-4d0e-8db7-caa7f4655202';
$apps[$x]['menu'][0]['parent_uuid'] = 'fd29e39c-c936-f5fc-8e2b-611681b266b5';
$apps[$x]['menu'][0]['category'] = 'internal';
$apps[$x]['menu'][0]['path'] = '/app/conference_controls/conference_controls.php';
$apps[$x]['menu'][0]['groups'][] = 'superadmin';
//$apps[$x]['menu'][0]['groups'][] = 'admin';
//$apps[$x]['menu'][0]['groups'][] = 'user';
?>

View File

@@ -0,0 +1,49 @@
<?php
//includes
require_once "root.php";
require_once "resources/require.php";
//check permissions
require_once "resources/check_auth.php";
if (permission_exists('conference_control_delete')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//get the id
if (count($_GET) > 0) {
$id = check_str($_GET["id"]);
}
//delete the data
if (strlen($id) > 0) {
//delete conference_control_detail
$sql = "delete from v_conference_control_details ";
$sql .= "where conference_control_uuid = '$id' ";
//$sql .= "and domain_uuid = '$domain_uuid' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($sql);
//delete conference_control
$sql = "delete from v_conference_controls ";
$sql .= "where conference_control_uuid = '$id' ";
//$sql .= "and domain_uuid = '$domain_uuid' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($sql);
}
//redirect the user
$_SESSION['message'] = $text['message-delete'];
header('Location: conference_controls.php');
?>

View File

@@ -0,0 +1,42 @@
<?php
//includes
require_once "root.php";
require_once "resources/require.php";
//check permissions
require_once "resources/check_auth.php";
if (permission_exists('conference_control_detail_delete')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//get the id
if (count($_GET) > 0) {
$id = check_str($_GET["id"]);
$conference_control_uuid = check_str($_GET["conference_control_uuid"]);
}
//delete the data
if (strlen($id) > 0) {
//delete conference_control_detail
$sql = "delete from v_conference_control_details ";
$sql .= "where conference_control_detail_uuid = '$id' ";
//$sql .= "and domain_uuid = '$domain_uuid' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($sql);
}
//redirect the user
$_SESSION['message'] = $text['message-delete'];
header('Location: conference_control_detail_edit.php?id='.$conference_control_uuid);
?>

View File

@@ -0,0 +1,226 @@
<?php
//includes
require_once "root.php";
require_once "resources/require.php";
//check permissions
require_once "resources/check_auth.php";
if (permission_exists('conference_control_detail_add') || permission_exists('conference_control_detail_edit')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//action add or update
if (isset($_REQUEST["id"])) {
$action = "update";
$conference_control_detail_uuid = check_str($_REQUEST["id"]);
}
else {
$action = "add";
}
//set the parent uuid
if (strlen($_GET["conference_control_uuid"]) > 0) {
$conference_control_uuid = check_str($_GET["conference_control_uuid"]);
}
//get http post variables and set them to php variables
if (count($_POST)>0) {
$control_digits = check_str($_POST["control_digits"]);
$control_action = check_str($_POST["control_action"]);
$control_data = check_str($_POST["control_data"]);
$control_enabled = check_str($_POST["control_enabled"]);
}
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//get the uuid
if ($action == "update") {
$conference_control_detail_uuid = check_str($_POST["conference_control_detail_uuid"]);
}
//check for all required data
$msg = '';
if (strlen($control_digits) == 0) { $msg .= $text['message-required']." ".$text['label-control_digits']."<br>\n"; }
if (strlen($control_action) == 0) { $msg .= $text['message-required']." ".$text['label-control_action']."<br>\n"; }
//if (strlen($control_data) == 0) { $msg .= $text['message-required']." ".$text['label-control_data']."<br>\n"; }
if (strlen($control_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-control_enabled']."<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('conference_control_detail_add')) {
$sql = "insert into v_conference_control_details ";
$sql .= "(";
//$sql .= "domain_uuid, ";
$sql .= "conference_control_detail_uuid, ";
$sql .= "conference_control_uuid, ";
$sql .= "control_digits, ";
$sql .= "control_action, ";
$sql .= "control_data, ";
$sql .= "control_enabled ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
//$sql .= "'$domain_uuid', ";
$sql .= "'".uuid()."', ";
$sql .= "'$conference_control_uuid', ";
$sql .= "'$control_digits', ";
$sql .= "'$control_action', ";
$sql .= "'$control_data', ";
$sql .= "'$control_enabled' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
$_SESSION["message"] = $text['message-add'];
header('Location: conference_control_edit.php?id='.$conference_control_uuid);
return;
} //if ($action == "add")
if ($action == "update" && permission_exists('conference_control_detail_edit')) {
$sql = "update v_conference_control_details set ";
$sql .= "conference_control_uuid = '$conference_control_uuid', ";
$sql .= "control_digits = '$control_digits', ";
$sql .= "control_action = '$control_action', ";
$sql .= "control_data = '$control_data', ";
$sql .= "control_enabled = '$control_enabled' ";
$sql .= "where conference_control_detail_uuid = '$conference_control_detail_uuid'";
//$sql .= "and domain_uuid = '$domain_uuid' ";
$db->exec(check_sql($sql));
unset($sql);
$_SESSION["message"] = $text['message-update'];
header('Location: conference_control_edit.php?id='.$conference_control_uuid);
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") {
$conference_control_detail_uuid = check_str($_GET["id"]);
$sql = "select * from v_conference_control_details ";
$sql .= "where conference_control_detail_uuid = '$conference_control_detail_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) {
$control_digits = $row["control_digits"];
$control_action = $row["control_action"];
$control_data = $row["control_data"];
$control_enabled = $row["control_enabled"];
}
unset ($prep_statement);
}
//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 "<tr>\n";
echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-conference_control_detail']."</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='conference_control_edit.php?id=$conference_control_uuid'\" value='".$text['button-back']."'>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-control_digits']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='control_digits' maxlength='255' value='$control_digits'>\n";
echo "<br />\n";
echo $text['description-control_digits']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-control_action']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='control_action' maxlength='255' value=\"$control_action\">\n";
echo "<br />\n";
echo $text['description-control_action']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-control_data']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='control_data' maxlength='255' value=\"$control_data\">\n";
echo "<br />\n";
echo $text['description-control_data']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-control_enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='control_enabled'>\n";
echo " <option value=''></option>\n";
if ($control_enabled == "true") {
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
}
else {
echo " <option value='true'>".$text['label-true']."</option>\n";
}
if ($control_enabled == "false") {
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
}
else {
echo " <option value='false'>".$text['label-false']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-control_enabled']."\n";
echo "</td>\n";
echo "</tr>\n";
echo " <tr>\n";
echo " <td colspan='2' align='right'>\n";
echo " <input type='hidden' name='conference_control_uuid' value='$conference_control_uuid'>\n";
if ($action == "update") {
echo " <input type='hidden' name='conference_control_detail_uuid' value='$conference_control_detail_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 "<br /><br />";
//include the footer
require_once "resources/footer.php";
?>

View File

@@ -0,0 +1,159 @@
<?php
//includes
require_once "root.php";
require_once "resources/require.php";
//check permissions
require_once "resources/check_auth.php";
if (permission_exists('conference_control_detail_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//get variables used to control the order
$order_by = check_str($_GET["order_by"]);
$order = check_str($_GET["order"]);
//add the search term
$search = check_str($_GET["search"]);
if (strlen($search) > 0) {
$sql_search = "and (";
$sql_search .= "control_digits like '%".$search."%'";
$sql_search .= "or control_action like '%".$search."%'";
$sql_search .= "or control_data like '%".$search."%'";
$sql_search .= "or control_enabled like '%".$search."%'";
$sql_search .= ")";
}
//additional includes
require_once "resources/header.php";
require_once "resources/paging.php";
//prepare to page the results
$sql = "select count(*) as num_rows from v_conference_control_details ";
$sql .= "where conference_control_uuid = '$conference_control_uuid' ";
//$sql .= "and domain_uuid = '$domain_uuid' ";
$sql .= $sql_search;
if (strlen($order_by) > 0) { $sql .= "order by $order_by $order "; }
$prep_statement = $db->prepare($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';
}
}
//prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = "";
$page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $page;
//get the list
$sql = "select * from v_conference_control_details ";
$sql .= "where conference_control_uuid = '$conference_control_uuid' ";
//$sql .= "and domain_uuid = '$domain_uuid' ";
$sql .= $sql_search;
if (strlen($order_by) > 0) { $sql .= "order by $order_by $order "; }
$sql .= "limit $rows_per_page offset $offset ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset ($prep_statement, $sql);
//alternate the row style
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
//show the content
echo "<table width='100%' border='0'>\n";
echo " <tr>\n";
echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-conference_control_details']."</b></td>\n";
//echo " <form method='get' action=''>\n";
//echo " <td width='50%' 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."'>\n";
//echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>\n";
//echo " </td>\n";
//echo " </form>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo th_order_by('control_digits', $text['label-control_digits'], $order_by, $order);
echo th_order_by('control_action', $text['label-control_action'], $order_by, $order);
echo th_order_by('control_data', $text['label-control_data'], $order_by, $order);
echo th_order_by('control_enabled', $text['label-control_enabled'], $order_by, $order);
echo "<td class='list_control_icons'>";
if (permission_exists('conference_control_detail_add')) {
echo "<a href='conference_control_detail_edit.php?conference_control_uuid=".$_GET['id']."' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
else {
echo "&nbsp;\n";
}
echo "</td>\n";
echo "<tr>\n";
if (is_array($result)) {
foreach($result as $row) {
if (permission_exists('conference_control_detail_edit')) {
$tr_link = "href='conference_control_detail_edit.php?conference_control_uuid=".$row['conference_control_uuid']."&id=".$row['conference_control_detail_uuid']."'";
}
echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_digits']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_action']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_data']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_enabled']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>";
if (permission_exists('conference_control_detail_edit')) {
echo "<a href='conference_control_detail_edit.php?conference_control_uuid=".$row['conference_control_uuid']."&id=".$row['conference_control_detail_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
}
if (permission_exists('conference_control_detail_delete')) {
echo "<a href='conference_control_detail_delete.php?conference_control_uuid=".$row['conference_control_uuid']."&id=".$row['conference_control_detail_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
}
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' align='left'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n";
echo " <td class='list_control_icons'>";
if (permission_exists('conference_control_detail_add')) {
echo "<a href='conference_control_detail_edit.php?conference_control_uuid=".$_GET['id']."' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
else {
echo "&nbsp;";
}
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "<br /><br />";
//include the footer
require_once "resources/footer.php";
?>

View File

@@ -0,0 +1,203 @@
<?php
//includes
require_once "root.php";
require_once "resources/require.php";
//check permissions
require_once "resources/check_auth.php";
if (permission_exists('conference_control_add') || permission_exists('conference_control_edit')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//action add or update
if (isset($_REQUEST["id"])) {
$action = "update";
$conference_control_uuid = check_str($_REQUEST["id"]);
}
else {
$action = "add";
}
//get http post variables and set them to php variables
if (count($_POST)>0) {
$control_name = check_str($_POST["control_name"]);
$control_enabled = check_str($_POST["control_enabled"]);
$control_description = check_str($_POST["control_description"]);
}
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$msg = '';
if ($action == "update") {
$conference_control_uuid = check_str($_POST["conference_control_uuid"]);
}
//check for all required data
if (strlen($control_name) == 0) { $msg .= $text['message-required']." ".$text['label-control_name']."<br>\n"; }
if (strlen($control_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-control_enabled']."<br>\n"; }
//if (strlen($control_description) == 0) { $msg .= $text['message-required']." ".$text['label-control_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('conference_control_add')) {
$sql = "insert into v_conference_controls ";
$sql .= "(";
//$sql .= "domain_uuid, ";
$sql .= "conference_control_uuid, ";
$sql .= "control_name, ";
$sql .= "control_enabled, ";
$sql .= "control_description ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
//$sql .= "'$domain_uuid', ";
$sql .= "'".uuid()."', ";
$sql .= "'$control_name', ";
$sql .= "'$control_enabled', ";
$sql .= "'$control_description' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
$_SESSION["message"] = $text['message-add'];
header("Location: conference_controls.php");
return;
} //if ($action == "add")
if ($action == "update" && permission_exists('conference_control_edit')) {
$sql = "update v_conference_controls set ";
$sql .= "control_name = '$control_name', ";
$sql .= "control_enabled = '$control_enabled', ";
$sql .= "control_description = '$control_description' ";
$sql .= "where conference_control_uuid = '$conference_control_uuid'";
//$sql .= "and domain_uuid = '$domain_uuid' ";
$db->exec(check_sql($sql));
unset($sql);
$_SESSION["message"] = $text['message-update'];
header("Location: conference_controls.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") {
$conference_control_uuid = check_str($_GET["id"]);
$sql = "select * from v_conference_controls ";
$sql .= "where conference_control_uuid = '$conference_control_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) {
$control_name = $row["control_name"];
$control_enabled = $row["control_enabled"];
$control_description = $row["control_description"];
}
unset ($prep_statement);
}
//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 "<tr>\n";
echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-conference_control']."</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='conference_controls.php'\" value='".$text['button-back']."'>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-control_name']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='control_name' maxlength='255' value=\"$control_name\">\n";
echo "<br />\n";
echo $text['description-control_name']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-control_enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='control_enabled'>\n";
echo " <option value=''></option>\n";
if ($control_enabled == "true") {
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
}
else {
echo " <option value='true'>".$text['label-true']."</option>\n";
}
if ($control_enabled == "false") {
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
}
else {
echo " <option value='false'>".$text['label-false']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-control_enabled']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-control_description']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='control_description' maxlength='255' value=\"$control_description\">\n";
echo "<br />\n";
echo $text['description-control_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='conference_control_uuid' value='$conference_control_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 "<br /><br />";
if ($action == "update") {
require "conference_control_details.php";
}
//include the footer
require_once "resources/footer.php";
?>

View File

@@ -0,0 +1,159 @@
<?php
//includes
require_once "root.php";
require_once "resources/require.php";
//check permissions
require_once "resources/check_auth.php";
if (permission_exists('conference_control_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//get variables used to control the order
$order_by = check_str($_GET["order_by"]);
$order = check_str($_GET["order"]);
//add the search term
$search = check_str($_GET["search"]);
if (strlen($search) > 0) {
$sql_search = "where (";
$sql_search .= "control_name like '%".$search."%'";
$sql_search .= "or control_enabled like '%".$search."%'";
$sql_search .= "or control_description like '%".$search."%'";
$sql_search .= ")";
}
//additional includes
require_once "resources/header.php";
require_once "resources/paging.php";
//prepare to page the results
$sql = "select count(*) as num_rows from v_conference_controls ";
//$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= $sql_search;
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
$prep_statement = $db->prepare($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';
}
}
//prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = "";
$page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $page;
//get the list
$sql = "select * from v_conference_controls ";
//$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= $sql_search;
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
$sql .= "limit $rows_per_page offset $offset ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset ($prep_statement, $sql);
//alternate the row style
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
//show the content
echo "<table width='100%' border='0'>\n";
echo " <tr>\n";
echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-conference_controls']."</b></td>\n";
echo " <form method='get' action=''>\n";
echo " <td width='50%' 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."'>\n";
echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>\n";
echo " </td>\n";
echo " </form>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align='left' colspan='2'>\n";
echo " ".$text['title_description-conference_control']."<br /><br />\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo th_order_by('control_name', $text['label-control_name'], $order_by, $order);
echo th_order_by('control_enabled', $text['label-control_enabled'], $order_by, $order);
echo th_order_by('control_description', $text['label-control_description'], $order_by, $order);
echo "<td class='list_control_icons'>";
if (permission_exists('conference_control_add')) {
echo "<a href='conference_control_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
else {
echo "&nbsp;\n";
}
echo "</td>\n";
echo "<tr>\n";
if (is_array($result)) {
foreach($result as $row) {
if (permission_exists('conference_control_edit')) {
$tr_link = "href='conference_control_edit.php?id=".$row['conference_control_uuid']."'";
}
echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_name']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_enabled']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_description']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>";
if (permission_exists('conference_control_edit')) {
echo "<a href='conference_control_edit.php?id=".$row['conference_control_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
}
if (permission_exists('conference_control_delete')) {
echo "<a href='conference_control_delete.php?id=".$row['conference_control_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
}
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='4' align='left'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n";
echo " <td class='list_control_icons'>";
if (permission_exists('conference_control_add')) {
echo "<a href='conference_control_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
else {
echo "&nbsp;";
}
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "<br /><br />";
//include the footer
require_once "resources/footer.php";
?>

View File

@@ -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 <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
// 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"]);
}
?>