From 78b65831ec4057b8ee1362dca0ccebad9be18e69 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 5 Nov 2015 11:19:22 -0700 Subject: [PATCH 1/9] Add new device permissions device_username_password, device_alternate, device_enable. --- app/devices/app_config.php | 14 + app/devices/device_edit.php | 932 ++++++++++++++++++------------------ 2 files changed, 485 insertions(+), 461 deletions(-) diff --git a/app/devices/app_config.php b/app/devices/app_config.php index d8f6591886..3e9a9c836e 100644 --- a/app/devices/app_config.php +++ b/app/devices/app_config.php @@ -105,6 +105,15 @@ $y++; $apps[$x]['permissions'][$y]['name'] = 'device_domain'; $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_username_password'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_alternate'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; $y++; $apps[$x]['permissions'][$y]['name'] = "device_profile_view"; $apps[$x]['permissions'][$y]['groups'][] = "admin"; @@ -127,6 +136,11 @@ $y++; $apps[$x]['permissions'][$y]['name'] = 'device_all'; $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_enable'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; //schema details $y = 0; //table array index diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 3ff97b01d8..949411d2a0 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -590,131 +590,133 @@ require_once "resources/require.php"; echo "\n"; echo "\n"; - echo " "; - echo " ".$text['label-lines'].""; - echo " "; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - if (permission_exists('device_line_password')) { - echo " \n"; - } - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - - $x = 0; - foreach($device_lines as $row) { - //determine whether to hide the element - if (strlen($device_line_uuid) == 0) { - $element['hidden'] = false; - $element['visibility'] = "visibility:visible;"; - } - else { - $element['hidden'] = true; - $element['visibility'] = "visibility:hidden;"; - } - //add the primary key uuid - if (strlen($row['device_line_uuid']) > 0) { - echo " \n"; - } - //show each row in the array - echo " \n"; - echo " \n"; - - echo " \n"; - - echo " \n"; - - echo " \n"; - - echo " \n"; - - echo " \n"; - - if (permission_exists('device_line_password')) { - echo " \n"; - } - - echo " \n"; - - echo " \n"; - - echo " \n"; - - echo " \n"; - - echo " "; + echo " "; + echo " "; - echo " "; - if (permission_exists('device_key_add') || permission_exists('device_key_edit')) { + $x = 0; + foreach($device_lines as $row) { + //determine whether to hide the element + if (strlen($device_line_uuid) == 0) { + $element['hidden'] = false; + $element['visibility'] = "visibility:visible;"; + } + else { + $element['hidden'] = true; + $element['visibility'] = "visibility:hidden;"; + } + //add the primary key uuid + if (strlen($row['device_line_uuid']) > 0) { + echo " \n"; + } + //show each row in the array + echo " \n"; + echo " \n"; + + echo " \n"; + + echo " \n"; + + echo " \n"; + + echo " \n"; + + echo " \n"; + + if (permission_exists('device_line_password')) { + echo " \n"; + } + + echo " \n"; + + echo " \n"; + + echo " \n"; + + echo " \n"; + + echo " \n"; + echo " \n"; + $x++; + } + echo "
".$text['label-line']."".$text['label-server_address']."".$text['label-outbound_proxy']."".$text['label-display_name']."".$text['label-user_id']."".$text['label-auth_id']."".$text['label-password']."".$text['label-sip_port']."".$text['label-sip_transport']."".$text['label-register_expires']."".$text['label-enabled']." 
\n"; - $selected = "selected=\"selected\" "; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - if (strlen($row['device_line_uuid']) > 0) { - if (permission_exists('device_delete')) { - echo " $v_link_label_delete\n"; - } + if (permission_exists('device_line_view') { + echo "
".$text['label-lines'].""; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + if (permission_exists('device_line_password')) { + echo " \n"; } - echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; echo " \n"; - $x++; - } - echo "
".$text['label-line']."".$text['label-server_address']."".$text['label-outbound_proxy']."".$text['label-display_name']."".$text['label-user_id']."".$text['label-auth_id']."".$text['label-password']."".$text['label-sip_port']."".$text['label-sip_transport']."".$text['label-register_expires']."".$text['label-enabled']." 
\n"; - if (strlen($text['description-lines']) > 0) { - echo "
".$text['description-lines']."\n"; - } - echo "
\n"; + $selected = "selected=\"selected\" "; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + if (strlen($row['device_line_uuid']) > 0) { + if (permission_exists('device_delete')) { + echo " $v_link_label_delete\n"; + } + } + echo "
\n"; + if (strlen($text['description-lines']) > 0) { + echo "
".$text['description-lines']."\n"; + } + echo " "; + echo " "; + } + + if (permission_exists('device_profile_edit')) { //device profile $sql = "select * from v_device_profiles "; $sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) "; @@ -764,85 +766,63 @@ require_once "resources/require.php"; echo " \n"; } - $x = 0; - foreach($device_keys as $row) { - //set the column names - if ($previous_device_key_vendor != $row['device_key_vendor']) { + if (permission_exists('device_profile_view')) { + $x = 0; + foreach($device_keys as $row) { + //set the column names + if ($previous_device_key_vendor != $row['device_key_vendor']) { + echo " \n"; + echo " ".$text['label-device_key_category']."\n"; + echo " ".$text['label-device_key_id']."\n"; + if ($vendor_count > 1 && strlen($row['device_key_vendor']) > 0) { + echo " ".ucwords($row['device_key_vendor'])."\n"; + } else { + echo " ".$text['label-device_key_type']."\n"; + } + echo " ".$text['label-device_key_line']."\n"; + echo " ".$text['label-device_key_value']."\n"; + echo " ".$text['label-device_key_extension']."\n"; + echo " ".$text['label-device_key_label']."\n"; + echo "  \n"; + echo " \n"; + } + //determine whether to hide the element + if (strlen($device_key_uuid) == 0) { + $element['hidden'] = false; + $element['visibility'] = "visibility:visible;"; + } + else { + $element['hidden'] = true; + $element['visibility'] = "visibility:hidden;"; + } + //add the primary key uuid + if (strlen($row['device_key_uuid']) > 0) { + echo " \n"; + } + //show all the rows in the array echo " \n"; - echo " ".$text['label-device_key_category']."\n"; - echo " ".$text['label-device_key_id']."\n"; - if ($vendor_count > 1 && strlen($row['device_key_vendor']) > 0) { - echo " ".ucwords($row['device_key_vendor'])."\n"; - } else { - echo " ".$text['label-device_key_type']."\n"; - } - echo " ".$text['label-device_key_line']."\n"; - echo " ".$text['label-device_key_value']."\n"; - echo " ".$text['label-device_key_extension']."\n"; - echo " ".$text['label-device_key_label']."\n"; - echo "  \n"; - echo " \n"; - } - //determine whether to hide the element - if (strlen($device_key_uuid) == 0) { - $element['hidden'] = false; - $element['visibility'] = "visibility:visible;"; - } - else { - $element['hidden'] = true; - $element['visibility'] = "visibility:hidden;"; - } - //add the primary key uuid - if (strlen($row['device_key_uuid']) > 0) { - echo " \n"; - } - //show all the rows in the array - echo " \n"; - echo "\n"; - echo " \n"; + echo " \n"; + if ($row['device_key_category'] == "line") { + echo " \n"; } else { - echo " \n"; + echo " \n"; } - } - else { - if (strtolower($device_vendor) == "cisco") { - if ($row['device_key_category'] == "expansion-1" || $row['device_key_category'] == "expansion") { - echo " \n"; - } - else { - echo " \n"; - } - if ($row['device_key_category'] == "expansion-2") { - echo " \n"; - } - else { - echo " \n"; - } + if ($row['device_key_category'] == "memory") { + echo " \n"; } else { + echo " \n"; + } + if ($row['device_key_category'] == "programmable") { + echo " \n"; + } + else { + echo " \n"; + } + if (strlen($device_vendor) == 0) { if ($row['device_key_category'] == "expansion") { echo " \n"; } @@ -850,222 +830,246 @@ require_once "resources/require.php"; echo " \n"; } } + else { + if (strtolower($device_vendor) == "cisco") { + if ($row['device_key_category'] == "expansion-1" || $row['device_key_category'] == "expansion") { + echo " \n"; + } + else { + echo " \n"; + } + if ($row['device_key_category'] == "expansion-2") { + echo " \n"; + } + else { + echo " \n"; + } + } + else { + if ($row['device_key_category'] == "expansion") { + echo " \n"; + } + else { + echo " \n"; + } + } - } - echo " \n"; - echo "\n"; - - echo "\n"; - $selected = "selected='selected'"; - echo " \n"; - echo "\n"; - - echo "\n"; - //echo " \n"; - if (strlen($row['device_key_vendor']) > 0) { - $device_key_vendor = $row['device_key_vendor']; - } - else { - $device_key_vendor = $device_vendor; - } - ?> - - - - - - \n"; - echo "\n"; - echo " \n"; - echo "\n"; - - echo "\n"; - echo " \n"; - echo "\n"; - - echo "\n"; - echo " \n"; - echo "\n"; - - echo "\n"; - echo " \n"; - echo "\n"; - - //echo " \n"; - //echo " \n"; - //echo " \n"; - echo " \n"; - if (strlen($row['device_key_uuid']) > 0) { - if (permission_exists('device_key_delete')) { - echo " $v_link_label_delete\n"; } - } - echo " \n"; - echo " \n"; - //set the previous vendor - $previous_device_key_vendor = $row['device_key_vendor']; - //increment the array key - $x++; + echo " \n"; + echo "\n"; + + echo "\n"; + $selected = "selected='selected'"; + echo " \n"; + echo "\n"; + + echo "\n"; + //echo " \n"; + if (strlen($row['device_key_vendor']) > 0) { + $device_key_vendor = $row['device_key_vendor']; + } + else { + $device_key_vendor = $device_vendor; + } + ?> + + + + + + \n"; + echo "\n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + if (strlen($row['device_key_uuid']) > 0) { + if (permission_exists('device_key_delete')) { + echo " $v_link_label_delete\n"; + } + } + echo " \n"; + echo " \n"; + //set the previous vendor + $previous_device_key_vendor = $row['device_key_vendor']; + //increment the array key + $x++; + } + echo " \n"; + if (strlen($text['description-keys']) > 0) { + echo "
".$text['description-keys']."\n"; + } + echo " "; + echo " "; } - echo " \n"; - if (strlen($text['description-keys']) > 0) { - echo "
".$text['description-keys']."\n"; - } - echo " "; - echo " "; } //device settings - if (permission_exists('device_setting_add')) { + if (permission_exists('device_setting_edit')) { echo " "; echo " ".$text['label-settings'].""; echo " "; @@ -1153,42 +1157,46 @@ require_once "resources/require.php"; echo " \n"; } - echo "\n"; - echo "\n"; - echo " ".$text['label-device']."\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo $text['description-device']."\n"; - echo "\n"; - echo "\n"; + if (permission_exists('device_username_password')) { + echo "\n"; + echo "\n"; + echo " ".$text['label-device']."\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo $text['description-device']."\n"; + echo "\n"; + echo "\n"; + } - echo "\n"; - echo "\n"; - echo " ".$text['label-device_uuid_alternate']."\n"; - echo "\n"; - echo "\n"; - if (strlen($device_uuid_alternate) == 0) { - echo " "; + if (permission_exists('device_alternate')) { + echo "\n"; + echo "\n"; + echo " ".$text['label-device_uuid_alternate']."\n"; + echo "\n"; + echo "\n"; + if (strlen($device_uuid_alternate) == 0) { + echo " "; + } + else { + $label = $device_alternate[0]['device_label']; + if (strlen($label) == 0) { $label = $device_alternate[0]['device_description']; } + if (strlen($label) == 0) { $label = $device_alternate[0]['device_mac_address']; } + echo " \n"; + echo " \n"; + echo " "; + echo " \n"; + echo " \n"; + echo "
$label $v_link_label_delete
\n"; + unset($label); + } + echo $text['description-device_uuid_alternate']."\n"; + echo "\n"; + echo "\n"; } - else { - $label = $device_alternate[0]['device_label']; - if (strlen($label) == 0) { $label = $device_alternate[0]['device_description']; } - if (strlen($label) == 0) { $label = $device_alternate[0]['device_mac_address']; } - echo " \n"; - echo " \n"; - echo " "; - echo " \n"; - echo " \n"; - echo "
$label $v_link_label_delete
\n"; - unset($label); - } - echo $text['description-device_uuid_alternate']."\n"; - echo "\n"; - echo "\n"; echo "\n"; echo "\n"; @@ -1253,29 +1261,31 @@ require_once "resources/require.php"; echo " \n"; } - echo "\n"; - echo "\n"; - echo " ".$text['label-device_provision_enable']."\n"; - echo "\n"; - echo "\n"; - echo " \n"; + if ($device_provision_enable == "true" || strlen($device_provision_enable) == 0) { + echo " \n"; + } + else { + echo " \n"; + } + if ($device_provision_enable == "false") { + echo " \n"; + } + else { + echo " \n"; + } + echo " \n"; + echo "
\n"; + echo $text['description-device_provision_enable']."\n"; + echo "\n"; + echo "\n"; } - else { - echo " \n"; - } - if ($device_provision_enable == "false") { - echo " \n"; - } - else { - echo " \n"; - } - echo " \n"; - echo "
\n"; - echo $text['description-device_provision_enable']."\n"; - echo "\n"; - echo "\n"; echo "\n"; echo "\n"; From 5f7fd707c2ec4858792ce0c9252e8988e8d9703d Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 5 Nov 2015 11:24:28 -0700 Subject: [PATCH 2/9] Fix the syntax by adding a missing ). --- app/devices/device_edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 949411d2a0..b69081b6b1 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -590,7 +590,7 @@ require_once "resources/require.php"; echo "\n"; echo "\n"; - if (permission_exists('device_line_view') { + if (permission_exists('device_line_view')) { echo " "; echo " ".$text['label-lines'].""; echo " "; From ef5a1eb4553eb5ffba832cbe29c3824cd0a6642a Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 5 Nov 2015 11:56:50 -0700 Subject: [PATCH 3/9] Add new device permissions for mac address, template, label, vendor, model, firmware, and description. --- app/devices/app_config.php | 26 ++++++ app/devices/device_edit.php | 160 +++++++++++++++++++++--------------- 2 files changed, 118 insertions(+), 68 deletions(-) diff --git a/app/devices/app_config.php b/app/devices/app_config.php index 3e9a9c836e..6f3f3cfaac 100644 --- a/app/devices/app_config.php +++ b/app/devices/app_config.php @@ -39,6 +39,18 @@ $apps[$x]['permissions'][$y]['groups'][] = "admin"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_mac_address'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_label'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_template'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; $apps[$x]['permissions'][$y]['name'] = "device_extension_view"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $apps[$x]['permissions'][$y]['groups'][] = "admin"; @@ -137,10 +149,24 @@ $apps[$x]['permissions'][$y]['name'] = 'device_all'; $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_vendor'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_model'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_firmware'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $y++; $apps[$x]['permissions'][$y]['name'] = 'device_enable'; $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; $apps[$x]['permissions'][$y]['groups'][] = 'admin'; $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_description'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $apps[$x]['permissions'][$y]['groups'][] = 'admin'; + $y++; //schema details $y = 0; //table array index diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index b69081b6b1..5d32adfa04 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -526,69 +526,82 @@ require_once "resources/require.php"; echo " ".$text['label-device_mac_address']."\n"; echo "\n"; echo "\n"; - echo " \n"; + if (permission_exists('device_mac_address')) { + echo " \n"; + } + else { + echo $device_mac_address; + } echo " \n"; echo "
\n"; echo $text['description-device_mac_address']."\n"; echo "\n"; echo "\n"; + echo "\n"; echo "\n"; echo " ".$text['label-device_label']."\n"; echo "\n"; echo "\n"; - echo " \n"; + if (permission_exists('device_label')) { + echo " \n"; + } + else { + echo $device_label; + } echo "
\n"; echo $text['description-device_label']."\n"; echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; - echo " ".$text['label-device_template']."\n"; - echo "\n"; - echo "\n"; - $device = new device; - $template_dir = $device->get_template_dir(); + if (permission_exists('device_template')) { + echo "\n"; + echo "\n"; + echo " ".$text['label-device_template']."\n"; + echo "\n"; + echo "\n"; + $device = new device; + $template_dir = $device->get_template_dir(); - echo "\n"; + echo "\n"; - if (is_dir($template_dir)) { - $templates = scandir($template_dir); - foreach($templates as $dir) { - if($file != "." && $dir != ".." && $dir[0] != '.') { - if(is_dir($template_dir . "/" . $dir)) { - echo ""; - $dh_sub=$template_dir . "/" . $dir; - if(is_dir($dh_sub)) { - $templates_sub = scandir($dh_sub); - foreach($templates_sub as $dir_sub) { - if($file_sub != '.' && $dir_sub != '..' && $dir_sub[0] != '.') { - if(is_dir($template_dir . '/' . $dir .'/'. $dir_sub)) { - if ($device_template == $dir."/".$dir_sub) { - echo "\n"; - } - else { - echo "\n"; + if (is_dir($template_dir)) { + $templates = scandir($template_dir); + foreach($templates as $dir) { + if($file != "." && $dir != ".." && $dir[0] != '.') { + if(is_dir($template_dir . "/" . $dir)) { + echo ""; + $dh_sub=$template_dir . "/" . $dir; + if(is_dir($dh_sub)) { + $templates_sub = scandir($dh_sub); + foreach($templates_sub as $dir_sub) { + if($file_sub != '.' && $dir_sub != '..' && $dir_sub[0] != '.') { + if(is_dir($template_dir . '/' . $dir .'/'. $dir_sub)) { + if ($device_template == $dir."/".$dir_sub) { + echo "\n"; + } + else { + echo "\n"; + } } } } + closedir($dh_sub); } - closedir($dh_sub); + echo ""; } - echo ""; } } + closedir($dh); } - closedir($dh); - } - echo "\n"; - echo "
\n"; - echo $text['description-device_template']."\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "
\n"; + echo $text['description-device_template']."\n"; + echo "\n"; + echo "\n"; + } if (permission_exists('device_line_view')) { echo " "; @@ -1198,38 +1211,44 @@ require_once "resources/require.php"; echo "\n"; } - echo "\n"; - echo "\n"; - echo " ".$text['label-device_vendor']."\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-device_vendor']."\n"; - echo "\n"; - echo "\n"; + if (permission_exists('device_vendor')) { + echo "\n"; + echo "\n"; + echo " ".$text['label-device_vendor']."\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-device_vendor']."\n"; + echo "\n"; + echo "\n"; + } - echo "\n"; - echo "\n"; - echo " ".$text['label-device_model']."\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-device_model']."\n"; - echo "\n"; - echo "\n"; + if (permission_exists('device_model')) { + echo "\n"; + echo "\n"; + echo " ".$text['label-device_model']."\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-device_model']."\n"; + echo "\n"; + echo "\n"; + } - echo "\n"; - echo "\n"; - echo " ".$text['label-device_firmware_version']."\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-device_firmware_version']."\n"; - echo "\n"; - echo "\n"; + if (permission_exists('device_firmware')) { + echo "\n"; + echo "\n"; + echo " ".$text['label-device_firmware_version']."\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-device_firmware_version']."\n"; + echo "\n"; + echo "\n"; + } if (permission_exists('device_domain')) { echo "\n"; @@ -1292,7 +1311,12 @@ require_once "resources/require.php"; echo " ".$text['label-device_description']."\n"; echo "\n"; echo "\n"; - echo " \n"; + if (permission_exists('device_description')) { + echo " \n"; + } + else { + echo $device_description."\n"; + } echo "
\n"; echo $text['description-device_description']."\n"; echo "\n"; From 2750163d6dcdfcd8f3a8e34a8cd6572b1efb519e Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 5 Nov 2015 12:05:49 -0700 Subject: [PATCH 4/9] Move the description inside the permission condition and adjust 2 of the permissions. --- app/devices/device_edit.php | 570 ++++++++++++++++++------------------ 1 file changed, 286 insertions(+), 284 deletions(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 5d32adfa04..f26e2ff17f 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -528,13 +528,13 @@ require_once "resources/require.php"; echo "\n"; if (permission_exists('device_mac_address')) { echo " \n"; + echo "
\n"; + echo $text['description-device_mac_address']."\n"; } else { echo $device_mac_address; } echo " \n"; - echo "
\n"; - echo $text['description-device_mac_address']."\n"; echo "\n"; echo "\n"; @@ -546,12 +546,13 @@ require_once "resources/require.php"; echo "\n"; if (permission_exists('device_label')) { echo " \n"; + echo "
\n"; + echo $text['description-device_label']."\n"; } else { echo $device_label; } - echo "
\n"; - echo $text['description-device_label']."\n"; + echo "\n"; echo "\n"; @@ -753,7 +754,9 @@ require_once "resources/require.php"; echo " "; echo " "; } + } + if (permission_exists('device_key_edit')) { $vendor_count = 0; foreach($device_keys as $row) { if ($previous_vendor != $row['device_key_vendor']) { @@ -779,63 +782,85 @@ require_once "resources/require.php"; echo " \n"; } - if (permission_exists('device_profile_view')) { - $x = 0; - foreach($device_keys as $row) { - //set the column names - if ($previous_device_key_vendor != $row['device_key_vendor']) { - echo " \n"; - echo " ".$text['label-device_key_category']."\n"; - echo " ".$text['label-device_key_id']."\n"; - if ($vendor_count > 1 && strlen($row['device_key_vendor']) > 0) { - echo " ".ucwords($row['device_key_vendor'])."\n"; - } else { - echo " ".$text['label-device_key_type']."\n"; - } - echo " ".$text['label-device_key_line']."\n"; - echo " ".$text['label-device_key_value']."\n"; - echo " ".$text['label-device_key_extension']."\n"; - echo " ".$text['label-device_key_label']."\n"; - echo "  \n"; - echo " \n"; - } - //determine whether to hide the element - if (strlen($device_key_uuid) == 0) { - $element['hidden'] = false; - $element['visibility'] = "visibility:visible;"; - } - else { - $element['hidden'] = true; - $element['visibility'] = "visibility:hidden;"; - } - //add the primary key uuid - if (strlen($row['device_key_uuid']) > 0) { - echo " \n"; - } - //show all the rows in the array + $x = 0; + foreach($device_keys as $row) { + //set the column names + if ($previous_device_key_vendor != $row['device_key_vendor']) { echo " \n"; - echo "\n"; - echo " \n"; + } + //show all the rows in the array + echo " \n"; + echo "\n"; + echo " \n"; - echo "\n"; + } + echo " \n"; + echo "\n"; - echo "\n"; - $selected = "selected='selected'"; - echo " \n"; - echo "\n"; + echo "\n"; + $selected = "selected='selected'"; + echo " \n"; + echo "\n"; - echo "\n"; - //echo " \n"; - if (strlen($row['device_key_vendor']) > 0) { - $device_key_vendor = $row['device_key_vendor']; - } - else { - $device_key_vendor = $device_vendor; - } + echo "\n"; + //echo " \n"; + if (strlen($row['device_key_vendor']) > 0) { + $device_key_vendor = $row['device_key_vendor']; + } + else { + $device_key_vendor = $device_vendor; + } + ?> + + + + - - - + + + \n"; - echo "\n"; - echo " + + \n"; + echo "\n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + if (strlen($row['device_key_uuid']) > 0) { + if (permission_exists('device_key_delete')) { + echo " $v_link_label_delete\n"; } - echo " \n"; - echo "\n"; - - echo "\n"; - echo " \n"; - echo "\n"; - - echo "\n"; - echo " \n"; - echo "\n"; - - echo "\n"; - echo " \n"; - echo "\n"; - - //echo " \n"; - //echo " \n"; - //echo " \n"; - echo " \n"; - if (strlen($row['device_key_uuid']) > 0) { - if (permission_exists('device_key_delete')) { - echo " $v_link_label_delete\n"; - } - } - echo " \n"; - echo " \n"; - //set the previous vendor - $previous_device_key_vendor = $row['device_key_vendor']; - //increment the array key - $x++; - } - echo " \n"; - if (strlen($text['description-keys']) > 0) { - echo "
".$text['description-keys']."\n"; - } - echo " "; - echo " "; + } + echo " \n"; + echo " \n"; + //set the previous vendor + $previous_device_key_vendor = $row['device_key_vendor']; + //increment the array key + $x++; } + echo " \n"; + if (strlen($text['description-keys']) > 0) { + echo "
".$text['description-keys']."\n"; + } + echo " "; + echo " "; } //device settings @@ -1313,12 +1314,13 @@ require_once "resources/require.php"; echo "\n"; if (permission_exists('device_description')) { echo " \n"; + echo "
\n"; + echo $text['description-device_description']."\n"; } else { echo $device_description."\n"; } - echo "
\n"; - echo $text['description-device_description']."\n"; + echo "\n"; echo "\n"; echo " \n"; From d39d58e6f6c7027c3450392d9bc78d0f0a80b172 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 5 Nov 2015 12:11:53 -0700 Subject: [PATCH 5/9] Show device copy when user has device_add permission. --- app/devices/device_edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index f26e2ff17f..12b4bfc0b2 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -514,7 +514,7 @@ require_once "resources/require.php"; echo "\n"; echo "\n"; echo " \n"; - if ($action != "add") { + if (permission_exists('device_add') && $action != "add") { echo " \n"; } echo " \n"; From cca5c118df17b9a1ef57bf08fdd503ce32908767 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 5 Nov 2015 12:25:30 -0700 Subject: [PATCH 6/9] Secure the device mac address when the user doesn't have permission to change it. --- app/devices/device_edit.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 12b4bfc0b2..af2231ef23 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -128,10 +128,25 @@ require_once "resources/require.php"; //get http post variables and set them to php variables if (count($_POST) > 0) { + //device mac address + if (permission_exists('device_mac_address')) { + $device_mac_address = check_str($_POST["device_mac_address"]); + $device_mac_address = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address)); + $_POST["device_mac_address"] = $device_mac_address; + } + else { + $orm = new orm; + $orm->name('devices'); + $orm->uuid($device_uuid); + $result = $orm->find()->get(); + //$message = $orm->message; + foreach ($result as &$row) { + $device_mac_address = $row["device_mac_address"]; + $_POST["device_mac_address"] = $device_mac_address; + } + unset ($prep_statement); + } //devices - $device_mac_address = check_str($_POST["device_mac_address"]); - $device_mac_address = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address)); - $_POST["device_mac_address"] = $device_mac_address; $device_label = check_str($_POST["device_label"]); $device_vendor = check_str($_POST["device_vendor"]); $device_uuid_alternate = check_str($_POST["device_uuid_alternate"]); From 7cda301460c5e6c85a678c704a070df9a2f641f1 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sun, 8 Nov 2015 07:30:29 -0700 Subject: [PATCH 7/9] Add the following to all yealink provisioning templates. account.1.nat.udp_update_enable = 3 In order to setup keep alive with sip notify. --- resources/templates/provision/yealink/t22p/{$mac}.cfg | 4 ++-- resources/templates/provision/yealink/t23g/{$mac}.cfg | 2 +- resources/templates/provision/yealink/t23p/{$mac}.cfg | 2 +- resources/templates/provision/yealink/t26p/{$mac}.cfg | 4 ++-- resources/templates/provision/yealink/t27p/{$mac}.cfg | 2 +- resources/templates/provision/yealink/t28p/{$mac}.cfg | 4 ++-- resources/templates/provision/yealink/t29g/{$mac}.cfg | 2 +- resources/templates/provision/yealink/t32g/{$mac}.cfg | 4 ++-- resources/templates/provision/yealink/t38g/{$mac}.cfg | 4 ++-- resources/templates/provision/yealink/t41p/{$mac}.cfg | 2 +- resources/templates/provision/yealink/t42g/{$mac}.cfg | 2 +- resources/templates/provision/yealink/vp530/{$mac}.cfg | 4 ++-- resources/templates/provision/yealink/w52p/{$mac}.cfg | 4 ++-- 13 files changed, 20 insertions(+), 20 deletions(-) diff --git a/resources/templates/provision/yealink/t22p/{$mac}.cfg b/resources/templates/provision/yealink/t22p/{$mac}.cfg index 7fef6e9bfc..ce904e36e6 100644 --- a/resources/templates/provision/yealink/t22p/{$mac}.cfg +++ b/resources/templates/provision/yealink/t22p/{$mac}.cfg @@ -223,8 +223,8 @@ account.1.nat.stun_server = #Configure the STUN server port, the default value is 3478. account.1.nat.stun_port = -#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default); -account.1.nat.udp_update_enable = +#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = diff --git a/resources/templates/provision/yealink/t23g/{$mac}.cfg b/resources/templates/provision/yealink/t23g/{$mac}.cfg index e09d088c44..8641aa3259 100644 --- a/resources/templates/provision/yealink/t23g/{$mac}.cfg +++ b/resources/templates/provision/yealink/t23g/{$mac}.cfg @@ -126,7 +126,7 @@ account.1.nat.stun_server = account.1.nat.stun_port = 3478 #Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; -account.1.nat.udp_update_enable = 1 +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = 30 diff --git a/resources/templates/provision/yealink/t23p/{$mac}.cfg b/resources/templates/provision/yealink/t23p/{$mac}.cfg index e09d088c44..8641aa3259 100644 --- a/resources/templates/provision/yealink/t23p/{$mac}.cfg +++ b/resources/templates/provision/yealink/t23p/{$mac}.cfg @@ -126,7 +126,7 @@ account.1.nat.stun_server = account.1.nat.stun_port = 3478 #Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; -account.1.nat.udp_update_enable = 1 +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = 30 diff --git a/resources/templates/provision/yealink/t26p/{$mac}.cfg b/resources/templates/provision/yealink/t26p/{$mac}.cfg index ecc4c4997b..2761774eaa 100644 --- a/resources/templates/provision/yealink/t26p/{$mac}.cfg +++ b/resources/templates/provision/yealink/t26p/{$mac}.cfg @@ -223,8 +223,8 @@ account.1.nat.stun_server = #Configure the STUN server port, the default value is 3478. account.1.nat.stun_port = -#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default); -account.1.nat.udp_update_enable = +#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = diff --git a/resources/templates/provision/yealink/t27p/{$mac}.cfg b/resources/templates/provision/yealink/t27p/{$mac}.cfg index e09d088c44..8641aa3259 100644 --- a/resources/templates/provision/yealink/t27p/{$mac}.cfg +++ b/resources/templates/provision/yealink/t27p/{$mac}.cfg @@ -126,7 +126,7 @@ account.1.nat.stun_server = account.1.nat.stun_port = 3478 #Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; -account.1.nat.udp_update_enable = 1 +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = 30 diff --git a/resources/templates/provision/yealink/t28p/{$mac}.cfg b/resources/templates/provision/yealink/t28p/{$mac}.cfg index ecc4c4997b..2761774eaa 100644 --- a/resources/templates/provision/yealink/t28p/{$mac}.cfg +++ b/resources/templates/provision/yealink/t28p/{$mac}.cfg @@ -223,8 +223,8 @@ account.1.nat.stun_server = #Configure the STUN server port, the default value is 3478. account.1.nat.stun_port = -#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default); -account.1.nat.udp_update_enable = +#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = diff --git a/resources/templates/provision/yealink/t29g/{$mac}.cfg b/resources/templates/provision/yealink/t29g/{$mac}.cfg index e09d088c44..8641aa3259 100644 --- a/resources/templates/provision/yealink/t29g/{$mac}.cfg +++ b/resources/templates/provision/yealink/t29g/{$mac}.cfg @@ -126,7 +126,7 @@ account.1.nat.stun_server = account.1.nat.stun_port = 3478 #Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; -account.1.nat.udp_update_enable = 1 +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = 30 diff --git a/resources/templates/provision/yealink/t32g/{$mac}.cfg b/resources/templates/provision/yealink/t32g/{$mac}.cfg index b7de551e22..a7f7534e5e 100644 --- a/resources/templates/provision/yealink/t32g/{$mac}.cfg +++ b/resources/templates/provision/yealink/t32g/{$mac}.cfg @@ -223,8 +223,8 @@ account.1.nat.stun_server = #Configure the STUN server port, the default value is 3478. account.1.nat.stun_port = -#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default); -account.1.nat.udp_update_enable = +#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = diff --git a/resources/templates/provision/yealink/t38g/{$mac}.cfg b/resources/templates/provision/yealink/t38g/{$mac}.cfg index e2f464c29b..cffa4df9dc 100644 --- a/resources/templates/provision/yealink/t38g/{$mac}.cfg +++ b/resources/templates/provision/yealink/t38g/{$mac}.cfg @@ -223,8 +223,8 @@ account.1.nat.stun_server = #Configure the STUN server port, the default value is 3478. account.1.nat.stun_port = -#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default); -account.1.nat.udp_update_enable = +#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = diff --git a/resources/templates/provision/yealink/t41p/{$mac}.cfg b/resources/templates/provision/yealink/t41p/{$mac}.cfg index e09d088c44..8641aa3259 100644 --- a/resources/templates/provision/yealink/t41p/{$mac}.cfg +++ b/resources/templates/provision/yealink/t41p/{$mac}.cfg @@ -126,7 +126,7 @@ account.1.nat.stun_server = account.1.nat.stun_port = 3478 #Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; -account.1.nat.udp_update_enable = 1 +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = 30 diff --git a/resources/templates/provision/yealink/t42g/{$mac}.cfg b/resources/templates/provision/yealink/t42g/{$mac}.cfg index 94d6cc28a1..70c98e9022 100644 --- a/resources/templates/provision/yealink/t42g/{$mac}.cfg +++ b/resources/templates/provision/yealink/t42g/{$mac}.cfg @@ -126,7 +126,7 @@ account.1.nat.stun_server = account.1.nat.stun_port = 3478 #Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; -account.1.nat.udp_update_enable = 1 +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = 30 diff --git a/resources/templates/provision/yealink/vp530/{$mac}.cfg b/resources/templates/provision/yealink/vp530/{$mac}.cfg index a380a3f81d..b35405d03e 100644 --- a/resources/templates/provision/yealink/vp530/{$mac}.cfg +++ b/resources/templates/provision/yealink/vp530/{$mac}.cfg @@ -253,8 +253,8 @@ account.1.nat.stun_server = #Configure the STUN server port, the default value is 3478. account.1.nat.stun_port = -#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default); -account.1.nat.udp_update_enable = +#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = diff --git a/resources/templates/provision/yealink/w52p/{$mac}.cfg b/resources/templates/provision/yealink/w52p/{$mac}.cfg index a6bc0d586a..2509a41fbf 100644 --- a/resources/templates/provision/yealink/w52p/{$mac}.cfg +++ b/resources/templates/provision/yealink/w52p/{$mac}.cfg @@ -147,8 +147,8 @@ account.1.nat.stun_server = #Configure the STUN server port, the default value is 3478. account.1.nat.stun_port = -#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default); -account.1.nat.udp_update_enable = +#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify; +account.1.nat.udp_update_enable = 3 #Specify the keep-alive interval (in seconds), the default value is 30. account.1.nat.udp_update_time = From 4ef7b049b0a3e162cae714cc7d2bbd1a9aa6a5ab Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sun, 8 Nov 2015 07:44:45 -0700 Subject: [PATCH 8/9] Change base_dir to script_dir in --- resources/templates/conf/autoload_configs/lua.conf.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/templates/conf/autoload_configs/lua.conf.xml b/resources/templates/conf/autoload_configs/lua.conf.xml index 0758bb6762..a5d861e812 100644 --- a/resources/templates/conf/autoload_configs/lua.conf.xml +++ b/resources/templates/conf/autoload_configs/lua.conf.xml @@ -13,7 +13,7 @@ These entries will be pre-pended to the LUA_PATH environment variable --> - + From a01a61e02cd6634e2a0567dd5539a6fbba5f7f17 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sun, 8 Nov 2015 13:40:08 -0700 Subject: [PATCH 9/9] Remove /scripts from the path as it is redundant. --- resources/templates/conf/autoload_configs/lua.conf.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/templates/conf/autoload_configs/lua.conf.xml b/resources/templates/conf/autoload_configs/lua.conf.xml index a5d861e812..534505dc3b 100644 --- a/resources/templates/conf/autoload_configs/lua.conf.xml +++ b/resources/templates/conf/autoload_configs/lua.conf.xml @@ -13,7 +13,7 @@ These entries will be pre-pended to the LUA_PATH environment variable --> - +