Fixing queries, php notices and warnings due recent changes (adding c_id in new tables)

skala
Julio Montoya 13 years ago
parent 057d9c7984
commit 7ad45b4dda
  1. 1
      main/admin/user_list.php
  2. 2
      main/calendar/agenda.lib.php
  3. 70
      main/exercice/question_pool.php
  4. 3
      main/inc/ajax/agenda.ajax.php
  5. 13
      main/inc/global.inc.php
  6. 5
      main/inc/lib/course.lib.php
  7. 7
      main/inc/lib/events.lib.inc.php
  8. 27
      main/inc/lib/main_api.lib.php
  9. 6
      main/inc/lib/social.lib.php
  10. 15
      main/inc/lib/statistics.lib.php
  11. 10
      main/inc/lib/template.lib.php
  12. 4
      main/inc/lib/tracking.lib.php
  13. 13
      main/inc/lib/usergroup.lib.php
  14. 13
      main/inc/lib/usermanager.lib.php
  15. 15
      main/inc/local.inc.php
  16. 26
      main/social/home.php
  17. 19
      main/user/subscribe_user.php
  18. 8
      main/user/user.php

@ -241,7 +241,6 @@ function login_user($user_id) {
$_SESSION['login_as'] = true; // will be useful later to know if the user is actually an admin or not (example reporting)s
$target_url = api_get_path(WEB_PATH)."user_portal.php";
//$message .= "<br/>Login successful. Go to <a href=\"$target_url\">$target_url</a>";
$message .= '<br />'.sprintf(get_lang('LoginSuccessfulGoToX'),'<a href="'.$target_url.'">'.$target_url.'</a>');
Display :: display_header(get_lang('UserList'));
Display :: display_normal_message($message,false);

@ -280,7 +280,7 @@ class Agenda
$my_session_id = $session_item['session_id'];
if (!empty($my_courses)) {
foreach ($my_courses as $course_item) {
$course_info = api_get_course_info($course_item['code']);
$course_info = api_get_course_info_by_id($course_item['id']);
$this->get_course_events($start, $end, $course_info, 0, $my_session_id);
}
}

@ -29,43 +29,22 @@ $this_section = SECTION_COURSES;
$is_allowedToEdit=api_is_allowed_to_edit(null,true);
if (empty($delete)) {
$delete = intval($_GET['delete']);
}
if ( empty ( $recup ) ) {
$recup = intval($_GET['recup']);
}
if ( empty ( $fromExercise ) ) {
$fromExercise = intval($_REQUEST['fromExercise']);
}
if(isset($_GET['exerciseId'])){
$exerciseId = intval($_GET['exerciseId']);
}
if (isset($_GET['courseCategoryId'])) {
$courseCategoryId = intval($_GET['courseCategoryId']);
}
$exerciseLevel = -1;
if(isset($_REQUEST['exerciseLevel'])){
$exerciseLevel = intval($_REQUEST['exerciseLevel']);
}
if(isset($_GET['answerType'])){
$answerType = intval($_REQUEST['answerType']);
}
$page = 0;
if(!empty($_GET['page'])){
$page = intval($_GET['page']);
}
$copy_question = 0;
if(!empty($_GET['copy_question'])){
$copy_question = intval($_GET['copy_question']);
}
$session_id = intval($_GET['session_id']);
$selected_course = intval($_GET['selected_course']);
$course_id_changed = intval($_GET['course_id_changed']); // save the id of the previous course selected by user to reset menu if we detect that user change course hub 13-10-2011
$exercice_id_changed = intval($_GET['exercice_id_changed']); // save the id of the previous exercice selected by user to reset menu if we detect that user change course hub 13-10-2011
$delete = isset($_GET['delete']) ? intval($_GET['delete']) : null;
$recup = isset($_GET['recup']) ? intval($_GET['recup']) : null;
$fromExercise = isset($_REQUEST['fromExercise']) ? intval($_REQUEST['fromExercise']) : null;
$exerciseId = isset($_REQUEST['exerciseId']) ? intval($_REQUEST['exerciseId']) : null;
$courseCategoryId = isset($_REQUEST['courseCategoryId']) ? intval($_REQUEST['courseCategoryId']) : null;
$exerciseLevel = isset($_REQUEST['exerciseLevel']) ? intval($_REQUEST['exerciseLevel']) : -1;
$answerType = isset($_REQUEST['answerType']) ? intval($_REQUEST['answerType']) : -1;
$page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 0;
$copy_question = isset($_REQUEST['copy_question']) ? intval($_REQUEST['copy_question']) : 0;
$session_id = isset($_REQUEST['session_id']) ? intval($_REQUEST['session_id']) : 0;
$selected_course = isset($_REQUEST['selected_course']) ? intval($_REQUEST['selected_course']) : 0;
// save the id of the previous course selected by user to reset menu if we detect that user change course hub 13-10-2011
$course_id_changed = isset($_REQUEST['course_id_changed']) ? intval($_REQUEST['course_id_changed']) : 0;
// save the id of the previous exercice selected by user to reset menu if we detect that user change course hub 13-10-2011
$exercice_id_changed = isset($_REQUEST['exercice_id_changed']) ? intval($_REQUEST['exercice_id_changed']) : 0;
// by default when we go to the page for the first time, we select the current course
if (!isset($_GET['selected_course']) && !isset($_GET['exerciseId'])) {
@ -77,7 +56,7 @@ $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
// picture path
$picturePath = $documentPath.'/images';
if(!($objExcercise instanceOf Exercise) && !empty($fromExercise)) {
if(!($objExercise instanceOf Exercise) && !empty($fromExercise)) {
$objExercise = new Exercise();
$objExercise->read($fromExercise);
}
@ -112,7 +91,7 @@ if ($is_allowedToEdit) {
// destruction of the Question object
unset($new_question_obj);
unset($old_question_obj);
if (!$objExcercise instanceOf Exercise) {
if (!$objExercise instanceOf Exercise) {
$objExercise = new Exercise();
$objExercise->read($fromExercise);
}
@ -142,7 +121,7 @@ if ($is_allowedToEdit) {
// destruction of the Question object
unset($objQuestionTmp);
if (!$objExcercise instanceOf Exercise) {
if (!$objExercise instanceOf Exercise) {
$objExercise = new Exercise();
$objExercise->read($fromExercise);
}
@ -184,7 +163,7 @@ if ($is_allowedToEdit) {
unset($new_question_obj);
unset($old_question_obj);
if (!$objExcercise instanceOf Exercise) {
if (!$objExercise instanceOf Exercise) {
$objExercise = new Exercise();
$objExercise->read($fromExercise);
}
@ -324,13 +303,14 @@ $exercise_list = get_all_exercises_for_course_id($course_info, $session_
$my_exercise_list = array();
$my_exercise_list['0'] = get_lang('AllExercises');
$my_exercise_list['-1'] = get_lang('OrphanQuestions');
if (is_array($exercise_list)) {
foreach($exercise_list as $row) {
$my_exercise_list[$row['id']] = "";
if ($row['id'] == $fromExercise && $selected_course == api_get_course_int_id()) {
$my_exercise_list[$row['id']] = ">&nbsp;&nbsp;&nbsp;&nbsp;"; // hub 13-10-2011
$my_exercise_list[$row['iid']] = "";
if ($row['iid'] == $fromExercise && $selected_course == api_get_course_int_id()) {
$my_exercise_list[$row['iid']] = ">&nbsp;&nbsp;&nbsp;&nbsp;"; // hub 13-10-2011
}
$my_exercise_list[$row['id']] .= $row['title'];
$my_exercise_list[$row['iid']] .= $row['title'];
}
}

@ -34,7 +34,8 @@ switch ($action) {
break;
}
$add_as_announcement = isset($_REQUEST['add_as_annonuncement']) ? $_REQUEST['add_as_annonuncement'] : null;
echo $agenda->add_event($_REQUEST['start'], $_REQUEST['end'], $_REQUEST['all_day'], $_REQUEST['view'], $_REQUEST['title'], $_REQUEST['content'], $_REQUEST['users_to_send'], $add_as_announcement);
$usersToSend = isset($_REQUEST['users_to_send']) ? $_REQUEST['users_to_send'] : null;
echo $agenda->add_event($_REQUEST['start'], $_REQUEST['end'], $_REQUEST['all_day'], $_REQUEST['view'], $_REQUEST['title'], $_REQUEST['content'], $usersToSend, $add_as_announcement);
break;
case 'edit_event':
if (!api_is_allowed_to_edit(null, true) && $type == 'course') {

@ -956,8 +956,6 @@ if (!isset($_SESSION['login_as']) && isset($_user)) {
$res_logout_date = convert_sql_date(Database::result($q_logout_date, 0, 'logout_date'));
if ($res_logout_date < time() - $app['configuration']['session_lifetime']) {
// it isn't, we should create a fresh entry
event_login();
// now that it's created, we can get its ID and carry on
$q_last_connection = Database::query($sql_last_connection);
$i_id_last_connection = Database::result($q_last_connection, 0, 'login_id');
@ -965,6 +963,9 @@ if (!isset($_SESSION['login_as']) && isset($_user)) {
$s_sql_update_logout_date = "UPDATE $tbl_track_login SET logout_date=NOW() WHERE login_id='$i_id_last_connection'";
Database::query($s_sql_update_logout_date);
} else {
// it isn't, we should create a fresh entry
event_login();
}
}
@ -1515,6 +1516,14 @@ $app->get('/data/document_templates/{file}', 'index.controller:getDocumentTempla
$app->get('/data/default_platform_document/', 'index.controller:getDefaultPlatformDocumentAction')
->assert('type', '.+');
// Group files
$app->get('/data/upload/groups/{groupId}/{file}', 'index.controller:getGroupFile')
->assert('type', '.+');
// User files
$app->match('/data/upload/users/', 'index.controller:getUserFile', 'GET|POST')
->assert('type', '.+');
//Fixes uses of $_course in the scripts
$_course = api_get_course_info();
$_cid = api_get_course_id();

@ -970,7 +970,8 @@ class CourseManager
* @param int if using the session_id: 0 or 2 (student, coach), if using session_id = 0 STUDENT or COURSEMANAGER
* @return array
*/
public static function get_user_list_from_course_code($course_code = null, $session_id = 0, $limit = null, $order_by = null, $filter_by_status = null, $return_count = null, $add_reports = false, $resumed_report = false, $extra_field = null) {
public static function get_user_list_from_course_code($course_code = null, $session_id = 0, $limit = null, $order_by = null, $filter_by_status = null, $return_count = null, $add_reports = false, $resumed_report = false, $extra_field = null)
{
// variable initialisation
$session_id = intval($session_id);
$course_code = Database::escape_string($course_code);
@ -998,7 +999,7 @@ class CourseManager
ON user.user_id = session_course_user.id_user
AND session_course_user.c_id="'.$courseId.'"
AND session_course_user.id_session = '.$session_id;
$where[] = ' session_course_user.course_code IS NOT NULL ';
$where[] = ' session_course_user.c_id IS NOT NULL ';
// 2 = coach
// 0 = student

@ -13,7 +13,6 @@
*/
/* INIT SECTION */
$TABLETRACK_LOGIN = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$TABLETRACK_OPEN = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_OPEN);
$TABLETRACK_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
@ -72,12 +71,12 @@ function event_open()
*/
function event_login()
{
global $_user;
global $TABLETRACK_LOGIN;
$TABLETRACK_LOGIN = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$_user = api_get_user_info();
$reallyNow = api_get_utc_datetime();
$sql = "INSERT INTO ".$TABLETRACK_LOGIN." (login_user_id, login_ip, login_date, logout_date) VALUES
('".$_user['user_id']."',
('".api_get_user_id()."',
'".Database::escape_string(api_get_real_ip())."',
'".$reallyNow."',
'".$reallyNow."'

@ -1130,7 +1130,12 @@ function api_is_self_registration_allowed() {
* @return integer the id of the current user, 0 if is empty
*/
function api_get_user_id() {
return empty($GLOBALS['_user']['user_id']) ? 0 : intval($GLOBALS['_user']['user_id']);
$userInfo = Session::read('_user');
if ($userInfo && isset($userInfo['user_id'])) {
return $userInfo['user_id'];
}
return 0;
//return isset($GLOBALS['_user']['user_id']) ? 0 : intval($GLOBALS['_user']['user_id']);
}
/**
@ -1291,7 +1296,7 @@ function _api_format_user($user, $add_password = false) {
*/
function api_get_user_info($user_id = '', $check_if_user_is_online = false, $show_password = false, $add_extra_values = false) {
if (empty($user_id)) {
global $_user;
$_user = Session::read('_user');
return _api_format_user($_user);
}
$sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." WHERE user_id='".Database::escape_string($user_id)."'";
@ -5086,9 +5091,10 @@ function api_get_status_of_user_in_course ($user_id, $courseId)
* @author Yannick Warnier <yannick.warnier@beeznest.com>
*/
function api_is_in_course($course_code = null) {
if (isset($_SESSION['_course']['sysCode'])) {
$courseCodeInSession = api_get_course_id();
if (isset($courseCodeInSession)) {
if (!empty($course_code)) {
return $course_code == $_SESSION['_course']['sysCode'];
return $course_code == $courseCodeInSession;
}
return true;
}
@ -5103,19 +5109,22 @@ function api_is_in_course($course_code = null) {
* @return boolean
* @author Ivan Tcholakov
*/
function api_is_in_group($group_id = null, $course_code = null) {
function api_is_in_group($group_id = null, $course_code = null)
{
$courseCodeInSession = api_get_course_id();
$groupIdInSession = api_get_group_id();
if (!empty($course_code)) {
if (isset($_SESSION['_course']['sysCode'])) {
if ($course_code != $_SESSION['_course']['sysCode']) return false;
if (isset($courseCodeInSession)) {
if ($course_code != $courseCodeInSession) return false;
} else {
return false;
}
}
if (isset($_SESSION['_gid']) && $_SESSION['_gid'] != '') {
if (isset($groupIdInSession) && $groupIdInSession != '') {
if (!empty($group_id)) {
return $group_id == $_SESSION['_gid'];
return $group_id == $groupIdInSession;
} else {
return true;
}

@ -475,14 +475,14 @@ class SocialManager extends UserManager {
} else {
$img_array = UserManager::get_user_picture_path_by_id($user_id,'web',true,true);
$big_image = UserManager::get_picture_user($user_id, $img_array['file'],'', USER_IMAGE_SIZE_BIG);
$big_image = $big_image['file'].'?'.uniqid();
$normal_image = $img_array['dir'].$img_array['file'].'?'.uniqid();
$big_image = $big_image['file'];
$normal_image = $img_array['dir'].$img_array['file'];
//--- User image
$html .= '<div class="well social-background-content">';
if ($img_array['file'] != 'unknown.jpg') {
$html .= '<a class="thumbnail thickbox" href="'.$big_image.'"><img src='.$normal_image.' /> </a>';
$html .= '<a class="thumbnail ajax" href="'.$big_image.'"><img src='.$normal_image.' /> </a>';
} else {
$html .= '<img src='.$normal_image.' width="110px" />';
}

@ -318,12 +318,12 @@ class Statistics {
* Show some stats about the number of logins
* @param string $type month, hour or day
*/
static function print_login_stats($type) {
global $_configuration;
static function print_login_stats($type)
{
$table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
if ($_configuration['multiple_access_urls']) {
if (api_is_multiple_url_enabled()) {
$table_url = ", $access_url_rel_user_table";
$where_url = " WHERE login_user_id=user_id AND access_url_id='".$current_url_id."'";
$where_url_last = ' AND login_date > DATE_SUB(NOW(),INTERVAL 1 %s)';
@ -392,13 +392,13 @@ class Statistics {
/**
* Print the number of recent logins
*/
static function print_recent_login_stats() {
global $_configuration;
static function print_recent_login_stats()
{
$total_logins = array();
$table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
if ($_configuration['multiple_access_urls']) {
if (api_is_multiple_url_enabled()) {
$table_url = ", $access_url_rel_user_table";
$where_url = " AND login_user_id=user_id AND access_url_id='".$current_url_id."'";
} else {
@ -695,13 +695,12 @@ class Statistics {
* Print the number of users that didn't login for a certain period of time
*/
static function print_users_not_logged_in_stats() {
global $_configuration;
$total_logins = array();
$table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
$total = self::count_users();
if ($_configuration['multiple_access_urls']) {
if (api_is_multiple_url_enabled()) {
$table_url = ", $access_url_rel_user_table";
$where_url = " AND login_user_id=user_id AND access_url_id='".$current_url_id."'";
} else {

@ -57,7 +57,7 @@ class Template
$this->jquery_ui_theme = 'smoothness';
//Setting system variables
$this->set_system_parameters();
$this->setSystemParameters();
//Setting user variables
$this->setUserParameters();
@ -282,7 +282,6 @@ class Template
$user_info = array();
$user_info['logged'] = 0;
$this->user_is_logged_in = false;
if (api_user_is_login()) {
$user_info = $this->app['current_user'];
$user_info['logged'] = 1;
@ -306,12 +305,13 @@ class Template
) : null;
$this->user_is_logged_in = true;
}
//Setting the $_u array that could be use in any template
$this->assign('_u', $user_info);
}
/** Set system parameters */
private function set_system_parameters()
private function setSystemParameters()
{
global $_configuration;
@ -487,8 +487,8 @@ class Template
/**
* Set header parameters
*/
private function setHeaderParameters() {
private function setHeaderParameters()
{
$_course = api_get_course_info();
$_configuration = $this->app['configuration'];
$this_section = $this->app['this_section'];

@ -4248,7 +4248,9 @@ class TrackingUserLog
return false;
}
$table_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql_ip = "SELECT login_date, login_ip FROM $table_login WHERE login_user_id = $user_id AND login_date < '$event_date' ORDER BY login_date DESC LIMIT 1";
$sql_ip = "SELECT login_date, login_ip FROM $table_login
WHERE login_user_id = $user_id AND login_date < '$event_date'
ORDER BY login_date DESC LIMIT 1";
$ip = '';
$res_ip = Database::query($sql_ip);
if ($res_ip !== false && Database::num_rows($res_ip) > 0) {

@ -601,13 +601,13 @@ class UserGroup extends Model
switch ($type) {
case 'system': // Base: absolute system path.
$base = api_get_path(SYS_CODE_PATH);
$base = api_get_path(SYS_DATA_PATH);
break;
case 'rel': // Base: semi-absolute web path (no server base).
$base = api_get_path(REL_CODE_PATH);
break;
case 'web': // Base: absolute web path.
$base = api_get_path(WEB_CODE_PATH);
$base = api_get_path(WEB_DATA_PATH);
break;
case 'none':
default: // Base: empty, the result path below will be relative.
@ -628,7 +628,7 @@ class UserGroup extends Model
}
$user = Database::fetch_array($res);
$picture_filename = trim($user['picture']);
$dir = $base.'upload/users/groups/'.$id.'/';
$dir = $base.'upload/groups/'.$id.'/';
if (empty($picture_filename) && $anonymous) {
return array(
'dir' => $base.'img/',
@ -1384,8 +1384,7 @@ class UserGroup extends Model
* @param string style css
* @return array with the file and the style of an image i.e $array['file'] $array['style']
*/
public static function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM , $style = '') {
$patch_profile = 'upload/users/groups/';
public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM , $style = '') {
$picture = array();
$picture['style'] = $style;
if ($picture_file == 'unknown.jpg') {
@ -1410,8 +1409,8 @@ class UserGroup extends Model
$size_picture = 'medium_';
}
$image_array_sys = self::get_group_picture_path_by_id($id, 'system', false, true);
$image_array = self::get_group_picture_path_by_id($id, 'web', false, true);
$image_array_sys = $this->get_group_picture_path_by_id($id, 'system', false, true);
$image_array = $this->get_group_picture_path_by_id($id, 'web', false, true);
$file = $image_array_sys['dir'].$size_picture.$picture_file;
if (file_exists($file)) {
$picture['file'] = $image_array['dir'].$size_picture.$picture_file;

@ -1216,7 +1216,12 @@ class UserManager {
$picture_filename = trim($user['picture_uri']);
if (api_get_setting('split_users_upload_directory') === 'true') {
if ($type == 'system') {
$dir = $base.'upload/users/'.substr((string)$user_id, 0, 1).'/'.$user_id.'/';
} else {
$dir = $base.'upload/users/?file='.substr((string)$user_id, 0, 1).'/'.$user_id.'/';
}
/* @todo check this validation
if (!empty($picture_filename) or $preview) {
$dir = $base.'upload/users/'.substr((string)$user_id, 0, 1).'/'.$user_id.'/';
@ -1229,7 +1234,10 @@ class UserManager {
if (empty($picture_filename) && $anonymous) {
return array('dir' => $base_unknown.'img/', 'file' => 'unknown.jpg');
}
return array('dir' => $dir, 'file' => $picture_filename);
return array(
'dir' => $dir,
'file' => $picture_filename
);
}
@ -2932,7 +2940,8 @@ class UserManager {
* @param int Access URL ID (optional)
* @return mixed Number of users or false on error
*/
public static function get_number_of_users($status=0, $access_url_id=null) {
public static function get_number_of_users($status=0, $access_url_id=null)
{
$t_u = Database::get_main_table(TABLE_MAIN_USER);
$t_a = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql = "SELECT count(*) FROM $t_u u";

@ -36,7 +36,6 @@ if (isset($_SESSION['conditional_login']['uid']) && $_SESSION['conditional_login
Session::write('_user', $_user);
Session::erase('conditional_login');
$uidReset=true;
event_login();
}*/
// parameters passed via GET
@ -192,7 +191,6 @@ if (!empty($_SESSION['_user']['user_id']) && !$login) {
if (in_array($current_access_url_id, $my_url_list)) {
ConditionalLogin::check_conditions($uData);
Session::write('_user', $uData);
event_login();
$logging_in = true;
} else {
$loginFailed = true;
@ -208,12 +206,10 @@ if (!empty($_SESSION['_user']['user_id']) && !$login) {
if (in_array(1, $my_url_list)) { //Check if this admin have the access_url_id = 1 which means the principal
ConditionalLogin::check_conditions($uData);
Session::write('_user', $uData);
event_login();
} else {
//This means a secondary admin wants to login so we check as he's a normal user
if (in_array($current_access_url_id, $my_url_list)) {
Session::write('_user', $uData);
event_login();
} else {
$loginFailed = true;
Session::erase('_uid');
@ -224,7 +220,6 @@ if (!empty($_SESSION['_user']['user_id']) && !$login) {
} else {
ConditionalLogin::check_conditions($uData);
Session::write('_user', $uData);
event_login();
$logging_in = true;
}
} else {
@ -393,9 +388,7 @@ if (!empty($_SESSION['_user']['user_id']) && !$login) {
if ($uData['expiration_date']>date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') {
$_user['user_id'] = $uData['user_id'];
$_user['status'] = $uData['status'];
Session::write('_user',$_user);
event_login();
} else {
$loginFailed = true;
Session::erase('_uid');
@ -459,8 +452,12 @@ if (!empty($cidReq) && (!isset($_SESSION['_cid']) or (isset($_SESSION['_cid']) &
//Setting app user variable
$_user = Session::read('_user');
$app['current_user'] = $_user;
if ($_user) {
$userInfo = api_get_user_info($_user['user_id']);
$app['current_user'] = $userInfo;
} else {
$app['current_user'] = null;
}
/* USER INIT */

@ -58,6 +58,8 @@ $user_info = UserManager::get_user_info_by_id(api_get_user_id());
$social_left_content = SocialManager::show_social_menu('home');
$usergroup = new UserGroup();
$social_right_content = '<div class="span5">';
$social_right_content .= '<div class="well_border">';
$social_right_content .= '<h3>'.get_lang('ContactInformation').'</h3>';
@ -67,8 +69,6 @@ $list = array(
array('title' => get_lang('Email'), 'content' => $user_info['email']),
);
$usergroup = new UserGroup();
// Current user information
$social_right_content .= '<div>'.Display::description($list).'</div>';
$social_right_content .= '
@ -76,7 +76,8 @@ $social_right_content .= '
<a class="btn" href="'.api_get_path(WEB_PATH).'main/auth/profile.php">
'.get_lang('EditProfile').'
</a>
</div></div>';
</div>
</div>';
if (api_get_setting('allow_skills_tool') == 'true') {
$social_right_content .= '<div class="well_border">';
@ -86,7 +87,6 @@ if (api_get_setting('allow_skills_tool') == 'true') {
$ranking_url = Display::url(sprintf(get_lang('YourSkillRankingX'), $ranking), $url, array('class' => 'btn'));
$skills = $skill->get_user_skills(api_get_user_id(), true);
$social_right_content .= '<h3>'.get_lang('Skills').'</h3>';
$lis = '';
if (!empty($skills)) {
@ -106,10 +106,10 @@ $social_right_content .= '</div>';
// Search box
$social_right_content .= '<div class="span4">';
$social_right_content .= UserManager::get_search_form('');
$social_right_content .= '<br />';
$social_right_content .= '</br>';
// Group box by age
$results = GroupPortalManager::get_groups_by_age(1,false);
$results = $usergroup->get_groups_by_age(1,false);
$groups_newest = array();
if (!empty($results)) {
@ -123,19 +123,13 @@ if (!empty($results)) {
$result['count'] = $result['count'].' '.get_lang('Members');
}
$group_url = "groups.php?id=$id";
$result['name'] = Display::url(api_ucwords(cut($result['name'],40,true)), $group_url).Display::span('<br />'.$result['count'],array('class'=>'box_description_group_member'));
$picture = GroupPortalManager::get_picture_group($id, $result['picture_uri'],80);
$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="10" height="44" border="2" align="left" width="44" />';
$result['name'] = Display::url(api_ucwords(Text::cut($result['name'],40,true)), $group_url).Display::span('<br />'.$result['count'],array('class'=>'box_description_group_member'));
$picture = $usergroup->get_picture_group($id, $result['picture'],80);
$result['picture'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="10" height="44" border="2" align="left" width="44" />';
$group_actions = '<div class="box_description_group_actions"><a href="groups.php?#tab_browse-2">'.get_lang('SeeMore').'</a></div>';
$groups_newest[]= array(Display::url($result['picture_uri'], $group_url), $result['name'], cut($result['description'],120,true).$group_actions);
$groups_newest[]= array(Display::url($result['picture'], $group_url), $result['name'], Text::cut($result['description'],120,true).$group_actions);
}
}
// Search box
$social_right_content .= '<div class="span4">';
$social_right_content .= UserManager::get_search_form('');
$social_right_content .= '<br />';
// Group box by age
$results = $usergroup->get_groups_by_age(1,false);

@ -30,7 +30,8 @@ if (!api_is_allowed_to_edit()) {
}
$tool_name = get_lang("SubscribeUserToCourse");
if (isset($_REQUEST['type']) && $_REQUEST['type']=='teacher') {
$type = isset($_REQUEST['type']) ? Security::remove_XSS($_REQUEST['type']) : null;
if ($type == 'teacher') {
$tool_name = get_lang("SubscribeUserToCourseAsTeacher");
}
@ -48,13 +49,13 @@ Display :: display_header($tool_name, "User");
echo '<div class="actions">';
$actions = null;
if (isset($_GET['keyword'])) {
$actions .= '<a href="subscribe_user.php?type='.Security::remove_XSS($_REQUEST['type']).'">'.Display::return_icon('clean_group.gif').' '.get_lang('ClearSearchResults').'</a>';
$actions .= '<a href="subscribe_user.php?type='.$type.'">'.Display::return_icon('clean_group.gif').' '.get_lang('ClearSearchResults').'</a>';
}
if (isset($_GET['subscribe_user_filter_value']) AND !empty($_GET['subscribe_user_filter_value'])) {
$actions .= '<a href="subscribe_user.php?type='.Security::remove_XSS($_REQUEST['type']).'">'.Display::return_icon('clean_group.gif').' '.get_lang('ClearFilterResults').'</a>';
$actions .= '<a href="subscribe_user.php?type='.$type.'">'.Display::return_icon('clean_group.gif').' '.get_lang('ClearFilterResults').'</a>';
}
if (api_get_setting('ProfilingFilterAddingUsers') == 'true') {
display_extra_profile_fields_filter();
display_extra_profile_fields_filter($type);
}
// Build search-form
@ -62,7 +63,7 @@ $form = new FormValidator('search_user', 'get', '', '', null, false);
$renderer = $form->defaultRenderer();
$renderer->setElementTemplate('<span>{element}</span> ');
$form->add_textfield('keyword', '', false);
$form->addElement('hidden', 'type', Security::remove_XSS($_REQUEST['type']));
$form->addElement('hidden', 'type', $type);
$form->addElement('style_submit_button', 'submit', get_lang('SearchButton'), 'class="search"');
$form->addElement('static', 'additionalactions', null, $actions);
$form->display();
@ -185,7 +186,7 @@ $sort_by_first_name = api_sort_by_first_name();
// Build table
$table = new SortableTable('subscribe_users', 'get_number_of_users', 'get_user_data', ($is_western_name_order xor $sort_by_first_name) ? 3 : 2);
$parameters['keyword'] = isset($_REQUEST['keyword']) ? Security::remove_XSS($_REQUEST['keyword']) : null;
$parameters ['type'] = isset($_REQUEST['type']) ? Security::remove_XSS($_REQUEST['type']) : null;
$parameters ['type'] = isset($_REQUEST['type']) ? $type : null;
$table->set_additional_parameters($parameters);
$col = 0;
$table->set_header($col ++, '', false);
@ -611,7 +612,7 @@ function email_filter($email) {
*/
function reg_filter($user_id) {
if (isset($_REQUEST['type']) && $_REQUEST['type']=='teacher') $type='teacher'; else $type='student';
$result = '<a class="btn btn-small btn-primary" href="'.api_get_self().'?register=yes&type='.$type.'&user_id='.$user_id.'">'.get_lang("reg").'</a>';
$result = '<a class="btn btn-small btn-primary" href="'.api_get_self().'?register=yes&type='.$type.'&user_id='.$user_id.'&'.api_get_cidreq().'">'.get_lang("reg").'</a>';
return $result;
}
@ -693,7 +694,7 @@ function search_additional_profile_fields($keyword)
* platform administration > profiling. Only the fields that have predefined fields are usefull for such a filter.
*
*/
function display_extra_profile_fields_filter() {
function display_extra_profile_fields_filter($type) {
// getting all the additional user profile fields
$extra = UserManager::get_extra_fields(0,50,5,'ASC');
@ -727,7 +728,7 @@ function display_extra_profile_fields_filter() {
}
echo '<form id="subscribe_user_filter" name="subscribe_user_filter" method="get" action="'.api_get_self().'?api_get_cidreq" style="float:left;">';
echo ' <input type="hidden" name="type" id="type" value="'.Security::remove_XSS($_REQUEST['type']).'" />';
echo ' <input type="hidden" name="type" id="type" value="'.$type.'" />';
echo '<select name="subscribe_user_filter_value" id="subscribe_user_filter_value">'.$return.'</select>';
echo '<button type="submit" name="submit_filter" id="submit_filter" value="" class="search">'.get_lang('Filter').'</button>';
echo '</form>';

@ -317,7 +317,7 @@ if (api_is_allowed_to_edit(null, true)) {
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$sql = 'SELECT '.$tbl_user.'.user_id
$sql = 'SELECT DISTINCT '.$tbl_user.'.user_id
FROM '.$tbl_user.' user
INNER JOIN '.$tbl_session_rel_user.' reluser
ON user.user_id = reluser.id_user AND reluser.relation_type<>'.SESSION_RELATION_TYPE_RRHH.'
@ -329,7 +329,7 @@ if (api_is_allowed_to_edit(null, true)) {
$result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC');
if ($row['user_id'] == $user_id || $row['user_id'] == "") {
CourseManager::unsubscribe_user($_GET['user_id'], $_SESSION['_course']['sysCode']);
CourseManager::unsubscribe_user($_GET['user_id'], $courseId);
$message = get_lang('UserUnsubscribed');
} else {
$message = get_lang('ThisStudentIsSubscribeThroughASession');
@ -372,10 +372,6 @@ if (isset($origin) && $origin == 'learnpath') {
Display::display_header($tool_name, "User");
}
/* MAIN CODE*/
//statistics
event_access_tool(TOOL_USER);

Loading…
Cancel
Save