parent
eecc085e86
commit
62e1de4996
@ -0,0 +1,9 @@ |
||||
{% macro avatar(image, alt, class) %} |
||||
{% if image %} |
||||
<img src="{{ asset(image) }}" class="{{class|default('img-circle')}}" alt="{{ alt }}" /> |
||||
{% else %} |
||||
{#{% image '@avatar_img' %}#} |
||||
{#<img src="{{ asset_url }}" class="{{ class|default('img-circle') }}" alt="{{alt}}" />#} |
||||
{#{% endimage %}#} |
||||
{% endif %} |
||||
{% endmacro %} |
@ -0,0 +1,150 @@ |
||||
<?php |
||||
|
||||
namespace Chamilo\UserBundle\Admin; |
||||
|
||||
use Sonata\UserBundle\Admin\Model\UserAdmin as BaseUserAdmin; |
||||
use Sonata\AdminBundle\Form\FormMapper; |
||||
|
||||
/** |
||||
* Class UserAdmin |
||||
* @package Chamilo\UserBundle\Admin |
||||
*/ |
||||
class UserAdmin extends BaseUserAdmin |
||||
{ |
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function configureFormFields(FormMapper $formMapper) |
||||
{ |
||||
// define group zoning |
||||
$formMapper |
||||
->tab('User') |
||||
->with('Profile', array('class' => 'col-md-6'))->end() |
||||
->with('General', array('class' => 'col-md-6'))->end() |
||||
->with('Social', array('class' => 'col-md-6'))->end() |
||||
->end() |
||||
->tab('Security') |
||||
->with('Status', array('class' => 'col-md-4'))->end() |
||||
->with('Groups', array('class' => 'col-md-4'))->end() |
||||
->with('Keys', array('class' => 'col-md-4'))->end() |
||||
->with('Roles', array('class' => 'col-md-12'))->end() |
||||
->end() |
||||
->tab('ExtraFields') |
||||
->with('ExtraFields', array('class' => 'col-md-4'))->end() |
||||
->end() |
||||
; |
||||
|
||||
$now = new \DateTime(); |
||||
|
||||
$formMapper |
||||
->tab('User') |
||||
->with('General') |
||||
->add('username') |
||||
->add('email') |
||||
->add('plainPassword', 'text', array( |
||||
'required' => (!$this->getSubject() || is_null($this->getSubject()->getId())) |
||||
)) |
||||
->end() |
||||
->with('Profile') |
||||
->add('dateOfBirth', 'sonata_type_date_picker', array( |
||||
'years' => range(1900, $now->format('Y')), |
||||
'dp_min_date' => '1-1-1900', |
||||
'dp_max_date' => $now->format('c'), |
||||
'required' => false |
||||
)) |
||||
->add('firstname', null, array('required' => false)) |
||||
->add('lastname', null, array('required' => false)) |
||||
->add('website', 'url', array('required' => false)) |
||||
->add('biography', 'text', array('required' => false)) |
||||
->add('gender', 'sonata_user_gender', array( |
||||
'required' => true, |
||||
'translation_domain' => $this->getTranslationDomain() |
||||
)) |
||||
->add('locale', 'locale', array('required' => false)) |
||||
->add('timezone', 'timezone', array('required' => false)) |
||||
->add('phone', null, array('required' => false)) |
||||
->end() |
||||
->with('Social') |
||||
->add('facebookUid', null, array('required' => false)) |
||||
->add('facebookName', null, array('required' => false)) |
||||
->add('twitterUid', null, array('required' => false)) |
||||
->add('twitterName', null, array('required' => false)) |
||||
->add('gplusUid', null, array('required' => false)) |
||||
->add('gplusName', null, array('required' => false)) |
||||
->end() |
||||
->end() |
||||
; |
||||
|
||||
if ($this->getSubject() && !$this->getSubject()->hasRole('ROLE_SUPER_ADMIN')) { |
||||
$formMapper |
||||
->tab('Security') |
||||
->with('Status') |
||||
->add('locked', null, array('required' => false)) |
||||
->add('expired', null, array('required' => false)) |
||||
->add('enabled', null, array('required' => false)) |
||||
->add('credentialsExpired', null, array('required' => false)) |
||||
->end() |
||||
->with('Groups') |
||||
->add('groups', 'sonata_type_model', array( |
||||
'required' => false, |
||||
'expanded' => true, |
||||
'multiple' => true |
||||
)) |
||||
->end() |
||||
->with('Roles') |
||||
->add('realRoles', 'sonata_security_roles', array( |
||||
'label' => 'form.label_roles', |
||||
'expanded' => true, |
||||
'multiple' => true, |
||||
'required' => false |
||||
)) |
||||
->end() |
||||
->end() |
||||
; |
||||
} |
||||
|
||||
$formMapper |
||||
->tab('Security') |
||||
->with('Keys') |
||||
->add('token', null, array('required' => false)) |
||||
->add('twoStepVerificationCode', null, array('required' => false)) |
||||
->end() |
||||
->end() |
||||
; |
||||
|
||||
$formMapper |
||||
->tab('ExtraFields') |
||||
->with('ExtraFields') |
||||
->add('extraFields', 'sonata_type_collection', array( |
||||
'cascade_validation' => true, |
||||
'type_options' => array( |
||||
// Prevents the "Delete" option from being displayed |
||||
'delete' => false, |
||||
'delete_options' => array( |
||||
// You may otherwise choose to put the field but hide it |
||||
'type' => 'hidden', |
||||
// In that case, you need to fill in the options as well |
||||
'type_options' => array( |
||||
'mapped' => false, |
||||
'required' => false, |
||||
) |
||||
) |
||||
) |
||||
), array( |
||||
'allow_delete' => true, |
||||
'by_reference' => false, |
||||
'edit' => 'inline', |
||||
'inline' => 'table', |
||||
'admin_code' => 'sonata.admin.user_extra_field_values' |
||||
/* 'edit' => 'inline', |
||||
'inline' => 'table', |
||||
'sortable' => 'position',*/ |
||||
) |
||||
) |
||||
->end() |
||||
->end() |
||||
; |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,70 @@ |
||||
<?php |
||||
|
||||
namespace Chamilo\UserBundle\Admin; |
||||
|
||||
use Sonata\AdminBundle\Admin\Admin; |
||||
use Sonata\AdminBundle\Form\FormMapper; |
||||
use Sonata\AdminBundle\Datagrid\DatagridMapper; |
||||
use Sonata\AdminBundle\Datagrid\ListMapper; |
||||
use Sonata\AdminBundle\Show\ShowMapper; |
||||
|
||||
|
||||
/** |
||||
* Class UserAdmin |
||||
* @package Chamilo\UserBundle\Admin |
||||
*/ |
||||
class UserField extends Admin |
||||
{ |
||||
/** |
||||
* @param FormMapper $formMapper |
||||
*/ |
||||
protected function configureFormFields(FormMapper $formMapper) |
||||
{ |
||||
$formMapper |
||||
->add('field_type', 'text') |
||||
->add('field_variable', 'text') |
||||
->add('field_display_text', 'text') |
||||
->add('field_default_value', 'text') |
||||
->add('field_order', 'text') |
||||
->add('field_visible', 'text') |
||||
->add('field_changeable', 'text') |
||||
->add('field_filter', 'text') |
||||
->add('field_loggeable', 'text') |
||||
->add('configuration') |
||||
; |
||||
} |
||||
|
||||
/** |
||||
* @param ShowMapper $showMapper |
||||
*/ |
||||
protected function configureShowField(ShowMapper $showMapper) |
||||
{ |
||||
$showMapper |
||||
->add('id', 'text') |
||||
->add('field_type', 'text') |
||||
->add('field_variable', 'text') |
||||
; |
||||
} |
||||
|
||||
/** |
||||
* @param DatagridMapper $datagridMapper |
||||
*/ |
||||
protected function configureDatagridFilters(DatagridMapper $datagridMapper) |
||||
{ |
||||
/*$datagridMapper |
||||
->add('field_type') |
||||
;*/ |
||||
} |
||||
|
||||
/** |
||||
* @param ListMapper $listMapper |
||||
*/ |
||||
protected function configureListFields(ListMapper $listMapper) |
||||
{ |
||||
$listMapper |
||||
->addIdentifier('id') |
||||
->add('field_variable', 'text') |
||||
->add('field_type', 'text') |
||||
; |
||||
} |
||||
} |
@ -0,0 +1,64 @@ |
||||
<?php |
||||
|
||||
namespace Chamilo\UserBundle\Admin; |
||||
|
||||
use Sonata\AdminBundle\Admin\Admin; |
||||
use Sonata\AdminBundle\Form\FormMapper; |
||||
use Sonata\AdminBundle\Datagrid\DatagridMapper; |
||||
use Sonata\AdminBundle\Datagrid\ListMapper; |
||||
use Sonata\AdminBundle\Show\ShowMapper; |
||||
|
||||
|
||||
/** |
||||
* Class UserAdmin |
||||
* @package Chamilo\UserBundle\Admin |
||||
*/ |
||||
class UserFieldValuesAdmin extends Admin |
||||
{ |
||||
/** |
||||
* @param FormMapper $formMapper |
||||
*/ |
||||
protected function configureFormFields(FormMapper $formMapper) |
||||
{ |
||||
$formMapper |
||||
->add('field') |
||||
//->add('user') |
||||
->add('field_value', 'text') |
||||
->add('comment', 'textarea') |
||||
->add('author') |
||||
; |
||||
} |
||||
|
||||
/** |
||||
* @param ShowMapper $showMapper |
||||
*/ |
||||
protected function configureShowField(ShowMapper $showMapper) |
||||
{ |
||||
$showMapper |
||||
->add('id', 'text') |
||||
; |
||||
} |
||||
|
||||
/** |
||||
* @param DatagridMapper $datagridMapper |
||||
*/ |
||||
protected function configureDatagridFilters(DatagridMapper $datagridMapper) |
||||
{ |
||||
$datagridMapper |
||||
->add('id') |
||||
->add('field') |
||||
; |
||||
} |
||||
|
||||
/** |
||||
* @param ListMapper $listMapper |
||||
*/ |
||||
protected function configureListFields(ListMapper $listMapper) |
||||
{ |
||||
$listMapper |
||||
->addIdentifier('id') |
||||
->addIdentifier('field') |
||||
->addIdentifier('user') |
||||
; |
||||
} |
||||
} |
Loading…
Reference in new issue