Minor - Adding comments, preparing code to move whoisonline.php to web/users/online but not for 1.10

skala
Julio Montoya 12 years ago
parent 821fa0b397
commit 2a86c0ed41
  1. 143
      main/admin/careers.php
  2. 6
      main/admin/user_list.php
  3. 47
      main/inc/global.inc.php
  4. 7
      main/inc/lib/online.inc.php
  5. 26
      main/inc/lib/social.lib.php
  6. 6
      main/social/profile.php
  7. 6
      src/ChamiloLMS/Controller/UserController.php
  8. 1
      web/.htaccess

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* @package chamilo.admin * @package chamilo.admin
*/ */
// Language files that need to be included. // Language files that need to be included.
@ -19,59 +19,91 @@ api_protect_admin_script();
$htmlHeadXtra[] = api_get_jqgrid_js(); $htmlHeadXtra[] = api_get_jqgrid_js();
// setting breadcrumbs // setting breadcrumbs
$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin')); $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[]=array('url' => 'career_dashboard.php','name' => get_lang('CareersAndPromotions')); $interbreadcrumb[] = array('url' => 'career_dashboard.php', 'name' => get_lang('CareersAndPromotions'));
$action = isset($_GET['action']) ? $_GET['action'] : null; $action = isset($_GET['action']) ? $_GET['action'] : null;
$check = Security::check_token('request'); $check = Security::check_token('request');
$token = Security::get_token(); $token = Security::get_token();
if ($action == 'add') { if ($action == 'add') {
$interbreadcrumb[]=array('url' => 'careers.php','name' => get_lang('Careers')); $interbreadcrumb[] = array('url' => 'careers.php', 'name' => get_lang('Careers'));
$interbreadcrumb[]=array('url' => '#','name' => get_lang('Add')); $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Add'));
} elseif ($action == 'edit') { } elseif ($action == 'edit') {
$interbreadcrumb[]=array('url' => 'careers.php','name' => get_lang('Careers')); $interbreadcrumb[] = array('url' => 'careers.php', 'name' => get_lang('Careers'));
$interbreadcrumb[]=array('url' => '#','name' => get_lang('Edit')); $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Edit'));
} else { } else {
$interbreadcrumb[]=array('url' => '#','name' => get_lang('Careers')); $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Careers'));
} }
Display::display_header($tool_name); Display::display_header($tool_name);
//jqgrid will use this URL to do the selects //jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_careers'; $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_careers';
//The order is important you need to check the the $column variable in the model.ajax.php file //The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(get_lang('Name'), get_lang('Description'), get_lang('Actions')); $columns = array(get_lang('Name'), get_lang('Description'), get_lang('Actions'));
//Column config //Column config
$column_model = array( $column_model = array(
array('name'=>'name', 'index'=>'name', 'width'=>'80', 'align'=>'left'), array('name' => 'name', 'index' => 'name', 'width' => '80', 'align' => 'left'),
array('name'=>'description', 'index'=>'description', 'width'=>'500', 'align'=>'left','sortable'=>'false'), array(
array('name'=>'actions', 'index'=>'actions', 'width'=>'100', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false') 'name' => 'description',
); 'index' => 'description',
//Autowidth 'width' => '500',
'align' => 'left',
'sortable' => 'false'
),
array(
'name' => 'actions',
'index' => 'actions',
'width' => '100',
'align' => 'left',
'formatter' => 'action_formatter',
'sortable' => 'false'
)
);
//Autowidth
$extra_params['autowidth'] = 'true'; $extra_params['autowidth'] = 'true';
//height auto //height auto
$extra_params['height'] = 'auto'; $extra_params['height'] = 'auto';
//With this function we can add actions to the jgrid (edit, delete, etc) //With this function we can add actions to the jgrid (edit, delete, etc)
$action_links = 'function action_formatter(cellvalue, options, rowObject) { $action_links = 'function action_formatter(cellvalue, options, rowObject) {
return \'<a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'. return \'<a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon(
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=copy&id=\'+options.rowId+\'">'.Display::return_icon('copy.png',get_lang('Copy'),'',ICON_SIZE_SMALL).'</a>'. 'edit.png',
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'. get_lang('Edit'),
'\'; '',
}'; ICON_SIZE_SMALL
).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(
api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES)
)."\'".')) return false;" href="?sec_token='.$token.'&action=copy&id=\'+options.rowId+\'">'.Display::return_icon(
'copy.png',
get_lang('Copy'),
'',
ICON_SIZE_SMALL
).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(
api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES)
)."\'".')) return false;" href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon(
'delete.png',
get_lang('Delete'),
'',
ICON_SIZE_SMALL
).'</a>'.
'\';
}';
?> ?>
<script> <script>
$(function() { $(function () {
<?php <?php
// grid definition see the $career->display() function // grid definition see the $career->display() function
echo Display::grid_js('careers', $url,$columns,$column_model,$extra_params, array(), $action_links,true); echo Display::grid_js('careers', $url,$columns,$column_model,$extra_params, array(), $action_links,true);
?> ?>
}); });
</script> </script>
<?php <?php
$career = new Career(); $career = new Career();
@ -87,45 +119,58 @@ switch ($action) {
$form = $career->return_form($url, 'add'); $form = $career->return_form($url, 'add');
// The validation or display // The validation or display
if ($form->validate()) { if ($form->validate()) {
if ($check) { if ($check) {
$values = $form->exportValues(); $values = $form->exportValues();
$res = $career->save($values); $res = $career->save($values);
if ($res) { if ($res) {
Display::display_confirmation_message(get_lang('ItemAdded')); Display::display_confirmation_message(get_lang('ItemAdded'));
} }
} }
$career->display(); $career->display();
} else { } else {
echo '<div class="actions">'; echo '<div class="actions">';
echo '<a href="'.api_get_self().'">'.Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>'; echo '<a href="'.api_get_self().'">'.Display::return_icon(
echo '</div>'; 'back.png',
get_lang('Back'),
'',
ICON_SIZE_MEDIUM
).'</a>';
echo '</div>';
$form->addElement('hidden', 'sec_token'); $form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token)); $form->setConstants(array('sec_token' => $token));
$form->display(); $form->display();
} }
break; break;
case 'edit': case 'edit':
// Action handling: Editing // Action handling: Editing
$url = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&id='.intval($_GET['id']); $url = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&id='.intval($_GET['id']);
$form = $career->return_form($url, 'edit'); $form = $career->return_form($url, 'edit');
// The validation or display // The validation or display
if ($form->validate()) { if ($form->validate()) {
if ($check) { if ($check) {
$values = $form->exportValues(); $values = $form->exportValues();
$career->update_all_promotion_status_by_career_id($values['id'],$values['status']); $career->update_all_promotion_status_by_career_id($values['id'], $values['status']);
$res = $career->update($values); $res = $career->update($values);
if ($values['status']) { if ($values['status']) {
Display::display_confirmation_message(sprintf(get_lang('CareerXUnarchived'), $values['name']), false); Display::display_confirmation_message(
sprintf(get_lang('CareerXUnarchived'), $values['name']),
false
);
} else { } else {
Display::display_confirmation_message(sprintf(get_lang('CareerXArchived'), $values['name']), false); Display::display_confirmation_message(sprintf(get_lang('CareerXArchived'), $values['name']), false);
} }
} }
$career->display(); $career->display();
} else { } else {
echo '<div class="actions">'; echo '<div class="actions">';
echo '<a href="'.api_get_self().'">'.Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>'; echo '<a href="'.api_get_self().'">'.Display::return_icon(
'back.png',
get_lang('Back'),
'',
ICON_SIZE_MEDIUM
).'</a>';
echo '</div>'; echo '</div>';
$form->addElement('hidden', 'sec_token'); $form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token)); $form->setConstants(array('sec_token' => $token));
@ -142,7 +187,7 @@ switch ($action) {
} }
$career->display(); $career->display();
break; break;
case 'copy': case 'copy':
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed(); api_not_allowed();
} }
@ -155,7 +200,7 @@ switch ($action) {
$career->display(); $career->display();
break; break;
default: default:
$career->display(); $career->display();
break; break;
} }
Display :: display_footer(); Display :: display_footer();

