Adding user extra fields as models.

1.10.x
Julio Montoya 10 years ago
parent eecc085e86
commit 62e1de4996
  1. 121
      app/config/assetic.yml
  2. 6
      app/config/sonata/sonata_user.yml
  3. 4
      composer.json
  4. 10
      src/Chamilo/AdminThemeBundle/Resources/views/Macros/box.html.twig
  5. 9
      src/Chamilo/AdminThemeBundle/Resources/views/Macros/image.html.twig
  6. 2
      src/Chamilo/AdminThemeBundle/Resources/views/Navbar/messages.html.twig
  7. 2
      src/Chamilo/AdminThemeBundle/Resources/views/Navbar/user.html.twig
  8. 2
      src/Chamilo/AdminThemeBundle/Resources/views/Sidebar/menu.html.twig
  9. 2
      src/Chamilo/AdminThemeBundle/Resources/views/layout/login-layout.html.twig
  10. 24
      src/Chamilo/CoreBundle/Entity/ExtraFieldValues.php
  11. 53
      src/Chamilo/CoreBundle/Entity/UserFieldValues.php
  12. 1
      src/Chamilo/CoreBundle/Migrations/Schema/v2/Core.php
  13. 93
      src/Chamilo/CoreBundle/Resources/config/admin.yml
  14. 2
      src/Chamilo/CoreBundle/Resources/views/Navbar/user.html.twig
  15. 150
      src/Chamilo/UserBundle/Admin/UserAdmin.php
  16. 70
      src/Chamilo/UserBundle/Admin/UserField.php
  17. 64
      src/Chamilo/UserBundle/Admin/UserFieldValuesAdmin.php
  18. 12
      src/Chamilo/UserBundle/Entity/User.php

