Restore code and move drupal user id update action to HookCreateDrupalUser.php - refs BT9083

1.10.x
Imanol Losada 10 years ago
parent 3c893775f6
commit d5d6ee1112
  1. 12
      main/inc/lib/hook/HookCreateUser.php
  2. 20
      main/inc/lib/usermanager.lib.php
  3. 6
      plugin/createdrupaluser/src/HookCreateDrupalUser.php

@ -17,21 +17,17 @@ class HookCreateUser extends HookEvent implements HookCreateUserEventInterface
/**
* Update all the observers
* @param int $type
* @param int $type
*
* @return array User ids
* @return int
*/
public function notifyCreateUser($type)
{
/** @var \HookCreateUserObserverInterface $observer */
$this->eventData['type'] = $type;
$userIds = array();
foreach ($this->observers as $observer) {
$userId = $observer->hookCreateUser($this);
if ($userId !== false) {
$userIds[] = $userId;
}
$observer->hookCreateUser($this);
}
return $userIds;
return 1;
}
}

@ -276,18 +276,6 @@ class UserManager
return api_set_failure('error inserting in Database');
}
if (!empty($hook)) {
$hook->setEventData(array(
'return' => $return,
'originalPassword' => $original_password
));
$userIds = $hook->notifyCreateUser(HOOK_EVENT_TYPE_POST);
foreach ($userIds as $userId) {
$key = key($userId);
$extra[$key] = $userId[$key];
}
}
if (is_array($extra) && count($extra) > 0) {
$res = true;
foreach ($extra as $fname => $fvalue) {
@ -295,6 +283,14 @@ class UserManager
}
}
self::update_extra_field_value($return, 'already_logged_in', 'false');
if (!empty($hook)) {
$hook->setEventData(array(
'return' => $return,
'originalPassword' => $original_password
));
$hook->notifyCreateUser(HOOK_EVENT_TYPE_POST);
}
return $return;
}

@ -22,8 +22,7 @@ class HookCreateDrupalUser extends HookObserver implements HookCreateUserObserve
/**
* Create a Drupal user when the Chamilo user is registered
* @param HookCreateUserEventInterface $hook The hook
* @return array|bool Drupal created user id
* @param HookCreateUserEventInterface $hook The hook
*/
public function hookCreateUser(HookCreateUserEventInterface $hook)
{
@ -57,9 +56,8 @@ class HookCreateDrupalUser extends HookObserver implements HookCreateUserObserve
$client = new SoapClient(null, $options);
$drupalUserId = $client->addUser($fields, $extraFields);
if ($drupalUserId !== false) {
$drupalUserId = array('drupal_user_id' => $drupalUserId);
UserManager::update_extra_field_value($return, 'drupal_user_id', $drupalUserId);
}
return $drupalUserId;
}
}

Loading…
Cancel
Save