/** * reorder custom VLAN field */ function reorderCustomField($table, $next, $current) { global $database; /* get field details */ $old = getFullFieldData($table, $current); /* update request */ if ($old['Null'] == "NO") { $query = 'ALTER TABLE `' . $table . '` MODIFY COLUMN `' . $current . '` ' . $old['Type'] . ' NOT NULL COMMENT "' . $old['Comment'] . '" AFTER `' . $next . '`;'; } else { $query = 'ALTER TABLE `' . $table . '` MODIFY COLUMN `' . $current . '` ' . $old['Type'] . ' DEFAULT NULL COMMENT "' . $old['Comment'] . '" AFTER `' . $next . '`;'; } try { $database->executeQuery($query); } catch (Exception $e) { $error = $e->getMessage(); print "<div class='alert alert-danger'>" . _('Error') . ": {$error}</div>"; updateLogTable('Custom Field reordering failed (' . $next . ' was not put before ' . $current . ')', $log, 2); return false; } updateLogTable('Custom Field reordering success (' . $next . ' put before ' . $current . ')', $log, 0); return true; }
table = name of the table action = action fieldName = field name to edit */ /* required functions */ require_once '../../functions/functions.php'; /* verify that user is admin */ checkAdmin(); /* reset field name for add! */ if ($_POST['action'] == "add") { $_POST['fieldName'] = ""; } else { $_POST['oldname'] = $_POST['fieldName']; } //old field val $fieldval = getFullFieldData($_POST['table'], $_POST['fieldName']); ?> <div class="pHeader"><?php print ucwords(_("{$_POST['action']}")); ?> <?php print _('custom field'); ?> </div> <div class="pContent"> <form id="editCustomFields">