/**
  * Create a Drupal user when the Chamilo user is registered
  * @param HookCreateUserEventInterface $hook The hook
  */
 public function hookCreateUser(HookCreateUserEventInterface $hook)
 {
     $data = $hook->getEventData();
     $drupalDomain = CreateDrupalUser::create()->get('drupal_domain');
     $drupalDomain = rtrim($drupalDomain, '/') . '/';
     if ($data['type'] === HOOK_EVENT_TYPE_POST) {
         $return = $data['return'];
         $originalPassword = $data['originalPassword'];
         $userInfo = api_get_user_info($return);
         $fields = array('name' => $userInfo['username'], 'pass' => $originalPassword, 'mail' => $userInfo['email'], 'status' => 1, 'init' => $userInfo['email']);
         $extraFields = array('first_name' => $userInfo['firstname'], 'last_name' => $userInfo['lastname']);
         $options = array('location' => $drupalDomain . 'sites/all/modules/chamilo/soap.php?wsdl', 'uri' => $drupalDomain);
         $client = new SoapClient(null, $options);
         $drupalUserId = false;
         if (isset($_SESSION['ws_drupal_user_id'])) {
             $drupalUserId = $_SESSION['ws_drupal_user_id'];
             return true;
         }
         if ($drupalUserId === false) {
             $drupalUserId = $client->addUser($fields, $extraFields);
         }
         if ($drupalUserId !== false) {
             UserManager::update_extra_field_value($return, 'drupal_user_id', $drupalUserId);
         }
     }
 }
示例#2
0
<?php

/* For licensing terms, see /license.txt */
/**
 * Get the plugin info
 * @author Angel Fernando Quiroz Campos <*****@*****.**>
 * @package chamilo.plugin.createDrupalUser
 */
require_once __DIR__ . '/config.php';
$plugin_info = CreateDrupalUser::create()->get_info();
示例#3
0
<?php

/* For licensing terms, see /license.txt */
/**
 * Initialization uninstall
 * @author Angel Fernando Quiroz Campos <*****@*****.**>
 * @package chamilo.plugin.createDrupalUser
 */
require_once __DIR__ . '/config.php';
CreateDrupalUser::create()->uninstall();