From e2a3376165870fdd5539278d2174b60e0ea2b8d4 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 14 Aug 2014 18:42:01 +0200 Subject: [PATCH] Updating course tool as services definition. --- app/config/security.yml | 8 +- app/config/sonata/sonata_page.yml | 1 - main/inc/lib/course.lib.php | 62 ++++---- src/Chamilo/CoreBundle/Admin/CourseAdmin.php | 1 + .../CoreBundle/Entity/CourseManager.php | 5 + .../EventListener/LegacyListener.php | 1 + .../CoreBundle/Resources/config/services.yml | 1 - .../Compiler/ToolCompilerClass.php | 2 +- .../Resources/config/services.yml | 132 +++++++++++++----- src/Chamilo/CourseBundle/Tool/Agenda.php | 12 -- src/Chamilo/CourseBundle/Tool/BaseTool.php | 33 ++++- .../Resources/config/services.yml | 12 +- 12 files changed, 187 insertions(+), 83 deletions(-) diff --git a/app/config/security.yml b/app/config/security.yml index 7210893e4b..be9e9e6208 100644 --- a/app/config/security.yml +++ b/app/config/security.yml @@ -31,11 +31,11 @@ security: id: fos_user.user_manager firewalls: dev: - pattern: ^/(_(profiler|wdt)|css|images|js|admin/_(wdt|profiler)|api/_(wdt|profiler))/ - security: false + pattern: ^/(_(profiler|wdt)|css|images|js|admin/_(wdt|profiler)|api/_(wdt|profiler))/ + security: false install: - pattern: ^/installer + pattern: /installer/(.*) security: false anonymous: true @@ -50,7 +50,7 @@ security: failure_path: null logout: path: /administration/logout - anonymous: false + anonymous: true main: pattern: .* diff --git a/app/config/sonata/sonata_page.yml b/app/config/sonata/sonata_page.yml index d8a28954cc..5361af672f 100644 --- a/app/config/sonata/sonata_page.yml +++ b/app/config/sonata/sonata_page.yml @@ -19,7 +19,6 @@ sonata_page: - ^installer - ^/installer/(.*) - install.php - - settings/(.*) ignore_route_patterns: - (.*)administration(.*) # ignore admin route, ie route containing 'admin' # sonata admin diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index c368a56a75..8e465da6da 100644 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -1,6 +1,8 @@ '0', + 'c_id' => $course_id, + 'name' => $tool->getName(), + 'category' => $tool->getCategory(), + 'link' => $tool->getLink(), + 'image' => $tool->getImage(), + 'visibility' => Text::string2binary(api_get_setting('course_create_active_tools', $tool->getName())), + 'admin' => 0, + 'address' => 'squaregrey.gif', + 'target' => 'self', + 'session_id' => 0 + ); + Database::insert($toolTable, $params); + } /* Course tools */ - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_COURSE_DESCRIPTION . "','course_description/','info.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'course_description')) . "','0','squaregrey.gif','NO','_self','authoring','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_CALENDAR_EVENT . "','calendar/agenda.php','agenda.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'agenda')) . "','0','squaregrey.gif','NO','_self','interaction','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_DOCUMENT . "','document/document.php','folder_document.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'documents')) . "','0','squaregrey.gif','NO','_self','authoring','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_LEARNPATH . "','newscorm/lp_controller.php','scorms.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'learning_path')) . "','0','squaregrey.gif','NO','_self','authoring','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_LINK . "','link/link.php','links.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'links')) . "','0','squaregrey.gif','NO','_self','authoring','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_QUIZ . "','exercice/exercice.php','quiz.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'quiz')) . "','0','squaregrey.gif','NO','_self','authoring','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_ANNOUNCEMENT . "','announcements/announcements.php','valves.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'announcements')) . "','0','squaregrey.gif','NO','_self','authoring','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_FORUM . "','forum/index.php','forum.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'forums')) . "','0','squaregrey.gif','NO','_self','interaction','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_DROPBOX . "','dropbox/index.php','dropbox.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'dropbox')) . "','0','squaregrey.gif','NO','_self','interaction','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_USER . "','user/user.php','members.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'users')) . "','0','squaregrey.gif','NO','_self','interaction','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_GROUP . "','group/group.php','group.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'groups')) . "','0','squaregrey.gif','NO','_self','interaction','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_CHAT . "','chat/chat.php','chat.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'chat')) . "','0','squaregrey.gif','NO','_self','interaction','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_STUDENTPUBLICATION . "','work/work.php','works.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'student_publications')) . "','0','squaregrey.gif','NO','_self','interaction','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_SURVEY."','survey/survey_list.php','survey.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'survey')) . "','0','squaregrey.gif','NO','_self','interaction','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_WIKI ."','wiki/index.php','wiki.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'wiki')) . "','0','squaregrey.gif','NO','_self','interaction','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_GRADEBOOK."','gradebook/index.php','gradebook.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'gradebook')). "','0','squaregrey.gif','NO','_self','authoring','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_GLOSSARY."','glossary/index.php','glossary.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'glossary')). "','0','squaregrey.gif','NO','_self','authoring','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_NOTEBOOK."','notebook/index.php','notebook.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'notebook'))."','0','squaregrey.gif','NO','_self','interaction','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_ATTENDANCE."','attendance/index.php','attendance.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'attendances'))."','0','squaregrey.gif','NO','_self','authoring','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_COURSE_PROGRESS."','course_progress/index.php','course_progress.gif','".Text::string2binary(api_get_setting('course_create_active_tools', 'course_progress'))."','0','squaregrey.gif','NO','_self','authoring','0', '', '')"); - Database::query("INSERT INTO $toolTable VALUES ($course_id, NULL, '" . TOOL_CURRICULUM."','curriculum','cv.png','".Text::string2binary(api_get_setting('course_create_active_tools', 'curriculum'))."','0','squaregrey.gif','NO','_self','authoring','0', '', '')"); - if (api_get_setting('service_visio', 'active') == 'true') { $mycheck = api_get_setting('service_visio', 'visio_host'); if (!empty($mycheck)) { diff --git a/src/Chamilo/CoreBundle/Admin/CourseAdmin.php b/src/Chamilo/CoreBundle/Admin/CourseAdmin.php index 15309b7857..71376a1c59 100644 --- a/src/Chamilo/CoreBundle/Admin/CourseAdmin.php +++ b/src/Chamilo/CoreBundle/Admin/CourseAdmin.php @@ -4,6 +4,7 @@ namespace Chamilo\CoreBundle\Admin; use Chamilo\CoreBundle\Entity\Listener\CourseListener; use Chamilo\CourseBundle\Entity\CTool; +use Chamilo\CoreBundle\Entity\Course; use Sonata\AdminBundle\Admin\Admin; use Sonata\AdminBundle\Form\FormMapper; use Sonata\AdminBundle\Datagrid\DatagridMapper; diff --git a/src/Chamilo/CoreBundle/Entity/CourseManager.php b/src/Chamilo/CoreBundle/Entity/CourseManager.php index 1da62d1c4f..737d83cb73 100644 --- a/src/Chamilo/CoreBundle/Entity/CourseManager.php +++ b/src/Chamilo/CoreBundle/Entity/CourseManager.php @@ -22,6 +22,11 @@ class CourseManager extends BaseEntityManager return $this->getRepository()->findByTitle($name); } + public function saveTools($courseId) + { + + } + /** * {@inheritdoc} */ diff --git a/src/Chamilo/CoreBundle/EventListener/LegacyListener.php b/src/Chamilo/CoreBundle/EventListener/LegacyListener.php index 934caa1478..ab553c60ca 100644 --- a/src/Chamilo/CoreBundle/EventListener/LegacyListener.php +++ b/src/Chamilo/CoreBundle/EventListener/LegacyListener.php @@ -39,6 +39,7 @@ class LegacyListener $database = new \Database($dbConnection, array()); \Database::setManager($this->container->get('doctrine')->getManager()); + \CourseManager::setToolList($this->container->get('chamilo.tool_chain')); Session::$urlGenerator = $this->container->get('router'); Session::$security = $this->container->get('security.context'); Session::$translator = $this->container->get('translator'); diff --git a/src/Chamilo/CoreBundle/Resources/config/services.yml b/src/Chamilo/CoreBundle/Resources/config/services.yml index d89befc89f..34820534b6 100644 --- a/src/Chamilo/CoreBundle/Resources/config/services.yml +++ b/src/Chamilo/CoreBundle/Resources/config/services.yml @@ -21,7 +21,6 @@ services: arguments: [ @chamilo.tool_chain ] tags: - { name: doctrine.orm.entity_listener } - # - { name: doctrine.event_listener, event: prePersist } html_editor: diff --git a/src/Chamilo/CourseBundle/DependencyInjection/Compiler/ToolCompilerClass.php b/src/Chamilo/CourseBundle/DependencyInjection/Compiler/ToolCompilerClass.php index 1ec38cb6e2..0bbebc735e 100644 --- a/src/Chamilo/CourseBundle/DependencyInjection/Compiler/ToolCompilerClass.php +++ b/src/Chamilo/CourseBundle/DependencyInjection/Compiler/ToolCompilerClass.php @@ -23,7 +23,7 @@ class ToolCompilerClass implements CompilerPassInterface ); $taggedServices = $container->findTaggedServiceIds( - 'chamilolm.course.tool' + 'chamilo.course.tool' ); foreach ($taggedServices as $id => $attributes) { diff --git a/src/Chamilo/CourseBundle/Resources/config/services.yml b/src/Chamilo/CourseBundle/Resources/config/services.yml index ac4cd03f03..036318e71d 100644 --- a/src/Chamilo/CourseBundle/Resources/config/services.yml +++ b/src/Chamilo/CourseBundle/Resources/config/services.yml @@ -8,138 +8,202 @@ services: chamilo.coursebundle.tool.agenda.class: class: Chamilo\CourseBundle\Tool\Agenda arguments: - - agenda - calendar_event + - authoring - calendar/agenda.php - agenda.gif tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.announcements.class: class: Chamilo\CourseBundle\Tool\Announcement arguments: - - document + - announcement + - authoring + - announcements/announcements.php + - valves.gif tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.assignment.class: class: Chamilo\CourseBundle\Tool\Assignment arguments: - - document + - assignment + - interaction + - work/work.php + - works.gif tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.attendance.class: class: Chamilo\CourseBundle\Tool\Attendance arguments: - attendance + - authoring + - attendance/index.php + - attendance.gif tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.course_description.class: class: Chamilo\CourseBundle\Tool\CourseDescription arguments: - - document + - course_description + - authoring + - course_description/index.php + - info.gif tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.chat.class: class: Chamilo\CourseBundle\Tool\Chat arguments: - chat + - interaction + - chat/chat.php + - chat.gif tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.course_progress.class: class: Chamilo\CourseBundle\Tool\CourseProgress arguments: - course_progress + - authoring + - course_progress/index.php + - course_progress.gif + tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.document.class: class: Chamilo\CourseBundle\Tool\Document arguments: - document + - authoring + - document/document.php + - folder_document.gif tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.dropbox.class: class: Chamilo\CourseBundle\Tool\Dropbox arguments: - - document + - dropbox + - interaction + - dropbox/index.php + - dropbox.gif + tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.exercise.class: class: Chamilo\CourseBundle\Tool\Exercise arguments: - - document + - quiz + - authoring + - exercice/exercice.php + - quiz.gif + tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.forum.class: class: Chamilo\CourseBundle\Tool\Forum arguments: - - document + - forum + - interaction + - forum/index.php + - forum.gif + tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.glossary.class: class: Chamilo\CourseBundle\Tool\Glossary arguments: - - document + - glossary + - authoring + - glossary/index.php + - glossary.gif + tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.gradebook.class: class: Chamilo\CourseBundle\Tool\Gradebook arguments: - - document + - gradebook + - authoring + - gradebook/index.php + - gradebook.gif + tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.group.class: class: Chamilo\CourseBundle\Tool\Group arguments: - - document + - group + - interaction + - group/group.php + - group.gif + tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.learning_path.class: class: Chamilo\CourseBundle\Tool\LearningPath arguments: - - document + - learnpath + - authoring + - newscorm/lp_controller.php + - scorms.gif tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.link.class: class: Chamilo\CourseBundle\Tool\Link arguments: - - document + - link + - authoring + - link/link.php + - links.gif + tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.survey.class: class: Chamilo\CourseBundle\Tool\Survey arguments: - - document + - survey + - interaction + - survey/survey_list.php + - survey.gif + tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.user.class: class: Chamilo\CourseBundle\Tool\User arguments: - - document + - user + - interaction + - user/user.php + - members.gif + tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo.coursebundle.tool.wiki.class: class: Chamilo\CourseBundle\Tool\Wiki arguments: - - document + - wiki + - interaction + - wiki/index.php + - wiki.gif tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } diff --git a/src/Chamilo/CourseBundle/Tool/Agenda.php b/src/Chamilo/CourseBundle/Tool/Agenda.php index 56c279208f..d837edccc5 100644 --- a/src/Chamilo/CourseBundle/Tool/Agenda.php +++ b/src/Chamilo/CourseBundle/Tool/Agenda.php @@ -9,17 +9,5 @@ namespace Chamilo\CourseBundle\Tool; */ class Agenda extends BaseTool { - /** - * {@inheritdoc} - */ - public function getLink() - { - return 'calendar/agenda.php'; - } - - public function getCategory() - { - return 'authoring'; - } } diff --git a/src/Chamilo/CourseBundle/Tool/BaseTool.php b/src/Chamilo/CourseBundle/Tool/BaseTool.php index 7f35688950..d5e3648233 100644 --- a/src/Chamilo/CourseBundle/Tool/BaseTool.php +++ b/src/Chamilo/CourseBundle/Tool/BaseTool.php @@ -11,15 +11,22 @@ use Symfony\Component\OptionsResolver\OptionsResolverInterface; abstract class BaseTool implements ToolInterface { protected $name; + protected $category; protected $link; protected $image; /** - * @param string $name + * @param $name + * @param $category + * @param $link + * @param $image */ - public function __construct($name) + public function __construct($name, $category, $link, $image) { $this->name = $name; + $this->category = $category; + $this->link = $link; + $this->image = $image; } /** @@ -30,11 +37,33 @@ abstract class BaseTool implements ToolInterface return $this->name; } + /** + * {@inheritdoc} + */ + public function getLink() + { + return $this->link; + } + + /** + * {@inheritdoc} + */ + public function getCategory() + { + return $this->category; + } + + /** + * {@inheritdoc} + */ public function getTarget() { return '_self'; } + /** + * {@inheritdoc} + */ public function getImage() { return $this->image; diff --git a/src/Chamilo/NotebookBundle/Resources/config/services.yml b/src/Chamilo/NotebookBundle/Resources/config/services.yml index 51b1445559..8c0cbff0f0 100644 --- a/src/Chamilo/NotebookBundle/Resources/config/services.yml +++ b/src/Chamilo/NotebookBundle/Resources/config/services.yml @@ -3,13 +3,17 @@ services: class: Chamilo\CourseBundle\Tool\Notebook arguments: - notebook + - interaction + - notebook/index.php + - notebook.gif + tags: - - { name: chamilolm.course.tool } + - { name: chamilo.course.tool } chamilo_notebook: - class: Chamilo\NotebookBundle\Form\Type\CNotebookType - tags: - - { name: form.type } + class: Chamilo\NotebookBundle\Form\Type\CNotebookType + tags: + - { name: form.type } notebook.manager: class: Chamilo\NotebookBundle\Entity\CNotebookManager