@ -11,18 +11,17 @@ assetic:
yui_css: { jar: "%kernel.root_dir%/../bin/yuicompressor.jar" }
assets:
chamilo_bootstrap:
chamilo_bootstrap_css:
inputs:
- "bundles/chamiloadmintheme/components/bootstrap/dist/css/bootstrap.min.css"
filters:
- cssrewrite
chamilo_font_awesome:
chamilo_font_awesome_css:
inputs:
- "bundles/chamiloadmintheme/components/fontawesome/css/font-awesome.min.css"
filters:
- cssrewrite
chamilo_ionicons:
chamilo_ionicons_css:
inputs:
- "bundles/chamiloadmintheme/components/adminlte/css/ionicons.css"
filters:
@ -30,9 +29,9 @@ assetic:
chamilo_css:
inputs:
- @chamilo_bootstrap
- @chamilo_font_awesome
- @chamilo_ionicons
- @chamilo_bootstrap_css
- @chamilo_font_awesome_css
- @chamilo_ionicons_css
- @ChamiloAdminThemeBundle/Resources/public/components/fullcalendar/dist/fullcalendar.min.css
- @ChamiloAdminThemeBundle/Resources/public/components/chosen-bower/chosen.css
- @ChamiloAdminThemeBundle/Resources/public/components/jquery-ui/themes/cupertino/jquery-ui.min.css
@ -94,32 +93,32 @@ assetic:
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.selectable.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.sortable.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.accordion.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.autocomplete.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.button.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.datepicker.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.dialog.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-blind.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-bounce.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-clip.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-drop.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-explode.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-fade.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-fold.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-highlight.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-pulsate.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-scale.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-shake.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-slide.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-transfer.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.menu.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.accordion.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.autocomplete.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.button.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.datepicker.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.dialog.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-blind.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-bounce.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-clip.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-drop.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-explode.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-fade.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-fold.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-highlight.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-pulsate.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-scale.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-shake.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-slide.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.effect-transfer.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.menu.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.position.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.progressbar.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.slider.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.spinner.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.tabs.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.progressbar.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.slider.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.spinner.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.tabs.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/jquery.ui.tooltip.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/i18n/jquery-ui-i18n.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/ui/i18n/jquery-ui-i18n.js
filters:
- yui_js
@ -157,35 +156,35 @@ assetic:
sonata_admin_js:
inputs:
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jquery/dist/jquery.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jquery.scrollTo/jquery.scrollTo.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jquery/dist/jquery.js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jquery.scrollTo/jquery.scrollTo.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js
# - %kernel.root_dir%/../web/bundles/sonatacore/vendor/moment/min/moment.min.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/bootstrap/dist/js/bootstrap.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js
# - %kernel.root_dir%/../web/bundles/sonatacore/vendor/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/select2/select2.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/jquery/jquery.form.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/jquery/jquery.confirmExit.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/App.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/Admin.js
- %kernel.root_dir%/../web/bundles/sonatacore/vendor/moment/min/moment.min.js
- @bootstrap_js
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js
- %kernel.root_dir%/../web/bundles/sonatacore/vendor/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js
- @ChamiloAdminThemeBundle/Resources/public/components/select2/select2.js
- %kernel.root_dir%/../web/bundles/sonataadmin/jquery/jquery.form.js
- %kernel.root_dir%/../web/bundles/sonataadmin/jquery/jquery.confirmExit.js
- %kernel.root_dir%/../web/bundles/sonataadmin/App.js
- %kernel.root_dir%/../web/bundles/sonataadmin/Admin.js
filters:
- yui_js
sonata_admin_css:
inputs:
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/bootstrap/dist/css/bootstrap.min.css
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/AdminLTE/css/font-awesome.min.css
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/AdminLTE/css/ionicons.min.css
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/AdminLTE/css/AdminLTE.css
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/themes/flick/jquery-ui.min.css
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/select2/select2.css
- @chamilo_bootstrap_css
- @chamilo_font_awesome_css
- @chamilo_ionicons_css
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/AdminLTE/css/AdminLTE.css
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jqueryui/themes/flick/jquery-ui.min.css
- @ChamiloAdminThemeBundle/Resources/public/components/select2/select2.css
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/select2/select2-bootstrap.css
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/x-editable/dist/bootstrap3-editable/css/bootstrap-editable.css
# - %kernel.root_dir%/../web/bundles/sonatacore/vendor/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css
# - %kernel.root_dir%/../web/bundles/sonataadmin/css/styles.css
# - %kernel.root_dir%/../web/bundles/sonataadmin/css/layout.css
- %kernel.root_dir%/../web/bundles/sonataadmin/vendor/x-editable/dist/bootstrap3-editable/css/bootstrap-editable.css
- %kernel.root_dir%/../web/bundles/sonatacore/vendor/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css
- %kernel.root_dir%/../web/bundles/sonataadmin/css/styles.css
- %kernel.root_dir%/../web/bundles/sonataadmin/css/layout.css
filters:
- cssrewrite
@ -193,22 +192,22 @@ assetic:
sonata_front_js:
inputs:
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/jquery/dist/jquery.js
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/bootstrap/dist/js/bootstrap.js
## - %kernel.root_dir%/../web/bundles/sonataproduct/js/product.js
# - %kernel.root_dir%/../web/bundles/sonatacore/js/base.js
# - %kernel.root_dir%/../web/bundles/sonatacore/select2/select2.min.js
## - %kernel.root_dir%/../web/bundles/sonatademo/js/demo.js
- @ChamiloAdminThemeBundle/Resources/public/components/jquery/dist/jquery.js
- @bootstrap_js
# - %kernel.root_dir%/../web/bundles/sonataproduct/js/product.js
- %kernel.root_dir%/../web/bundles/sonatacore/js/base.js
- @ChamiloAdminThemeBundle/Resources/public/components/select2/select2.js
# - %kernel.root_dir%/../web/bundles/sonatademo/js/demo.js
filters:
- yui_js
sonata_front_css:
inputs:
# - %kernel.root_dir%/../web/bundles/sonataadmin/vendor/bootstrap/dist/css/bootstrap.min.css
# - %kernel.root_dir%/../web/bundles/sonatacore/select2/select2.css
- @chamilo_bootstrap_css
- @ChamiloAdminThemeBundle/Resources/public/components/select2/select2.css
# - %kernel.root_dir%/../web/bundles/mopabootstrap/css/datepicker.css
#- %kernel.root_dir%/../web/bundles/sonatademo/css/demo.css
# - %kernel.root_dir%/../web/bundles/sonatademo/css/demo.css
filters:
- cssrewrite

