Adding user popup in the course list see #4586

skala
Julio Montoya 13 years ago
parent b415bfb2ce
commit eb955270af
  1. 19
      main/inc/ajax/user_manager.ajax.php
  2. 104
      main/inc/lib/course.lib.php
  3. 3
      main/inc/lib/main_api.lib.php
  4. 23
      main/inc/lib/template.lib.php
  5. 6
      main/inc/lib/userportal.lib.php
  6. 7
      main/social/home.php
  7. 5
      main/social/profile.php
  8. 45
      main/template/default/layout/head.tpl
  9. 2
      main/template/default/layout/layout_2_col.tpl
  10. 1
      user_portal.php

@ -3,11 +3,28 @@
/**
* Responses to AJAX calls
*/
$language_file = array('admin', 'registration');
$language_file = array('admin', 'registration', 'userInfo');
require_once '../global.inc.php';
$action = $_GET['a'];
switch ($action) {
case 'get_user_popup':
$user_info = api_get_user_info($_REQUEST['user_id']);
//var_dump($user_info);
echo '<div class="well">';
echo '<div class="row">';
echo '<div class="span2">';
echo '<img src="'.$user_info['avatar'].'" /> ';
echo '</div>';
echo '<div class="span2">';
echo '<h3>'.$user_info['complete_name'].'</h3> '.$user_info['mail'].' '.$user_info['official_code'];
echo '<br/><br/><a class="btn" href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$user_info['user_id'].'">'.get_lang('ViewSharedProfile').'</a>';
echo '</div>';
echo '</div>';
echo '</div>';
break;
case 'user_id_exists':
if (api_is_anonymous()) {
echo '';

@ -1368,13 +1368,18 @@ class CourseManager {
return $teachers;
}
public static function get_teacher_list_from_course_code_to_string($course_code, $separator = ',') {
public static function get_teacher_list_from_course_code_to_string($course_code, $separator = USER_SEPARATOR, $add_link_to_profile = false) {
$teacher_list = self::get_teacher_list_from_course_code($course_code);
$teacher_string = '';
$list = array();
if (!empty($teacher_list)) {
foreach($teacher_list as $teacher) {
$list[]= api_get_person_name($teacher['firstname'], $teacher['lastname']);
$teacher_name = api_get_person_name($teacher['firstname'], $teacher['lastname']);
if ($add_link_to_profile) {
$url = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup&resizable=0&height=350&user_id='.$teacher['user_id'];
$teacher_name = Display::url($teacher_name, $url, array('class' => 'ajax'));
}
$list[]= $teacher_name;
}
if (!empty($list)) {
$teacher_string = array_to_string($list, $separator);
@ -1383,6 +1388,66 @@ class CourseManager {
return $teacher_string;
}
/**
* This function returns information about coachs from a course in session
* @param int - optional, session id
* @param string - optional, course code
* @return array - array containing user_id, lastname, firstname, username
*
*/
function get_coachs_from_course($session_id=0, $course_code='') {
if (!empty($session_id)) {
$session_id = intval($session_id);
} else {
$session_id = api_get_session_id();
}
if (!empty($course_code)) {
$course_code = Database::escape_string($course_code);
} else {
$course_code = api_get_course_id();
}
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$coaches = array();
$sql = "SELECT u.user_id,u.lastname,u.firstname,u.username FROM $tbl_user u,$tbl_session_course_user scu
WHERE u.user_id = scu.id_user AND scu.id_session = '$session_id' AND scu.course_code = '$course_code' AND scu.status = 2";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs)) {
$coaches[] = $row;
}
return $coaches;
} else {
return false;
}
}
function get_coachs_from_course_to_string($session_id = 0, $course_code = null, $separator = USER_SEPARATOR, $add_link_to_profile = false) {
$coachs_course = self::get_coachs_from_course($session_id, $course_code);
$course_coachs = array();
if (is_array($coachs_course)) {
foreach ($coachs_course as $coach_course) {
$coach_name = api_get_person_name($coach_course['firstname'], $coach_course['lastname']);
if ($add_link_to_profile) {
$url = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup&resizable=0&height=350&user_id='.$coach_course['user_id'];
$coach_name = Display::url($coach_name, $url, array('class' => 'ajax'));
}
$course_coachs[] = $coach_name;
}
}
$coaches_to_string = null;
if (is_array($course_coachs) && count($course_coachs)> 0 ) {
$coaches_to_string = array_to_string($course_coachs, $separator);
}
return $coaches_to_string;
}
function get_coach_list_from_course_code_to_string($course_code, $session_id) {
$tutor_data = '';
if ($session_id != 0) {
@ -1392,7 +1457,7 @@ class CourseManager {
$coach_list[] = $coach['complete_name'];
}
if (!empty($coach_list)) {
$tutor_data = implode (', ', $coach_list);
$tutor_data = implode(USER_SEPARATOR, $coach_list);
}
}
return $tutor_data;
@ -1409,6 +1474,7 @@ class CourseManager {
public static function get_real_and_linked_user_list($course_code, $with_sessions = true, $session_id = 0) {
//get list of virtual courses
$virtual_course_list = self::get_virtual_courses_linked_to_real_course($course_code);
$complete_user_list = array();
//get users from real course
$user_list = self::get_user_list_from_course_code($course_code, $session_id);
@ -1455,7 +1521,6 @@ class CourseManager {
while ($result = Database::fetch_array($sql_result)) {
$result_array[] = $result;
}
return $result_array;
}
@ -1670,8 +1735,7 @@ class CourseManager {
$sql = "DELETE FROM $table_stats_links WHERE links_cours_id = '".$virtual_course['code']."'";
Database::query($sql);
$sql = "DELETE FROM $table_stats_uploads WHERE upload_cours_id = '".$virtual_course['code']."'";
Database::query($sql);
Database::query($sql);
// Delete the course from the course table
$sql = "DELETE FROM $table_course WHERE code='".$virtual_course['code']."'";
@ -2717,8 +2781,8 @@ class CourseManager {
}
/**
* Builds the course block in userportal.php
* @todo use smarty
* Builds the course block in user_portal.php
* @todo use Twig
*/
public function course_item_html($params, $is_sub_content = false) {
$html = '';
@ -2744,6 +2808,7 @@ class CourseManager {
return $html;
}
public function course_item_parent($main_content, $sub_content, $sub_sub_content = null) {
return '<div class="well">'.$main_content.$sub_content.$sub_sub_content.'</div>';
}
@ -2833,7 +2898,7 @@ class CourseManager {
$course_title .= $course_info['visual_code'];
}
if (api_get_setting('display_teacher_in_courselist') == 'true') {
$params['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string($course['code'], USER_SEPARATOR);
$params['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string($course['code'], USER_SEPARATOR, true);
}
$course_title .= '&nbsp;';
$course_title .= Display::return_icon('klipper.png', get_lang('CourseAutoRegister'));
@ -2975,7 +3040,7 @@ class CourseManager {
$course_title .= $course_info['visual_code'];
}
if (api_get_setting('display_teacher_in_courselist') == 'true') {
$teachers = CourseManager::get_teacher_list_from_course_code_to_string($course['code'], USER_SEPARATOR);
$teachers = CourseManager::get_teacher_list_from_course_code_to_string($course['code'], USER_SEPARATOR, true);
}
$params['icon'] = $status_icon;
@ -3149,23 +3214,14 @@ class CourseManager {
if (api_get_setting('display_teacher_in_courselist') == 'true') {
if (api_get_setting('use_session_mode') == 'true' && !$nosession) {
$teacher_list = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code'], USER_SEPARATOR);
$teacher_list = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code'], USER_SEPARATOR, true);
$course_coachs = CourseManager::get_coachs_from_course_to_string($course_info['id_session'], $course['code'], USER_SEPARATOR, true);
$coachs_course = api_get_coachs_from_course($course_info['id_session'], $course['code']);
$course_coachs = array();
if (is_array($coachs_course)) {
foreach ($coachs_course as $coach_course) {
$course_coachs[] = api_get_person_name($coach_course['firstname'], $coach_course['lastname']);
}
}
if ($course_info['status'] == COURSEMANAGER || ($course_info['status'] == STUDENT && empty($course_info['id_session'])) || empty($course_info['status'])) {
$params['teachers'] = $teacher_list;
}
if (($course_info['status'] == STUDENT && !empty($course_info['id_session'])) || ($is_coach && $course_info['status'] != COURSEMANAGER)) {
if (is_array($course_coachs) && count($course_coachs)> 0 ) {
$params['coaches'] = array_to_string($course_coachs, USER_SEPARATOR);
}
$params['coaches'] = $course_coachs;
}
} else {
$params['teachers'] = $teacher_list;
@ -3287,8 +3343,6 @@ class CourseManager {
return false;
}
/**
* Creates a new course code based in a given code
*
@ -3645,4 +3699,6 @@ class CourseManager {
$result = Database::select('c_id, accesses, total_score, users', $table_course_ranking, array('where' => array('url_id = ?' => $params), 'order' => 'accesses DESC', 'limit' => $limit), 'all', true);
return $result;
}
} //end class CourseManager

@ -1863,7 +1863,8 @@ function api_get_session_condition($session_id, $and = true, $with_base_content
* This function returns information about coachs from a course in session
* @param int - optional, session id
* @param string - optional, course code
* @return array - array containing user_id, lastname, firstname, username.
* @return array - array containing user_id, lastname, firstname, username
* @deprecated use CourseManager::get_coaches_from_course
*/
function api_get_coachs_from_course($session_id=0,$course_code='') {

@ -14,7 +14,7 @@ require_once api_get_path(LIBRARY_PATH).'plugin.lib.php';
require_once api_get_path(LIBRARY_PATH).'symfony/Twig/Autoloader.php';
//class Template extends Smarty {
class Template {
class Template {
var $style = 'default'; //see the template folder
var $preview_theme = null;
@ -32,12 +32,10 @@ class Template {
var $params = array();
function __construct($title = '', $show_header = true, $show_footer = true, $show_learnpath = false) {
function __construct($title = '', $show_header = true, $show_footer = true, $show_learnpath = false) {
//parent::__construct();
//Twig settings
//Twig settings
Twig_Autoloader::register();
$template_paths = array(
@ -56,18 +54,14 @@ class Template {
$this->twig->addFilter('get_path',new Twig_Filter_Function('api_get_path'));
$this->twig->addFilter('get_setting',new Twig_Filter_Function('api_get_setting'));
// Smarty like
/*
$lexer = new Twig_Lexer($this->twig, array(
//'tag_comment' => array('{*', '*}'),
//'tag_comment' => array('{#', '#}'),
//'tag_block' => array('{', '}'),
//'tag_variable' => array('{$', '}'),
));
$this->twig->setLexer($lexer);
//--------
));
$this->twig->setLexer($lexer);*/
//Page title
$this->title = $title;
@ -455,7 +449,7 @@ class Template {
$css_file_to_string .= api_get_css($css_file);
}
// @todo move this somewhere else
// @todo move this somewhere else. Special fix when using tablets in order to see the text near icons
if (SHOW_TEXT_NEAR_ICONS == true) {
//hack in order to fix the actions buttons
$css_file_to_string .= '<style>
@ -509,6 +503,7 @@ class Template {
$this->set_help();
//@todo move this in the template
$bug_notification_link = '';
if (api_get_setting('show_link_bug_notification') == 'true' && $this->user_is_logged_in) {
$bug_notification_link = '<li class="report">

@ -12,10 +12,8 @@ class IndexManager {
var $home = '';
var $default_home = 'home/';
function __construct($title, $load_template = true) {
if ($load_template) {
$this->tpl = new Template($title);
}
function __construct($title) {
$this->tpl = new Template($title);
$this->home = api_get_home_path();
$this->user_id = api_get_user_id();
$this->load_directories_preview = false;

@ -21,7 +21,12 @@ $this_section = SECTION_SOCIAL;
unset($_SESSION['this_section']);//for hmtl editor repository
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') !='true' ){
if (api_get_setting('allow_social_tool') !='true' ) {
$url = api_get_path(WEB_CODE_PATH).'auth/profile.php';
header('Location: '.$url);
exit;
api_not_allowed();
}

@ -13,7 +13,10 @@ require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
if (api_get_setting('allow_social_tool') !='true') {
api_not_allowed();
$url = api_get_path(WEB_PATH).'whoisonline.php?id='.intval($_GET['u']);
header('Location: '.$url);
exit;
//api_not_allowed();
}
$user_id = api_get_user_id();

@ -55,6 +55,21 @@ var disconnect_lang = '{{"ChatDisconnected"|get_lang}}';
{{ extra_headers}}
<script type="text/javascript">
function get_url_params(q, attribute) {
var vars;
var hash;
if (q != undefined) {
q = q.split('&');
for(var i = 0; i < q.length; i++){
hash = q[i].split('=');
if (hash[0] == attribute) {
return hash[1];
}
}
}
}
$(document).scroll(function() {
// Top bar scroll effect
@ -88,18 +103,38 @@ $(document).ready(function() {
var url = this.href;
var dialog = $("#dialog");
if ($("#dialog").length == 0) {
dialog = $('<div id="dialog" style="display:none"></div>').appendTo('body');
dialog = $('<div id="dialog" style="display:none"></div>').appendTo('body');
}
width_value = 580;
height_value = 450;
resizable_value = true;
new_param = get_url_params(url, 'width');
if (new_param) {
width_value = new_param;
}
new_param = get_url_params(url, 'height')
if (new_param) {
height_value = new_param;
}
new_param = get_url_params(url, 'resizable');
if (new_param) {
resizable_value = new_param;
}
// load remote content
dialog.load(
url,
{},
function(responseText, textStatus, XMLHttpRequest) {
dialog.dialog({
modal : true,
width : 580,
height : 450
modal : true,
width : width_value,
height : height_value,
resizable : resizable_value,
});
});
//prevent the browser to follow the link

@ -37,7 +37,7 @@
{% if content is not null %}
<section id="main_content">
{{ content }}
{{ content }}
</section>
{% endif %}

@ -89,7 +89,6 @@ $this_section = SECTION_COURSES;
Header
Include the HTTP, HTML headers plus the top banner.
*/
if ($load_dirs) {
$url = api_get_path(WEB_AJAX_PATH).'document.ajax.php?a=document_preview';
$folder_icon = api_get_path(WEB_IMG_PATH).'icons/22/folder.png';

Loading…
Cancel
Save