function display_resource($role, $tree, $values, $acl, $sep, $iParent) { $i = 0; foreach ($tree as $node) { $i++; ?> <tr> <?php $icon = 'document'; switch ($node['type']) { case 'module': $icon = 'application-block'; break; case 'controller': $icon = 'application-icon-large'; break; case 'action': $icon = 'application-dialog'; break; } ?> <td> <?php echo $sep; ?> <img src="<?php echo image_url('fugue/' . $icon . '.png'); ?> " width="16" height="16" /> <?php echo $node['name']; ?> </td> <?php $checkname = 'rule_resource[' . $node['id'] . ']'; $value = TRUE; if (isset($values[$node['id']])) { $value = $values[$node['id']]->access; } ?> <td style="text-align: center"> <input type="radio" id="allow<?php echo $iParent . '_' . $i; ?> " name="<?php echo $checkname; ?> " value="allow" <?php echo set_radio($checkname, 'allow', $value == 'allow'); ?> /> </td> <td style="text-align: center"> <input type="radio" id="deny<?php echo $iParent . '_' . $i; ?> " name="<?php echo $checkname; ?> " value="deny" <?php echo set_radio($checkname, 'deny', $value == 'deny'); ?> /> </td> <td style="text-align: center"> <?php if ($value == 'allow') { $acl->removeAllow($role, $node['name']); } elseif ($value == 'deny') { $acl->removeDeny($role, $node['name']); } ?> <input type="radio" name="<?php echo $checkname; ?> " value="" <?php echo set_radio($checkname, '', $value); ?> /> <?php if ($acl->isAllowed($role, $node['name'])) { ?> <em style="color: green;">Allow</em> <?php } else { ?> <em style="color: #999;">Deny</em> <?php } ?> </td> </tr> <?php if (isset($node['children'])) { display_resource($role, $node['children'], $values, $acl, $sep . ' ', $iParent . '_' . $i); } } }
$template['files'][] = 'resources_retrieve.html'; $template['resources'] = ""; $template['category_list'] = ""; // Pull all details $all_locations_assoc = $db->GetAssoc("SELECT * FROM " . LOCATIONS_TABLE . " WHERE location_id != 0 ORDER BY loc_order_hash ASC, loc_name ASC"); // Define the SQL to pull all resources, alter if a specific row is requested $sql = "SELECT * FROM " . RESOURCES_TABLE; if ($row = isset($_GET['row'])) { $sql .= " WHERE resource_id = " . clean_string($_GET['row']); } $all_resources = $db->Execute($sql . " ORDER BY resource_id ASC"); // If this isn't a category refresh, we generate the return location and bookable location drop-downs if (!$cat) { $template['location_list'] = display_form($all_locations, "create_base_location", FALSE, FALSE); $template['book_location'] = str_replace("create_base_location", "create_book_location", $template['location_list']); // Display resources foreach ($all_resources as $resource) { $display = display_resource($resource); if ($ajax) { echo $display; } else { $template['resources'] .= $display; } } } $template['category_list'] = display_categories($all_categories); if ($ajax && $cat) { echo $template['category_list']; } else { $template['category_list'] = display_categories($all_categories); }
function display_resource($role, $tree, $values, $acl, $sep, $iParent) { $i = 0; foreach ($tree as $node) { $i++; $checkname = 'rule_resource[' . $node['id'] . ']'; $value = ''; if (isset($values[$node['id']])) { $value = $values[$node['id']]->access; } if ($value == 'allow') { $acl->removeAllow($role, $node['name']); } elseif ($value == 'deny') { $acl->removeDeny($role, $node['name']); } $default_value = $acl->isAllowed($role, $node['name']) ? 'allow' : 'deny'; $tr_class = ''; if ($default_value == 'allow') { $tr_class = 'success'; } elseif ($default_value == 'deny') { $tr_class = 'danger'; } if ($value == 'allow') { $tr_class = 'success'; } elseif ($value == 'deny') { $tr_class = 'danger'; } ?> <tr class="<?php echo $tr_class; ?> "> <?php $icon = 'fa-question'; switch ($node['type']) { case 'module': $icon = 'fa-folder-open-o'; break; case 'controller': $icon = 'fa-file-text-o'; break; case 'action': $icon = 'fa-gear'; break; } ?> <td class="resource-column" style="max-width: 200px; overflow-x: auto;"> <?php echo $sep; ?> <i class="fa <?php echo $icon; ?> "></i> <?php echo $node['name']; ?> </td> <td> <label class="i-switch bg-success"> <input type="radio" id="allow<?php echo $iParent . '_' . $i; ?> " name="<?php echo $checkname; ?> " value="allow" <?php echo set_radio($checkname, 'allow', $value == 'allow'); ?> /> <i></i> </label> </td> <td> <label class="i-switch bg-danger"> <input type="radio" id="deny<?php echo $iParent . '_' . $i; ?> " name="<?php echo $checkname; ?> " value="deny" <?php echo set_radio($checkname, 'deny', $value == 'deny'); ?> /> <i></i> </label> </td> <td> <label class="i-switch <?php echo $default_value == 'allow' ? 'bg-success' : 'bg-danger'; ?> "> <input type="radio" name="<?php echo $checkname; ?> " value="" <?php echo set_radio($checkname, '', $value == ''); ?> /> <i></i> </label> </td> </tr> <?php if (isset($node['children'])) { display_resource($role, $node['children'], $values, $acl, $sep . ' ', $iParent . '_' . $i); } } }