From 1aba0054c14340a19f6db9fc74ca84ceb2bbc11d Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 11 Aug 2014 19:48:40 +0200 Subject: [PATCH] Adding SettingsBundle. --- app/AppKernel.php | 1 + app/config/config.yml | 4 + app/config/routing.yml | 14 +- .../CoreBundle/Entity/SettingsCurrent.php | 57 ++++++- .../CoreBundle/Resources/config/services.yml | 7 +- .../views/Settings/platform.html.twig | 22 +++ .../Settings/AgendaSettingsSchema.php | 33 +++++ .../Settings/ChatSettingsSchema.php | 31 ++++ .../Settings/CourseSettingsSchema.php | 59 ++++++++ .../Settings/DisplaySettingsSchema.php | 68 +++++++++ .../Settings/DocumentSettingsSchema.php | 59 ++++++++ .../Settings/DropboxSettingsSchema.php | 35 +++++ .../Settings/EditorSettingsSchema.php | 45 ++++++ .../Settings/ExerciseSettingsSchema.php | 40 +++++ .../Settings/ForumSettingsSchema.php | 29 ++++ .../Settings/GlossarySettingsSchema.php | 33 +++++ .../Settings/GradebookSettingsSchema.php | 42 ++++++ .../Settings/GroupSettingsSchema.php | 31 ++++ .../Settings/MailSettingsSchema.php | 31 ++++ .../Settings/MessageSettingsSchema.php | 32 ++++ .../Settings/PlatformSettingsSchema.php | 37 +++-- .../Settings/ProfileSettingsSchema.php | 42 ++++++ .../Settings/RegistrationSettingsSchema.php | 55 +++++++ .../Settings/SearchSettingsSchema.php | 33 +++++ .../Settings/SecuritySettingsSchema.php | 40 +++++ .../Settings/SessionSettingsSchema.php | 39 +++++ .../Settings/SkillSettingsSchema.php | 33 +++++ .../Settings/SocialSettingsSchema.php | 31 ++++ .../Settings/SurveySettingsSchema.php | 31 ++++ .../Settings/TrackingSettingsSchema.php | 31 ++++ .../Process/Step/SetupStep.php | 20 ++- .../ChamiloLMSSettingsBundle.php | 13 ++ .../ChamiloLMSSettingsExtension.php | 25 ++++ .../DependencyInjection/Configuration.php | 29 ++++ .../Manager/SettingsManager.php | 140 ++++++++++++++++++ .../Resources/config/services.xml | 11 ++ .../SettingsBundle/Resources/doc/index.rst | 0 .../Resources/translations/messages.fr.xlf | 11 ++ .../Resources/views/Default/index.html.twig | 1 + 39 files changed, 1264 insertions(+), 31 deletions(-) create mode 100644 src/ChamiloLMS/CoreBundle/Resources/views/Settings/platform.html.twig create mode 100644 src/ChamiloLMS/CoreBundle/Settings/AgendaSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/ChatSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/CourseSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/DisplaySettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/DocumentSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/DropboxSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/EditorSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/ExerciseSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/ForumSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/GlossarySettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/GradebookSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/GroupSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/MailSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/MessageSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/ProfileSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/RegistrationSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/SearchSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/SecuritySettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/SessionSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/SkillSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/SocialSettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/SurveySettingsSchema.php create mode 100644 src/ChamiloLMS/CoreBundle/Settings/TrackingSettingsSchema.php create mode 100644 src/ChamiloLMS/SettingsBundle/ChamiloLMSSettingsBundle.php create mode 100644 src/ChamiloLMS/SettingsBundle/DependencyInjection/ChamiloLMSSettingsExtension.php create mode 100644 src/ChamiloLMS/SettingsBundle/DependencyInjection/Configuration.php create mode 100644 src/ChamiloLMS/SettingsBundle/Manager/SettingsManager.php create mode 100644 src/ChamiloLMS/SettingsBundle/Resources/config/services.xml create mode 100644 src/ChamiloLMS/SettingsBundle/Resources/doc/index.rst create mode 100644 src/ChamiloLMS/SettingsBundle/Resources/translations/messages.fr.xlf create mode 100644 src/ChamiloLMS/SettingsBundle/Resources/views/Default/index.html.twig diff --git a/app/AppKernel.php b/app/AppKernel.php index d4f3ea31f1..3f55bd528a 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -147,6 +147,7 @@ class AppKernel extends Kernel //new JMS\SerializerBundle\JMSSerializerBundle($this), new Sp\BowerBundle\SpBowerBundle(), new Oro\Bundle\MigrationBundle\OroMigrationBundle(), + new ChamiloLMS\SettingsBundle\ChamiloLMSSettingsBundle(), ); if (in_array($this->getEnvironment(), array('dev', 'test'))) { diff --git a/app/config/config.yml b/app/config/config.yml index 71a191d5f7..fdf229d607 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -234,6 +234,10 @@ sylius_resource: sylius_settings: driver: doctrine/orm + classes: + parameter: + model: ChamiloLMS\CoreBundle\Entity\SettingsCurrent + doctrine_cache: providers: diff --git a/app/config/routing.yml b/app/config/routing.yml index 36b00d2536..b5b7a862ea 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -56,12 +56,20 @@ login_check: chamilolms_installer: resource: "@ChamiloLMSInstallerBundle/Resources/config/routing.yml" -sylius_settings: - pattern: /settings +chamilolms_corebundle_platform_settings: + pattern: /settings/platform defaults: _controller: sylius.controller.settings:updateAction namespace: platform - template: SyliusSettingsBundle:Settings:update.html.twig + template: ChamiloLMSCoreBundle:Settings:platform.html.twig + +chamilolms_corebundle_course_settings: + pattern: /settings/course + defaults: + _controller: sylius.controller.settings:updateAction + namespace: course + template: ChamiloLMSCoreBundle:Settings:platform.html.twig + # Always at the end core_bundle: diff --git a/src/ChamiloLMS/CoreBundle/Entity/SettingsCurrent.php b/src/ChamiloLMS/CoreBundle/Entity/SettingsCurrent.php index 0240fee27d..429806567a 100644 --- a/src/ChamiloLMS/CoreBundle/Entity/SettingsCurrent.php +++ b/src/ChamiloLMS/CoreBundle/Entity/SettingsCurrent.php @@ -3,6 +3,7 @@ namespace ChamiloLMS\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; +use Sylius\Bundle\SettingsBundle\Model\ParameterInterface; /** * SettingsCurrent @@ -10,7 +11,7 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Table(name="settings_current", uniqueConstraints={@ORM\UniqueConstraint(name="unique_setting", columns={"variable", "subkey", "category", "access_url"})}, indexes={@ORM\Index(name="access_url", columns={"access_url"}), @ORM\Index(name="idx_settings_current_au_cat", columns={"access_url", "category"})}) * @ORM\Entity */ -class SettingsCurrent +class SettingsCurrent implements ParameterInterface { /** * @var integer @@ -109,9 +110,9 @@ class SettingsCurrent { $this->accessUrl = 1; $this->accessUrlLocked = 0; + $this->access_url_changeable = 1; } - /** * Get id * @@ -397,4 +398,56 @@ class SettingsCurrent { return $this->accessUrlLocked; } + + /** + * {@inheritdoc} + */ + public function getNamespace() + { + return $this->getCategory(); + } + + /** + * {@inheritdoc} + */ + public function setNamespace($namespace) + { + $this->setCategory($namespace); + return $this; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->getVariable(); + } + + /** + * {@inheritdoc} + */ + public function setName($name) + { + $this->setTitle($name); + $this->setVariable($name); + return $this; + } + + /** + * {@inheritdoc} + */ + public function getValue() + { + return $this->getSelectedValue(); + } + + /** + * {@inheritdoc} + */ + public function setValue($value) + { + $this->setSelectedValue($value); + return $this; + } } diff --git a/src/ChamiloLMS/CoreBundle/Resources/config/services.yml b/src/ChamiloLMS/CoreBundle/Resources/config/services.yml index e24cc64858..c23bbcae85 100644 --- a/src/ChamiloLMS/CoreBundle/Resources/config/services.yml +++ b/src/ChamiloLMS/CoreBundle/Resources/config/services.yml @@ -116,4 +116,9 @@ services: chamilolms.settings_schema.platform: class: ChamiloLMS\CoreBundle\Settings\PlatformSettingsSchema tags: - - { name: sylius.settings_schema, namespace: platform } + - { name: sylius.settings_schema, namespace: platform } + + chamilolms.settings_schema.course: + class: ChamiloLMS\CoreBundle\Settings\CourseSettingsSchema + tags: + - { name: sylius.settings_schema, namespace: course } diff --git a/src/ChamiloLMS/CoreBundle/Resources/views/Settings/platform.html.twig b/src/ChamiloLMS/CoreBundle/Resources/views/Settings/platform.html.twig new file mode 100644 index 0000000000..7940957413 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Resources/views/Settings/platform.html.twig @@ -0,0 +1,22 @@ + +{% from 'SyliusResourceBundle:Macros:actions.html.twig' import update %} + +{% block topbar %} + +{% endblock %} + +{% block content %} + + +{{ form_errors(form) }} + +
+ {{ form_rest(form) }} + {{ update() }} +
+{% endblock %} diff --git a/src/ChamiloLMS/CoreBundle/Settings/AgendaSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/AgendaSettingsSchema.php new file mode 100644 index 0000000000..9e1927f259 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/AgendaSettingsSchema.php @@ -0,0 +1,33 @@ +setDefaults(array( + 'allow_personal_agenda' => '', + 'display_mini_month_calendar' => '', + 'display_upcoming_events' => '', + 'number_of_upcoming_events' => '', + 'default_calendar_view' => '', + )) + ->setAllowedTypes(array( + 'allow_personal_agenda' => array('string') + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('allow_personal_agenda') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/ChatSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/ChatSettingsSchema.php new file mode 100644 index 0000000000..7dc7db015e --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/ChatSettingsSchema.php @@ -0,0 +1,31 @@ +setDefaults(array( + 'show_chat_folder' => '', + 'allow_global_chat' => '', + + )) + ->setAllowedTypes(array( + 'allow_personal_agenda' => array('string') + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('allow_personal_agenda') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/CourseSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/CourseSettingsSchema.php new file mode 100644 index 0000000000..aac4208238 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/CourseSettingsSchema.php @@ -0,0 +1,59 @@ +setDefaults(array( + 'homepage_view' => '', + 'show_toolshortcuts' => '', + 'course_create_active_tools' => '', //course_progress attendances notebook glossary survey 'gradebook course_description, agenda, documents, learning_path,links, announcements, forums dropbox quiz users groups chat online_conference student_publications wiki + 'display_coursecode_in_courselist' => '', + 'display_teacher_in_courselist' => '', + 'student_view_enabled' => '', + 'go_to_course_after_login' => '', + 'show_navigation_menu' => '', + 'enable_tool_introduction' => '', + 'breadcrumbs_course_homepage' => '', + 'example_material_course_creation' => '', + 'allow_course_theme' => '', + 'allow_users_to_create_courses' => '', + 'show_courses_descriptions_in_catalog' => '', + 'send_email_to_admin_when_create_course' => '', + 'allow_user_course_subscription_by_course_admin' => '', + 'course_validation' => '', + 'course_validation_terms_and_conditions_url' => '', + 'course_hide_tools' => '', + 'scorm_cumulative_session_time' => '', + 'courses_default_creation_visibility' => '', + 'allow_public_certificates' => '', + )) + ->setAllowedTypes(array( + 'homepage_view' => array('string'), + 'show_toolshortcuts' => array('string'), + 'course_create_active_tools' => array('string'), + 'display_coursecode_in_courselist' => array('string'), + 'display_teacher_in_courselist' => array('string'), + 'student_view_enabled' => array('string'), + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('homepage_view') + ->add('show_toolshortcuts') + ->add('course_create_active_tools') + ->add('display_coursecode_in_courselist') + ->add('display_teacher_in_courselist') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/DisplaySettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/DisplaySettingsSchema.php new file mode 100644 index 0000000000..fd395dfde3 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/DisplaySettingsSchema.php @@ -0,0 +1,68 @@ +setDefaults(array( + 'enable_help_link' => '', + 'show_administrator_data' => '', + 'show_tutor_data' => '', + 'show_teacher_data' => '', + 'showonline' => '', + 'allow_user_headings' => '', + 'time_limit_whosonline' => '', + 'allow_email_editor' => '', + 'show_email_addresses' => '', + 'show_number_of_courses' => '', + 'show_empty_course_categories' => '', + 'show_back_link_on_top_of_tree' => '', + 'show_different_course_language' => '', + 'display_categories_on_homepage' => '', + 'show_closed_courses' => '', + 'allow_students_to_browse_courses' => '', + 'show_link_bug_notification' => '', + 'accessibility_font_resize' => '', + 'show_admin_toolbar' => '', + 'show_hot_courses' => '', + 'user_name_order' => '', + 'user_name_sort_by' => '', + 'use_virtual_keyboard' => '', + 'disable_copy_paste' => '', + 'breadcrumb_navigation_display' => '', + 'bug_report_link' => '' + + + )) + ->setAllowedTypes(array( + 'enable_help_link' => array('string'), + 'show_administrator_data' => array('string'), + 'show_tutor_data' => array('string'), + 'show_teacher_data' => array('string'), + 'showonline' => array('string'), + 'allow_user_headings' => array('string'), + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('enable_help_link', 'choice', array('choices' => + array('true' => 'Yes', 'no' => 'No')) + ) + ->add('show_administrator_data') + ->add('show_tutor_data') + ->add('show_teacher_data') + ->add('showonline') + ->add('allow_user_headings') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/DocumentSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/DocumentSettingsSchema.php new file mode 100644 index 0000000000..96c16d50e7 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/DocumentSettingsSchema.php @@ -0,0 +1,59 @@ +setDefaults(array( + 'default_document_quotum' => '', + 'default_group_quotum' => '', + 'permanently_remove_deleted_files' => '', + 'upload_extensions_list_type' => '', + 'upload_extensions_blacklist' => '', + 'upload_extensions_whitelist' => '', + 'upload_extensions_skip' => '', + 'upload_extensions_replace_by' => '', + 'permissions_for_new_directories' => '', + 'permissions_for_new_files' => '', + 'show_glossary_in_documents' => '', + 'students_download_folders' => '', + 'users_copy_files' => '', + 'pdf_export_watermark_enable' => '', + 'pdf_export_watermark_by_course' => '', + 'pdf_export_watermark_text' => '', + 'students_export2pdf' => '', + 'show_users_folders' => '', + 'show_default_folders' => '', + 'enabled_text2audio' => '', + 'enable_nanogong' => '', + 'show_documents_preview' => '', + 'enable_wami_record' => '', + 'enable_webcam_clip' => '', + 'tool_visible_by_default_at_creation' => '',// documents + 'documents_default_visibility_defined_in_course' => '', + 'allow_personal_user_files' => '', + )) + ->setAllowedTypes(array( + 'default_document_quotum' => array('string'), + 'default_group_quotum' => array('string'), + 'permanently_remove_deleted_files' => array('string'), + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('default_document_quotum') + ->add('default_group_quotum') + ->add('permanently_remove_deleted_files') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/DropboxSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/DropboxSettingsSchema.php new file mode 100644 index 0000000000..31c4e2cac7 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/DropboxSettingsSchema.php @@ -0,0 +1,35 @@ +setDefaults(array( + 'dropbox_allow_overwrite' => '', + 'dropbox_max_filesize' => '', + 'dropbox_allow_just_upload' => '', + 'dropbox_allow_student_to_student' => '', + 'dropbox_allow_group' => '', + 'dropbox_allow_mailing' => '', + + )) + ->setAllowedTypes(array( + 'dropbox_allow_overwrite' => array('string') + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('dropbox_allow_overwrite') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/EditorSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/EditorSettingsSchema.php new file mode 100644 index 0000000000..ffce0dd938 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/EditorSettingsSchema.php @@ -0,0 +1,45 @@ +setDefaults(array( + 'math_mimetex' => '', + 'math_asciimathML' => '', + 'enabled_asciisvg' => '', + 'include_asciimathml_script' => '', + 'youtube_for_students' => '', + 'block_copy_paste_for_students' => '', + 'more_buttons_maximized_mode' => '', + 'enabled_wiris' => '', + 'allow_spellcheck' => '', + 'force_wiki_paste_as_plain_text' => '', + 'enabled_googlemaps' => '', + 'enabled_imgmap' => '', + 'enabled_support_svg' => '', + 'enabled_insertHtml' => '', + 'enabled_support_pixlr' => '', + 'htmlpurifier_wiki' => '', + 'enable_iframe_inclusion' => '', + )) + ->setAllowedTypes(array( + 'allow_personal_agenda' => array('string') + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('allow_personal_agenda') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/ExerciseSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/ExerciseSettingsSchema.php new file mode 100644 index 0000000000..386eb4f2e4 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/ExerciseSettingsSchema.php @@ -0,0 +1,40 @@ +setDefaults(array( + 'exercise_min_score' => '', + 'exercise_max_score' => '', + 'enable_quiz_scenario' => '', + )) + ->setAllowedTypes(array( + 'homepage_view' => array('string'), + 'show_toolshortcuts' => array('string'), + 'course_create_active_tools' => array('string'), + 'display_coursecode_in_courselist' => array('string'), + 'display_teacher_in_courselist' => array('string'), + 'student_view_enabled' => array('string'), + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('homepage_view') + ->add('show_toolshortcuts') + ->add('course_create_active_tools') + ->add('display_coursecode_in_courselist') + ->add('display_teacher_in_courselist') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/ForumSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/ForumSettingsSchema.php new file mode 100644 index 0000000000..b4064c053e --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/ForumSettingsSchema.php @@ -0,0 +1,29 @@ +setDefaults(array( + 'default_forum_view' => '', + )) + ->setAllowedTypes(array( + 'default_forum_view' => array('string') + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('default_forum_view') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/GlossarySettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/GlossarySettingsSchema.php new file mode 100644 index 0000000000..7b94750d67 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/GlossarySettingsSchema.php @@ -0,0 +1,33 @@ +setDefaults(array( + 'show_glossary_in_extra_tools' + + )) + ->setAllowedTypes(array( + 'show_glossary_in_extra_tools' => array('string'), + + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('enable_help_link', 'choice', array('choices' => + array('true' => 'Yes', 'no' => 'No')) + ); + + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/GradebookSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/GradebookSettingsSchema.php new file mode 100644 index 0000000000..926d7fab8d --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/GradebookSettingsSchema.php @@ -0,0 +1,42 @@ +setDefaults(array( + 'gradebook_enable' => '', + 'gradebook_score_display_coloring' => '', + 'gradebook_score_display_custom' => '', + 'gradebook_score_display_colorspl' => '', + 'gradebook_score_display_upperlim' => '', + 'gradebook_number_decimals' => '', + 'allow_hr_skills_management' => '', + 'teachers_can_change_score_settin' => '', + 'gradebook_enable_grade_model' => '', + 'teachers_can_change_grade_model_' => '', + 'gradebook_default_weight' => '', + 'gradebook_locking_enabled' => '', + 'gradebook_default_grade_model_id' => '', + 'gradebook_show_percentage_in_rep' => '' + )) + ->setAllowedTypes(array( + 'gradebook_enable' => array('string') + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('gradebook_enable') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/GroupSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/GroupSettingsSchema.php new file mode 100644 index 0000000000..152daeb593 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/GroupSettingsSchema.php @@ -0,0 +1,31 @@ +setDefaults(array( + 'allow_group_categories' => '' + )) + ->setAllowedTypes(array( + 'allow_group_categories' => array('string'), + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('allow_group_categories', 'choice', array('choices' => + array('true' => 'Yes', 'no' => 'No')) + ) + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/MailSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/MailSettingsSchema.php new file mode 100644 index 0000000000..efb193f7d2 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/MailSettingsSchema.php @@ -0,0 +1,31 @@ +setDefaults(array( + 'noreply_email_address' => '', + activate_email_template + + )) + ->setAllowedTypes(array( + 'noreply_email_address' => array('string') + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('noreply_email_address', 'email') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/MessageSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/MessageSettingsSchema.php new file mode 100644 index 0000000000..b55023d116 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/MessageSettingsSchema.php @@ -0,0 +1,32 @@ +setDefaults(array( + 'allow_message_tool' => '', + 'allow_send_message_to_all_platform_users' => '', + 'message_max_upload_filesize' => '', + + )) + ->setAllowedTypes(array( + 'allow_personal_agenda' => array('string') + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('allow_personal_agenda') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/PlatformSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/PlatformSettingsSchema.php index 09aade075b..200024db21 100644 --- a/src/ChamiloLMS/CoreBundle/Settings/PlatformSettingsSchema.php +++ b/src/ChamiloLMS/CoreBundle/Settings/PlatformSettingsSchema.php @@ -12,16 +12,24 @@ class PlatformSettingsSchema implements SchemaInterface { $builder ->setDefaults(array( - 'portal_name' => 'Campus Chamilo', - 'company_title' => 'Chamilo Association', - 'company_url' => 'http://www.chamilo.org', - 'enable_help_link' => '' + 'institution' => 'Campus Chamilo', + 'institution_url' => 'http://www.chamilo.org', + 'site_name' => 'Chamilo Association', + 'administrator_email' => '', + 'administrator_name' => '', + 'administrator_surname' => '', + 'administrator_phone' => '', + 'timezone_value' => '', + 'settings_latest_update' => '', )) ->setAllowedTypes(array( - 'portal_name' => array('string'), - 'company_title' => array('string'), - 'company_url' => array('string'), - 'enable_help_link' => array('string'), + 'institution' => array('string'), + 'institution_url' => array('string'), + 'site_name' => array('string'), + 'administrator_email' => array('string'), + 'administrator_name' => array('string'), + 'administrator_surname' => array('string'), + 'administrator_phone' => array('string') )) ; } @@ -29,12 +37,13 @@ class PlatformSettingsSchema implements SchemaInterface public function buildForm(FormBuilderInterface $builder) { $builder - ->add('portal_name') - ->add('company_title') - ->add('company_url') - ->add('enable_help_link', 'choice', array('choices' => - array('true' => 'Yes', 'no' => 'No')) - ) + ->add('institution') + ->add('institution_url') + ->add('site_name') + ->add('administrator_email') + ->add('administrator_name') + ->add('administrator_surname') + ->add('administrator_phone') ; } } diff --git a/src/ChamiloLMS/CoreBundle/Settings/ProfileSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/ProfileSettingsSchema.php new file mode 100644 index 0000000000..dce51162aa --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/ProfileSettingsSchema.php @@ -0,0 +1,42 @@ +setDefaults(array( + 'profile' => '', // name, officialcode, email, picture, login, password, language, phone openid, theme apikeys + 'extended_profile' => '', + 'account_valid_duration' => '', + 'split_users_upload_directory' => '', + 'user_selected_theme' => '', + 'use_users_timezone' => '', + 'allow_users_to_change_email_with_no_password' => '', + 'login_is_email' => '', + + + )) + ->setAllowedTypes(array( + 'profile' => array('string') + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('profile') + + /*->add('enable_help_link', 'choice', array('choices' => + array('true' => 'Yes', 'no' => 'No')) + )*/ + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/RegistrationSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/RegistrationSettingsSchema.php new file mode 100644 index 0000000000..2d9bc63e4d --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/RegistrationSettingsSchema.php @@ -0,0 +1,55 @@ +setDefaults(array( + 'registration' => '', //officialcode, email, language, phone + 'allow_registration' =>'' , + 'allow_registration_as_teacher' => '', + 'allow_lostpassword' => '', + 'page_after_login' => '', + 'extendedprofile_registration' => '', + 'allow_terms_conditions' => '', + 'student_page_after_login' => '', + 'teacher_page_after_login' => '', + 'drh_page_after_login' => '', + 'sessionadmin_page_after_login' => '', + 'student_autosubscribe' => '', + 'teacher_autosubscribe' => '', + 'drh_autosubscribe' => '', + 'sessionadmin_autosubscribe' => '', + 'platform_unsubscribe_allowed' => '', + )) + ->setAllowedTypes(array( + 'registration' => array('string'), + 'allow_registration' => array('string'), + 'allow_registration_as_teacher' => array('string'), + 'allow_lostpassword' => array('string'), + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('registration') + ->add('allow_registration') + ->add('allow_registration_as_teacher') + ->add('allow_lostpassword') + + + /*->add('enable_help_link', 'choice', array('choices' => + array('true' => 'Yes', 'no' => 'No')) + )*/ + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/SearchSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/SearchSettingsSchema.php new file mode 100644 index 0000000000..31ade78551 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/SearchSettingsSchema.php @@ -0,0 +1,33 @@ +setDefaults(array( + 'search_enabled' => '', + 'search_prefilter_prefix' => '', + 'search_show_unlinked_results' => '', + 'number_of_upcoming_events' => '', + + )) + ->setAllowedTypes(array( + 'allow_personal_agenda' => array('string') + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('allow_personal_agenda') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/SecuritySettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/SecuritySettingsSchema.php new file mode 100644 index 0000000000..aef59aecff --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/SecuritySettingsSchema.php @@ -0,0 +1,40 @@ +setDefaults(array( + 'filter_terms' => '', + 'allow_browser_sniffer' => '', + 'admins_can_set_users_pass' => '', + )) + ->setAllowedTypes(array( + 'homepage_view' => array('string'), + 'show_toolshortcuts' => array('string'), + 'course_create_active_tools' => array('string'), + 'display_coursecode_in_courselist' => array('string'), + 'display_teacher_in_courselist' => array('string'), + 'student_view_enabled' => array('string'), + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('homepage_view') + ->add('show_toolshortcuts') + ->add('course_create_active_tools') + ->add('display_coursecode_in_courselist') + ->add('display_teacher_in_courselist') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/SessionSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/SessionSettingsSchema.php new file mode 100644 index 0000000000..2a59fc66f8 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/SessionSettingsSchema.php @@ -0,0 +1,39 @@ +setDefaults(array( + 'add_users_by_coach' => '', + 'extend_rights_for_coach' => '', + 'show_session_coach' => '', + 'show_session_data' => '', + 'allow_coach_to_edit_course_session' => '', + 'show_groups_to_users' => '', + 'hide_courses_in_sessions' => '', + 'allow_session_admins_to_manage_all_sessions' => '', + 'session_tutor_reports_visibility' => '', + 'session_page_enabled' => '', + 'allow_teachers_to_create_sessions' => '', + )) + ->setAllowedTypes(array( + 'add_users_by_coach' => array('string') + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('add_users_by_coach') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/SkillSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/SkillSettingsSchema.php new file mode 100644 index 0000000000..f5d309a005 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/SkillSettingsSchema.php @@ -0,0 +1,33 @@ +setDefaults(array( + 'allow_skills_tool' => '', + 'display_mini_month_calendar' => '', + 'display_upcoming_events' => '', + 'number_of_upcoming_events' => '', + + )) + ->setAllowedTypes(array( + 'allow_personal_agenda' => array('string') + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('allow_personal_agenda') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/SocialSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/SocialSettingsSchema.php new file mode 100644 index 0000000000..c7c3df2880 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/SocialSettingsSchema.php @@ -0,0 +1,31 @@ +setDefaults(array( + 'allow_social_tool' => '', + allow_students_to_create_groups_in_social + + )) + ->setAllowedTypes(array( + 'allow_social_tool' => array('string') + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('allow_social_tool') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/SurveySettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/SurveySettingsSchema.php new file mode 100644 index 0000000000..7cbf80e0e9 --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/SurveySettingsSchema.php @@ -0,0 +1,31 @@ +setDefaults(array( + 'survey_email_sender_noreply' => '', + extend_rights_for_coach_on_survey + + )) + ->setAllowedTypes(array( + 'survey_email_sender_noreply' => array('string') + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('survey_email_sender_noreply') + ; + } +} diff --git a/src/ChamiloLMS/CoreBundle/Settings/TrackingSettingsSchema.php b/src/ChamiloLMS/CoreBundle/Settings/TrackingSettingsSchema.php new file mode 100644 index 0000000000..d58a88578d --- /dev/null +++ b/src/ChamiloLMS/CoreBundle/Settings/TrackingSettingsSchema.php @@ -0,0 +1,31 @@ +setDefaults(array( + 'header_extra_content' => '', + footer_extra_content + + )) + ->setAllowedTypes(array( + 'allow_personal_agenda' => array('string') + )) + ; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('allow_personal_agenda') + ; + } +} diff --git a/src/ChamiloLMS/InstallerBundle/Process/Step/SetupStep.php b/src/ChamiloLMS/InstallerBundle/Process/Step/SetupStep.php index 4c81ea09c7..998eaf9fe3 100644 --- a/src/ChamiloLMS/InstallerBundle/Process/Step/SetupStep.php +++ b/src/ChamiloLMS/InstallerBundle/Process/Step/SetupStep.php @@ -57,18 +57,16 @@ class SetupStep extends AbstractStep $settingsManager = $this->get('sylius.settings.manager'); $settings = $settingsManager->loadSettings('platform'); - $settings->set( - 'portal_name', - $form->get('portal')->get('portal_name')->getData() - ); - $settings->set( - 'company_title', - $form->get('portal')->get('company_title')->getData() - ); - $settings->set( - 'company_url', - $form->get('portal')->get('company_url')->getData() + $parameters = array( + 'institution' => $form->get('portal')->get('institution')->getData(), + 'institution_url' => $form->get('portal')->get('institution_url')->getData(), + 'site_name' => $form->get('portal')->get('site_name')->getData(), + 'administrator_email' => $adminUser->getEmail(), + 'administrator_name' => $adminUser->getName(), + 'administrator_surname' => $adminUser->getLastName(), + 'administrator_phone' => $adminUser->getPhone() ); + $settings->setParameters($parameters); $settingsManager->saveSettings('platform', $settings); diff --git a/src/ChamiloLMS/SettingsBundle/ChamiloLMSSettingsBundle.php b/src/ChamiloLMS/SettingsBundle/ChamiloLMSSettingsBundle.php new file mode 100644 index 0000000000..03144607ec --- /dev/null +++ b/src/ChamiloLMS/SettingsBundle/ChamiloLMSSettingsBundle.php @@ -0,0 +1,13 @@ +load('services.xml'); + } +} diff --git a/src/ChamiloLMS/SettingsBundle/DependencyInjection/Configuration.php b/src/ChamiloLMS/SettingsBundle/DependencyInjection/Configuration.php new file mode 100644 index 0000000000..a77fe98d0d --- /dev/null +++ b/src/ChamiloLMS/SettingsBundle/DependencyInjection/Configuration.php @@ -0,0 +1,29 @@ +root('chamilo_lms_settings'); + + // Here you should define the parameters that are allowed to + // configure your bundle. See the documentation linked above for + // more information on that topic. + + return $treeBuilder; + } +} diff --git a/src/ChamiloLMS/SettingsBundle/Manager/SettingsManager.php b/src/ChamiloLMS/SettingsBundle/Manager/SettingsManager.php new file mode 100644 index 0000000000..dc49f2ace3 --- /dev/null +++ b/src/ChamiloLMS/SettingsBundle/Manager/SettingsManager.php @@ -0,0 +1,140 @@ + + */ +class SettingsManager extends SyliusSessionManager +{ + /** + * {@inheritdoc} + */ + public function loadSettings($namespace) + { + if (isset($this->resolvedSettings[$namespace])) { + return $this->resolvedSettings[$namespace]; + } + + if ($this->cache->contains($namespace)) { + $parameters = $this->cache->fetch($namespace); + } else { + $parameters = $this->getParameters($namespace); + } + + $schema = $this->schemaRegistry->getSchema($namespace); + + $settingsBuilder = new SettingsBuilder(); + $schema->buildSettings($settingsBuilder); + + foreach ($settingsBuilder->getTransformers() as $parameter => $transformer) { + if (array_key_exists($parameter, $parameters)) { + $parameters[$parameter] = $transformer->reverseTransform($parameters[$parameter]); + } + } + + $parameters = $settingsBuilder->resolve($parameters); + + return $this->resolvedSettings[$namespace] = new Settings($parameters); + } + + /** + * {@inheritdoc} + * @throws ValidatorException + */ + public function saveSettings($namespace, Settings $settings) + { + $schema = $this->schemaRegistry->getSchema($namespace); + + $settingsBuilder = new SettingsBuilder(); + $schema->buildSettings($settingsBuilder); + + $parameters = $settingsBuilder->resolve($settings->getParameters()); + + foreach ($settingsBuilder->getTransformers() as $parameter => $transformer) { + if (array_key_exists($parameter, $parameters)) { + $parameters[$parameter] = $transformer->transform($parameters[$parameter]); + } + } + + if (isset($this->resolvedSettings[$namespace])) { + $this->resolvedSettings[$namespace]->setParameters($parameters); + } + + $persistedParameters = $this->parameterRepository->findBy(array('category' => $namespace)); + $persistedParametersMap = array(); + + foreach ($persistedParameters as $parameter) { + $persistedParametersMap[$parameter->getName()] = $parameter; + } + + foreach ($parameters as $name => $value) { + if (isset($persistedParametersMap[$name])) { + $persistedParametersMap[$name]->setValue($value); + } else { + /** @var SettingsCurrent $parameter */ + $parameter = $this->parameterRepository->createNew(); + + $parameter + ->setNamespace($namespace) + ->setName($name) + ->setValue($value) + ->setAccessUrlChangeable(1) + ; + + /* @var $errors ConstraintViolationListInterface */ + $errors = $this->validator->validate($parameter); + if (0 < $errors->count()) { + throw new ValidatorException($errors->get(0)->getMessage()); + } + + $this->parameterManager->persist($parameter); + } + } + + $this->parameterManager->flush(); + + $this->cache->save($namespace, $parameters); + } + + /** + * Load parameter from database. + * + * @param string $namespace + * + * @return array + */ + private function getParameters($namespace) + { + $parameters = array(); + + foreach ($this->parameterRepository->findBy(array('category' => $namespace)) as $parameter) { + $parameters[$parameter->getName()] = $parameter->getValue(); + } + + return $parameters; + } +} diff --git a/src/ChamiloLMS/SettingsBundle/Resources/config/services.xml b/src/ChamiloLMS/SettingsBundle/Resources/config/services.xml new file mode 100644 index 0000000000..1a0871998c --- /dev/null +++ b/src/ChamiloLMS/SettingsBundle/Resources/config/services.xml @@ -0,0 +1,11 @@ + + + + + + ChamiloLMS\SettingsBundle\Manager\SettingsManager + + + diff --git a/src/ChamiloLMS/SettingsBundle/Resources/doc/index.rst b/src/ChamiloLMS/SettingsBundle/Resources/doc/index.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/ChamiloLMS/SettingsBundle/Resources/translations/messages.fr.xlf b/src/ChamiloLMS/SettingsBundle/Resources/translations/messages.fr.xlf new file mode 100644 index 0000000000..fd59e6c166 --- /dev/null +++ b/src/ChamiloLMS/SettingsBundle/Resources/translations/messages.fr.xlf @@ -0,0 +1,11 @@ + + + + + + Symfony2 is great + J'aime Symfony2 + + + + diff --git a/src/ChamiloLMS/SettingsBundle/Resources/views/Default/index.html.twig b/src/ChamiloLMS/SettingsBundle/Resources/views/Default/index.html.twig new file mode 100644 index 0000000000..4ce626e9be --- /dev/null +++ b/src/ChamiloLMS/SettingsBundle/Resources/views/Default/index.html.twig @@ -0,0 +1 @@ +Hello {{ name }}!