/** * This function is used when drawing the visible export options to ths page. It determines which export groups & * types get displayed for a particular form, View and account. * * @param mixed $account_id - "admin" or the client ID * @param integer $form_id * @param integer $view_id * @return array an array of hashes */ function exp_get_assigned_export_types($account_id, $form_id, $view_id) { global $g_table_prefix; $is_client = $account_id == "admin" ? false : true; // Step 1: get all accessible export GROUPS $private_client_accessible_export_group_ids = array(); if ($is_client) { $query = mysql_query("\n SELECT export_group_id\n FROM {$g_table_prefix}module_export_group_clients\n WHERE account_id = {$account_id}\n "); while ($row = mysql_fetch_assoc($query)) { $private_client_accessible_export_group_ids[] = $row["export_group_id"]; } } $export_groups = exp_get_export_groups(); $accessible_export_groups = array(); foreach ($export_groups as $group) { if ($group["visibility"] == "hide") { continue; } if ($group["access_type"] == "public") { $accessible_export_groups[] = $group; } else { if ($is_client) { if ($group["access_type"] != "admin" && in_array($group["export_group_id"], $private_client_accessible_export_group_ids)) { $accessible_export_groups[] = $group; } } else { $accessible_export_groups[] = $group; } } } // so far so good. We now have a list of export groups that hav been filtered by visibility & whether // the client can see them. Next, factor in the current form ID and view ID $filtered_export_groups = array(); foreach ($accessible_export_groups as $export_group) { if ($export_group["form_view_mapping"] == "all") { $filtered_export_groups[] = $export_group; } else { if ($export_group["form_view_mapping"] == "only") { $mapping = exp_deserialized_export_group_mapping($export_group["forms_and_views"]); if (!in_array($form_id, $mapping["form_ids"])) { continue; } if (in_array("form{$form_id}_all_views", $mapping["view_ids"]) || in_array($view_id, $mapping["view_ids"])) { $filtered_export_groups[] = $export_group; } } else { if ($export_group["form_view_mapping"] == "except") { $mapping = exp_deserialized_export_group_mapping($export_group["forms_and_views"]); if (in_array("form{$form_id}_all_views", $mapping["view_ids"])) { continue; } if (in_array($view_id, $mapping["view_ids"])) { continue; } $filtered_export_groups[] = $export_group; } } } } // Step 2: alright! Now we get the list of export types for the accessible Views $export_groups_and_types = array(); foreach ($filtered_export_groups as $export_group) { $export_types = exp_get_export_types($export_group["export_group_id"], true); if (count($export_types) == 0) { continue; } $export_group["export_types"] = $export_types; $export_groups_and_types[] = $export_group; } return $export_groups_and_types; }
<?php if (isset($request["update_permissions"])) { list($g_success, $g_message) = exp_update_export_group_permissions($request); } $forms = ft_get_form_view_list(); $export_group_info = exp_get_export_group($export_group_id); $mappings = exp_deserialized_export_group_mapping($export_group_info["forms_and_views"]); $page_vars["page"] = "permissions"; $page_vars["forms"] = $forms; $page_vars["selected_form_ids"] = $mappings["form_ids"]; $page_vars["selected_view_ids"] = $mappings["view_ids"]; $page_vars["export_group_id"] = $export_group_id; $page_vars["export_group_info"] = $export_group_info; $page_vars["head_title"] = "{$L["module_name"]} - {$LANG["word_permissions"]}"; $page_vars["head_js"] = <<<EOF \$(function() { \$("input[name=access_type]").bind("click change", function() { var form_type = this.value; if (form_type == "private") { \$("#custom_clients").show(); } else { \$("#custom_clients").hide(); } }); \$("input[name=form_view_mapping]").bind("click change", function() { var form_type = this.value; if (form_type == "all") { \$("#custom_forms").hide();