アドミンジェネレーターではCredentialを設定しておく
管理ページでアドミンジェネレーターを使う場合には、
入る権限がない人に対して、万が一にでも見せちゃいけない項目には、Credentialを設定しておく。
generator: param: fields: mail_address: {name: メールアドレス, credentials: [admin]}
fieldsに設定すると、listやeditに設定しなくてもいい。
あとは、filterを追加して、IPやPHP_AUTH_USERなどで適宜、許可してあげればいい。
ただ、ひとつ問題があって、
アドミンジェネレーターのlistアクションのfilterは表示されないが、動いてしまう。
修正する箇所は、ジェネレーターのtemplate/actions/actions.class.phpのaddFiltersCriteriaのところ
*************** *** 355,360 **** --- 355,365 ---- <?php if ($this->getParameterValue('list.filters')): ?> <?php foreach ($this->getColumns('list.filters') as $column): $type = $column->getCreoleType() ?> <?php if (($column->isPartial() || $column->isComponent()) && $this->getParameterValue('list.fields.'.$column->getName().'.filter_criteria_disabled')) continue ?> + <?php $credentials = $this->getParameterValue('list.fields.'.$column->getName().'.credentials') ?> + <?php if ($credentials): $credentials = str_replace("\n", ' ', var_export($credentials, true)) ?> + if ($this->getUser()->hasCredential(<?php echo $credentials ?>)) + { + <?php endif; ?> if (isset($this->filters['<?php echo $column->getName() ?>_is_empty'])) { $criterion = $c->getNewCriterion(<?php echo $this->getPeerClassName() ?>::<?php echo strtoupper($column->getName()) ?>, ''); *************** *** 407,412 **** --- 412,420 ---- <?php endif; ?> } <?php endif; ?> + <?php if ($credentials): ?> + } + <?php endif; ?> <?php endforeach; ?> <?php endif; ?> }
見れる人だけには見せるという方針でやらないと、いろいろ面倒なことになったりする場合もあるので。