/**
  * Function to create a user in Drupal.
  *
  * @param array  $params associated array
  * @param string $mail email id for cms user
  *
  * @return uid if user exists, false otherwise
  *
  * @access public
  *
  */
 function createUser(&$params, $mail)
 {
     $form_state = array();
     $form_state['input'] = array('name' => $params['cms_name'], 'mail' => $params[$mail], 'op' => 'Create new account');
     $admin = user_access('administer users');
     if (!variable_get('user_email_verification', TRUE) || $admin) {
         $form_state['input']['pass'] = array('pass1' => $params['cms_pass'], 'pass2' => $params['cms_pass']);
     }
     $form_state['rebuild'] = FALSE;
     $form_state['programmed'] = TRUE;
     $form_state['method'] = 'post';
     $form_state['build_info']['args'] = array();
     $config = CRM_Core_Config::singleton();
     // we also need to redirect b
     $config->inCiviCRM = TRUE;
     $form = drupal_retrieve_form('user_register_form', $form_state);
     $form_state['process_input'] = 1;
     $form_state['submitted'] = 1;
     drupal_process_form('user_register_form', $form, $form_state);
     $config->inCiviCRM = FALSE;
     if (form_get_errors()) {
         return FALSE;
     } else {
         return $form_state['user']->uid;
     }
 }
Esempio n. 2
0
 /**
  * Function to create a user in Drupal.
  *
  * @param array  $params associated array
  * @param string $mail email id for cms user
  *
  * @return uid if user exists, false otherwise
  *
  * @access public
  *
  */
 function createUser(&$params, $mail)
 {
     $form_state = form_state_defaults();
     $form_state['input'] = array('name' => $params['cms_name'], 'mail' => $params[$mail], 'op' => 'Create new account');
     $admin = user_access('administer users');
     if (!variable_get('user_email_verification', TRUE) || $admin) {
         $form_state['input']['pass'] = array('pass1' => $params['cms_pass'], 'pass2' => $params['cms_pass']);
     }
     if (!empty($params['notify'])) {
         $form_state['input']['notify'] = $params['notify'];
     }
     $form_state['rebuild'] = FALSE;
     $form_state['programmed'] = TRUE;
     $form_state['complete form'] = FALSE;
     $form_state['method'] = 'post';
     $form_state['build_info']['args'] = array();
     /*
      * if we want to submit this form more than once in a process (e.g. create more than one user)
      * we must force it to validate each time for this form. Otherwise it will not validate
      * subsequent submissions and the manner in which the password is passed in will be invalid
      * */
     $form_state['must_validate'] = TRUE;
     $config = CRM_Core_Config::singleton();
     // we also need to redirect b
     $config->inCiviCRM = TRUE;
     $form = drupal_retrieve_form('user_register_form', $form_state);
     $form_state['process_input'] = 1;
     $form_state['submitted'] = 1;
     $form['#array_parents'] = array();
     $form['#tree'] = FALSE;
     drupal_process_form('user_register_form', $form, $form_state);
     $config->inCiviCRM = FALSE;
     if (form_get_errors()) {
         return FALSE;
     }
     return $form_state['user']->uid;
 }
 /**
  * Function to create a user in Drupal.
  *
  * @param array  $params associated array
  * @param string $mail email id for cms user
  *
  * @return uid if user exists, false otherwise
  *
  * @access public
  */
 function createUser(&$params, $mail)
 {
     $form_state = array();
     $form_state['values'] = array('name' => $params['cms_name'], 'mail' => $params[$mail], 'op' => 'Create new account');
     if (!variable_get('user_email_verification', TRUE)) {
         $form_state['values']['pass']['pass1'] = $params['cms_pass'];
         $form_state['values']['pass']['pass2'] = $params['cms_pass'];
     }
     $config = CRM_Core_Config::singleton();
     // we also need to redirect b
     $config->inCiviCRM = TRUE;
     $form = drupal_retrieve_form('user_register', $form_state);
     $form['#post'] = $form_state['values'];
     drupal_prepare_form('user_register', $form, $form_state);
     // remove the captcha element from the form prior to processing
     unset($form['captcha']);
     drupal_process_form('user_register', $form, $form_state);
     $config->inCiviCRM = FALSE;
     if (form_get_errors() || !isset($form_state['user'])) {
         return FALSE;
     }
     return $form_state['user']->uid;
 }
Esempio n. 4
0
 /**
  * Retrieves and saves current modules list into $_originalModules and $_modules.
  */
 function checkOriginalModules()
 {
     if (empty($this->_originalModules)) {
         require_once './modules/system/system.admin.inc';
         $form_state = array();
         $form = drupal_retrieve_form('system_modules', $form_state);
         $this->_originalModules = drupal_map_assoc($form['status']['#default_value']);
         $this->_modules = $this->_originalModules;
     }
 }