Replacing public with web + adding LearnpathController

skala
Julio Montoya 13 years ago
parent e45ac82306
commit f7d7d8d2d9
  1. 1
      index.php
  2. 10
      main/inc/global.inc.php
  3. 8
      main/newscorm/lp_list.php
  4. 88
      src/ChamiloLMS/Controller/LearnpathController.php
  5. 7
      user_portal.php
  6. 0
      web/.htaccess
  7. 0
      web/index.php

@ -38,4 +38,5 @@ $htmlHeadXtra[] = '
//$cookie = new Cookie('TestCookie', 'cookies_yes', time()+3600*24*31*12); //$cookie = new Cookie('TestCookie', 'cookies_yes', time()+3600*24*31*12);
//$response->headers->setCookie($cookie); //$response->headers->setCookie($cookie);
$app->run(); $app->run();

@ -130,6 +130,7 @@ $app->register(new Silex\Provider\HttpCacheServiceProvider(), array(
//$app->register(new Silex\Provider\SessionServiceProvider()); //$app->register(new Silex\Provider\SessionServiceProvider());
/*
use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\User; use Symfony\Component\Security\Core\User\User;
@ -172,7 +173,7 @@ class UserProvider implements UserProviderInterface
return $class === 'Symfony\Component\Security\Core\User\User'; return $class === 'Symfony\Component\Security\Core\User\User';
} }
} }
/*
$app->register(new Silex\Provider\SecurityServiceProvider(), array( $app->register(new Silex\Provider\SecurityServiceProvider(), array(
'security.firewalls' => array( 'security.firewalls' => array(
'secured' => array( 'secured' => array(
@ -953,6 +954,10 @@ $app['userportal.controller'] = $app->share(function () use ($app) {
return new ChamiloLMS\Controller\UserPortalController(); return new ChamiloLMS\Controller\UserPortalController();
}); });
$app['learnpath.controller'] = $app->share(function () use ($app) {
return new ChamiloLMS\Controller\LearnpathController();
});
/* /*
class PostController class PostController
{ {
@ -977,5 +982,8 @@ $app->get('/', 'index.controller:indexAction');
//user_portal.php //user_portal.php
$app->get('/userportal', 'userportal.controller:indexAction'); $app->get('/userportal', 'userportal.controller:indexAction');
$app->get('/learnpath/subscribe_users/{id}', 'learnpath.controller:indexAction')->bind('subscribe_users');
$app->post('/learnpath/subscribe_users/{id}', 'learnpath.controller:indexAction')->bind('subscribe_users');
//$app->mount('/', 'index.controller'); //$app->mount('/', 'index.controller');
return $app; return $app;

@ -277,11 +277,14 @@ foreach ($categories as $item) {
// Session test not necessary if we want to show base course learning paths inside the session (see http://support.chamilo.org/projects/chamilo-18/wiki/Tools_and_sessions). // Session test not necessary if we want to show base course learning paths inside the session (see http://support.chamilo.org/projects/chamilo-18/wiki/Tools_and_sessions).
//if ($current_session == $details['lp_session']) { //if ($current_session == $details['lp_session']) {
if (!isset($details['subscribe_users']) || $details['subscribe_users'] != 1) {
if ($details['lp_visibility'] == 0) { if ($details['lp_visibility'] == 0) {
$dsp_visible = "<a href=\"".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=1\">".Display::return_icon('invisible.png', get_lang('Show'), '', ICON_SIZE_SMALL)."</a>"; $dsp_visible = "<a href=\"".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=1\">".Display::return_icon('invisible.png', get_lang('Show'), '', ICON_SIZE_SMALL)."</a>";
} else { } else {
$dsp_visible = "<a href='".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=0'>".Display::return_icon('visible.png', get_lang('Hide'), '', ICON_SIZE_SMALL)."</a>"; $dsp_visible = "<a href='".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=0'>".Display::return_icon('visible.png', get_lang('Hide'), '', ICON_SIZE_SMALL)."</a>";
} }
}
/* PUBLISH COMMAND */ /* PUBLISH COMMAND */
if ($current_session == $details['lp_session']) { if ($current_session == $details['lp_session']) {
@ -326,7 +329,7 @@ foreach ($categories as $item) {
/* FUll screen VIEW */ /* FUll screen VIEW */
if ($current_session == $details['lp_session']) { if ($current_session == $details['lp_session']) {
switch($details['lp_view_mode']) { switch ($details['lp_view_mode']) {
case 'fullscreen': case 'fullscreen':
$dsp_default_view = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_view_mode&lp_id='.$id.'">'. $dsp_default_view = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_view_mode&lp_id='.$id.'">'.
Display::return_icon('view_fullscreen.png', get_lang('ViewModeFullScreen'), '', ICON_SIZE_SMALL).'</a>'; Display::return_icon('view_fullscreen.png', get_lang('ViewModeFullScreen'), '', ICON_SIZE_SMALL).'</a>';
@ -364,7 +367,6 @@ foreach ($categories as $item) {
} }
} }
/* Export */ /* Export */
if ($details['lp_type'] == 1) { if ($details['lp_type'] == 1) {
@ -381,7 +383,7 @@ foreach ($categories as $item) {
//Subscribe users //Subscribe users
$subscribe_users = null; $subscribe_users = null;
if ($details['subscribe_users'] == 1) { if ($details['subscribe_users'] == 1) {
$subscribe_users = Display::url(Display::return_icon('add.png', get_lang('AddUsers')), "lp_subscribe_users.php?lp_id=$id"); $subscribe_users = Display::url(Display::return_icon('add.png', get_lang('AddUsers')), api_get_path(WEB_PATH)."learnpath/subscribe_users/$id");
} }
/* Auto Lunch LP code */ /* Auto Lunch LP code */

@ -0,0 +1,88 @@
<?php
namespace ChamiloLMS\Controller;
use Silex\Application;
use Symfony\Component\HttpFoundation\Response;
class LearnpathController {
function indexAction(Application $app, $id) {
$request = $app['request'];
$sessionId = api_get_session_id();
$lpId = $id;
if (empty($lpId)) {
var_dump($lpId);
//return $app->redirect('lp_controller.php');
}
$course = $app['orm.em']->getRepository('Entity\EntityCourse')->find(api_get_course_int_id());
$subscribedUsers = $app['orm.em']->getRepository('Entity\EntityCourse')->getSubscribedStudents($course);
$subscribedUsers = $subscribedUsers->getQuery();
$subscribedUsers = $subscribedUsers->execute();
$choices = array();
foreach ($subscribedUsers as $user) {
$choices[$user->getUserId()] = $user->getCompleteName();
}
$subscribedUsersInLp = $app['orm.em']->getRepository('Entity\EntityCItemProperty')->getUsersSubscribedToItem('learnpath', $lpId, $course);
$selectedChoices = array();
foreach ($subscribedUsersInLp as $itemProperty) {
$userId = $itemProperty->getToUserId();
$user = $app['orm.em']->getRepository('Entity\EntityUser')->find($userId);
$selectedChoices[$user->getUserId()] = $user->getCompleteName();
if (isset($choices[$user->getUserId()])) {
unset($choices[$user->getUserId()]);
}
}
$form = $app['form.factory']->createBuilder('form')
->add('origin', 'choice', array(
'label' => get_lang('Origin'),
'multiple' => true,
'required' => false,
'expanded' => false,
/*'class' => 'Entity\EntityCourse',
'property' => 'complete_name',
'query_builder' => function(\Entity\Repository\CourseRepository $repo) use ($course) {
$repo = $repo->getSubscribedStudents($course);
return $repo;
},*/
'choices' => $choices
))
->add('destination', 'choice', array(
'label' => get_lang('Destination'),
'multiple' => true,
'expanded' => false,
'required' => false,
/*'class' => 'Entity\EntityCourse',
'property' => 'complete_name',
'query_builder' => function(\Entity\Repository\CourseRepository $repo) use ($course) {
return $repo->getSubscribedStudents($course);
},*/
'choices' => $selectedChoices
))
->getForm();
if ($request->getMethod() == 'POST') {
$form->bind($request);
//$data = $form->getData();
$data = $request->get('form');
$destination = isset($data['destination']) ? $data['destination'] : array();
$app['orm.em']->getRepository('Entity\EntityCItemProperty')->SubscribedUsersToItem('learnpath', $course, $sessionId, $lpId, $destination);
return $app->redirect($app['url_generator']->generate('subscribe_users', array('lp_id' => $lpId)));
} else {
$app['template']->assign('form', $form->createView());
}
$response = $app['template']->render_template('learnpath/subscribe_users.tpl');
//return new Response($response, 200, array('Cache-Control' => 's-maxage=3600, private'));
return new Response($response, 200, array());
}
}

@ -15,6 +15,10 @@
* @todo display_digest, shouldn't this be removed and be made into an extension? * @todo display_digest, shouldn't this be removed and be made into an extension?
*/ */
//Temporal hack
header('Location: web/userportal');
exit;
/** /**
* INIT SECTION * INIT SECTION
*/ */
@ -78,6 +82,3 @@ if ($load_dirs) {
}); });
</script>'; </script>';
} }
$app->get('/', 'UserPortalController::indexAction');
$app->run();
Loading…
Cancel
Save