function smarty_function_display_edit_submission_view_dropdown($params, &$smarty)
{
    global $LANG;
    if (empty($params["form_id"])) {
        $smarty->trigger_error("assign: missing 'form_id' parameter.");
        return;
    }
    if (empty($params["view_id"])) {
        $smarty->trigger_error("assign: missing 'view_id' parameter.");
        return;
    }
    if (empty($params["submission_id"])) {
        $smarty->trigger_error("assign: missing 'submission_id' parameter.");
        return;
    }
    if (empty($params["account_id"])) {
        $smarty->trigger_error("assign: missing 'account_id' parameter.");
        return;
    }
    $is_admin = $params["is_admin"] ? $params["is_admin"] : false;
    $form_id = $params["form_id"];
    $view_id = $params["view_id"];
    $submission_id = $params["submission_id"];
    $account_id = $params["account_id"];
    if ($is_admin) {
        $views = ft_get_form_views($form_id);
    } else {
        $views = ft_get_form_views($form_id, $account_id);
    }
    // loop through the Views assigned to this user and IFF the view contains the submission,
    // add it to the dropdown list
    if (count($views) > 1) {
        $same_page = ft_get_clean_php_self();
        $html = "<select onchange=\"window.location='{$same_page}?form_id={$form_id}&submission_id={$submission_id}&view_id=' + this.value\">\r\n\t    <optgroup label=\"Views\">\n";
        foreach ($views as $view_info) {
            $curr_view_id = $view_info["view_id"];
            $curr_view_name = $view_info["view_name"];
            if (ft_check_view_contains_submission($form_id, $curr_view_id, $submission_id)) {
                $selected = $curr_view_id == $view_id ? " selected" : "";
                $html .= "<option value=\"{$curr_view_id}\"{$selected}>{$curr_view_name}</option>";
            }
        }
        $html .= "</optgroup></select>\n";
    }
    return $html;
}
コード例 #2
0
ファイル: emails.php プロジェクト: jdearaujo/core
/**
 * The main email function for Form Tools. This gets executed on particular events in a submissions life: when
 * first placed ("on_submission"), when edited ("on_edit") and when deleted ("on_delete"). This function does
 * the horrible job of figuring out precisely what the administrator wants, and sends the email(s) to the
 * appropriate recipients.
 *
 * @param string $event "on_submission", "on_edit", "on_delete"
 * @param integer $form_id
 * @param integer $submission_id
 */
