Beispiel #1
0
 * You should have received a copy of the GNU Affero General Public License
 * along with allocPSA. If not, see <http://www.gnu.org/licenses/>.
*/
require_once "../alloc.php";
if (!have_entity_perm("config", PERM_UPDATE, $current_user, true)) {
    alloc_error("Permission denied.", true);
}
$table = $_POST["configName"] or $table = $_GET["configName"];
$TPL["table"] = $table;
if ($_POST["save"]) {
    foreach ((array) $_POST[$table . "ID"] as $k => $tableID) {
        // Delete
        if (in_array($tableID, (array) $_POST["delete"])) {
            $t = new meta($table);
            $t->set_id($tableID);
            $t->delete();
            // Save
        } else {
            $a = array($table . "ID" => $tableID, $table . "Seq" => $_POST[$table . "Seq"][$k], $table . "Label" => $_POST[$table . "Label"][$k], $table . "Name" => $_POST[$table . "Name"][$k], $table . "Colour" => $_POST[$table . "Colour"][$k], $table . "Seq" => $_POST[$table . "Seq"][$k], "numberToBasic" => $_POST["numberToBasic"][$k], $table . "Active" => in_array($tableID, $_POST[$table . "Active"]));
            $orig_tableID = $_POST[$table . "IDOrig"][$k];
            $t = new meta($table);
            $t->read_array($a);
            $errs = $t->validate();
            if (!$errs) {
                if ($orig_tableID && $orig_tableID != $tableID) {
                    $a[$table . "Active"] = in_array($orig_tableID, $_POST[$table . "Active"]);
                    $t->read_array($a);
                    $t->set_id($orig_tableID);
                    $k = new db_field($table . "ID");
                    // If the primary key has changed, then it needs special handling.
                    $k->set_value($tableID);