- user.php file deleted using controller to render user information public/user/usernameXpull/2715/head
parent
2d4f240538
commit
520cffe0d8
@ -1,69 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\CoreBundle\Controller\User; |
||||
|
||||
use Chamilo\CoreBundle\Controller\BaseController; |
||||
use Symfony\Component\HttpFoundation\Response; |
||||
use Symfony\Component\Routing\Annotation\Route; |
||||
|
||||
/** |
||||
* Class ProfileController. |
||||
* |
||||
* @package Chamilo\CoreBundle\Controller |
||||
*/ |
||||
class ProfileController extends BaseController |
||||
{ |
||||
/** |
||||
* My files. |
||||
* |
||||
* @Route("/{username}/files", methods={"GET"}) |
||||
*/ |
||||
public function fileAction($username) |
||||
{ |
||||
if ($this->getUser()->getUsername() != $username) { |
||||
return $this->abort(401); |
||||
} |
||||
|
||||
$userId = \UserManager::get_user_id_from_username($username); |
||||
$userInfo = api_get_user_info($userId); |
||||
|
||||
$this->getTemplate()->assign( |
||||
'driver_list', |
||||
'PersonalDriver,DropBoxDriver' |
||||
); |
||||
|
||||
$editor = $this->getTemplate()->renderTemplate( |
||||
$this->getHtmlEditor()->getEditorStandAloneTemplate() |
||||
); |
||||
|
||||
$this->getTemplate()->assign('user', $userInfo); |
||||
$this->getTemplate()->assign('editor', $editor); |
||||
|
||||
$response = $this->getTemplate()->renderTemplate( |
||||
$this->getTemplatePath().'files.tpl' |
||||
); |
||||
|
||||
return new Response($response, 200, []); |
||||
} |
||||
|
||||
/** |
||||
* Gets that rm.wav sound. |
||||
* |
||||
* @Route("/{username}/sounds/{file}", methods={"GET"}) |
||||
*/ |
||||
public function getSoundAction() |
||||
{ |
||||
$file = api_get_path(LIBRARY_PATH).'elfinder/rm.wav'; |
||||
|
||||
return $this->app->sendFile($file); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function getTemplatePath() |
||||
{ |
||||
return 'user/'; |
||||
} |
||||
} |
||||
@ -1,104 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\CoreBundle\Controller\User; |
||||
|
||||
use Chamilo\CoreBundle\Controller\BaseController; |
||||
use Chamilo\CoreBundle\Entity\CourseRelUser; |
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
||||
use Symfony\Component\HttpFoundation\JsonResponse; |
||||
use Symfony\Component\HttpFoundation\Request; |
||||
use Symfony\Component\HttpFoundation\Response; |
||||
use Symfony\Component\Routing\Annotation\Route; |
||||
|
||||
/** |
||||
* Class UserController. |
||||
* |
||||
* @package Chamilo\CoreBundle\Controller |
||||
* @Route("/user") |
||||
* |
||||
* @author Julio Montoya <gugli100@gmail.com> |
||||
*/ |
||||
class UserController extends BaseController |
||||
{ |
||||
/** |
||||
* @Route("/me", methods={"GET"}) |
||||
*/ |
||||
public function indexAction(Request $request) |
||||
{ |
||||
$userInfo = api_get_user_info($this->getUser()->getUserId()); |
||||
|
||||
return $this->getTemplate()->render( |
||||
$this->getTemplatePath().'me.tpl', |
||||
['user', $userInfo] |
||||
); |
||||
|
||||
$response = $this->getTemplate()->renderTemplate( |
||||
$this->getTemplatePath().'me.tpl' |
||||
); |
||||
|
||||
return new Response($response, 200, ['user', $userInfo]); |
||||
} |
||||
|
||||
/** |
||||
* @Route("/{username}", methods={"GET"}) |
||||
* |
||||
* @Template("ChamiloCoreBundle:User:profile.html.twig") |
||||
*/ |
||||
public function profileAction($username) |
||||
{ |
||||
$userId = \UserManager::get_user_id_from_username($username); |
||||
$userInfo = api_get_user_info($userId); |
||||
|
||||
return [ |
||||
'user' => $userInfo, |
||||
'form_send_message' => \MessageManager::generate_message_form( |
||||
'send_message' |
||||
), |
||||
'form_send_invitation' => \MessageManager::generate_invitation_form( |
||||
'send_invitation' |
||||
), |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* @Route("/me/my_courses", methods={"GET"}, options={"expose"=true}) |
||||
*/ |
||||
public function myCoursesAction() |
||||
{ |
||||
$user = $this->getUser(); |
||||
$courses = $user->getCourses(); |
||||
|
||||
$output = []; |
||||
/** @var CourseRelUser $courseRelUser */ |
||||
foreach ($courses as $courseRelUser) { |
||||
$course = $courseRelUser->getCourse(); |
||||
if ($course) { |
||||
$output[] = [ |
||||
'id' => $course->getId(), |
||||
'title' => $course->getTitle(), |
||||
]; |
||||
} |
||||
} |
||||
|
||||
return $response = new JsonResponse(['items' => $output]); |
||||
} |
||||
|
||||
/** |
||||
* @Route("/online", methods={"GET"}) |
||||
*/ |
||||
public function onlineAction($app) |
||||
{ |
||||
$response = $app['template']->renderLayout('layout_1_col.tpl'); |
||||
|
||||
return new Response($response, 200, []); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function getTemplatePath() |
||||
{ |
||||
return 'user/'; |
||||
} |
||||
} |
||||
@ -0,0 +1,38 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\CoreBundle\Controller; |
||||
|
||||
use Chamilo\CoreBundle\Controller\BaseController; |
||||
use Chamilo\CoreBundle\Entity\CourseRelUser; |
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
||||
use Symfony\Component\HttpFoundation\JsonResponse; |
||||
use Symfony\Component\HttpFoundation\Request; |
||||
use Symfony\Component\HttpFoundation\Response; |
||||
use Symfony\Component\Routing\Annotation\Route; |
||||
|
||||
/** |
||||
* Class UserController. |
||||
* |
||||
* @Route("/user") |
||||
* |
||||
* @author Julio Montoya <gugli100@gmail.com> |
||||
*/ |
||||
class UserController extends BaseController |
||||
{ |
||||
/** |
||||
* @Route("/{username}", methods={"GET"}) |
||||
* |
||||
* @param string $username |
||||
* |
||||
* @Template("ChamiloCoreBundle:User:profile.html.twig") |
||||
* |
||||
* @return Response |
||||
*/ |
||||
public function profileAction($username): array |
||||
{ |
||||
$user = $this->container->get('fos_user.user_manager')->findUserByUsername($username); |
||||
|
||||
return ['user' => $user]; |
||||
} |
||||
} |
||||
@ -1,138 +1,16 @@ |
||||
{% block left_column %} |
||||
<script> |
||||
function checkLength(o, n, min, max) { |
||||
if (o.val().length > max || o.val().length < min) { |
||||
o.addClass("ui-state-error"); |
||||
//updateTips( "Length of " + n + " must be between " + min + " and " + max + "." ); |
||||
return false; |
||||
} else { |
||||
return true; |
||||
} |
||||
} |
||||
{% extends "@ChamiloTheme/Layout/layout_one_col.html.twig" %} |
||||
|
||||
function send_message_to_user(user_id) { |
||||
var subject = $("#subject_id"); |
||||
var content = $("#content_id"); |
||||
$("#send_message_form").show(); |
||||
$("#send_message_div").dialog({ |
||||
modal: true, |
||||
height: 350, |
||||
buttons: { |
||||
"{{ 'Send' | trans }}": function () { |
||||
var bValid = true; |
||||
bValid = bValid && checkLength(subject, "subject", 1, 255); |
||||
bValid = bValid && checkLength(content, "content", 1, 255); |
||||
{% block content %} |
||||
{% autoescape false %} |
||||
<h3>{{ user.username }}</h3> |
||||
{{ user.firstname }} |
||||
{{ user.lastname }} |
||||
{{ user.competences }} |
||||
{{ user.openarea }} |
||||
{{ user.teach }} |
||||
|
||||
if (bValid) { |
||||
var url = "{{ url('web.ajax') }}message.ajax.php?a=send_message&user_id=" + user_id; |
||||
var params = $("#send_message_form").serialize(); |
||||
$.ajax({ |
||||
url: url + "&" + params, |
||||
success: function (data) { |
||||
$("#message_ajax_reponse").html(data); |
||||
$("#message_ajax_reponse").show(); |
||||
$("#send_message_div").dialog({buttons: {}}); |
||||
$("#send_message_form").hide(); |
||||
$("#send_message_div").dialog("close"); |
||||
$("#subject_id").val(""); |
||||
$("#content_id").val(""); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
}, |
||||
close: function () { |
||||
} |
||||
}); |
||||
$("#send_message_div").dialog("open"); |
||||
//prevent the browser to follow the link |
||||
} |
||||
|
||||
function send_invitation_to_user(user_id) { |
||||
var content = $("#content_invitation_id"); |
||||
$("#send_invitation_form").show(); |
||||
$("#send_invitation_div").dialog({ |
||||
modal: true, |
||||
buttons: { |
||||
"{{ 'SendInvitation' | trans }}": function () { |
||||
var bValid = true; |
||||
bValid = bValid && checkLength(content, "content", 1, 255); |
||||
if (bValid) { |
||||
var url = "{{ url('web.ajax') }}message.ajax.php?a=send_invitation&user_id=" + user_id; |
||||
var params = $("#send_invitation_form").serialize(); |
||||
$.ajax({ |
||||
url: url + "&" + params, |
||||
success: function (data) { |
||||
$("#message_ajax_reponse").html(data); |
||||
$("#message_ajax_reponse").show(); |
||||
$("#send_invitation_div").dialog({buttons: {}}); |
||||
$("#send_invitation_form").hide(); |
||||
$("#send_invitation_div").dialog("close"); |
||||
$("#content_invitation_id").val(""); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
}, |
||||
close: function () { |
||||
} |
||||
}); |
||||
$("#send_invitation_div").dialog("open"); |
||||
//prevent the browser to follow the link |
||||
} |
||||
{{ user.diplomas }} |
||||
|
||||
$(document).ready(function () { |
||||
$("input#id_btn_send_invitation").bind("click", function () { |
||||
if (confirm("'.trans('SendMessageInvitation', '').'")) { |
||||
$("#form_register_friend").submit(); |
||||
} |
||||
}); |
||||
|
||||
$("#send_message_div").dialog({ |
||||
autoOpen: false, |
||||
modal: false, |
||||
width: 550, |
||||
height: 300 |
||||
}); |
||||
|
||||
$("#send_invitation_div").dialog({ |
||||
autoOpen: false, |
||||
modal: false, |
||||
width: 550, |
||||
height: 300 |
||||
}); |
||||
|
||||
}); |
||||
</script> |
||||
|
||||
<div class="well social-background-content"> |
||||
<img src="{{ user.avatar }}"/> |
||||
</div> |
||||
|
||||
<div class="well sidebar-nav"> |
||||
<ul class="nav nav-pills nav-stacked"> |
||||
<li> |
||||
<a href="javascript:void(0);" |
||||
onclick="javascript:send_message_to_user('{{ user.id }}');"> |
||||
{{ 'SendMessage' | trans }} |
||||
</a> |
||||
</li> |
||||
<li> |
||||
<a href="javascript:void(0);" |
||||
onclick="javascript:send_invitation_to_user('{{ user.id }}');"> |
||||
{{ 'SendInvitation' | trans }} |
||||
</a> |
||||
</li> |
||||
</ul> |
||||
</div> |
||||
|
||||
{% endblock %} |
||||
|
||||
{% block right_column %} |
||||
<span id="message_ajax_reponse"></span> |
||||
<div class="well_border"> |
||||
<h3>{{ user.complete_name }} @{{ user.username }} </h3> |
||||
</div> |
||||
{{ form_send_message }} |
||||
{{ form_send_invitation }} |
||||
{% endautoescape %} |
||||
{% endblock %} |
||||
|
||||
@ -1,46 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Clean URls for the Social Network. |
||||
* |
||||
* The idea is to access to the user info more easily: |
||||
* http://campus.chamilo.org/admin instead of |
||||
* http://campus.chamilo.org/main/social/profile.php?1 |
||||
* To use this you should rename the htaccess to .htaccess and check your |
||||
* virtualhost configuration |
||||
* |
||||
* More improvements will come in next versions of Chamilo maybe in the 1.8.8 |
||||
* |
||||
* @package chamilo.main |
||||
*/ |
||||
$cidReset = true; |
||||
require_once 'main/inc/global.inc.php'; |
||||
|
||||
/** |
||||
* Access permissions check. |
||||
*/ |
||||
//api_block_anonymous_users(); |
||||
|
||||
/** |
||||
* Treat URL arguments. |
||||
*/ |
||||
$array_keys = array_keys($_GET); |
||||
|
||||
if (empty($array_keys)) { |
||||
// we cant find your friend |
||||
header('Location: whoisonline.php'); |
||||
exit; |
||||
} |
||||
|
||||
$username = substr($array_keys[0], 0, 20); // max len of an username |
||||
$friend_id = UserManager::get_user_id_from_username($username); |
||||
|
||||
if (!$friend_id) { |
||||
// we cant find your friend |
||||
header('Location: whoisonline.php'); |
||||
exit; |
||||
} |
||||
|
||||
Display::display_header(get_lang('UserInfo')); |
||||
echo SocialManager::display_individual_user($friend_id); |
||||
Display::display_footer(); |
||||
Loading…
Reference in new issue