Ejemplo n.º 1
0
function update_s_site_plugin_input_field($site_type, $field, $order_no, $description, $prompt, $field_type, $default_value, $refresh_mask)
{
    if (strlen($site_type) > 0 && strlen($field) > 0) {
        $site_type = strtolower($site_type);
        $field = strtolower($field);
        if ($order_no !== FALSE && !is_numeric($order_no)) {
            $order_no = 0;
        }
        if ($field_type !== FALSE) {
            $field_type = strtolower($field_type);
            if (!in_array($field_type, get_legal_input_field_types())) {
                $field_type = 'text';
            }
        }
        $query = "UPDATE s_site_plugin_input_field " . "SET description = " . ($description !== FALSE ? "'" . addslashes(trim(strip_tags($description))) . "'" : "description") . ($order_no !== FALSE ? ", order_no = " . $order_no . "" : "") . ($prompt !== FALSE ? ", prompt = '" . addslashes(trim(strip_tags($prompt))) . "'" : "") . ($field_type !== FALSE ? ", field_type = '" . $field_type . "'" : "") . ($default_value !== FALSE ? ", default_value = '" . addslashes(trim(strip_tags($default_value))) . "'" : "") . ($refresh_mask !== FALSE ? ", refresh_mask = '" . addslashes(trim(strip_tags($refresh_mask))) . "'" : "") . " WHERE site_type = '{$site_type}' AND field = '{$field}'";
        $update = db_query($query);
        // We should not treat updates that were not actually updated because value did not change as failures.
        $rows_affected = db_affected_rows();
        if ($update && $rows_affected !== -1) {
            if ($rows_affected > 0) {
                opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($site_type, $field, $order_no, $description, $prompt, $field_type, $default_value, $refresh_mask));
            }
            return TRUE;
        } else {
            opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($site_type, $field, $order_no, $description, $prompt, $field_type, $default_value, $refresh_mask));
            return FALSE;
        }
    }
    //else
    return FALSE;
}
Ejemplo n.º 2
0
function display_site_plugin_input_field_row($record_r, $row)
{
    global $PHP_SELF;
    global $ADMIN_TYPE;
    if (is_not_empty_array($record_r)) {
        echo "<input type=\"hidden\" name=\"exists_ind[{$row}]\" value=\"Y\">";
        echo "<td class=\"data\">" . get_input_field("order_no[{$row}]", NULL, "Order No", "number(3)", "Y", $record_r['order_no'], FALSE) . "</td>";
        echo "<td class=\"data\">" . get_input_field("field[{$row}]", NULL, "Field Name", "readonly", "Y", $record_r['field'], FALSE) . "</td>";
    } else {
        echo "<input type=\"hidden\" name=\"exists_ind[{$row}]\" value=\"N\">";
        echo "<td class=\"data\">" . get_input_field("order_no[{$row}]", NULL, "Order No", "number(3)", "Y", NULL, FALSE) . "</td>";
        echo "<td class=\"data\">" . get_input_field("field[{$row}]", NULL, "Field Name", "text(10,20)", "Y", NULL, FALSE) . "</td>";
    }
    echo "<td class=\"data\">" . get_input_field("description[{$row}]", NULL, "Description", "text(20,255)", 'N', $record_r['description'], FALSE) . "</td>";
    echo "<td class=\"data\">" . get_input_field("prompt[{$row}]", NULL, "URL", "text(10,30)", 'N', $record_r['prompt'], FALSE) . "</td>";
    echo "<td class=\"data\">" . custom_select("field_type[{$row}]", get_legal_input_field_types(), "%value%", 1, $record_r['field_type']) . "</td>";
    echo "<td class=\"data\">" . get_input_field("refresh_mask[{$row}]", NULL, "Refresh Mask", "text(20,255)", 'N', $record_r['refresh_mask'], FALSE) . "</td>";
    echo "<td class=\"data\">" . get_input_field("default_value[{$row}]", NULL, "Default Value", "text(7,50)", 'N', $record_r['default_value'], FALSE) . "</td>";
    echo "\n<td class=\"data\">";
    if (is_not_empty_array($record_r)) {
        echo "<a href=\"{$PHP_SELF}?type={$ADMIN_TYPE}&op=delete_site_plugin_input_field&site_type=" . $record_r['site_type'] . "&field=" . $record_r['field'] . "\">Delete</a>";
    } else {
        echo "&nbsp;";
    }
    echo "\n</td>";
}