コード例 #1
0
function smarty_function_export_groups_dropdown($params, &$smarty)
{
    global $LANG;
    if (empty($params["name_id"])) {
        $smarty->trigger_error("assign: missing 'name_id' parameter. This is used to give the select field a name and id value.");
        return;
    }
    $default_value = isset($params["default"]) ? $params["default"] : "";
    $attributes = array("id" => $params["name_id"], "name" => $params["name_id"]);
    $attribute_str = "";
    while (list($key, $value) = each($attributes)) {
        if (!empty($value)) {
            $attribute_str .= " {$key}=\"{$value}\"";
        }
    }
    $export_groups = exp_get_export_groups();
    $rows = array();
    foreach ($export_groups as $group_info) {
        $export_group_id = $group_info["export_group_id"];
        $group_name = $group_info["group_name"];
        $rows[] = "<option value=\"{$export_group_id}\" " . ($default_value == $export_group_id ? "selected" : "") . ">{$group_name}</option>";
    }
    $dd = "<select {$attribute_str}>" . join("\n", $rows) . "</select>";
    return $dd;
}
コード例 #2
0
ファイル: index.php プロジェクト: jeffthestampede/excelsior
require_once "../../global/library.php";
ft_init_module_page();
$request = array_merge($_POST, $_GET);
$sortable_id = "export_group_list";
if (isset($request["add_export_group"])) {
    list($g_success, $g_message) = exp_add_export_group($request);
}
if (isset($request["delete"])) {
    list($g_success, $g_message) = exp_delete_export_group($request["delete"]);
}
if (isset($request["update"])) {
    $request["sortable_id"] = $sortable_id;
    list($g_success, $g_message) = exp_reorder_export_groups($request);
}
$export_groups = exp_get_export_groups();
// ------------------------------------------------------------------------------------------------
$page_vars = array();
$page_vars["export_groups"] = $export_groups;
$page_vars["sortable_id"] = $sortable_id;
$page_vars["head_string"] = <<<END
<link type="text/css" rel="stylesheet" href="{$g_root_url}/modules/export_manager/global/css/styles.css">
<script src="{$g_root_url}/global/scripts/sortable.js"></script>
END;
$page_vars["head_js"] = <<<EOF
var page_ns = {};
page_ns.dialog = \$("<div></div>");

page_ns.delete_export_group = function(el) {
  ft.create_dialog({
    dialog:     page_ns.dialog,
コード例 #3
0
/**
 * 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;
}