@ -8,9 +8,9 @@ doctrine:
ChamiloUserBundle: ~
SonataUserBundle: ~
sonata_user:
#admin:
#user:
#class: Chamilo\UserBundle\Admin\UserAdmin
admin:
user:
class: Chamilo\UserBundle\Admin\UserAdmin
class: # Entity Classes
user: Chamilo\UserBundle\Entity\User

@ -114,7 +114,7 @@
"friendsofsymfony/comment-bundle": "~2.0",
"simplethings/entity-audit-bundle": "~0.5",
"simplethings/entity-audit-bundle": "~0.7",
"willdurand/faker-bundle": "~1.0",
"mopa/bootstrap-bundle": "v3.0.0-beta4",
@ -189,7 +189,7 @@
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "10.0.x-dev"
"dev-master": "2.0.x-dev"
}
}
}

@ -26,15 +26,7 @@
{% endmacro %}
{% 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 %}
{% macro menu_item(item) %}
<li id="{{ item.identifier }}" class=" {{ item.isActive ? 'active' : '' }} {{ item.hasChildren? 'treeview' : '' }}">

@ -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 %}

@ -1,5 +1,5 @@
<!-- Messages: style can be found in dropdown.less-->
{% import "ChamiloAdminThemeBundle:layout:macros.html.twig" as macro %}
{% import "ChamiloAdminThemeBundle:Macros:image.html.twig" as macro %}
<li class="dropdown messages-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-envelope"></i>

@ -1,5 +1,5 @@
<!-- User Account: style can be found in dropdown.less -->
{% import "ChamiloAdminThemeBundle:layout:macros.html.twig" as macro %}
{% import "ChamiloAdminThemeBundle:Macros:box.html.twig" as macro %}
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="glyphicon glyphicon-user"></i>

@ -1,5 +1,5 @@
<!-- sidebar menu: : style can be found in sidebar.less -->
{% import "ChamiloAdminThemeBundle:layout:macros.html.twig" as macro %}
{% import "ChamiloAdminThemeBundle:Macros:box.html.twig" as macro %}
<ul class="sidebar-menu">
{% for item in menu %}
{{ macro.menu_item(item) }}

@ -1,4 +1,4 @@
{% import "ChamiloAdminThemeBundle:layout:macros.html.twig" as macro %}
{% import "ChamiloAdminThemeBundle:Macros:box.html.twig" as macro %}
<!doctype html>
<!--[if lt IE 7 ]><html lang="en" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]><html lang="en" class="no-js ie7"> <![endif]-->

