当前位置: 首页>>代码示例>>PHP>>正文


PHP custom_profile::build_insert_sql_array方法代码示例

本文整理汇总了PHP中custom_profile::build_insert_sql_array方法的典型用法代码示例。如果您正苦于以下问题:PHP custom_profile::build_insert_sql_array方法的具体用法?PHP custom_profile::build_insert_sql_array怎么用?PHP custom_profile::build_insert_sql_array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在custom_profile的用法示例。


在下文中一共展示了custom_profile::build_insert_sql_array方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: user_add

/**
* Adds an user
*
* @param mixed $user_row An array containing the following keys (and the appropriate values): username, group_id (the group to place the user in), user_email and the user_type(usually 0). Additional entries not overridden by defaults will be forwarded.
* @param string $cp_data custom profile fields, see custom_profile::build_insert_sql_array
* @param array $notifications_data The notifications settings for the new user
* @return the new user's ID.
*/
function user_add($user_row, $cp_data = false, $notifications_data = null)
{
    global $db, $user, $auth, $config, $phpbb_root_path, $phpEx;
    global $phpbb_dispatcher, $phpbb_container;
    if (empty($user_row['username']) || !isset($user_row['group_id']) || !isset($user_row['user_email']) || !isset($user_row['user_type'])) {
        return false;
    }
    $username_clean = utf8_clean_string($user_row['username']);
    if (empty($username_clean)) {
        return false;
    }
    $sql_ary = array('username' => $user_row['username'], 'username_clean' => $username_clean, 'user_password' => isset($user_row['user_password']) ? $user_row['user_password'] : '', 'user_email' => strtolower($user_row['user_email']), 'user_email_hash' => phpbb_email_hash($user_row['user_email']), 'group_id' => $user_row['group_id'], 'user_type' => $user_row['user_type']);
    // These are the additional vars able to be specified
    $additional_vars = array('user_permissions' => '', 'user_timezone' => $config['board_timezone'], 'user_dateformat' => $config['default_dateformat'], 'user_lang' => $config['default_lang'], 'user_style' => (int) $config['default_style'], 'user_actkey' => '', 'user_ip' => '', 'user_regdate' => time(), 'user_passchg' => time(), 'user_options' => 230271, 'user_new' => 0, 'user_inactive_reason' => 0, 'user_inactive_time' => 0, 'user_lastmark' => time(), 'user_lastvisit' => 0, 'user_lastpost_time' => 0, 'user_lastpage' => '', 'user_posts' => 0, 'user_colour' => '', 'user_avatar' => '', 'user_avatar_type' => '', 'user_avatar_width' => 0, 'user_avatar_height' => 0, 'user_new_privmsg' => 0, 'user_unread_privmsg' => 0, 'user_last_privmsg' => 0, 'user_message_rules' => 0, 'user_full_folder' => PRIVMSGS_NO_BOX, 'user_emailtime' => 0, 'user_notify' => 0, 'user_notify_pm' => 1, 'user_notify_type' => NOTIFY_EMAIL, 'user_allow_pm' => 1, 'user_allow_viewonline' => 1, 'user_allow_viewemail' => 1, 'user_allow_massemail' => 1, 'user_sig' => '', 'user_sig_bbcode_uid' => '', 'user_sig_bbcode_bitfield' => '', 'user_form_salt' => unique_id());
    // Now fill the sql array with not required variables
    foreach ($additional_vars as $key => $default_value) {
        $sql_ary[$key] = isset($user_row[$key]) ? $user_row[$key] : $default_value;
    }
    // Any additional variables in $user_row not covered above?
    $remaining_vars = array_diff(array_keys($user_row), array_keys($sql_ary));
    // Now fill our sql array with the remaining vars
    if (sizeof($remaining_vars)) {
        foreach ($remaining_vars as $key) {
            $sql_ary[$key] = $user_row[$key];
        }
    }
    /**
     * Use this event to modify the values to be inserted when a user is added
     *
     * @event core.user_add_modify_data
     * @var array	user_row		Array of user details submited to user_add
     * @var array	cp_data			Array of Custom profile fields submited to user_add
     * @var array	sql_ary		Array of data to be inserted when a user is added
     * @since 3.1.0-a1
     * @change 3.1.0-b5
     */
    $vars = array('user_row', 'cp_data', 'sql_ary');
    extract($phpbb_dispatcher->trigger_event('core.user_add_modify_data', compact($vars)));
    ///archi11 code starts
    $sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
    $db->sql_query($sql);
    $last_user_id = $db->sql_nextid();
    // **** CVC-11/22/15
    $sql1 = "INSERT INTO " . USER_SUBACCOUNT . " (uid,alias_accout_id) values('" . $user->data['user_id'] . "','" . $last_user_id . "')";
    // **** CVC-11/22/15
    $db->sql_query($sql1);
    // **** CVC-11/22/15
    $user_id = $db->sql_nextid();
    // Insert Custom Profile Fields
    if ($cp_data !== false && sizeof($cp_data)) {
        $cp_data['user_id'] = (int) $user_id;
        $cp = $phpbb_container->get('profilefields.manager');
        if (!class_exists('custom_profile')) {
            // **** CVC-11/22/15
            include_once $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx;
            // **** CVC-11/22/15
        }
        // **** CVC-11/22/15
        $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', custom_profile::build_insert_sql_array($cp_data));
        // **** CVC-11/22/15
        //$db->sql_build_array('INSERT', $cp->build_insert_sql_array($cp_data));
        $db->sql_query($sql);
    }
    // Place into appropriate group...
    $sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' ' . $db->sql_build_array('INSERT', array('user_id' => (int) $user_id, 'group_id' => (int) $user_row['group_id'], 'user_pending' => 0));
    $db->sql_query($sql);
    // Now make it the users default group...
    group_set_user_default($user_row['group_id'], array($user_id), false);
    // Add to newly registered users group if user_new is 1
    if ($config['new_member_post_limit'] && $sql_ary['user_new']) {
        $sql = 'SELECT group_id
			FROM ' . GROUPS_TABLE . "\n\t\t\tWHERE group_name = 'NEWLY_REGISTERED'\n\t\t\t\tAND group_type = " . GROUP_SPECIAL;
        $result = $db->sql_query($sql);
        $add_group_id = (int) $db->sql_fetchfield('group_id');
        $db->sql_freeresult($result);
        if ($add_group_id) {
            global $phpbb_log;
            // Because these actions only fill the log unneccessarily we skip the add_log() entry.
            $phpbb_log->disable('admin');
            // Add user to "newly registered users" group and set to default group if admin specified so.
            if ($config['new_member_group_default']) {
                group_user_add($add_group_id, $user_id, false, false, true);
                $user_row['group_id'] = $add_group_id;
            } else {
                group_user_add($add_group_id, $user_id);
            }
            $phpbb_log->enable('admin');
        }
    }
    // set the newest user and adjust the user count if the user is a normal user and no activation mail is sent
    if ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_FOUNDER) {
        set_config('newest_user_id', $user_id, true);
//.........这里部分代码省略.........
开发者ID:corycubbage,项目名称:ShadoWorld,代码行数:101,代码来源:functions_user.php

示例2: user_add

/**
* Adds an user
*
* @param mixed $user_row An array containing the following keys (and the appropriate values): username, group_id (the group to place the user in), user_email and the user_type(usually 0). Additional entries not overridden by defaults will be forwarded.
* @param string $cp_data custom profile fields, see custom_profile::build_insert_sql_array
* @return the new user's ID.
*/
function user_add($user_row, $cp_data = false)
{
    global $db, $user, $auth, $config, $phpbb_root_path, $phpEx;
    if (empty($user_row['username']) || !isset($user_row['group_id']) || !isset($user_row['user_email']) || !isset($user_row['user_type'])) {
        return false;
    }
    $username_clean = utf8_clean_string($user_row['username']);
    if (empty($username_clean)) {
        return false;
    }
    $sql_ary = array('username' => $user_row['username'], 'username_clean' => $username_clean, 'user_password' => isset($user_row['user_password']) ? $user_row['user_password'] : '', 'user_pass_convert' => 0, 'user_email' => strtolower($user_row['user_email']), 'user_email_hash' => crc32(strtolower($user_row['user_email'])) . strlen($user_row['user_email']), 'group_id' => $user_row['group_id'], 'user_type' => $user_row['user_type']);
    // These are the additional vars able to be specified
    $additional_vars = array('user_permissions' => '', 'user_timezone' => $config['board_timezone'], 'user_dateformat' => $config['default_dateformat'], 'user_lang' => $config['default_lang'], 'user_style' => (int) $config['default_style'], 'user_actkey' => '', 'user_ip' => '', 'user_regdate' => time(), 'user_passchg' => time(), 'user_options' => 895, 'user_inactive_reason' => 0, 'user_inactive_time' => 0, 'user_lastmark' => time(), 'user_lastvisit' => 0, 'user_lastpost_time' => 0, 'user_lastpage' => '', 'user_posts' => 0, 'user_dst' => (int) $config['board_dst'], 'user_colour' => '', 'user_occ' => '', 'user_interests' => '', 'user_avatar' => '', 'user_avatar_type' => 0, 'user_avatar_width' => 0, 'user_avatar_height' => 0, 'user_new_privmsg' => 0, 'user_unread_privmsg' => 0, 'user_last_privmsg' => 0, 'user_message_rules' => 0, 'user_full_folder' => PRIVMSGS_NO_BOX, 'user_emailtime' => 0, 'user_notify' => 0, 'user_notify_pm' => 1, 'user_notify_type' => NOTIFY_EMAIL, 'user_allow_pm' => 1, 'user_allow_viewonline' => 1, 'user_allow_viewemail' => 1, 'user_allow_massemail' => 1, 'user_sig' => '', 'user_sig_bbcode_uid' => '', 'user_sig_bbcode_bitfield' => '', 'user_form_salt' => unique_id());
    // Now fill the sql array with not required variables
    foreach ($additional_vars as $key => $default_value) {
        $sql_ary[$key] = isset($user_row[$key]) ? $user_row[$key] : $default_value;
    }
    // Any additional variables in $user_row not covered above?
    $remaining_vars = array_diff(array_keys($user_row), array_keys($sql_ary));
    // Now fill our sql array with the remaining vars
    if (sizeof($remaining_vars)) {
        foreach ($remaining_vars as $key) {
            $sql_ary[$key] = $user_row[$key];
        }
    }
    $sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
    $db->sql_query($sql);
    $user_id = $db->sql_nextid();
    // Insert Custom Profile Fields
    if ($cp_data !== false && sizeof($cp_data)) {
        $cp_data['user_id'] = (int) $user_id;
        if (!class_exists('custom_profile')) {
            include_once $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx;
        }
        $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', custom_profile::build_insert_sql_array($cp_data));
        $db->sql_query($sql);
    }
    // Place into appropriate group...
    $sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' ' . $db->sql_build_array('INSERT', array('user_id' => (int) $user_id, 'group_id' => (int) $user_row['group_id'], 'user_pending' => 0));
    $db->sql_query($sql);
    // Now make it the users default group...
    group_set_user_default($user_row['group_id'], array($user_id), false);
    // set the newest user and adjust the user count if the user is a normal user and no activation mail is sent
    if ($user_row['user_type'] == USER_NORMAL) {
        set_config('newest_user_id', $user_id, true);
        set_config('newest_username', $user_row['username'], true);
        set_config('num_users', $config['num_users'] + 1, true);
        $sql = 'SELECT group_colour
			FROM ' . GROUPS_TABLE . '
			WHERE group_id = ' . (int) $user_row['group_id'];
        $result = $db->sql_query_limit($sql, 1);
        $row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        set_config('newest_user_colour', $row['group_colour'], true);
    }
    return $user_id;
}
开发者ID:Phatboy82,项目名称:phpbbgarage,代码行数:64,代码来源:functions_user.php

示例3: user_add

/**
* Add User
*/
function user_add($user_row, $cp_data = false)
{
    global $db, $user, $auth, $config, $phpbb_root_path, $phpEx;
    if (empty($user_row['username']) || !isset($user_row['group_id']) || !isset($user_row['user_email']) || !isset($user_row['user_type'])) {
        return false;
    }
    $sql_ary = array('username' => $user_row['username'], 'user_password' => isset($user_row['user_password']) ? $user_row['user_password'] : '', 'user_email' => $user_row['user_email'], 'user_email_hash' => (int) crc32(strtolower($user_row['user_email'])) . strlen($user_row['user_email']), 'group_id' => $user_row['group_id'], 'user_type' => $user_row['user_type']);
    // These are the additional vars able to be specified
    $additional_vars = array('user_permissions' => '', 'user_timezone' => 0, 'user_dateformat' => $config['default_dateformat'], 'user_lang' => $config['default_lang'], 'user_style' => $config['default_style'], 'user_allow_pm' => 1, 'user_actkey' => '', 'user_ip' => '', 'user_regdate' => time(), 'user_lastmark' => time(), 'user_lastvisit' => 0, 'user_lastpost_time' => 0, 'user_lastpage' => '', 'user_posts' => 0, 'user_dst' => 0, 'user_colour' => '', 'user_avatar' => '', 'user_avatar_type' => 0, 'user_avatar_width' => 0, 'user_avatar_height' => 0, 'user_new_privmsg' => 0, 'user_unread_privmsg' => 0, 'user_last_privmsg' => 0, 'user_message_rules' => 0, 'user_full_folder' => PRIVMSGS_NO_BOX, 'user_emailtime' => 0, 'user_notify' => 0, 'user_notify_pm' => 1, 'user_notify_type' => NOTIFY_EMAIL, 'user_allow_pm' => 1, 'user_allow_email' => 1, 'user_allow_viewonline' => 1, 'user_allow_viewemail' => 1, 'user_allow_massemail' => 1, 'user_sig' => '', 'user_sig_bbcode_uid' => '', 'user_sig_bbcode_bitfield' => 0);
    // Now fill the sql array with not required variables
    foreach ($additional_vars as $key => $default_value) {
        $sql_ary[$key] = isset($user_row[$key]) ? $user_row[$key] : $default_value;
    }
    // Any additional variables in $user_row not covered above?
    $remaining_vars = array_diff(array_keys($user_row), array_keys($sql_ary));
    // Now fill our sql array with the remaining vars
    if (sizeof($remaining_vars)) {
        foreach ($remaining_vars as $key) {
            $sql_ary[$key] = $user_row[$key];
        }
    }
    $db->sql_transaction('begin');
    $sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
    $db->sql_query($sql);
    $user_id = $db->sql_nextid();
    // Insert Custom Profile Fields
    if ($cp_data !== false && sizeof($cp_data)) {
        $cp_data['user_id'] = (int) $user_id;
        if (!class_exists('custom_profile')) {
            include_once $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx;
        }
        $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', custom_profile::build_insert_sql_array($cp_data));
        $db->sql_query($sql);
    }
    // Place into appropriate group...
    $sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' ' . $db->sql_build_array('INSERT', array('user_id' => (int) $user_id, 'group_id' => (int) $user_row['group_id'], 'user_pending' => 0));
    $db->sql_query($sql);
    $db->sql_transaction('commit');
    return $user_id;
}
开发者ID:yunsite,项目名称:gloryroad,代码行数:43,代码来源:functions_user.php


注:本文中的custom_profile::build_insert_sql_array方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。