示例#1
0
if (!$gCurrentUser->editInventory()) {
    $gMessage->show($gL10n->get('SYS_NO_RIGHTS'));
}
// set headline of the script
if ($getInfId > 0) {
    $headline = $gL10n->get('ORG_EDIT_PROFILE_FIELD');
} else {
    $headline = $gL10n->get('ORG_CREATE_PROFILE_FIELD');
}
$gNavigation->addUrl(CURRENT_URL, $headline);
// benutzerdefiniertes Feldobjekt anlegen
$itemField = new TableInventoryField($gDb);
if ($getInfId > 0) {
    $itemField->readDataById($getInfId);
    // hidden must be 0, if the flag should be set
    if ($itemField->getValue('inf_hidden') == 1) {
        $itemField->setValue('inf_hidden', 0);
    } else {
        $itemField->setValue('inf_hidden', 1);
    }
    // Pruefung, ob das Feld zur aktuellen Organisation gehoert
    if ($itemField->getValue('cat_org_id') > 0 && $itemField->getValue('cat_org_id') != $gCurrentOrganization->getValue('org_id')) {
        $gMessage->show($gL10n->get('SYS_NO_RIGHTS'));
    }
} else {
    // default values for a new field
    $itemField->setValue('inf_hidden', 1);
}
if (isset($_SESSION['fields_request'])) {
    // hidden must be 0, if the flag should be set
    if ($_SESSION['fields_request']['inf_hidden'] == 1) {
示例#2
0
require_once '../../system/common.php';
require_once '../../system/login_valid.php';
// Initialize and check the parameters
$getInfId = admFuncVariableIsValid($_GET, 'inf_id', 'numeric');
$getMode = admFuncVariableIsValid($_GET, 'mode', 'numeric', array('requireValue' => true));
$getSequence = admFuncVariableIsValid($_GET, 'sequence', 'string', array('validValues' => array('UP', 'DOWN')));
// only users with the right to edit inventory could use this script
if (!$gCurrentUser->editInventory()) {
    $gMessage->show($gL10n->get('SYS_NO_RIGHTS'));
}
// create item field object
$itemField = new TableInventoryField($gDb);
if ($getInfId > 0) {
    $itemField->readDataById($getInfId);
    // check if profile field belongs to actual organization
    if ($itemField->getValue('cat_org_id') > 0 && $itemField->getValue('cat_org_id') != $gCurrentOrganization->getValue('org_id')) {
        $gMessage->show($gL10n->get('SYS_NO_RIGHTS'));
    }
    // if system profile field then set usf_type to default
    if ($itemField->getValue('inf_system') == 1) {
        $_POST['inf_type'] = $itemField->getValue('inf_type');
    }
}
if ($getMode === 1) {
    // Feld anlegen oder updaten
    $_SESSION['fields_request'] = $_POST;
    // pruefen, ob Pflichtfelder gefuellt sind
    // (bei Systemfeldern duerfen diese Felder nicht veraendert werden)
    if ($itemField->getValue('inf_system') == 0 && strlen($_POST['inf_name']) === 0) {
        $gMessage->show($gL10n->get('SYS_FIELD_EMPTY', $gL10n->get('SYS_NAME')));
    }