Contacts: Fixed/implemented permissions, added Relations.

This commit is contained in:
Nate Jones
2015-03-27 04:35:21 +00:00
parent 726cca7d99
commit 26e7d2c718
26 changed files with 881 additions and 336 deletions
+23 -46
View File
@@ -27,50 +27,22 @@
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
//get variables used to control the order
$order_by = check_str($_GET["order_by"]);
$order = check_str($_GET["order"]);
//prepare to page the results
// $sql = "select count(*) as num_rows from v_contact_settings ";
// $sql .= "where contact_uuid = '$contact_uuid' ";
// 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 = 2;
// $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;
if (permission_exists('contact_setting_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//get the list
$sql = "select * from v_contact_settings ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and contact_uuid = '$contact_uuid' ";
if (strlen($order_by) == 0) {
$sql .= "order by ";
$sql .= "contact_setting_category asc ";
$sql .= ", contact_setting_subcategory asc ";
$sql .= ", contact_setting_order asc ";
}
else {
$sql .= "order by ".$order_by." ".$order." ";
}
// $sql .= "limit ".$rows_per_page." offset ".$offset." ";
$sql .= "order by ";
$sql .= "contact_setting_category asc ";
$sql .= ", contact_setting_subcategory asc ";
$sql .= ", contact_setting_order asc ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
@@ -103,19 +75,22 @@ require_once "resources/paging.php";
echo "<th style='text-align: center;'>".$text['label-enabled']."</th>";
echo "<th>".$text['label-description']."</th>";
echo "<td class='list_control_icons'>";
echo "<a href='contact_setting_edit.php?contact_uuid=".$contact_uuid."' alt='".$text['button-add']."'>$v_link_label_add</a>";
if (permission_exists('contact_setting_add')) {
echo "<a href='contact_setting_edit.php?contact_uuid=".$contact_uuid."' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
echo "</td>\n";
echo "</tr>\n";
if ($result_count > 0) {
$previous_category = '';
foreach($result as $row) {
$tr_link = " href='contact_setting_edit.php?contact_uuid=".$contact_uuid."&id=".$row['contact_setting_uuid']."'";
if (permission_exists('contact_setting_edit')) {
$tr_link = " href='contact_setting_edit.php?contact_uuid=".$contact_uuid."&id=".$row['contact_setting_uuid']."'";
}
echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['contact_setting_category']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'><a href='contact_setting_edit.php?contact_uuid=".$contact_uuid."&id=".$row['contact_setting_uuid']."'>".$row['contact_setting_subcategory']."</a></td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['contact_setting_name']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>\n";
$category = $row['contact_setting_category'];
$subcategory = $row['contact_setting_subcategory'];
$name = $row['contact_setting_name'];
@@ -132,18 +107,20 @@ require_once "resources/paging.php";
echo " <td valign='top' class='".$row_style[$c]."' style='text-align: center;'>".ucwords($row['contact_setting_enabled'])."&nbsp;</td>\n";
echo " <td valign='top' class='row_stylebg'>".$row['contact_setting_description']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>";
echo "<a href='contact_setting_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['contact_setting_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
if (permission_exists('contact_setting_edit')) {
echo "<a href='contact_setting_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['contact_setting_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
}
if (permission_exists('contact_setting_delete')) {
echo "<a href='contact_setting_delete.php?contact_uuid=".$row['contact_uuid']."&id=".$row['contact_setting_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
}
echo " </td>\n";
echo "</tr>\n";
$previous_category = $row['contact_setting_category'];
if ($c==0) { $c=1; } else { $c=0; }
$c = ($c) ? 0 : 1;
} //end foreach
unset($sql, $result, $row_count);
} //end if results
echo "</table>";
//include the footer
//require_once "resources/footer.php";
?>