@ -405,8 +405,8 @@ function get_user_data($from, $number_of_items, $column, $direction, $get_count
$image_path = UserManager::get_user_picture_path_by_id($user[0], 'web', false, true); $image_path = UserManager::get_user_picture_path_by_id($user[0], 'web', false, true);
$user_profile = UserManager::get_picture_user($user[0], $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" '); $user_profile = UserManager::get_picture_user($user[0], $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
if (!api_is_anonymous()) { if (!api_is_anonymous()) {
$photo = '<center><a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$user[0].'" title="'.get_lang('Info').'"> $photo = '<center><a href="'.api_get_path(WEB_CODE_PATH).'?social/profile.php&u='.$user[0].'" title="'.get_lang('Info').'">
<img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($user[2],$user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" /></a></center>'; <img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($user[2],$user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" /></a></center>';
} else { } else {
$photo = '<center><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" /></center>'; $photo = '<center><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" /></center>';
} }
@ -439,7 +439,7 @@ function email_filter($email) {
* @return string HTML-code with a mailto-link * @return string HTML-code with a mailto-link
*/ */
function user_filter($name, $params, $row) { function user_filter($name, $params, $row) {
return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>'; return '<a href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$row[0].'">'.$name.'</a>';
} }
/** /**

@ -128,8 +128,6 @@ if ($alreadyInstalled) {
$userPasswordCrypted = (!empty($_configuration['password_encryption']) ? $_configuration['password_encryption'] : 'sha1'); $userPasswordCrypted = (!empty($_configuration['password_encryption']) ? $_configuration['password_encryption'] : 'sha1');
} }
/* /*
$settingsFile = __DIR__."/../../app/config/settings.yml"; $settingsFile = __DIR__."/../../app/config/settings.yml";
$app->register(new Igorw\Silex\ConfigServiceProvider($settingsFile, array( $app->register(new Igorw\Silex\ConfigServiceProvider($settingsFile, array(
@ -153,8 +151,8 @@ $app['languages_file'] = array();
$app['installed'] = $alreadyInstalled; $app['installed'] = $alreadyInstalled;
//Loading $app settings //Loading $app settings
require_once __DIR__.'/../../src/ChamiloLMS/Resources/config/prod.php'; //require_once __DIR__.'/../../src/ChamiloLMS/Resources/config/prod.php';
//require_once __DIR__.'/../../src/ChamiloLMS/Resources/config/dev.php'; require_once __DIR__.'/../../src/ChamiloLMS/Resources/config/dev.php';
//Setting HttpCacheService provider in order to use do: $app['http_cache']->run(); //Setting HttpCacheService provider in order to use do: $app['http_cache']->run();
/* /*
@ -679,11 +677,6 @@ $app['mailer'] = $app->share(function ($app) {
return new \Swift_Mailer($app['swiftmailer.transport']); return new \Swift_Mailer($app['swiftmailer.transport']);
}); });
// Check and modify the date of user in the track.e.online table
if ($alreadyInstalled && !$x = strpos($_SERVER['PHP_SELF'], 'whoisonline.php')) {
Online::LoginCheck(isset($_user['user_id']) ? $_user['user_id'] : '');
}
$app['api_get_languages'] = api_get_languages(); $app['api_get_languages'] = api_get_languages();
/* Loading languages and sublanguages */ /* Loading languages and sublanguages */
@ -859,7 +852,7 @@ if (api_get_setting('login_is_email') == 'true') {
define('USERNAME_MAX_LENGTH', $default_username_length); define('USERNAME_MAX_LENGTH', $default_username_length);
//Silex filters: before|after|finish /** Silex Middlewares: A before application middleware allows you to tweak the Request before the controller is executed */
$app->before( $app->before(
function () use ($app, $checkConnection) { function () use ($app, $checkConnection) {
@ -879,21 +872,38 @@ $app->before(
} }
if (!is_writable(api_get_path(SYS_ARCHIVE_PATH))) { if (!is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
$app->abort(500, "archive folder must be writeable"); $app->abort(500, "temp folder must be writeable");
} }
// Check and modify the date of user in the track.e.online table
//if ($checkConnection && !$x = strpos($_SERVER['PHP_SELF'], 'whoisonline.php')) {
Online::loginCheck(api_get_user_id());
//}
//$app['request']->getSession()->start(); //$app['request']->getSession()->start();
//var_dump($app['cidReset']);
}
);
/** Silex Middlewares: An after application middleware allows you to tweak the Response before it is sent to the client */
$app->after(
function (Request $request, Response $response) {
} }
); );
/** Silex Middlewares: A finish application middleware allows you to execute tasks after the Response has been sent to
* the client (like sending emails or logging) */
$app->finish( $app->finish(
function (Request $request) use ($app) { function (Request $request) use ($app) {
/*if ($request->get('_route') == 'logout') {
}*/
} }
); );
// The global variable $charset has been defined in a language file too (trad4all.inc.php), this is legacy situation. // The global variable $charset has been defined in a language file too (trad4all.inc.php), this is legacy situation.
// So, we have to reassign this variable again in order to keep its value right. // So, we have to reassign this variable again in order to keep its value right.
$charset = $charset_initial_value; $charset = $charset_initial_value;
@ -952,8 +962,6 @@ if (empty($default_quota)) {
define('DEFAULT_DOCUMENT_QUOTA', $default_quota); define('DEFAULT_DOCUMENT_QUOTA', $default_quota);
//Default template settings loaded in template.inc.php //Default template settings loaded in template.inc.php
$app['template.show_header'] = true; $app['template.show_header'] = true;
$app['template.show_footer'] = true; $app['template.show_footer'] = true;
@ -1043,14 +1051,21 @@ $app->get('/userportal/{type}/{filter}/{page}', 'userPortal.controller:indexActi
//Logout page //Logout page
$app->get('/logout', 'index.controller:logoutAction')->bind('logout'); $app->get('/logout', 'index.controller:logoutAction')->bind('logout');
//Courses
$app->match('/courses/{courseCode}/index.php', 'course_home.controller:indexAction', 'GET|POST'); $app->match('/courses/{courseCode}/index.php', 'course_home.controller:indexAction', 'GET|POST');
$app->match('/courses/{courseCode}', 'course_home.controller:indexAction', 'GET|POST'); $app->match('/courses/{courseCode}', 'course_home.controller:indexAction', 'GET|POST');
//Certificates
$app->match('/certificates/{id}', 'certificate.controller:indexAction', 'GET'); $app->match('/certificates/{id}', 'certificate.controller:indexAction', 'GET');
//Username
$app->match('/user/{username}', 'user.controller:indexAction', 'GET'); $app->match('/user/{username}', 'user.controller:indexAction', 'GET');
/*$app->match('/users/online', 'user.controller:onlineAction', 'GET');
$app->match('/users/online-in-course', 'user.controller:onlineInCourseAction', 'GET');
$app->match('/users/online-in-session', 'user.controller:onlineInSessionAction', 'GET');*/
//Portal news
$app->match('/news/{id}', 'news.controller:indexAction', 'GET'); $app->match('/news/{id}', 'news.controller:indexAction', 'GET');
//LP controller //LP controller

@ -21,7 +21,12 @@ use \ChamiloSession as Session;
class Online { class Online {
static function LoginCheck($uid) { /**
* Checking user in DB
* @param int $uid
*/
static function loginCheck($uid)
{
global $_course; global $_course;
$uid = (int) $uid; $uid = (int) $uid;
$online_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ONLINE); $online_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ONLINE);

@ -746,7 +746,7 @@ class SocialManager extends UserManager {
$status = get_status_from_code($user_object->status); $status = get_status_from_code($user_object->status);
$interbreadcrumb[] = array('url' => 'whoisonline.php', 'name' => get_lang('UsersOnLineList')); $interbreadcrumb[] = array('url' => SocialManager::getUserOnlineLink(), 'name' => get_lang('UsersOnLineList'));
if ($returnContent == false) { if ($returnContent == false) {
Display::display_header($alt, null, $alt); Display::display_header($alt, null, $alt);
@ -913,4 +913,28 @@ class SocialManager extends UserManager {
} }
return $content; return $content;
} }
/**
*
* @param $courseCode
* @param null $sessionId
* @return string
*/
static function getUserOnlineLink($courseCode = null, $sessionId = null)
{
if (empty($courseCode) && empty($sessionId)) {
return api_get_path(WEB_PATH).'whoisonline.php';
//return api_get_path(WEB_PUBLIC_PATH).'users/online';
}
if (!empty($courseCode)) {
//return api_get_path(WEB_PUBLIC_PATH).'users/online-in-course/'.$courseCode;
return api_get_path(WEB_PATH).'whoisonline.php?cidReq='.$courseCode;
}
if (!empty($sessionId)) {
//return api_get_path(WEB_PUBLIC_PATH).'users/online-in-session/'.$courseCode;
return api_get_path(WEB_PATH).'whoisonlinesession.php?session_id='.$sessionId;
}
}
} }

@ -12,7 +12,7 @@ $cidReset = true;
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
if (api_get_setting('allow_social_tool') !='true') { if (api_get_setting('allow_social_tool') !='true') {
$url = api_get_path(WEB_PATH).'whoisonline.php?id='.intval($_GET['u']); $url = api_get_path(WEB_CODE_PATH).'social/profile.php?u='.intval($_GET['u']);
header('Location: '.$url); header('Location: '.$url);
exit; exit;
} }
@ -390,7 +390,7 @@ if ($show_full_profile) {
$friend_html .= '<div><h3>'.get_lang('SocialFriend').'</h3></div>'; $friend_html .= '<div><h3>'.get_lang('SocialFriend').'</h3></div>';
$friend_html.= '<div id="friend-container" class="social-friend-container">'; $friend_html.= '<div id="friend-container" class="social-friend-container">';
$friend_html.= '<div id="friend-header">'; $friend_html.= '<div id="friend-header">';
$friend_html.= '<div>'.get_lang('NoFriendsInYourContactList').'<br /><a class="btn" href="'.api_get_path(WEB_PATH).'whoisonline.php">'.get_lang('TryAndFindSomeFriends').'</a></div>'; $friend_html.= '<div>'.get_lang('NoFriendsInYourContactList').'<br /><a class="btn" href="'.api_get_path(WEB_PUBLIC_PATH).'users/online">'.get_lang('TryAndFindSomeFriends').'</a></div>';
$friend_html.= '</div>'; // close div friend-header $friend_html.= '</div>'; // close div friend-header
} }
$friend_html.= '</div>'; $friend_html.= '</div>';
@ -546,7 +546,7 @@ if ($show_full_profile) {
// COURSES LIST // COURSES LIST
$my_courses = null; $my_courses = null;
if ( is_array($list) ) { if (isset($list) && !empty($list)) {
$my_courses .= '<div><h3>'.api_ucfirst(get_lang('MyCourses')).'</h3></div>'; $my_courses .= '<div><h3>'.api_ucfirst(get_lang('MyCourses')).'</h3></div>';
$my_courses .= '<div class="social-content-training">'; $my_courses .= '<div class="social-content-training">';

@ -29,6 +29,7 @@ class UserController
/** /**
* @param Application $app * @param Application $app
* @todo remove whoisonline.php script and use this
* *
* @return Response * @return Response
*/ */
@ -36,7 +37,6 @@ class UserController
{ {
$response = $app['template']->render_layout('layout_1_col.tpl'); $response = $app['template']->render_layout('layout_1_col.tpl');
return new Response($response, 200, array()); return new Response($response, 200, array());
} }
@ -52,13 +52,11 @@ class UserController
/** /**
* @param Application $app * @param Application $app
*
* @return Response * @return Response
*/ */
public function onlineInSessionAction(Application $app) public function onlineInSessionAction(Application $app)
{ {
} }
} }

@ -2,7 +2,6 @@
Options -MultiViews Options -MultiViews
RewriteEngine On RewriteEngine On
#RewriteBase /path/to/app
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L] RewriteRule ^ index.php [L]
</IfModule> </IfModule>
Loading…
Cancel
Save