Example #1
0
function show_access($k, $v, $is_mod = false)
{
    $html = '';
    if (is_array($v)) {
        $html .= '<li class="' . ($is_mod ? 'access-mod' : '') . '"><label>' . show_collapse(true) . show_check_box(2) . '<span class="access-fold">' . $k . '</span></label>';
        $html .= '<ul class="access-expand">';
        foreach ($v as $k2 => $v2) {
            $html .= show_access($k2, $v2);
        }
        $html .= '</ul>';
        $html .= '</li>';
    } else {
        $html .= '<li><label><input type="checkbox" name="" ' . (rand(0, 1) ? 'checked="checked"' : '') . '/><span class="access-name">' . $k . '</span><span class="access-uri">' . $v . '</span></label></li>';
    }
    return $html;
}
Example #2
0
function show_access($k, $v, $is_mod = false, $black = false)
{
    $html = '';
    if (is_assoc_array($v)) {
        $html .= '<li class="' . ($is_mod ? 'access-mod' : '') . '"><label>' . show_collapse(true) . show_check_box(2) . '<span class="access-fold">' . $k . '</span></label>';
        $html .= '<ul class="access-expand">';
        foreach ($v as $k2 => $v2) {
            $html .= show_access($k2, $v2, null, $black);
        }
        $html .= '</ul>';
        $html .= '</li>';
    } else {
        $n = $black ? 'act_bids' : 'act_wids';
        $cls = $v[1] == '*' ? 'root-item' : '';
        $html .= '<li class="' . $cls . '"><label>' . '<input type="checkbox" name="' . $n . '[]" value="' . $v[0] . '" ' . ($v[2] ? 'checked="checked"' : '') . '/>' . '<span class="access-name">' . $k . '</span><span class="access-uri">' . $v[1] . '</span>' . '</label></li>';
    }
    return $html;
}
Example #3
0
/**
 * *
 *  display addition and modification form
 *
 */
