Replace UserManager::get_user_info_by_id with api_get_user_info.

1.10.x
Julio Montoya 11 years ago
parent fe2d6deafe
commit f175a68a45
  1. 23
      custompages/first_login-dist.php
  2. 2
      main/admin/ldap_synchro.php
  3. 22
      main/admin/user_list.php
  4. 3
      main/auth/conditional_login/conditional_login.php
  5. 2
      main/auth/external_login/functions.inc.php
  6. 4
      main/auth/external_login/updateUser.php
  7. 88
      main/auth/key/key_auth.class.php
  8. 14
      main/auth/profile.php
  9. 5
      main/document/document.php
  10. 2
      main/dropbox/dropbox_functions.inc.php
  11. 16
      main/exercice/exercise.class.php
  12. 9
      main/messages/new_message.php
  13. 4
      main/messages/outbox.php

@ -17,7 +17,7 @@ if (! isset($_SESSION['conditional_login']['uid']))
die("Not Authorised");
if (isset($_POST['password'])) {
$u = UserManager::get_user_info_by_id($_SESSION['conditional_login']['uid']);
$u = api_get_user_info($_SESSION['conditional_login']['uid']);
if ($_POST['password'] != $_POST['password2']) {
header('Location: '. api_get_self().'?invalid=2');
exit();
@ -27,7 +27,26 @@ if (isset($_POST['password'])) {
exit();
}
$password = $_POST['password'];
$updated = UserManager::update_user($u['user_id'], $u['firstname'], $u['lastname'], $u['username'], $password, $u['auth_source'], $u['email'], $u['status'], $u['official_code'], $u['phone'], $u['picture_uri'], $u['expiration_date'], $u['active'], $u['creator_id'], $u['hr_dept_id'], null, $u['language'],'');
$updated = UserManager::update_user(
$u['user_id'],
$u['firstname'],
$u['lastname'],
$u['username'],
$password,
$u['auth_source'],
$u['email'],
$u['status'],
$u['official_code'],
$u['phone'],
$u['picture_uri'],
$u['expiration_date'],
$u['active'],
$u['creator_id'],
$u['hr_dept_id'],
null,
$u['language'],
''
);
if ($updated) {
UserManager::update_extra_field_value($u['user_id'], 'already_logged_in', 'true');

@ -106,7 +106,7 @@ foreach($Sessions as $session){
$user_id = UserManager::create_user($firstname,$lastname,$status,$email,$username,$password,$official_code,api_get_setting('platformLanguage'),$phone,$picture_uri,$auth_source,$expiration_date,$active);
$UserAdd[]=$user_id;
} else {
$user = UserManager::get_user_info($username);
$user = api_get_user_info_from_username($username);
$user_id=$user['user_id'];
UserManager::update_user($user_id, $firstname, $lastname, $username, null, null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active);
$UserUpdate[]=$user_id;

@ -304,6 +304,7 @@ function prepare_user_sql_query($is_count) {
*
* This function defines globals.
* @param int $userId
*
* @return bool False on failure, redirection on success
* @author Evie Embrechts
* @author Yannick Warnier <yannick.warnier@dokeos.com>
@ -831,27 +832,6 @@ $form->addElement('html', '</td><td>');
$form->addElement('checkbox', 'check_easy_passwords', null, get_lang('CheckEasyPasswords'));
/*
* @todo fix this code
$extra_data = UserManager::get_extra_fields( 0,10,5, 'ASC', true, 1);
var_dump($extra_data);
$extra_options = array();
if (!empty($extra_data)) {
$extra_options[0] = get_lang('All');
// get information about extra data for adding to input select
foreach ($extra_data as $field_variable => $field_value) {
$extra = UserManager::get_extra_field_information_by_name($field_variable);
$extra_options[$field_variable] = $extra['field_display_text'];
}
$form->addElement('select', 'keyword_extra_data', get_lang('ExtraData'), $extra_options, array('id'=>'input_select_extra_data', 'style'=>'margin-left:17px', 'onchange'=>'if(this.value!=0){document.getElementById(\'extra_data_text\').style.display=\'block\';document.getElementById(\'input_extra_text\').value = "";}else{document.getElementById(\'extra_data_text\').style.display=\'none\';}'));
$form->addElement('html', '<div id="extra_data_text" style="display:none;">');
$form->addText('keyword_extra_data_text', '', false, array('style'=>'margin-left:17px', 'id'=>'input_extra_text'));
$form->addElement('html', '</div>');
} else {
$form->addElement('html', '<div id="extra_data_text" style="display:none;">');
}*/
$form->addElement('html', '</td></tr>');
$form->addElement('html', '<tr><td>');

@ -27,10 +27,11 @@ array_push($login_conditions, array(
//));
function dc_check_phone_number($user){
$uInfo = UserManager::get_user_info_by_id($user['user_id']);
$uInfo = api_get_user_info($user['user_id']);
if (empty($uInfo['phone'])) {
return false;
}
return true;
}

@ -152,7 +152,7 @@ function external_add_user($u) {
* @author ndiechburg <noel@cblue.be>
* */
function external_update_user($new_user) {
$old_user = UserManager::get_user_info_by_id($new_user['user_id']);
$old_user = api_get_user_info($new_user['user_id']);
$u = array_merge($old_user, $new_user);
$updated = UserManager::update_user($u['user_id'], $u['firstname'], $u['lastname'], $u['username'], null, $u['auth_source'], $u['email'], $u['status'], $u['official_code'], $u['phone'], $u['picture_uri'], $u['expiration_date'], $u['active'], $u['creator_id'], $u['hr_dept_id'], $u['extra'], $u['language'], '');
if (isset($u['courses']) && !empty($u['courses'])) {

@ -5,13 +5,13 @@
This script must not exit.
*/
use \ChamiloSession as Session;
use ChamiloSession as Session;
require_once(dirname(__FILE__) . '/functions.inc.php');
//MAIN CODE
//$uData variable is set in local.inc.php
$user = UserManager::get_user_info_by_id($uData['user_id']);
$user = api_get_user_info($uData['user_id']);
$new_user = external_get_user_info($login);
$user['firstname'] = $new_user['firstname'];
$user['lastname'] = $new_user['lastname'];

@ -1,39 +1,39 @@
<?php
use \ChamiloSession as Session;
use ChamiloSession as Session;
/**
* Used to authenticate user with an access token. By default this method is disabled.
* Method used primarily to make API calls: Rss, file upload.
*
* Access is granted only for the services that are enabled.
*
* To be secured this method must
*
*
* Access is granted only for the services that are enabled.
*
* To be secured this method must
*
* 1) be called through httpS to avoid sniffing (note that this is the case anyway with other methods such as cookies)
* 2) the url/access token must be secured
*
* This authentication method is session less. This is to ensure that the navigator
*
* This authentication method is session less. This is to ensure that the navigator
* do not receive an access cookie that will grant it access to other parts of the
* application.
*
*
*
*
* Usage:
*
* Enable KeyAuth for a specific service. Add the following lines so that
* the key authentication method is enabled for a specific service before
*
* Enable KeyAuth for a specific service. Add the following lines so that
* the key authentication method is enabled for a specific service before
* calling global.inc.php.
*
*
* include_once '.../main/inc/autoload.inc.php';
* KeyAuth::enable_services('my_service');
* include_once '.../main/inc/global.inc.php';
*
*
*
*
* Enable url access for a short period of time:
*
*
* token = KeyAuth::create_temp_token();
* url = '...?access_token=' . $token ;
*
*
* @see AccessToken
* @license see /license.txt
* @author Laurent Opprecht <laurent@opprecht.info> for the Univesity of Geneva
@ -52,7 +52,7 @@ class KeyAuth
/**
* Returns enabled services
*
*
* @return array
*/
public static function get_services()
@ -61,9 +61,9 @@ class KeyAuth
}
/**
* Name of the service for which we are goint to check the API Key.
* Name of the service for which we are goint to check the API Key.
* If empty it disables authentication.
*
*
* !! 10 chars max !!
*/
public static function enable_services($_)
@ -109,7 +109,7 @@ class KeyAuth
}
/**
* Enable key authentication for the default service - i.e. chamilo
* Enable key authentication for the default service - i.e. chamilo
*/
public static function enable()
{
@ -124,7 +124,7 @@ class KeyAuth
/**
* Returns true if the key authentication method is enabled. False otherwise.
* Default to false.
*
*
* @return bool
*/
public static function is_enabled()
@ -133,7 +133,7 @@ class KeyAuth
}
/**
* @return KeyAuth
* @return KeyAuth
*/
public static function instance()
{
@ -146,18 +146,18 @@ class KeyAuth
protected function __construct()
{
}
/**
* Returns true if authentication accepts to run otherwise returns false.
*
* @return boolean
*
* @return boolean
*/
public function accept()
{
/**
* Authentication method must be enabled
* Authentication method must be enabled
*/
if (!self::is_enabled()) {
return false;
@ -174,7 +174,7 @@ class KeyAuth
}
/**
* The service corresponding to the key must be enabled.
* The service corresponding to the key must be enabled.
*/
$service = $key['api_service'];
if (!self::is_service_enabled($service)) {
@ -182,9 +182,9 @@ class KeyAuth
}
/**
* User associated with the key must be active
* User associated with the key must be active
*/
$user = UserManager::get_user_info_by_id($token->get_user_id());
$user = api_get_user_info($token->get_user_id());
if (empty($user)) {
return false;
}
@ -193,16 +193,16 @@ class KeyAuth
}
/**
* Token must be valid.
* Token must be valid.
*/
return $token->is_valid();
}
/**
* If accepted tear down session, log in user and returns true.
* If accepted tear down session, log in user and returns true.
* If not accepted do nothing and returns false.
*
* @return boolean
*
* @return boolean
*/
public function login()
{
@ -210,22 +210,22 @@ class KeyAuth
return false;
}
/**
* ! important this is to ensure we don't grant access for other parts
* ! important this is to ensure we don't grant access for other parts
*/
Session::destroy();
/**
* We don't allow redirection since access is granted only for this call
* We don't allow redirection since access is granted only for this call
*/
global $no_redirection, $noredirection;
$no_redirection = true;
$noredirection = true;
Session::write('noredirection', $noredirection);
$user_id = $this->get_user_id();
$course_code = $this->get_course_code();
$group_id = $this->get_group_id();
Login::init_user($user_id, true);
Login::init_course($course_code, true);
Login::init_group($group_id, true);
@ -235,7 +235,7 @@ class KeyAuth
/**
* Returns the request access token
*
*
* @return AccessToken
*/
public function get_access_token()
@ -243,20 +243,20 @@ class KeyAuth
$string = Request::get(self::PARAM_ACCESS_TOKEN);
return AccessToken::parse($string);
}
public function get_user_id()
{
return $this->get_access_token()->get_user_id();
}
public function get_course_code()
{
return Request::get('cidReq', 0);
}
public function get_group_id()
{
return Request::get('gidReq', 0);
}
}
}

@ -94,7 +94,7 @@ $table_user = Database :: get_main_table(TABLE_MAIN_USER);
/*
* Get initial values for all fields.
*/
$user_data = UserManager::get_user_info_by_id(api_get_user_id());
$user_data = api_get_user_info(api_get_user_id());
$array_list_key = UserManager::get_api_keys(api_get_user_id());
$id_temp_key = UserManager::get_api_key_id(api_get_user_id(), 'dokeos');
$value_array = $array_list_key[$id_temp_key];
@ -268,7 +268,7 @@ if (is_platform_authentication() && is_profile_editable() && api_get_setting('pr
// EXTRA FIELDS
$extra_data = UserManager::get_extra_user_data(api_get_user_id(), true);
$return_params = UserManager::set_extra_fields_in_form($form, $extra_data, 'profile', false, api_get_user_id());
$return_params = UserManager::set_extra_fields_in_form($form, $extra_data, false, api_get_user_id());
$jquery_ready_content = $return_params['jquery_ready_content'];
// the $jquery_ready_content variable collects all functions that will be load in the $(document).ready javascript function
@ -364,11 +364,14 @@ function check_user_password($password) {
*/
function check_user_email($email) {
$user_id = api_get_user_id();
if ($user_id != strval(intval($user_id)) || empty($email)) { return false; }
if ($user_id != strval(intval($user_id)) || empty($email)) {
return false;
}
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$email = Database::escape_string($email);
$sql_password = "SELECT * FROM $table_user WHERE user_id='".$user_id."' AND email='".$email."'";
$result = Database::query($sql_password);
$sql = "SELECT * FROM $table_user
WHERE user_id='".$user_id."' AND email='".$email."'";
$result = Database::query($sql);
return Database::num_rows($result) != 0;
}
@ -593,6 +596,7 @@ if ($form->validate()) {
}
}
}
if (api_get_setting('profile', 'officialcode') == 'true' && isset($user_data['official_code'])) {
$sql .= ", official_code = '".Database::escape_string($user_data['official_code'])."'";
}

@ -1705,10 +1705,9 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) {
if (!empty($groupId)) {
if (!empty($document_data['insert_user_id'])) {
$user_info = UserManager::get_user_info_by_id($document_data['insert_user_id']);
$user_name = api_get_person_name($user_info['firstname'], $user_info['lastname']);
$user_info = api_get_user_info($document_data['insert_user_id']);
$user_link = '<div class="document_owner">'.
get_lang('Owner').': '.UserManager::displayUserProfile($user_info).'</div>';
get_lang('Owner').': '.UserManager::getUserProfileLink($user_info).'</div>';
}
}

@ -895,7 +895,7 @@ function store_add_dropbox()
if ($b_send_mail) {
foreach ($new_work_recipients as $recipient_id) {
$recipent_temp = UserManager :: get_user_info_by_id($recipient_id);
$recipent_temp = api_get_user_info($recipient_id);
$additionalParameters = array(
'smsType' => SmsPlugin::NEW_FILE_SHARED_COURSE_BY,
'userId' => $recipient_id,

@ -3967,7 +3967,7 @@ class Exercise
. '&id='
. $exe_id
. '&action=qualify';
$user_info = UserManager::get_user_info_by_id(api_get_user_id());
$user_info = api_get_user_info(api_get_user_id());
$msg = '<p>'.get_lang('ExerciseAttempted').' :</p>
<p>'.get_lang('AttemptDetails').' : </p>
@ -4043,7 +4043,7 @@ class Exercise
. '&id='
. $exe_id
. '&action=qualify';
$user_info = UserManager::get_user_info_by_id(api_get_user_id());
$user_info = api_get_user_info(api_get_user_id());
$msg = '<p>'.get_lang('OpenQuestionsAttempted').' :</p>
<p>'.get_lang('AttemptDetails').' : </p>
@ -4140,7 +4140,7 @@ class Exercise
. '&id='
. $exe_id
. '&action=qualify';
$user_info = UserManager::get_user_info_by_id(api_get_user_id());
$user_info = api_get_user_info(api_get_user_id());
$oral_question_list = null;
foreach ($question_list_answers as $item) {
@ -4183,11 +4183,11 @@ class Exercise
</tr>
</table>';
$msg .= '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'),$oral_question_list).'<br />';
$msg1 = str_replace("#exercise#", $this->exercise, $msg);
$msg = str_replace("#firstName#", $user_info['firstname'],$msg1);
$msg1 = str_replace("#lastName#", $user_info['lastname'],$msg);
$msg = str_replace("#mail#", $user_info['email'],$msg1);
$msg = str_replace("#course#", $course_info['name'],$msg1);
$msg1 = str_replace("#exercise#", $this->exercise, $msg);
$msg = str_replace("#firstName#", $user_info['firstname'], $msg1);
$msg1 = str_replace("#lastName#", $user_info['lastname'], $msg);
$msg = str_replace("#mail#", $user_info['email'], $msg1);
$msg = str_replace("#course#", $course_info['name'], $msg1);
if ($origin != 'learnpath') {
$msg.= get_lang('ClickToCommentAndGiveFeedback').', <br />

@ -204,8 +204,12 @@ function manage_form($default, $select_from_user_list = null, $sent_to = null)
$form->addElement('hidden','save_form','save_form');
//adding reply mail
$user_reply_info = UserManager::get_user_info_by_id($message_reply_info['user_sender_id']);
$default['content'] = '<p><br/></p>'.sprintf(get_lang('XWroteY'), api_get_person_name($user_reply_info['firstname'], $user_reply_info['lastname']), Security::filter_terms($message_reply_info['content']));
$user_reply_info = api_get_user_info($message_reply_info['user_sender_id']);
$default['content'] = '<p><br/></p>'.sprintf(
get_lang('XWroteY'),
$user_reply_info['complete_name'],
Security::filter_terms($message_reply_info['content'])
);
}
if (empty($group_id)) {
@ -310,7 +314,6 @@ if ($group_id != 0) {
// LEFT COLUMN
$social_left_content = null;
$userInfo = UserManager::get_user_info_by_id($user_id);
if (api_get_setting('allow_social_tool') == 'true') {
//Block Social Menu
$social_menu_block = SocialManager::show_social_menu('messages');

@ -100,13 +100,13 @@ if (isset($_REQUEST['action'])) {
}
$social_right_content = '';
$userInfo = UserManager::get_user_info_by_id($user_id);
if (api_get_setting('allow_social_tool') == 'true') {
//Block Social Menu
$social_menu_block = SocialManager::show_social_menu('messages');
$social_right_content .= '<div class="actions">';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.
Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>';
$social_right_content .= '</div>';
}
//MAIN CONTENT

Loading…
Cancel
Save