function ft_send_emails($event, $form_id, $submission_id)
{
    $all_form_email_templates = ft_get_email_template_list($form_id);
    // filter out those templates that aren't for this event
    $email_templates = array();
    foreach ($all_form_email_templates as $template_info) {
        $events = explode(",", $template_info["email_event_trigger"]);
        if (!in_array($event, $events)) {
            continue;
        }
        if ($template_info["email_status"] == "disabled") {
            continue;
        }
        // if this email template has been mapped to or more particular View, make sure the View ID is
        // valid & that the submission can be seen in at least one of the Views
        if ($template_info["view_mapping_type"] == "specific") {
            $view_ids = $template_info["when_sent_view_ids"];
            $found = false;
            foreach ($view_ids as $view_id) {
                if (ft_check_view_contains_submission($form_id, $view_id, $submission_id)) {
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                continue;
            }
        }
        $email_templates[] = $template_info;
    }
    // now process each template individually
    foreach ($email_templates as $template_info) {
        $email_id = $template_info["email_id"];
        ft_process_email_template($form_id, $submission_id, $email_id);
    }
}
コード例 #3
0
ファイル: edit_submission.php プロジェクト: jdearaujo/core
require dirname(__FILE__) . "/edit_submission__code.php";
$account_id = $_SESSION["ft"]["account"]["account_id"];
// blur the GET and POST variables into a single variable for easy reference
$request = array_merge($_GET, $_POST);
$form_id = ft_load_field("form_id", "curr_form_id");
$view_id = ft_load_field("view_id", "form_{$form_id}_view_id");
$submission_id = isset($request["submission_id"]) ? $request["submission_id"] : "";
if (empty($submission_id)) {
    header("location: index.php");
    exit;
}
$tab_number = ft_load_field("tab", "view_{$view_id}_current_tab", 1);
$grouped_views = ft_get_grouped_views($form_id, array("omit_hidden_views" => true, "omit_empty_groups" => true, "account_id" => $account_id));
// check the current client is permitted to view this information!
ft_check_client_may_view($account_id, $form_id, $view_id);
if (!ft_check_view_contains_submission($form_id, $view_id, $submission_id)) {
    header("location: index.php");
    exit;
}
// store this submission ID
$_SESSION["ft"]["last_submission_id"] = $submission_id;
// get a list of all editable fields in the View. This is used both for security purposes
// for the update function and to determine whether the page contains any editable fields
$editable_field_ids = _ft_get_editable_view_fields($view_id);
// handle POST requests
$failed_validation = false;
if (isset($_POST) && !empty($_POST)) {
    // add the view ID to the request hash, for use by the ft_update_submission function
    $request["view_id"] = $view_id;
    $request["editable_field_ids"] = $editable_field_ids;
    list($g_success, $g_message) = ft_update_submission($form_id, $submission_id, $request);
コード例 #4
0
function smarty_function_views_dropdown($params, &$smarty)
{
    global $LANG;
    if (empty($params["form_id"])) {
        $smarty->trigger_error("assign: missing 'form_id' parameter.");
        return;
    }
    $form_id = $params["form_id"];
    $name_id = isset($params["name_id"]) ? $params["name_id"] : "";
    $show_empty_label = isset($params["show_empty_label"]) ? $params["show_empty_label"] : false;
    $empty_label = isset($params["empty_label"]) ? $params["empty_label"] : $LANG["phrase_please_select"];
    $selected = isset($params["selected"]) ? $params["selected"] : "";
    $onchange = isset($params["onchange"]) ? $params["onchange"] : "";
    $submission_id = isset($params["submission_id"]) ? $params["submission_id"] : "";
    $omit_hidden_views = isset($params["omit_hidden_views"]) ? $params["omit_hidden_views"] : false;
    $create_view_dropdown = isset($params["create_view_dropdown"]) ? $params["create_view_dropdown"] : false;
    $class = isset($params["class"]) ? $params["class"] : "";
    $open_html = isset($params["open_html"]) ? $params["open_html"] : "";
    $close_html = isset($params["close_html"]) ? $params["close_html"] : "";
    $hide_single_view = isset($params["hide_single_view"]) ? $params["hide_single_view"] : false;
    // if the calling page has the view information already calculated, it can pass it to this function to
    // reduce the amount of work it needs to do. Otherwise, it will just do a separate request for the data
    $grouped_views = isset($params["grouped_views"]) ? $params["grouped_views"] : ft_get_grouped_views($form_id, array("omit_hidden_views" => $omit_hidden_views));
    $attributes = array("id" => $name_id, "name" => $name_id, "onchange" => $onchange, "class" => $class);
    $attribute_str = "";
    while (list($key, $value) = each($attributes)) {
        if (!empty($value)) {
            $attribute_str .= " {$key}=\"{$value}\"";
        }
    }
    $num_views = 0;
    $class_str = empty($class) ? "" : " class=\"{$class}\"";
    $dd = "<select {$attribute_str}{$class_str}>";
    if ($show_empty_label) {
        $dd .= "<option value=\"\">{$empty_label}</option>";
    }
    if ($create_view_dropdown) {
        $dd .= "<option value=\"blank_view_all_fields\">{$LANG["phrase_new_view_all_fields"]}</option>";
        $dd .= "<option value=\"blank_view_no_fields\">{$LANG["phrase_new_blank_view"]}</option>";
    }
    foreach ($grouped_views as $curr_group) {
        $group_name = $curr_group["group"]["group_name"];
        $view_options = "";
        foreach ($curr_group["views"] as $view_info) {
            $curr_view_id = $view_info["view_id"];
            $view_name = $view_info["view_name"];
            $is_selected = $curr_view_id == $selected ? "selected" : "";
            if (empty($submission_id)) {
                $view_options .= "<option value=\"{$curr_view_id}\" {$is_selected}>{$view_name}</option>\n";
                $num_views++;
            } else {
                if (ft_check_view_contains_submission($form_id, $curr_view_id, $submission_id)) {
                    $view_options .= "<option value=\"{$curr_view_id}\" {$is_selected}>{$view_name}</option>";
                    $num_views++;
                }
            }
        }
        if (!empty($view_options)) {
            if (!empty($group_name)) {
                $dd .= "<optgroup label=\"{$group_name}\">";
            }
            $dd .= $view_options;
            if (!empty($group_name)) {
                $dd .= "</optgroup>";
            }
        }
    }
    $dd .= "</select>";
    if ($num_views <= 1 && $hide_single_view) {
        // do nothing!
        $dd = "";
    } else {
        $dd = $open_html . $dd . $close_html;
    }
    return $dd;
}