38 lines
1.4 KiB
PHP
38 lines
1.4 KiB
PHP
<?php
|
|
|
|
function sf_guard_user_admin_select_tag($name, $value, $params = array())
|
|
{
|
|
|
|
$fc = stFunctionCache::getInstance('sfGuardUser');
|
|
|
|
$options = $fc->cacheCall(function() {
|
|
$group = sfGuardGroupPeer::retrieveByName('admin');
|
|
|
|
$c = new Criteria();
|
|
$c->addJoin(sfGuardUserPeer::ID, sfGuardUserGroupPeer::USER_ID, Criteria::LEFT_JOIN);
|
|
$cc = $c->getNewCriterion(sfGuardUserPeer::IS_SUPER_ADMIN, true);
|
|
$cc->addOr($c->getNewCriterion(sfGuardUserGroupPeer::GROUP_ID, $group->getId()));
|
|
$c->add($cc);
|
|
$c->addAscendingOrderByColumn(sfGuardUserPeer::USERNAME);
|
|
|
|
$results = array();
|
|
|
|
foreach (sfGuardUserPeer::doSelect($c) as $user)
|
|
{
|
|
if ($user->getIsSuperAdmin() || in_array('backend', $user->getAllPermissionNames()) && $user->hasModulePermission('stOrder.access') && $user->hasModulePermission('stOrder.modification'))
|
|
{
|
|
$results[$user->getId()] = $user->getUsername();
|
|
}
|
|
}
|
|
|
|
return $results;
|
|
}, array(), array('id' => 'sf_guard_user_admin_select_tag'));
|
|
|
|
if (isset($params['include_custom']) && is_array($params['include_custom']))
|
|
{
|
|
$options = array_replace($params['include_custom'], $options);
|
|
unset($params['include_custom']);
|
|
}
|
|
|
|
return select_tag($name, options_for_select($options, $value, $params));
|
|
} |