Fixed disabling of users through unsubscription - refs BT#4882

skala
Yannick Warnier 12 years ago
parent 0b9e502884
commit fe49cde7ea
  1. 16
      main/inc/lib/sessionmanager.lib.php
  2. 5
      tests/migrate/migration.custom.class.php

@ -2245,11 +2245,13 @@ class SessionManager {
* @params int new session id
* @params int see SessionManager::get_session_change_user_reasons()
*/
static function change_user_session($user_id, $old_session_id, $new_session_id, $reason_id) {
if (!empty($user_id) && !empty($old_session_id) && !empty($new_session_id)) {
static function change_user_session($user_id, $old_session_id, $new_session_id=null, $reason_id) {
if (!empty($user_id) && !empty($old_session_id)) {
$user_id = intval($user_id);
$old_session_id = intval($old_session_id);
$new_session_id = intval($new_session_id);
if (!empty($new_session_id)) {
$new_session_id = intval($new_session_id);
}
$reason_id = intval($reason_id);
//self::unsubscribe_user_from_session($old_session_id, $user_id, $reason_id);
@ -2282,7 +2284,7 @@ class SessionManager {
switch ($reason_id) {
case self::SESSION_CHANGE_USER_REASON_SCHEDULE:
case self::SESSION_CHANGE_USER_REASON_CLASSROOM:
case self::SESSION_CHANGE_USER_REASON_LOCATION:
case self::SESSION_CHANGE_USER_REASON_LOCATION:
//Adding to the new session
self::suscribe_users_to_session($new_session_id, array($user_id), null, false);
@ -2298,8 +2300,8 @@ class SessionManager {
$now = api_get_utc_datetime();
//Setting the moved_status
$sql = "UPDATE $tbl_session_rel_user SET moved_status = $reason_id, moved_at = '$now'
WHERE id_session = '$old_session_id' AND id_user ='$user_id'";
$sql = "UPDATE $tbl_session_rel_user SET moved_status = $reason_id, moved_at = '$now' ".
"WHERE id_session = '$old_session_id' AND id_user ='$user_id'";
Database::query($sql);
return true;
@ -2687,4 +2689,4 @@ class SessionManager {
);
return $return_array;
}
}
}

@ -889,8 +889,9 @@ class MigrationCustom {
if (!empty($session_id)) {
$before = SessionManager::get_user_status_in_session($session_id, $user_id);
//SessionManager::suscribe_users_to_session($session_id, array($user_id), SESSION_VISIBLE_READ_ONLY, false, false);
SessionManager::unsubscribe_user_from_session($session_id, $user_id);
$message = "Move Session to empty";
//SessionManager::unsubscribe_user_from_session($session_id, $user_id);
SessionManager::change_user_session($user_id, $session_id, null, 4);
$message = "Move Session to empty (cancelled subscription)";
return self::check_if_user_is_subscribe_to_session($user_id, $session_id, $message, $before);
} else {
return array(

Loading…
Cancel
Save