function display_add($db, $tableinfo, $Allfields, $id, $namein, $system_settings)
{
    global $PHP_SELF, $md, $max_menu_length, $USER, $LAYOUT, $_POST, $_SESSION;
    $dbstring = $PHP_SELF;
    $dbstring .= "?";
    $dbstring .= "tablename=" . $tableinfo->name . "&";
    echo "<form method='post' id='protocolform' enctype='multipart/form-data' name='subform' action='{$dbstring}";
    echo SID;
    ?>
'><?php 
    if (!$magic) {
        $magic = time();
    }
    echo "<input type='hidden' name='magic' value='{$magic}'>\n";
    echo "<input type='hidden' name='md' value='{$md}'>\n";
    echo "<table border=0 align='center'>\n";
    if ($id) {
        echo "<tr><td align='center'><h3>Modify " . $tableinfo->label . " entry <i>{$namein}</i></h3>\n";
        echo "<input type='hidden' name='id' value='{$id}'></td></tr>\n";
    } else {
        echo "<tr><td align='center'><h3>New " . $tableinfo->label . " entry</h3></td></tr>\n";
    }
    echo "<tr><td>\n<table border=0 align='center'>\n";
    foreach ($Allfields as $nowfield) {
        // give plugin a chance to modify data
        if (function_exists('plugin_display_add_pre')) {
            plugin_display_add_pre($db, $tableinfo->id, $nowfield);
        }
        // see if display_record is set
        if ($nowfield['display_record'] == 'Y' || $nowfield['display_table'] == 'Y') {
            // To persist between multiple invocation, grab POST vars
            if ($nowfield['modifiable'] == 'Y' && isset($_POST[$nowfield['name']]) && $_POST[$nowfield['name']] && isset($_POST['submit'])) {
                $nowfield['values'] = $_POST[$nowfield['name']];
                $nowfield['text'] = $_POST[$nowfield['name']];
            }
            if ($nowfield['modifiable'] != 'Y' && $nowfield['datatype'] != 'sequence') {
                echo "<input type='hidden' name='{$nowfield['name']}' value='{$nowfield['values']}'>\n";
                if (function_exists('plugin_modify_seq')) {
                    $nowfield['text'] = plugin_modify_seq($db, $tableinfo->id, $nowfield);
                }
                if ($nowfield['text'] && $nowfield['text'] != '' && $nowfield['text'] != ' ') {
                    echo "<tr><th>{$nowfield['label']}:</th>";
                    echo "<td>{$nowfield['text']}";
                }
            } elseif ($nowfield['modifiable'] == 'Y' && ($nowfield['datatype'] == 'text' || $nowfield['datatype'] == 'int' || $nowfield['datatype'] == 'float' || $nowfield['datatype'] == 'date')) {
                echo "<tr><th>{$nowfield['label']}:";
                if ($nowfield['required'] == 'Y') {
                    echo "<sup style='color:red'>&nbsp;*</sup>";
                }
                echo "</th>\n";
                if ($nowfield['datatype'] == 'text') {
                    //$size=60;
                    // mike likes this to be a textlong field, let's try
                    echo "<td><textarea name='{$nowfield['name']}' rows='2'cols=80>{$nowfield['values']}</textarea>";
                } elseif ($nowfield['datatype'] == 'date') {
                    $size = 10;
                    echo "<td><input type='text' name='{$nowfield['name']}' value='{$nowfield['text']}' size='{$size}'>";
                } else {
                    $size = 10;
                    echo "<td><input type='text' name='{$nowfield['name']}' value='{$nowfield['values']}' size='{$size}'>";
                }
            } elseif ($nowfield['datatype'] == 'sequence') {
                if (!is_numeric($nowfield['text'])) {
                    // find the highest sequence and return that plus one
                    $rmax = $db->Execute("SELECT MAX({$nowfield['name']}) AS {$nowfield['name']} FROM " . $tableinfo->realname);
                    $newseq = $rmax->fields[0] + 1;
                    if (function_exists('plugin_modify_seq')) {
                        $newseq = plugin_modify_seq($db, $tableinfo->id, $nowfield);
                    }
                } else {
                    $newseq = $nowfield['text'];
                }
                echo "<input type='hidden' name='{$nowfield['name']}' value='{$newseq}'>\n";
                echo "<tr><th>{$nowfield['label']}:";
                if ($nowfield['required'] == 'Y') {
                    echo "<sup style='color:red'>&nbsp;*</sup>";
                }
                echo "</th>\n";
                if ($nowfield['modifiable'] == 'N') {
                    echo "<td>{$newseq}";
                } else {
                    echo "<td><input type='text' name='{$nowfield['name']}' value='{$newseq}' size='10'>";
                }
                echo "</td></tr>\n";
            } elseif ($nowfield['datatype'] == 'textlong') {
                echo "<tr><th>{$nowfield['label']}:";
                if ($nowfield['required'] == 'Y') {
                    echo "<sup style='color:red'>&nbsp;*</sup>";
                }
                echo "<td><textarea name='{$nowfield['name']}' rows='5' cols='80' value='{$nowfield['values']}'>{$nowfield['values']}</textarea>";
            } elseif ($nowfield['datatype'] == 'link') {
                echo "<tr><th>{$nowfield['label']} (http link):";
                if ($nowfield['required'] == 'Y') {
                    echo "<sup style='color:red'>&nbsp;*</sup>";
                }
                echo "<td><input type='text' name='{$nowfield['name']}' value='{$nowfield['values']}' size='60'>";
            } elseif ($nowfield['datatype'] == 'pulldown') {
                // get previous value
                $r = $db->Execute("SELECT typeshort,id FROM {$nowfield['ass_t']} ORDER BY sortkey,typeshort");
                if ($nowfield['datatype'] == 'pulldown') {
                    $text = $r->GetMenu2("{$nowfield['name']}", $nowfield['values'], true, false);
                } else {
                    $text = $r->GetMenu2("{$nowfield['name']}", $nowfield['values'], true, true);
                }
                echo "<tr><th>{$nowfield['label']}:";
                if ($nowfield['required'] == 'Y') {
                    echo "<sup style='color:red'>&nbsp;*</sup>";
                }
                echo "</th>\n<td>";
                if ($USER['permissions'] & $LAYOUT) {
                    $jscript = " onclick='MyWindow=window.open (\"general.php?tablename=" . $tableinfo->name . "&amp;edit_type={$nowfield['ass_t']}&amp;jsnewwindow=true&amp;formname=subform&amp;selectname={$nowfield['name']}" . SID . "\",\"type\",\"scrollbars,resizable,toolbar,status,width=700,height=500\");MyWindow.focus()'";
                    echo "<input type='button' name='edit_button' value='Edit {$nowfield['label']}' {$jscript}><br>\n";
                }
                echo "{$text}<br>";
            } elseif ($nowfield['datatype'] == 'table') {
                // only display primary key here
                if (!$nowfield['ass_local_key']) {
                    // get previous value
                    $r = $db->Execute("SELECT COUNT(id) FROM {$nowfield['ass_table_name']}");
                    if ($r->fields[0] > $max_menu_length) {
                        $text = "<input type='hidden' name='max_{$nowfield['name']}' value='true'>\n";
                        $text .= "<input type='text' name='{$nowfield['name']}' value='{$nowfield['nested']['values']}'>";
                    } else {
                        $text = GetValuesMenu($db, $nowfield['name'], $nowfield['values'], $nowfield['ass_table_name'], $nowfield['ass_column_name'], false);
                    }
                    echo "<tr><th>{$nowfield['label']}:";
                    if ($nowfield[required] == "Y") {
                        echo "<sup style='color:red'>&nbsp;*</sup>";
                    }
                    echo "</th>\n<td>{$text}<br>";
                }
            }
            if ($nowfield['datatype'] == 'textlarge') {
                echo "<tr><th>{$nowfield['name']}:";
                if ($nowfield['required'] == 'Y') {
                    echo "<sup style='color:red'>&nbsp;*</sup>";
                }
                echo "</th><td colspan=6><textarea name='{$nowfield['name']}' rows='5' cols='100%'>{$nowfield['values']}</textarea>";
            }
            if ($nowfield['datatype'] == 'file' || $nowfield['datatype'] == 'image') {
                $files = get_files($db, $tableinfo->name, $id, $nowfield['columnid'], 0, 'big');
                echo '<tr>';
                echo "<th>{$nowfield['label']}:</th>\n";
                echo "</th>\n";
                echo '<td colspan=4> <table border=0>';
                for ($i = 0; $i < sizeof($files); $i++) {
                    echo "<tr><td colspan=2>" . $files[$i]['link'];
                    echo "&nbsp;&nbsp;(<i>" . $files[$i]['name'] . "</i>, " . $files[$i]['type'] . " file)</td>\n";
                    echo "<td><input type='submit' name='def_" . $files[$i]["id"] . "' value='Delete' Onclick=\"if(confirm('Are you sure the file " . $files[$i]["name"] . " should be removed?')){return true;}return false;\"></td></tr>\n";
                }
                echo '<tr><th>Upload ' . $nowfield['datatype'] . "</th>\n";
                echo "<td>&nbsp;</td><td><input type='file' name='" . $nowfield[name] . "[]' value='{$filename}'></td>\n";
                echo "</tr></table><br>\n\n";
            } elseif ($nowfield['datatype'] == 'mpulldown') {
                unset($valueArray);
                // get previous value
                $r = $db->Execute("SELECT typeshort,id FROM {$nowfield['ass_t']} ORDER BY sortkey,type");
                $rbv = $db->Execute("SELECT typeid FROM {$nowfield['key_t']} WHERE recordid={$id}");
                while ($rbv && !$rbv->EOF) {
                    $valueArray[] = $rbv->fields[0];
                    $rbv->MoveNext();
                }
                $text = $r->GetMenu2($nowfield['name'] . '[]', $valueArray, true, true);
                echo "<tr><th>{$nowfield['label']}:";
                if ($nowfield['required'] == 'Y') {
                    echo "<sup style='color:red'>&nbsp;*</sup>";
                }
                echo "</th>\n<td>";
                if ($USER['permissions'] & $LAYOUT) {
                    $jscript = " onclick='MyWindow=window.open (\"general.php?tablename=" . $tableinfo->name . "&edit_type={$nowfield['ass_t']}&amp;jsnewwindow=true&amp;formname=subform&amp;selectname={$nowfield['name']}" . SID . "\",\"type\",\"scrollbars,resizable,toolbar,status,width=700,height=500\");MyWindow.focus()'";
                    echo "<input type='button' name='edit_button' value='Edit {$nowfield['label']}' {$jscript}><br>\n";
                }
                echo "{$text}<br>";
            }
        }
        if (function_exists('plugin_display_add')) {
            plugin_display_add($db, $tableinfo->id, $nowfield);
        }
    }
    // end of foreach ($Allfields)
    echo "</table>\n</td>\n</tr>\n";
    /* Call to a function that runs at the end when adding a new record*/
    if (function_exists("plugin_display_add_post") && !$id) {
        plugin_display_add_post($db, $tableinfo->id);
    }
    echo '<tr><td colspan=4>';
    show_access($db, $tableinfo->id, $id, $USER, $system_settings);
    echo "</td></tr>\n";
    echo "<tr>";
    if ($id) {
        $value = "Modify Record";
    } else {
        $value = "Add Record";
    }
    // submit and clear buttons
    echo "<td align='center'>\n";
    if ($_SESSION['javascript_enabled']) {
        echo "<input type='hidden' name='subm' value=''>\n";
        // echo "<input type='button' name='sub' value='$value' onclick='document.subform.subm.value=\"$value\"; document.subform.submit(); window.opener.document.g_form.search.value=\"Search\"; window.opener.document.g_form.submit(); window.opener.focus(); self.close();'>\n";
        echo "<input type='button' name='sub' value='{$value}' onclick='document.subform.subm.value=\"{$value}\"; document.subform.submit();'>\n";
        //echo "<input type='button' name='Close' onclick='self.close(); window.opener.focus();' value='Cancel'>\n";
        echo "<input type='button' name='Close' onclick='document.subform.submit();' value='Cancel'>\n";
    } else {
        echo "<input type='submit' name='submit' value='{$value}'>\n";
        echo "&nbsp;&nbsp;";
        echo "<input type='submit' name='submit' value='Cancel'></td>\n";
    }
    echo "</tr>\n</table>\n</form>\n";
}