From 6926452b753c65073da54a9d7e8897530a01bd0e Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Sat, 6 Aug 2016 16:28:48 -0600 Subject: [PATCH] Update device_vendor_functions.php Show the group permissions on device_vendor_functions.php. --- app/devices/device_vendor_functions.php | 79 ++++++++++++++++++------- 1 file changed, 56 insertions(+), 23 deletions(-) diff --git a/app/devices/device_vendor_functions.php b/app/devices/device_vendor_functions.php index 33edce4ee1..a3d84c7946 100644 --- a/app/devices/device_vendor_functions.php +++ b/app/devices/device_vendor_functions.php @@ -71,7 +71,7 @@ $sql .= "limit $rows_per_page offset $offset "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $vendor_functions = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset ($prep_statement, $sql); //alternate the row style @@ -96,6 +96,7 @@ echo "\n"; echo th_order_by('name', $text['label-name'], $order_by, $order); echo th_order_by('value', $text['label-value'], $order_by, $order); + echo "".$text['label-groups']."\n"; echo th_order_by('enabled', $text['label-enabled'], $order_by, $order); echo th_order_by('description', $text['label-description'], $order_by, $order); echo ""; @@ -108,27 +109,59 @@ echo "\n"; echo "\n"; - if (is_array($result)) { - foreach($result as $row) { - if (permission_exists('device_vendor_function_edit')) { - $tr_link = "href='device_vendor_function_edit.php?device_vendor_uuid=".$row['device_vendor_uuid']."&id=".$row['device_vendor_function_uuid']."'"; - } - echo "\n"; - //echo " ".$row['label']." \n"; - echo " ".$row['name']." \n"; - echo " ".$row['value']." \n"; - echo " ".$row['enabled']." \n"; - echo " ".$row['description']." \n"; - echo " "; - if (permission_exists('device_vendor_function_edit')) { - echo "$v_link_label_edit"; - } - if (permission_exists('device_vendor_function_delete')) { - echo "$v_link_label_delete"; - } - echo " \n"; - echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } + if (is_array($vendor_functions)) { + foreach($vendor_functions as $row) { + + //get the groups that have been assigned to the vendor functions + $sql = "select "; + $sql .= " fg.*, g.domain_uuid as group_domain_uuid "; + $sql .= "from "; + $sql .= " v_device_vendor_function_groups as fg, "; + $sql .= " v_groups as g "; + $sql .= "where "; + $sql .= " fg.group_uuid = g.group_uuid "; + //$sql .= " and fg.device_vendor_uuid = :device_vendor_uuid "; + $sql .= " and fg.device_vendor_uuid = '$device_vendor_uuid' "; + //$sql .= " and fg.device_vendor_function_uuid = :device_vendor_function_uuid "; + $sql .= " and fg.device_vendor_function_uuid = '".$row['device_vendor_function_uuid']."' "; + $sql .= "order by "; + $sql .= " g.domain_uuid desc, "; + $sql .= " g.group_name asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->bindParam(':device_vendor_uuid', $device_vendor_uuid); + $prep_statement->bindParam(':device_vendor_function_uuid', $row['device_vendor_function_uuid']); + $prep_statement->execute(); + $vendor_function_groups = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset($sql, $prep_statement); + unset($group_list); + foreach ($vendor_function_groups as &$sub_row) { + $group_list[] = $sub_row["group_name"].(($sub_row['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$sub_row['group_domain_uuid']]['domain_name'] : null); + } + $group_list = isset($group_list) ? implode(', ', $group_list) : ''; + unset ($vendor_function_groups); + //build the edit link + if (permission_exists('device_vendor_function_edit')) { + $tr_link = "href='device_vendor_function_edit.php?device_vendor_uuid=".$row['device_vendor_uuid']."&id=".$row['device_vendor_function_uuid']."'"; + } + //show the row of data + echo "\n"; + //echo " ".$row['label']." \n"; + echo " ".$row['name']." \n"; + echo " ".$row['value']." \n"; + echo " ".$group_list." \n"; + echo " ".$row['enabled']." \n"; + echo " ".$row['description']." \n"; + echo " "; + if (permission_exists('device_vendor_function_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('device_vendor_function_delete')) { + echo "$v_link_label_delete"; + } + echo " \n"; + echo "\n"; + //toggle the value of the c variable + if ($c==0) { $c=1; } else { $c=0; } } //end foreach unset($sql, $result, $row_count); } //end if results @@ -157,4 +190,4 @@ //include the footer require_once "resources/footer.php"; -?> \ No newline at end of file +?>