Adding SettingsBundle.

1.10.x
Julio Montoya 12 years ago
parent e87f25fbb3
commit 1aba0054c1
  1. 1
      app/AppKernel.php
  2. 4
      app/config/config.yml
  3. 14
      app/config/routing.yml
  4. 57
      src/ChamiloLMS/CoreBundle/Entity/SettingsCurrent.php
  5. 7
      src/ChamiloLMS/CoreBundle/Resources/config/services.yml
  6. 22
      src/ChamiloLMS/CoreBundle/Resources/views/Settings/platform.html.twig
  7. 33
      src/ChamiloLMS/CoreBundle/Settings/AgendaSettingsSchema.php
  8. 31
      src/ChamiloLMS/CoreBundle/Settings/ChatSettingsSchema.php
  9. 59
      src/ChamiloLMS/CoreBundle/Settings/CourseSettingsSchema.php
  10. 68
      src/ChamiloLMS/CoreBundle/Settings/DisplaySettingsSchema.php
  11. 59
      src/ChamiloLMS/CoreBundle/Settings/DocumentSettingsSchema.php
  12. 35
      src/ChamiloLMS/CoreBundle/Settings/DropboxSettingsSchema.php
  13. 45
      src/ChamiloLMS/CoreBundle/Settings/EditorSettingsSchema.php
  14. 40
      src/ChamiloLMS/CoreBundle/Settings/ExerciseSettingsSchema.php
  15. 29
      src/ChamiloLMS/CoreBundle/Settings/ForumSettingsSchema.php
  16. 33
      src/ChamiloLMS/CoreBundle/Settings/GlossarySettingsSchema.php
  17. 42
      src/ChamiloLMS/CoreBundle/Settings/GradebookSettingsSchema.php
  18. 31
      src/ChamiloLMS/CoreBundle/Settings/GroupSettingsSchema.php
  19. 31
      src/ChamiloLMS/CoreBundle/Settings/MailSettingsSchema.php
  20. 32
      src/ChamiloLMS/CoreBundle/Settings/MessageSettingsSchema.php
  21. 37
      src/ChamiloLMS/CoreBundle/Settings/PlatformSettingsSchema.php
  22. 42
      src/ChamiloLMS/CoreBundle/Settings/ProfileSettingsSchema.php
  23. 55
      src/ChamiloLMS/CoreBundle/Settings/RegistrationSettingsSchema.php
  24. 33
      src/ChamiloLMS/CoreBundle/Settings/SearchSettingsSchema.php
  25. 40
      src/ChamiloLMS/CoreBundle/Settings/SecuritySettingsSchema.php
  26. 39
      src/ChamiloLMS/CoreBundle/Settings/SessionSettingsSchema.php
  27. 33
      src/ChamiloLMS/CoreBundle/Settings/SkillSettingsSchema.php
  28. 31
      src/ChamiloLMS/CoreBundle/Settings/SocialSettingsSchema.php
  29. 31
      src/ChamiloLMS/CoreBundle/Settings/SurveySettingsSchema.php
  30. 31
      src/ChamiloLMS/CoreBundle/Settings/TrackingSettingsSchema.php
  31. 20
      src/ChamiloLMS/InstallerBundle/Process/Step/SetupStep.php
  32. 13
      src/ChamiloLMS/SettingsBundle/ChamiloLMSSettingsBundle.php
  33. 25
      src/ChamiloLMS/SettingsBundle/DependencyInjection/ChamiloLMSSettingsExtension.php
  34. 29
      src/ChamiloLMS/SettingsBundle/DependencyInjection/Configuration.php
  35. 140
      src/ChamiloLMS/SettingsBundle/Manager/SettingsManager.php
  36. 11
      src/ChamiloLMS/SettingsBundle/Resources/config/services.xml
  37. 0
      src/ChamiloLMS/SettingsBundle/Resources/doc/index.rst
  38. 11
      src/ChamiloLMS/SettingsBundle/Resources/translations/messages.fr.xlf
  39. 1
      src/ChamiloLMS/SettingsBundle/Resources/views/Default/index.html.twig

@ -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'))) {

@ -234,6 +234,10 @@ sylius_resource:
sylius_settings:
driver: doctrine/orm
classes:
parameter:
model: ChamiloLMS\CoreBundle\Entity\SettingsCurrent
doctrine_cache:
providers:

