Exemplo n.º 1
0
<?php

// admin header
session_start();
require_once 'lib/php/DOLib.php';
if (!swValidate('s_username')) {
    header("location: index.php");
}
connect();
// save new value and redirect to the page to view the change
$save = $_POST['save'];
if ($save) {
    StaticField::createStaticField($save, $_POST['value']);
    $location = ViewUrl::getViewUrl($save);
    if ($location) {
        header("location: view.php?location=" . $location);
    } else {
        header("location: view.php");
    }
}
//get default value for the textarea (either from selecting an item in the history, or from the current active record)
$name = $_GET['name'];
if ($_GET['init']) {
    $row = StaticField::getStaticFieldById($_GET['init']);
} else {
    $row = StaticField::getStaticFieldByName($name);
}
if ($row) {
    $initValue = restoreValue($row[2]);
}
//delete history entry
        case 'getStaticFieldById':
            $result = "getStaticFieldById result:" . implode(",", StaticField::getStaticFieldById($id));
            break;
        case 'getAllStaticFieldsByName':
            $staticFields = StaticField::getAllStaticFieldsByName($name);
            if (!$staticFields) {
                $result = "no record for the name={$name}";
            } else {
                foreach ($staticFields as $sf) {
                    $sfList[] = implode(",", $sf);
                }
                $result = "getAllStaticFieldsByName result:\n" . implode("<br/>", $sfList);
            }
            break;
        case 'createStaticField':
            StaticField::createStaticField($name, $value);
            $result = "static field created: name={$name}, value={$value}";
            break;
        case 'deleteStaticField':
            if (StaticField::deleteStaticField($id)) {
                $result = "static field deleted: id={$id}";
            } else {
                $result = "cannot delete field with id={$id} because it is the current static field for the name {$name}";
            }
            break;
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>