@ -5,6 +5,7 @@ namespace Chamilo\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Sylius\Component\Attribute\Model\AttributeValue as BaseAttributeValue;
use Chamilo\UserBundle\Entity\User;
/**
* ExtraFieldValues
@ -18,7 +19,7 @@ class ExtraFieldValues extends BaseAttributeValue
*
* @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
@ -27,7 +28,7 @@ class ExtraFieldValues extends BaseAttributeValue
*
* @ORM\Column(name="field_id", type="integer", precision=0, scale=0, nullable=false, unique=false)
*/
protected $fieldId;
//protected $fieldId;
/**
* @var \DateTime
@ -41,21 +42,16 @@ class ExtraFieldValues extends BaseAttributeValue
*
* @ORM\Column(name="user_id", type="string", precision=0, scale=0, nullable=false, unique=false)
*/
protected $userId;
//protected $userId;
/**
* @var string
* @Gedmo\Versioned
*
* @ORM\Column(name="comment", type="string", precision=0, scale=0, nullable=true, unique=false)
*/
protected $comment;
/**
* @ORM\OneToOne(targetEntity="Chamilo\UserBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $user;
/**
*
@ -65,11 +61,19 @@ class ExtraFieldValues extends BaseAttributeValue
$this->tms = new \DateTime();
}
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
/**
* @param $user
* @return $this
*/
public function setUser($user)
public function setUser(User $user)
{
$this->user = $user;

@ -5,6 +5,7 @@ namespace Chamilo\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Sylius\Component\Attribute\Model\AttributeTypes;
use Chamilo\UserBundle\Entity\User;
/**
* UserFieldValues
@ -21,7 +22,7 @@ class UserFieldValues extends ExtraFieldValues
*
* @ORM\Column(name="author_id", type="string", precision=0, scale=0, nullable=false, unique=false)
*/
protected $authorId;
//protected $authorId;
/**
* @var string
@ -37,6 +38,18 @@ class UserFieldValues extends ExtraFieldValues
*/
protected $field;
/**
* @ORM\OneToOne(targetEntity="Chamilo\UserBundle\Entity\User")
* @ORM\JoinColumn(name="author_id", referencedColumnName="id")
*/
protected $author;
/**
* @ORM\OneToOne(targetEntity="Chamilo\UserBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $user;
/**
* Set fieldValue
*
@ -73,6 +86,29 @@ class UserFieldValues extends ExtraFieldValues
return $this;
}
/**
* Get author
*
* @return User
*/
public function getAuthor()
{
return $this->author;
}
/**
* Get author
*
* @return User
*/
public function setAuthor($author)
{
$this->author = $author;
return $this;
}
/**
* Get questionId
*
@ -91,6 +127,18 @@ class UserFieldValues extends ExtraFieldValues
return $this->field;
}
/**
* @param $user
* @return $this
*/
public function setUser(User $user)
{
$this->user = $user;
$this->setUserId($user->getId());
return $this;
}
/**
* {@inheritdoc}
*/
@ -113,6 +161,9 @@ class UserFieldValues extends ExtraFieldValues
return $this->fieldValue;
}
/**
* @return string
*/
public function getType()
{
return $this->getExtraField()->getFieldTypeToString();

@ -111,6 +111,7 @@ class Core implements Migration, OrderedMigrationInterface
$queries->addQuery("CREATE TABLE session_rel_user (id_session INT NOT NULL, id_user INT NOT NULL, relation_type INT NOT NULL, moved_to INT DEFAULT NULL, moved_status INT DEFAULT NULL, moved_at DATETIME NOT NULL, INDEX idx_session_rel_user_id_user_moved (id_user, moved_to), PRIMARY KEY(id_session, id_user, relation_type)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$queries->addQuery("CREATE TABLE skill (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, short_code VARCHAR(100) NOT NULL, description LONGTEXT NOT NULL, access_url_id INT NOT NULL, icon VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$queries->addQuery("CREATE TABLE user_field_values (id INT AUTO_INCREMENT NOT NULL, field_id INT NOT NULL, tms DATETIME NOT NULL, user_id VARCHAR(255) NOT NULL, comment VARCHAR(255) DEFAULT NULL, author_id VARCHAR(255) NOT NULL, field_value LONGTEXT DEFAULT NULL, INDEX user_id (user_id, field_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$queries->addQuery("CREATE TABLE user_field_values_audit (id INT NOT NULL, rev INT NOT NULL, field_id INT DEFAULT NULL, author_id VARCHAR(255) DEFAULT NULL, user_id VARCHAR(255) DEFAULT NULL, field_value LONGTEXT DEFAULT NULL, tms DATETIME DEFAULT NULL, comment VARCHAR(255) DEFAULT NULL, revtype VARCHAR(4) NOT NULL, PRIMARY KEY(id, rev)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$queries->addQuery("CREATE TABLE user_friend_relation_type (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(20) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$queries->addQuery("CREATE TABLE session_field_options (id INT AUTO_INCREMENT NOT NULL, field_id INT NOT NULL, option_value LONGTEXT DEFAULT NULL, option_display_text VARCHAR(255) DEFAULT NULL, option_order INT DEFAULT NULL, priority INT DEFAULT NULL, priority_message VARCHAR(255) DEFAULT NULL, tms DATETIME NOT NULL, INDEX idx_session_field_options_field_id (field_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$queries->addQuery("CREATE TABLE session_path (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) DEFAULT NULL, description LONGTEXT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");

@ -23,46 +23,67 @@ services:
- [ setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.course_rel_user:
class: Chamilo\CoreBundle\Admin\CourseRelUserAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "LMS", label: "CourseRelUser" }
arguments:
- ~
- Chamilo\CoreBundle\Entity\CourseRelUser
- ~
calls:
- [ setTranslationDomain, [ChamiloCoreBundle]]
class: Chamilo\CoreBundle\Admin\CourseRelUserAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "LMS", label: "CourseRelUser" }
arguments:
- ~
- Chamilo\CoreBundle\Entity\CourseRelUser
- ~
calls:
- [ setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.session_rel_course:
class: Chamilo\CoreBundle\Admin\SessionRelCourseAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "LMS", label: "SessionRelCourseAdmin" }
arguments:
- ~
- Chamilo\CoreBundle\Entity\SessionRelCourse
- ~
calls:
- [ setTranslationDomain, [ChamiloCoreBundle]]
class: Chamilo\CoreBundle\Admin\SessionRelCourseAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "LMS", label: "SessionRelCourseAdmin" }
arguments:
- ~
- Chamilo\CoreBundle\Entity\SessionRelCourse
- ~
calls:
- [ setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.access_url:
class: Chamilo\CoreBundle\Admin\AccessUrlAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "LMS", label: "AccessUrlAdmin" }
arguments:
- ~
- Chamilo\CoreBundle\Entity\AccessUrl
- ~
calls:
- [ setTranslationDomain, [ChamiloCoreBundle]]
class: Chamilo\CoreBundle\Admin\AccessUrlAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "LMS", label: "AccessUrlAdmin" }
arguments:
- ~
- Chamilo\CoreBundle\Entity\AccessUrl
- ~
calls:
- [ setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.access_url_rel_course:
class: Chamilo\CoreBundle\Admin\AccessUrlRelCourseAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "LMS", label: "AccessUrlRelCourseAdmin" }
arguments:
- ~
- Chamilo\CoreBundle\Entity\AccessUrlRelCourse
- ~
calls:
- [ setTranslationDomain, [ChamiloCoreBundle]]
class: Chamilo\CoreBundle\Admin\AccessUrlRelCourseAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "LMS", label: "AccessUrlRelCourseAdmin" }
arguments:
- ~
- Chamilo\CoreBundle\Entity\AccessUrlRelCourse
- ~
calls:
- [ setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.user_field:
class: Chamilo\UserBundle\Admin\UserField
tags:
- { name: sonata.admin, manager_type: orm, group: "LMS", label: "UserField" }
arguments:
- ~
- Chamilo\CoreBundle\Entity\UserField
- ~
calls:
- [ setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.user_field_values:
class: Chamilo\UserBundle\Admin\UserFieldValuesAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "LMS", label: "UserFieldValues" }
arguments:
- ~
- Chamilo\CoreBundle\Entity\UserFieldValues
- ~
calls:
- [ setTranslationDomain, [ChamiloCoreBundle]]

@ -1,5 +1,5 @@
<!-- User Account: style can be found in dropdown.less -->
{% import "ChamiloAdminThemeBundle:layout:macros.html.twig" as macro %}
{% import "ChamiloAdminThemeBundle:Macros:box.html.twig" as macro %}
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="glyphicon glyphicon-user"></i>

@ -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')
;
}
}

@ -343,6 +343,7 @@ class User extends BaseUser implements ParticipantInterface, ThemeUser
$this->portals = new ArrayCollection();
$this->dropBoxSentFiles = new ArrayCollection();
$this->dropBoxReceivedFiles = new ArrayCollection();
$this->extraFields = new ArrayCollection();
//$this->userId = 0;
//$this->createdAt = new \DateTime();
//$this->updatedAt = new \DateTime();
@ -1400,10 +1401,10 @@ class User extends BaseUser implements ParticipantInterface, ThemeUser
*/
public function addExtraField(ExtraFieldValues $attribute)
{
if (!$this->hasExtraField($attribute)) {
//if (!$this->hasExtraField($attribute)) {
$attribute->setUser($this);
$this->extraFields->add($attribute);
}
//}
return $this;
}
@ -1413,10 +1414,10 @@ class User extends BaseUser implements ParticipantInterface, ThemeUser
*/
public function removeExtraField(ExtraFieldValues $attribute)
{
if ($this->hasExtraField($attribute)) {
//if ($this->hasExtraField($attribute)) {
$this->extraFields->removeElement($attribute);
$attribute->setUser($this);
}
//}
return $this;
}
@ -1426,6 +1427,9 @@ class User extends BaseUser implements ParticipantInterface, ThemeUser
*/
public function hasExtraField($attribute)
{
if (!$this->extraFields) {
return false;
}
return $this->extraFields->contains($attribute);
}

Loading…
Cancel
Save