@ -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:

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

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

@ -0,0 +1,22 @@
{% from 'SyliusResourceBundle:Macros:actions.html.twig' import update %}
{% block topbar %}
<ol class="breadcrumb">
<li>{{ 'sylius.breadcrumb.configuration'|trans }}</li>
<li>{{ 'sylius.breadcrumb.general_settings'|trans }}</li>
</ol>
{% endblock %}
{% block content %}
<div class="page-header">
<h1><i class="glyphicon glyphicon-info-sign"></i> {{ 'sylius.settings.general_header'|trans|raw }}</h1>
</div>
{{ form_errors(form) }}
<form action="{{ path('chamilolms_corebundle_platform_settings') }}" method="post" class="form-horizontal" novalidate>
{{ form_rest(form) }}
{{ update() }}
</form>
{% endblock %}

@ -0,0 +1,33 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CourseSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

@ -0,0 +1,31 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CourseSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

@ -0,0 +1,59 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CourseSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

@ -0,0 +1,68 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class DisplaySettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

@ -0,0 +1,59 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class DocumentSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

@ -0,0 +1,35 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class DropboxSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

@ -0,0 +1,45 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CourseSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

@ -0,0 +1,40 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CourseSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

@ -0,0 +1,29 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class ForumSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->setDefaults(array(
'default_forum_view' => '',
))
->setAllowedTypes(array(
'default_forum_view' => array('string')
))
;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder
->add('default_forum_view')
;
}
}

@ -0,0 +1,33 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class DisplaySettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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'))
);
}
}

@ -0,0 +1,42 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class GradebookSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

@ -0,0 +1,31 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class GroupSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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'))
)
;
}
}

@ -0,0 +1,31 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class MailSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

@ -0,0 +1,32 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CourseSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

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

@ -0,0 +1,42 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class ProfileSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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'))
)*/
;
}
}

@ -0,0 +1,55 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CourseSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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'))
)*/
;
}
}

@ -0,0 +1,33 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CourseSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

@ -0,0 +1,40 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class SecuritySettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

@ -0,0 +1,39 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class SessionSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

@ -0,0 +1,33 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class SkillSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

@ -0,0 +1,31 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class SocialSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

@ -0,0 +1,31 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CourseSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

@ -0,0 +1,31 @@
<?php
namespace ChamiloLMS\CoreBundle\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
class TrackingSettingsSchema implements SchemaInterface
{
public function buildSettings(SettingsBuilderInterface $builder)
{
$builder
->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')
;
}
}

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

@ -0,0 +1,13 @@
<?php
namespace ChamiloLMS\SettingsBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class ChamiloLMSSettingsBundle extends Bundle
{
public function getParent()
{
return 'SyliusSettingsBundle';
}
}

@ -0,0 +1,25 @@
<?php
namespace ChamiloLMS\SettingsBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
/**
* This is the class that loads and manages your bundle configuration
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class ChamiloLMSSettingsExtension extends Extension
{
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
}
}

@ -0,0 +1,29 @@
<?php
namespace ChamiloLMS\SettingsBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* This is the class that validates and merges configuration from your app/config files
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->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;
}
}

@ -0,0 +1,140 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ChamiloLMS\SettingsBundle\Manager;
use Doctrine\Common\Cache\Cache;
use Doctrine\Common\Persistence\ObjectManager;
use Sylius\Bundle\SettingsBundle\Model\Settings;
use Sylius\Bundle\SettingsBundle\Schema\SchemaRegistryInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilder;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Component\Validator\Exception\ValidatorException;
use Symfony\Component\Validator\ValidatorInterface;
use Sylius\Bundle\SettingsBundle\Manager\SettingsManager as SyliusSessionManager;
use ChamiloLMS\CoreBundle\Entity\SettingsCurrent;
/**
* Settings manager.
*
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
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;
}
}

@ -0,0 +1,11 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="sylius.settings.manager.class">ChamiloLMS\SettingsBundle\Manager\SettingsManager</parameter>
</parameters>
</container>

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>Symfony2 is great</source>
<target>J'aime Symfony2</target>
</trans-unit>
</body>
</file>
</xliff>
Loading…
Cancel
Save