Merge branch '1.9.x' of github.com:chamilo/chamilo-lms into 1.9.x

1.9.x
Yannick Warnier 10 years ago
commit 3ca8bb6869
  1. 3
      main/inc/lib/message.lib.php
  2. 1
      main/inc/lib/webservices/MessagesWebService.class.php
  3. 44
      tests/scripts/update_user_extra_field.php
  4. 2
      webservices/rest.php

@ -1601,7 +1601,8 @@ class MessageManager
. "ON m.user_receiver_id = u.user_id "
. "WHERE u.user_id = $userId "
. "AND m.msg_status = " . MESSAGE_STATUS_UNREAD . " "
. "AND m.id > $lastId";
. "AND m.id > $lastId "
. "ORDER BY m.send_date DESC";
$result = Database::query($sql);

@ -113,6 +113,7 @@ class MessagesWebService extends WebService
'firstname' => $message['firstname'],
'completeName' => api_get_person_name($message['firstname'], $message['lastname']),
),
'sendDate' => $message['send_date'],
'content' => $message['content'],
'hasAttachments' => $hasAttachments,
'platform' => array(

@ -0,0 +1,44 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Updates an user extra field
* a file is needed with this format:
*
* user;country
* julio;France
*
* Where:
* "country "is the name of the user extra field,
* "France" is the value to save.
* "julio" is the username of the user to be updated
*
*/
exit;
require __DIR__.'/../../main/inc/global.inc.php';
// Define origin and destination courses' code
$extraFieldName = 'dni';
$debug = true;
api_protect_admin_script();
$extraField = new ExtraField('user');
$file = 'file.csv';
$users = Import :: csv_to_array($file);
foreach ($users as $user) {
$userInfo = api_get_user_info_from_username($user['user']);
if (!empty($userInfo)) {
if ($debug == false) {
UserManager::update_extra_field_value(
$userInfo['user_id'],
$extraFieldName,
$user[$extraFieldName]
);
}
echo 'Updating extrafield "'.$extraFieldName.'": '.$user[$extraFieldName].'<br />';
} else {
echo 'User does not exists: '.$user['user'].'<br />';
}
}

@ -76,4 +76,6 @@ switch ($action) {
}
/* View */
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
echo json_encode($json);

Loading…
Cancel
Save