Skip to content
Snippets Groups Projects
Forked from Stud.IP / Stud.IP
1046 commits behind the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
_form.php 3.78 KiB
<?php
# Lifter010:

/**
 * @var string $action
 * @var string $lock_rule_type
 * @var LockRule $lock_rule
 * @var array $rule_type_names
 * @var array $lock_rule_permissions
 * @var array $lock_config
 */
use Studip\Button;

?>
<form action="<?= $action ?>" method="post" class="default">
    <?= CSRFProtection::tokenTag(); ?>
    <fieldset>
        <legend>
            <? if ($lock_rule->name) : ?>
                <?= sprintf(_('Sperrebene "%s" ändern'), htmlready($lock_rule["name"])) ?>
            <? else : ?>
                <?= _('Neue Sperrebene eingeben für den Bereich:') ?> <?= $rule_type_names[$lock_rule_type]; ?>
            <? endif ?>
        </legend>

        <label>
            <?= _("Name") ?>

            <input type="text" style="width:90%" required name="lockdata_name"
                   value="<?= htmlReady($lock_rule['name']) ?>">
       </label>

       <label>
            <?= _('Beschreibung') ?>
            <?= tooltipIcon(_('Dieser Text wird auf allen Seiten mit gesperrtem Inhalt angezeigt')) ?>

            <textarea name="lockdata_description" rows="5"
                      style="width:90%"><?= htmlReady($lock_rule["description"]) ?></textarea>
      </label>

      <label>
            <?= _('Nutzerstatus') ?>
            <?= tooltipIcon(_('Die Einstellungen dieser Sperrebene gelten für Nutzer bis zu dieser Berechtigung')) ?>

            <select name="lockdata_permission">
                <? foreach ($lock_rule_permissions as $p) : ?>
                    <option <?= ($lock_rule['permission'] == $p ? 'selected' : '') ?>><?= $p ?></option>
                <? endforeach; ?>
            </select>
        </label>
    </fieldset>

    <footer>
        <?= Button::create(_('Übernehmen'), 'ok', ['title' => _('Einstellungen übernehmen')]) ?>
    </footer>


    <? foreach ($lock_config['groups'] as $group => $group_title) : ?>
        <? $attributes = array_filter(array_map(function ($a) use ($group) {
            return $a['group'] == $group ? $a['name'] : null;
        }, $lock_config['attributes'])); ?>
        <? if (count($attributes)) : ?>
            <br>
            <table class="default">
                <caption>
                    <?= htmlready($group_title) ?>
                </caption>
                <colgroup>
                    <col style="width: 70%">
                    <col style="width: 15%">
                    <col style="width: 15%">
                </colgroup>
                <thead>
                <tr>
                    <th></th>
                    <th><?= _('gesperrt') ?></th>
                    <th><?= _('nicht gesperrt') ?></th>
                </tr>
                </thead>
                <tbody>
                <? foreach ($attributes as $attr => $attr_name) : ?>
                    <tr>
                        <td>
                            <?= htmlready($attr_name) ?>
                        </td>
                        <td>
                            <input type="radio"
                                   name="lockdata_attributes[<?= $attr ?>]"
                                   <?= !empty($lock_rule['attributes'][$attr]) ? 'checked' : '' ?>
                                   value="1">
                        </td>
                        <td>
                            <input type="radio"
                                   name="lockdata_attributes[<?= $attr ?>]"
                                   <?= empty($lock_rule['attributes'][$attr]) ? 'checked' : '' ?>
                                   value="0"/>
                        </td>
                    </tr>
                <? endforeach ?>
                </tbody>
            </table>

        <footer>
            <?= Button::create(_('Übernehmen'), 'ok', ['title' => _('Einstellungen übernehmen')]) ?>
        </footer>
        <? endif ?>

    <? endforeach ?>
</form>