代码之家  ›  专栏  ›  技术社区  ›  Kevin

Drupal和NetForum:创建用户

  •  1
  • Kevin  · 技术社区  · 15 年前

    我正在尝试从Drupal的Web表单在NetForum中创建一个用户。

    使用webform挂钩,我调用两个函数来获取用户的电子邮件地址和名,并在用户提交基本webform时创建一个netforum帐户。

    但是,当我点击Submit时,表单超时,NetForum的看门狗错误是“无法获取HTTP头”。我在实现过程中是否做了错误的事情?我一直在等待。

    http://wiki.avectra.com/XWeb:WEBWebUserCreate

    function inclind_form_webform_submission_insert($node, $submission) {
    
        // find the email address in the form
    
        $form_fields = $node->webform['components'];
    
        foreach ($form_fields as $key => $value) {
            $arguments = array();
            $response = '';
    
            if ($value['type'] == 'email') {
                $arguments = array(
                   'emailToMatch' => $submission->data[$key]['value'][0]
                );
    
                $response = netforum_xweb_request('WEBWebUserFindUsersByEmail', $arguments, NULL);
    
                if (!isset($response) || $response->{@attributes}['recordResult'] == 0) {
                    inclind_form_create_netforum_user($form_fields, $submission);
                }
            }
        }
    
        return;
    }
    
    
    /*
    *    Create a user in netForum based on form data
    *
    *     @param $form_fields
    *         The form structure passed in from inclind_form_webform_submission_insert
    *  @param $submission
    *      The form data passed in from inclind_form_webform_submission_insert
    */
    
    function inclind_form_create_netforum_user($form_fields, $submission) {
    
        $arguments = array();
        $arguments['oWebUser']['Individual'] = array();
        $arguments['oWebUser']['Email'] = array();
        $arguments['oWebUser']['Customer'] = array();
        $arguments['oWebUser']['Business_Address'] = array();
        $arguments['oWebUser']['Business_Phone'] = array();
        $arguments['oWebUser']['Business_Phone_XRef'] = array();
        $arguments['oWebUser']['Business_Fax'] = array();
        $arguments['oWebUser']['Business_Fax_XRef'] = array();
    
    
        foreach ($form_fields as $key => $value) {
            if ($value['form_key'] == 'ind_first_name') {
                $arguments['oWebUser']['Individual']['ind_first_name'] = $submission->data[$key]['value'][0];
            }
            if ($value['form_key'] == 'ind_last_name') {
                $arguments['oWebUser']['Individual']['ind_last_name'] = $submission->data[$key]['value'][0];
            }
            if (strlen($arguments['oWebUser']['Individual']['ind_first_name']) && strlen($arguments['oWebUser']['Individual']['ind_last_name'])) {
                $arguments['oWebUser']['Individual']['ind_full_name'] = $arguments['oWebUser']['Individual']['ind_first_name'] . ' ' . $arguments['oWebUser']['Individual']['ind_last_name'];
            }
            if ($value['form_key'] == 'eml_address') {
                $arguments['oWebUser']['Email']['eml_address'] = $submission->data[$key]['value'][0];
                $arguments['oWebUser']['Customer']['cst_web_login'] = $submission->data[$key]['value'][0];
                $arguments['oWebUser']['Customer']['cst_new_password'] = user_password(20);
                $arguments['oWebUser']['Customer']['cst_new_password_confirm'] = $arguments['oWebUser']['Customer']['cst_new_password'];
            }
            if ($value['form_key'] == 'adr_post_code') {
                $arguments['oWebUser']['Business_Address']['adr_post_code'] = $submission->data[$key]['value'][0];
            }
        }
    
        if (!isset($arguments['oWebUser']['Business_Address']['adr_city'])) {
            $arguments['oWebUser']['Business_Address']['adr_city'] = 'Not Given';
        }
    
        if (!isset($arguments['oWebUser']['Business_Address']['adr_state'])) {
            $arguments['oWebUser']['Business_Address']['adr_state'] = 'NA';
        }
    
        if (!isset($arguments['oWebUser']['Business_Address']['adr_post_code'])) {
            $arguments['oWebUser']['Business_Address']['adr_post_code'] = '00000';
        }
    
        if (!isset($arguments['oWebUser']['Business_Address']['adr_country'])) {
            $arguments['oWebUser']['Business_Address']['adr_country'] = 'Not Given';
        }
    
        if (!isset($arguments['oWebUser']['Business_Phone']['phn_number'])) {
            $arguments['oWebUser']['Business_Phone']['phn_number'] = '000-000-0000';
        }
    
        if (!isset($arguments['oWebUser']['Business_Phone_XRef']['cph_extension'])) {
            $arguments['oWebUser']['Business_Phone_XRef']['cph_extension'] = '000';
        }
    
        if (!isset($arguments['oWebUser']['Business_Fax']['fax_number'])) {
            $arguments['oWebUser']['Business_Fax']['fax_number'] = '000-000-0000';
        }
    
        $response = netforum_xweb_request('WEBWebUserCreate', $arguments, '1 min');
        watchdog('netforum', 'netforum user @user created', array('@user' => $arguments['oWebUser']['Email']['eml_address']), WATCHDOG_NOTICE);
    }
    
    1 回复  |  直到 15 年前
        1
  •  1
  •   Kevin    15 年前