/** * Put a member into a usergroup temporarily / extend such a temporary usergroup membership. Note that if people are subsequently removed from the usergroup they won't be put back in; this allows the admin to essentially cancel the subscription - however, if it is then extended, they do keep the time they had before too. * * @param MEMBER The member going in the usergroup. * @param GROUP The usergroup. * @param integer The number of minutes (may be negative to take time away). * @param boolean Whether to put the member into as a primary group if this is a new temporary membership (it is recommended to NOT use this, since we don't track the source group and hence on expiry the member is put back to the first default group - but also generally you probably don't want to box yourself in with moving people's primary group, it ties your future flexibility down a lot). */ function bump_member_group_timeout($member_id, $group_id, $num_minutes, $prefer_for_primary_group = false) { // We don't want guests here! if (is_guest($member_id)) { fatal_exit(do_lang_tempcode('INTERNAL_ERROR')); } require_code('ocf_groups_action'); require_code('ocf_groups_action2'); require_code('ocf_members'); // Add to group if not already there $test = in_array($group_id, $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id)); if (!$test) { // Add them to the group if (get_value('unofficial_ecommerce') == '1' && get_forum_type() != 'ocf') { $GLOBALS['FORUM_DB']->add_member_to_group($member_id, $group_id); } else { if ($prefer_for_primary_group) { $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_update('f_members', array('m_primary_group' => $group_id), array('id' => $member_id), '', 1); $GLOBALS['FORUM_DRIVER']->MEMBER_ROWS_CACHED = array(); } else { ocf_add_member_to_group($member_id, $group_id); } } } // Extend or add, depending on whether they're in it yet $existing_timeout = $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_value_null_ok('f_group_member_timeouts', 'timeout', array('member_id' => $member_id, 'group_id' => $group_id)); if (is_null($existing_timeout)) { // Add $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_insert('f_group_member_timeouts', array('member_id' => $member_id, 'group_id' => $group_id, 'timeout' => time() + 60 * $num_minutes)); } else { // Extend $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_update('f_group_member_timeouts', array('timeout' => $existing_timeout + 60 * $num_minutes), array('member_id' => $member_id, 'group_id' => $group_id), '', 1); } global $USERS_GROUPS_CACHE, $GROUP_MEMBERS_CACHE; $USERS_GROUPS_CACHE = array(); $GROUP_MEMBERS_CACHE = array(); }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_members($db, $table_prefix, $file_base) { $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'users ORDER BY user_id', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('member', strval($row['user_id']))) { continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['user_name']); if (!is_null($test)) { import_id_remap_put('member', strval($row['user_id']), $test); continue; } $language = ''; if ($row['user_language'] != '') { switch ($language) { case 'english': $language = 'EN'; break; } } $primary_group = import_id_remap_get('group', $row['user_group_id']); $secondary_groups = array(); $custom_fields = array(ocf_make_boiler_custom_field('im_icq') => $row['user_icq'], ocf_make_boiler_custom_field('im_aim') => $row['user_aim'], ocf_make_boiler_custom_field('im_msn') => $row['user_msnm'], ocf_make_boiler_custom_field('im_yahoo') => $row['user_ym'], ocf_make_boiler_custom_field('interests') => $row['user_interests'], ocf_make_boiler_custom_field('location') => $row['user_city'] . ',' . $row['user_region'] . ',' . $row['user_country'], ocf_make_boiler_custom_field('occupation') => $row['user_occupation']); if ($row['user_homepage'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = strlen($row['user_homepage']) > 0 ? '[url]' . $row['user_homepage'] . '[/url]' : ''; } $signature = $this->fix_links($row['user_signature'], $db, $table_prefix, $file_base); $validated = $row['user_activation_key'] == '' ? 1 : 0; $reveal_age = 0; $exp = explode('-', $row['user_birthday']); list($bday_day, $bday_month, $bday_year) = array($exp[2], $exp[1], $exp[0]); $views_signatures = 1; $preview_posts = 1; $title = ''; $photo_url = ''; $photo_thumb_url = ''; $avatar_url = $row['user_avatar']; if (substr($avatar_url, 0, strlen('images/avatars/galleries/')) == 'images/avatars/galleries/') { $avatar_url = str_replace('images/avatars/galleries/', 'themes/default/images/ocf_default_avatars/', $avatar_url); } else { $avatar_url = str_replace('images/avatars/', 'uploads/ocf_avatars/', $avatar_url); } $password = $row['user_password']; $type = 'md5'; $salt = ''; $id_new = ocf_make_member($row['user_name'], $password, $row['user_email'], NULL, $bday_day, $bday_month, $bday_year, $custom_fields, NULL, $primary_group, $validated, strtotime($row['user_joined']), strtotime($row['user_joined']), '', $avatar_url, $signature, 0, $preview_posts, $reveal_age, $title, $photo_url, $photo_thumb_url, $views_signatures, 0, $language, 1, $row['user_admin_emails'], '', '', '', false, $type, $salt, 1); // Fix usergroup leadership $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => -$row['user_id'])); import_id_remap_put('member', strval($row['user_id']), $id_new); // Set up usergroup membership foreach ($secondary_groups as $s) { list($group, $userpending) = $s; ocf_add_member_to_group($id_new, $group, 1 - $userpending); } // OCP fields foreach ($row as $field => $val) { if (substr($val, 0, 4) == 'ocp_') { $GLOBALS['OCF_DRIVER']->set_custom_field($id_new, $field, substr($val, 4)); } } } $row_start += 200; } while (count($rows) > 0); }
/** * The actualiser to add a member to a usergroup. * * @param boolean Whether to skip checking permission for usergroup control * @param ?string Username to add (NULL: read from environment) * @return tempcode The UI */ function add_to($special_permission = false, $username = NULL) { $title = get_page_title('ADD_MEMBER_TO_GROUP'); $_id = get_param('id'); if (is_numeric($_id)) { $id = intval($_id); } else { $id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_groups g LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=g.g_name', 'g.id', array('text_original' => $_id)); if (is_null($id)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } } if ($id == db_get_first_id()) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } if (is_null($username)) { $username = trim(post_param('username')); } if ($username == '') { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN')); } if (!$special_permission && !ocf_may_control_group($id, get_member())) { access_denied('I_ERROR'); } $member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($username); if (is_null($member_id)) { warn_exit(do_lang_tempcode('_USER_NO_EXIST', escape_html($username))); } $test = $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id, false, false); if (in_array($id, $test)) { warn_exit(do_lang_tempcode('ALREADY_IN_GROUP')); } ocf_add_member_to_group($member_id, $id); $url = build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $id), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_members($db, $table_prefix, $file_base) { $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT *,u.userid AS userid FROM ' . $table_prefix . 'user u LEFT JOIN ' . $table_prefix . 'administrator a ON u.userid=a.userid LEFT JOIN ' . $table_prefix . 'usertextfield t ON u.userid=t.userid ORDER BY u.userid', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('member', strval($row['userid']))) { continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['username']); if (!is_null($test)) { import_id_remap_put('member', strval($row['userid']), $test); continue; } $language = ''; if ($row['languageid'] != 0) { $rows2 = $db->query('SELECT languagecode FROM ' . $table_prefix . 'language WHERE languageid=' . strval((int) $row['languageid'])); if (array_key_exists(0, $rows2)) { $language = strtoupper($rows2[0]['languagecode']); if (!file_exists(get_custom_file_base() . '/lang_custom/' . $language) && !file_exists(get_file_base() . '/lang/' . $language)) { $language = ''; } } } $primary_group = import_id_remap_get('group', strval($row['usergroupid'])); $secondary_groups = array(); if ($row['membergroupids'] != '') { $secondary_groups = explode(',', $row['membergroupids']); } $custom_fields = array(ocf_make_boiler_custom_field('im_icq') => $row['icq'], ocf_make_boiler_custom_field('im_aim') => $row['aim'], ocf_make_boiler_custom_field('im_yahoo') => $row['yahoo']); if ($row['homepage'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = strlen($row['homepage']) > 0 ? '[url]' . $row['homepage'] . '[/url]' : ''; } if ($row['msn'] != '') { $custom_fields[ocf_make_boiler_custom_field('im_msn')] = $row['msn']; } $signature = $row['signature']; $validated = 1; $reveal_age = $row['birthday'] != '' ? 1 : 0; $bits = explode('-', $row['birthday']); if ($reveal_age == 1 && count($bits) == 3) { list($bday_month, $bday_day, $bday_year) = $bits; } else { list($bday_month, $bday_day, $bday_year) = array(0, 0, 0); } $title = $row['customtitle'] == 1 ? $row['usertitle'] : ''; $views_signatures = $row['options'] & 1; $preview_posts = 1; // These are done in the members-files stage $avatar_url = ''; $photo_url = ''; $photo_thumb_url = ''; $password = $row['password']; $type = 'vb3'; $salt = $row['salt']; $requests = $db->query('SELECT * FROM ' . $table_prefix . 'usergrouprequest WHERE userid=' . strval((int) $row['userid'])); foreach ($requests as $i => $request) { $requests[$i]['usergroupid'] = import_id_remap_get('group', strval($request['usergroupid'])); } //if (($row['adminpermissions']&256)!=0) $secondary_groups[]=array('usergroupid'=>db_get_first_id()+1); $id_new = ocf_make_member($row['username'], $password, $row['email'], NULL, $bday_day, $bday_month, $bday_year, $custom_fields, strval($row['timezoneoffset']), $primary_group, $validated, $row['joindate'], $row['lastvisit'], '', $avatar_url, $signature, 0, $preview_posts, $reveal_age, $title, $photo_url, $photo_thumb_url, $views_signatures, $row['autosubscribe'], $language, $row['options'] & 16, $row['options'] & 16, '', $row['ipaddress'], '', false, $type, $salt, 1, $row['lastpost'] == 0 ? $row['lastpost'] : NULL); // Fix usergroup leadership $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => -$row['userid'])); import_id_remap_put('member', strval($row['userid']), $id_new); // Set up usergroup membership foreach ($secondary_groups as $group) { $group = import_id_remap_get('group', strval($group['usergroupid'])); ocf_add_member_to_group($id_new, $group, 1); } foreach ($requests as $request) { ocf_add_member_to_group($id_new, $request['usergroupid'], 0); } } $row_start += 200; } while (count($rows) > 0); }
/** * Standard modular render function for profile tabs edit hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return ?array A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set) */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $order = 0; // Actualiser if (post_param('submitting_settings_tab', NULL) !== NULL) { require_code('ocf_members_action2'); $is_ldap = ocf_is_ldap_member($member_id_of); $is_httpauth = ocf_is_httpauth_member($member_id_of); $is_remote = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_password_compat_scheme') == 'remote'; if ($is_ldap || $is_httpauth || $is_remote || $member_id_of != $member_id_viewing && !has_specific_permission($member_id_viewing, 'assume_any_member')) { $password = NULL; } else { $password = post_param('edit_password'); if ($password == '') { $password = NULL; } else { $password_confirm = trim(post_param('password_confirm')); if ($password != $password_confirm) { warn_exit(make_string_tempcode(escape_html(do_lang('PASSWORD_MISMATCH')))); } } } $custom_fields = ocf_get_all_custom_fields_match($GLOBALS['FORUM_DRIVER']->get_members_groups($member_id_of), $member_id_of != $member_id_viewing && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL, $member_id_of != $member_id_viewing ? NULL : 1, $member_id_of != $member_id_viewing ? NULL : 1); $actual_custom_fields = ocf_read_in_custom_fields($custom_fields, $member_id_of); $pt_allow = array_key_exists('pt_allow', $_POST) ? implode(',', $_POST['pt_allow']) : ''; $tmp_groups = $GLOBALS['OCF_DRIVER']->get_usergroup_list(true, true); $all_pt_allow = ''; foreach (array_keys($tmp_groups) as $key) { if ($key != db_get_first_id()) { if ($all_pt_allow != '') { $all_pt_allow .= ','; } $all_pt_allow .= strval($key); } } if ($pt_allow == $all_pt_allow) { $pt_allow = '*'; } $pt_rules_text = post_param('pt_rules_text', NULL); if (has_specific_permission($member_id_viewing, 'member_maintenance')) { $validated = post_param_integer('validated', 0); $primary_group = $is_ldap || !has_specific_permission($member_id_viewing, 'assume_any_member') ? NULL : post_param_integer('primary_group', NULL); $is_perm_banned = post_param_integer('is_perm_banned', 0); $old_is_perm_banned = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_is_perm_banned'); if ($old_is_perm_banned != $is_perm_banned) { if ($is_perm_banned == 1) { ocf_ban_member($member_id_of); } else { ocf_unban_member($member_id_of); } } $highlighted_name = post_param_integer('highlighted_name', 0); if (has_specific_permission($member_id_viewing, 'probate_members')) { $on_probation_until = get_input_date('on_probation_until'); $current__on_probation_until = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_on_probation_until'); if ((is_null($on_probation_until) || $on_probation_until <= time()) && $current__on_probation_until > time()) { log_it('STOP_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } elseif (!is_null($on_probation_until) && $on_probation_until > time() && $current__on_probation_until <= time()) { log_it('START_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } elseif (!is_null($on_probation_until) && $current__on_probation_until > $on_probation_until && $on_probation_until > time() && $current__on_probation_until > time()) { log_it('REDUCE_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } elseif (!is_null($on_probation_until) && $current__on_probation_until < $on_probation_until && $on_probation_until > time() && $current__on_probation_until > time()) { log_it('EXTEND_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } } else { $on_probation_until = NULL; } } else { $validated = NULL; $primary_group = NULL; $highlighted_name = NULL; $on_probation_until = NULL; } if (has_actual_page_access($member_id_viewing, 'admin_ocf_join') || has_specific_permission($member_id_of, 'rename_self')) { $username = $is_ldap || $is_remote ? NULL : post_param('edit_username', NULL); } else { $username = NULL; } $email = post_param('email_address', NULL); if (!is_null($email)) { $email = trim($email); } $theme = post_param('theme', NULL); if ($is_remote) { $preview_posts = NULL; $zone_wide = NULL; $auto_monitor_contrib_content = NULL; $views_signatures = NULL; $timezone = NULL; } else { $preview_posts = post_param_integer('preview_posts', 0); $zone_wide = post_param_integer('zone_wide', 0); $auto_monitor_contrib_content = NULL; //post_param_integer('auto_monitor_contrib_content',0); Moved to notifications tab $views_signatures = post_param_integer('views_signatures', 0); $timezone = post_param('timezone', get_site_timezone()); } ocf_edit_member($member_id_of, $email, $preview_posts, post_param_integer('dob_day', -1), post_param_integer('dob_month', -1), post_param_integer('dob_year', -1), $timezone, $primary_group, $actual_custom_fields, $theme, post_param_integer('reveal_age', 0), $views_signatures, $auto_monitor_contrib_content, post_param('language', NULL), post_param_integer('allow_emails', 0), post_param_integer('allow_emails_from_staff', 0), $validated, $username, $password, $zone_wide, $highlighted_name, $pt_allow, $pt_rules_text, $on_probation_until); if (!array_key_exists('secondary_groups', $_POST)) { $_POST['secondary_groups'] = array(); } require_code('ocf_groups_action2'); $members_groups = $GLOBALS['OCF_DRIVER']->get_members_groups($member_id_of); $group_count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)'); $groups = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), $group_count > 200 ? array('g_is_private_club' => 0) : NULL)); foreach ($_POST['secondary_groups'] as $group_id) { $group = $groups[intval($group_id)]; if ($group['g_hidden'] == 1 && !in_array($group['id'], $members_groups) && !has_specific_permission($member_id_viewing, 'see_hidden_groups')) { continue; } if (!in_array($group['id'], $members_groups) && (has_specific_permission($member_id_viewing, 'assume_any_member') || $group['g_open_membership'] == 1)) { ocf_add_member_to_group($member_id_of, $group['id']); } } foreach ($members_groups as $group_id) { if (!in_array(strval($group_id), $_POST['secondary_groups'])) { ocf_member_leave_group($group_id, $member_id_of); } } $GLOBALS['FORUM_DB']->query('DELETE FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_member_known_login_ips WHERE i_member_id=' . strval($member_id_of) . ' AND ' . db_string_not_equal_to('i_val_code', '')); // So any re-confirms can happen if (addon_installed('awards')) { require_code('awards'); handle_award_setting('member', strval($member_id_of)); } attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform'); } if ($leave_to_ajax_if_possible) { return NULL; } // UI $title = do_lang_tempcode('SETTINGS'); $myrow = $GLOBALS['FORUM_DRIVER']->get_member_row($member_id_of); if (is_null($myrow)) { warn_exit(do_lang_tempcode('USER_NO_EXIST')); } require_code('ocf_members_action2'); list($fields, $hidden) = ocf_get_member_fields_settings(false, $member_id_of, NULL, $myrow['m_email_address'], $myrow['m_preview_posts'], $myrow['m_dob_day'], $myrow['m_dob_month'], $myrow['m_dob_year'], get_users_timezone($member_id_of), $myrow['m_theme'], $myrow['m_reveal_age'], $myrow['m_views_signatures'], $myrow['m_auto_monitor_contrib_content'], $myrow['m_language'], $myrow['m_allow_emails'], $myrow['m_allow_emails_from_staff'], $myrow['m_validated'], $myrow['m_primary_group'], $myrow['m_username'], $myrow['m_is_perm_banned'], '', $myrow['m_zone_wide'], $myrow['m_highlighted_name'], $myrow['m_pt_allow'], get_translated_text($myrow['m_pt_rules_text'], $GLOBALS['FORUM_DB']), $myrow['m_on_probation_until']); // Awards? if (addon_installed('awards')) { require_code('awards'); $fields->attach(get_award_fields('member', strval($member_id_of))); } $redirect = get_param('redirect', NULL); if (!is_null($redirect)) { $hidden->attach(form_input_hidden('redirect', $redirect)); } $hidden->attach(form_input_hidden('submitting_settings_tab', '1')); $javascript = "\n\t\t\tvar form=document.getElementById('email_address').form;\n\t\t\tform.prior_profile_edit_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tif (typeof form.elements['edit_password']!='undefined')\n\t\t\t\t\t{\n\t\t\t\t\t\tif ((form.elements['password_confirm']) && (form.elements['password_confirm'].value!=form.elements['edit_password'].value))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('PASSWORD_MISMATCH')) . "');\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof form.prior_profile_edit_submit!='undefined' && form.prior_profile_edit_submit) return form.prior_profile_edit_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t"; $text = ''; return array($title, $fields, $text, $javascript, $order, $hidden); }
/** * Standard modular file writing function for OcCLE FS hooks. * * @param array The current meta-directory path * @param string The root node of the current meta-directory * @param string The file name * @param string The new file contents * @param array A reference to the OcCLE filesystem object * @return boolean Success? */ function write_file($meta_dir, $meta_root_node, $file_name, $contents, &$occle_fs) { if (get_forum_type() != 'ocf') { return false; } if (count($meta_dir) == 1) { //We're in a member's directory, and writing one of their profile fields $coded_fields = array('theme' => 'm_theme', 'avatar' => 'm_avatar_url', 'validated' => 'm_validated', 'timezone_offset' => 'm_timezone_offset', 'primary_group' => 'm_primary_group', 'signature' => 'm_signature', 'banned' => 'm_is_perm_banned', 'preview_posts' => 'm_preview_posts', 'dob_day' => 'm_dob_day', 'dob_month' => 'm_dob_month', 'dob_year' => 'm_dob_year', 'reveal_age' => 'm_reveal_age', 'e-mail' => 'm_email_address', 'title' => 'm_title', 'photo' => 'm_photo_url', 'photo_thumb' => 'm_photo_thumb_url', 'view_signatures' => 'm_views_signatures', 'auto_monitor_contrib_content' => 'm_auto_monitor_contrib_content', 'language' => 'm_language', 'allow_e-mails' => 'm_allow_emails', 'allow_e-mails_from_staff' => 'm_allow_emails_from_staff', 'notes' => 'm_notes', 'wide' => 'm_zone_wide', 'max_attach_size' => 'm_max_email_attach_size_mb', 'highlighted_name' => 'm_highlighted_name'); if (array_key_exists($file_name, $coded_fields)) { $GLOBALS['FORUM_DB']->query_update('f_members', array($coded_fields[$file_name] => $contents), array('id' => $GLOBALS['FORUM_DRIVER']->get_member_from_username($meta_dir[0])), '', 1); return true; } require_code('ocf_members_action'); require_code('ocf_members_action2'); $field_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_custom_fields f LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=f.cf_name', 'f.id', array('text_original' => $file_name)); if (is_null($field_id)) { $GLOBALS['FORUM_DRIVER']->install_create_custom_field($file_name, 10); $field_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_custom_fields f LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=f.cf_name', 'f.id', array('text_original' => $file_name)); } if (is_null($field_id)) { $field_id = ocf_make_custom_field($file_name); } ocf_set_custom_field($GLOBALS['FORUM_DRIVER']->get_member_from_username($meta_dir[0]), $field_id, $contents); } elseif (count($meta_dir) == 2) { if ($meta_dir[1] != 'groups') { return false; } //We're in a member's usergroup directory, and writing one of their usergroup associations require_code('ocf_groups_action'); require_code('ocf_groups_action2'); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); $group_id = array_search($file_name, $groups); if ($group_id !== false) { ocf_add_member_to_group($GLOBALS['FORUM_DRIVER']->get_member_from_username($meta_dir[0]), $group_id, 1); } else { return false; } } else { return false; } //Group files can't be written, and other files shouldn't even exist anywhere else! return true; }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_members($db, $table_prefix, $file_base) { $row_start = 0; $rows = array(); $default_group = get_first_default_group(); do { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'members WHERE id_member<>-1 ORDER BY id_member', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('member', strval($row['id_member']))) { continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['member_name']); if (!is_null($test)) { import_id_remap_put('member', strval($row['id_member']), $test); continue; } $language = 'EN'; $secondary = explode(',', $row['additional_groups']); $secondary_groups = array(); foreach ($secondary as $g) { if (trim($g) != '') { $g = import_id_remap_get('group', $g, true); if (!is_null($g)) { $secondary_groups[] = intval($g); } } } $primary_group = $row['id_group']; if ($primary_group == 0) { $primary_group = $row['id_post_group']; } if ($primary_group == 0) { $primary_group = $default_group; } else { $primary_group = import_id_remap_get('group', strval($primary_group)); } $custom_fields = array(ocf_make_boiler_custom_field('im_icq') => $row['icq'], ocf_make_boiler_custom_field('im_aim') => $row['aim'], ocf_make_boiler_custom_field('im_msn') => $row['msn'], ocf_make_boiler_custom_field('im_yahoo') => $row['yim']); if ($row['website_url'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = $row['website_url']; } $signature = str_replace(array('[html]', '[/html]'), array('', ''), html_to_comcode($row['signature'])); $signature = $this->fix_links($signature, $db, $table_prefix, $file_base); $validated = 1; $reveal_age = 0; if ($row['birthdate'] != '') { $birthdate = $row['birthdate']; $birthdata = explode('-', $birthdate); $bday_day = isset($birthdata[0]) && $birthdata[0] != '' ? $birthdata[0] : NULL; $bday_month = isset($birthdata[1]) && $birthdata[1] != '' ? $birthdata[1] : NULL; $bday_year = isset($birthdata[2]) && $birthdata[2] != '' ? $birthdata[2] : NULL; } else { list($bday_day, $bday_month, $bday_year) = array(NULL, NULL, NULL); } $views_signatures = 1; $preview_posts = 1; $track_posts = $row['notify_announcements']; $title = ''; // These are done in the members-files stage $avatar_url = ''; $photo_url = ''; $photo_thumb_url = ''; $password = $row['passwd']; $type = 'smf'; $salt = $row['password_salt']; $allow_emails = intval($row['instant_messages']) > 0 ? 1 : 0; if ($row['date_registered'] == 0) { $row['date_registered'] = time(); } $id_new = ocf_make_member($row['member_name'], $password, $row['email_address'], NULL, $bday_day, $bday_month, $bday_year, $custom_fields, $row['time_offset'] == 0 ? '' : strval($row['time_offset']), $primary_group, $validated, $row['date_registered'], $row['last_login'], '', $avatar_url, $signature, 0, $preview_posts, $reveal_age, $title, $photo_url, $photo_thumb_url, $views_signatures, $track_posts, $language, $allow_emails, 1, '', '', '', false, $type, $salt, 1); //cpf stuff $cpf_rows = $db->query('SELECT id_field, col_name FROM ' . $table_prefix . 'custom_fields'); foreach ($cpf_rows as $cpf_row) { $cpf_id = import_id_remap_get('cpf', strval($cpf_row['id_field'])); if (!($cpf_value = $db->query('SELECT value FROM ' . $table_prefix . 'themes WHERE id_member=' . $row['id_member'] . ' AND variable=\'' . $cpf_row['col_name'] . '\''))) { continue; } $value = isset($cpf_value[0]['value']) ? $cpf_value[0]['value'] : ''; ocf_set_custom_field($id_new, $cpf_id, $value); } // Fix usergroup leadership $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => $row['id_member'])); import_id_remap_put('member', strval($row['id_member']), $id_new); // Set up usergroup membership foreach ($secondary_groups as $s) { ocf_add_member_to_group($id_new, $s, 1); } } $row_start += 200; } while (count($rows) > 0); }
/** * Handling of a usergroup subscription. * * @param ID_TEXT The purchase ID. * @param array Details relating to the product. * @param ID_TEXT The product. */ function handle_usergroup_subscription($purchase_id, $details, $product) { $member_id = $GLOBALS['SITE_DB']->query_value_null_ok('subscriptions', 's_member_id', array('id' => intval($purchase_id))); if (is_null($member_id)) { return; } require_code('ocf_groups_action'); require_code('ocf_groups_action2'); require_code('ocf_members'); require_code('notifications'); $usergroup_subscription_id = intval(substr($product, 9)); $dbs_bak = $GLOBALS['NO_DB_SCOPE_CHECK']; $GLOBALS['NO_DB_SCOPE_CHECK'] = true; $rows = $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_select('f_usergroup_subs', array('*'), array('id' => $usergroup_subscription_id), '', 1); $GLOBALS['NO_DB_SCOPE_CHECK'] = $dbs_bak; if (array_key_exists(0, $rows)) { $myrow = $rows[0]; $new_group = $myrow['s_group_id']; $object = find_product($product); } else { $object = NULL; } if (is_null($object)) { return; // The usergroup subscription has been deleted, and this was to remove the payment for it } $test = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT id FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'subscriptions WHERE (' . db_string_equal_to('s_state', 'cancelled') . ') AND ' . db_string_equal_to('id', $purchase_id)); if (!is_null($test)) { $test = in_array($new_group, $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id)); if ($test) { // Remove them from the group if (is_null($GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_value_null_ok('f_group_member_timeouts', 'member_id', array('member_id' => $member_id, 'group_id' => $new_group)))) { if (get_value('unofficial_ecommerce') == '1' && get_forum_type() != 'ocf') { $GLOBALS['FORUM_DB']->remove_member_from_group($member_id, $new_group); } else { // if ($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id,'m_primary_group')==$new_group) if ($myrow['s_uses_primary'] == 1) { $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_update('f_members', array('m_primary_group' => get_first_default_group()), array('id' => $member_id), '', 1); } else { $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_delete('f_group_members', array('gm_group_id' => $new_group, 'gm_member_id' => $member_id)); // ,'',1 } } dispatch_notification('paid_subscription_ended', NULL, do_lang('PAID_SUBSCRIPTION_ENDED', NULL, NULL, NULL, get_lang($member_id)), get_translated_text($myrow['s_mail_end'], NULL, get_lang($member_id)), array($member_id), A_FROM_SYSTEM_PRIVILEGED); } } } else { $test = in_array($new_group, $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id)); if (!$test) { // Add them to the group if (get_value('unofficial_ecommerce') == '1' && get_forum_type() != 'ocf') { $GLOBALS['FORUM_DB']->add_member_to_group($member_id, $new_group); } else { if ($myrow['s_uses_primary'] == 1) { $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_update('f_members', array('m_primary_group' => $new_group), array('id' => $member_id), '', 1); } else { ocf_add_member_to_group($member_id, $new_group); } } $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_delete('f_group_member_timeouts', array('member_id' => $member_id, 'group_id' => $new_group)); dispatch_notification('paid_subscription_started', NULL, do_lang('PAID_SUBSCRIPTION_STARTED'), get_translated_text($myrow['s_mail_start'], NULL, get_lang($member_id)), array($member_id), A_FROM_SYSTEM_PRIVILEGED); } } }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_members($db, $table_prefix, $file_base) { $default_group = get_first_default_group(); $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'users u LEFT JOIN ' . $table_prefix . 'banlist b ON u.user_id=b.ban_userid WHERE u.user_id<>-1 ORDER BY u.user_id', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('member', strval($row['user_id']))) { continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['username']); if (!is_null($test)) { import_id_remap_put('member', strval($row['user_id']), $test); continue; } $language = ''; if ($row['user_lang'] != '') { switch ($language) { case 'english': $language = 'EN'; break; } } $primary_group = $default_group; $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'user_group WHERE user_id=' . strval((int) $row['user_id']), 200, $row_start); $secondary_groups = array(); foreach ($rows2 as $row2) { $g = import_id_remap_get('group', strval($row2['group_id']), true); if (!is_null($g)) { $secondary_groups[] = array($g, $row2['user_pending']); } } if ($row['user_level'] == 1) { $secondary_groups[] = array(db_get_first_id() + 1, 0); } $custom_fields = array(ocf_make_boiler_custom_field('im_icq') => $row['user_icq'], ocf_make_boiler_custom_field('im_aim') => $row['user_aim'], ocf_make_boiler_custom_field('im_msn') => $row['user_msnm'], ocf_make_boiler_custom_field('im_yahoo') => $row['user_yim'], ocf_make_boiler_custom_field('interests') => $row['user_interests'], ocf_make_boiler_custom_field('location') => $row['user_from'], ocf_make_boiler_custom_field('occupation') => $row['user_occ']); if ($row['user_website'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = strlen($row['user_website']) > 0 ? '[url]' . $row['user_website'] . '[/url]' : ''; } $signature = $this->fix_links($row['user_sig'], $db, $table_prefix); $validated = $row['user_active']; $reveal_age = 0; list($bday_day, $bday_month, $bday_year) = array(NULL, NULL, NULL); $views_signatures = 1; $preview_posts = 1; $track_posts = $row['user_notify']; $title = ''; // These are done in the members-files stage $avatar_url = ''; $photo_url = ''; $photo_thumb_url = ''; $password = $row['user_password']; $type = 'md5'; $salt = ''; $id_new = ocf_make_member($row['username'], $password, $row['user_email'], NULL, $bday_day, $bday_month, $bday_year, $custom_fields, strval($row['user_timezone']), $primary_group, $validated, $row['user_regdate'], $row['user_lastvisit'], '', $avatar_url, $signature, !is_null($row['ban_id']) ? 1 : 0, $preview_posts, $reveal_age, $title, $photo_url, $photo_thumb_url, $views_signatures, $track_posts, $language, $row['user_allow_pm'], 1, '', '', '', false, $type, $salt, 1); // Fix usergroup leadership $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => -$row['user_id'])); import_id_remap_put('member', strval($row['user_id']), $id_new); // Set up usergroup membership foreach ($secondary_groups as $s) { list($group, $userpending) = $s; ocf_add_member_to_group($id_new, $group, 1 - $userpending); } } $row_start += 200; } while (count($rows) > 0); }
/** * Standard aed_module add actualiser. * * @return ID_TEXT The entry added */ function add_actualisation() { require_code('ocf_forums_action2'); $_group_leader = post_param('group_leader'); if ($_group_leader != '') { $group_leader = $GLOBALS['FORUM_DRIVER']->get_member_from_username($_group_leader); if (is_null($group_leader)) { warn_exit(do_lang_tempcode('_USER_NO_EXIST', $_group_leader)); } } else { $group_leader = NULL; } $name = post_param('name'); $id = ocf_make_group($name, 0, 0, 0, '', '', NULL, NULL, $group_leader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000, 0, post_param_integer('open_membership', 0), 1); // Create forum $mods = $GLOBALS['FORUM_DRIVER']->get_moderator_groups(); $access_mapping = array(); foreach ($mods as $m_id) { $access_mapping[$m_id] = 5; } $_cat = get_option('club_forum_parent_category'); if (is_numeric($_cat)) { $cat = intval($_cat); } else { $cat = $GLOBALS['FORUM_DB']->query_value_null_ok('f_categories', 'id', array('c_title' => $_cat)); if (is_null($cat)) { $cat = $GLOBALS['FORUM_DB']->query_value('f_categories', 'MIN(id)'); } } $_forum = get_option('club_forum_parent_forum'); if (is_numeric($_forum)) { $forum = intval($_forum); } else { $forum = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'id', array('f_name' => $_forum)); if (is_null($forum)) { $forum = $GLOBALS['FORUM_DB']->query_value('f_forums', 'MIN(id)'); } } $is_threaded = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'f_is_threaded', array('id' => $forum)); $forum_id = ocf_make_forum($name, do_lang('FORUM_FOR_CLUB', $name), $cat, $access_mapping, $forum, 1, 1, 0, '', '', '', 'last_post', $is_threaded); $this->_set_permissions($id, $forum_id); require_code('ocf_groups_action2'); ocf_add_member_to_group(get_member(), $id); if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'groups')) { syndicate_described_activity('ocf:ACTIVITY_ADD_CLUB', $name, '', '', '_SEARCH:groups:view:' . strval($id), '', '', 'ocf_clubs'); } return strval($id); }
/** * The actualiser for adding a member. * * @return tempcode The UI */ function step2() { $title = get_page_title('ADD_MEMBER'); // Read in data $username = trim(post_param('username')); $password = trim(post_param('password')); /* $password_confirm=trim(post_param('password_confirm')); if ($password!=$password_confirm) warn_exit(make_string_tempcode(escape_html(do_lang('PASSWORD_MISMATCH'))));*/ $email_address = trim(post_param('email_address', '')); $dob_day = post_param_integer('dob_day', NULL); $dob_month = post_param_integer('dob_month', NULL); $dob_year = post_param_integer('dob_year', NULL); $reveal_age = post_param_integer('reveal_age', 0); $timezone = post_param('timezone', get_site_timezone()); $language = post_param('language', get_site_default_lang()); $allow_emails = post_param_integer('allow_emails', 0); $allow_emails_from_staff = post_param_integer('allow_emails_from_staff', 0); $custom_fields = ocf_get_all_custom_fields_match(ocf_get_all_default_groups(true)); $actual_custom_fields = ocf_read_in_custom_fields($custom_fields); $validated = post_param_integer('validated', 0); $primary_group = has_specific_permission(get_member(), 'assume_any_member') ? post_param_integer('primary_group') : NULL; $theme = post_param('theme', ''); $views_signatures = post_param_integer('views_signatures', 0); $preview_posts = post_param_integer('preview_posts', 0); $auto_monitor_contrib_content = post_param_integer('auto_monitor_contrib_content', 0); $pt_allow = array_key_exists('pt_allow', $_POST) ? implode(',', $_POST['pt_allow']) : ''; $tmp_groups = $GLOBALS['OCF_DRIVER']->get_usergroup_list(true, true); $all_pt_allow = ''; foreach (array_keys($tmp_groups) as $key) { if ($key != db_get_first_id()) { if ($all_pt_allow != '') { $all_pt_allow .= ','; } $all_pt_allow .= strval($key); } } if ($pt_allow == $all_pt_allow) { $pt_allow = '*'; } $pt_rules_text = post_param('pt_rules_text', ''); breadcrumb_set_parents(array(array('_SEARCH:admin_ocf_join:menu', do_lang_tempcode('MEMBERS')), array('_SELF:_SELF:misc', do_lang_tempcode('ADD_MEMBER')))); breadcrumb_set_self(do_lang_tempcode('DETAILS')); // Add member $id = ocf_make_member($username, $password, $email_address, NULL, $dob_day, $dob_month, $dob_year, $actual_custom_fields, $timezone, $primary_group, $validated, time(), NULL, '', NULL, '', 0, $preview_posts, $reveal_age, '', '', '', $views_signatures, $auto_monitor_contrib_content, $language, $allow_emails, $allow_emails_from_staff, '', '', '', true, '', '', post_param_integer('zone_wide', 0), NULL, NULL, post_param_integer('highlighted_name', 0), $pt_allow, $pt_rules_text); // Secondary groups if (array_key_exists('secondary_groups', $_POST)) { require_code('ocf_groups_action2'); $members_groups = array(); $group_count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)'); $groups = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), $group_count > 200 ? array('g_is_private_club' => 0) : NULL)); foreach ($_POST['secondary_groups'] as $group_id) { $group = $groups[intval($group_id)]; if ($group['g_hidden'] == 1 && !in_array($group['id'], $members_groups) && !has_specific_permission(get_member(), 'see_hidden_groups')) { continue; } if (in_array($group['id'], $members_groups) || has_specific_permission(get_member(), 'assume_any_member') || $group['g_open_membership'] == 1) { ocf_add_member_to_group($id, $group['id']); } } } $special_links = array(); if (addon_installed('galleries')) { require_lang('galleries'); $special_links[] = array('galleries', array('cms_galleries', array('type' => 'gimp', 'id' => $id), get_module_zone('cms_galleries')), do_lang('ADD_GALLERY')); } require_code('templates_donext'); return do_next_manager($title, do_lang_tempcode('SUCCESS'), NULL, NULL, array('_SELF', array('type' => 'misc'), '_SELF'), NULL, NULL, array('members', array('type' => 'view', 'id' => $id), get_module_zone('members')), array('members', array('type' => 'misc'), get_module_zone('members'), do_lang_tempcode('MEMBERS')), NULL, NULL, NULL, NULL, NULL, $special_links, NULL, NULL, NULL, NULL, do_lang_tempcode('MEMBERS')); }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_members($db, $table_prefix, $file_base) { $row_start = 0; $rows = array(); $default_group = get_first_default_group(); do { $rows = $db->query('SELECT u.ID_MEMBER AS \'muid\',u.*,b.* FROM ' . $table_prefix . 'members u LEFT JOIN ' . $table_prefix . 'ban_items b ON u.ID_MEMBER=b.ID_MEMBER WHERE u.ID_MEMBER<>-1 ORDER BY u.ID_MEMBER', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('member', strval($row['muid']))) { continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['memberName']); if (!is_null($test)) { import_id_remap_put('member', strval($row['muid']), $test); continue; } $language = 'EN'; $secondary = explode(',', $row['additionalGroups']); $secondary_groups = array(); foreach ($secondary as $g) { if (trim($g) != '') { $g = import_id_remap_get('group', $g, true); if (!is_null($g)) { $secondary_groups[] = intval($g); } } } $primary_group = $row['ID_GROUP']; if ($primary_group == 0) { $primary_group = $row['ID_POST_GROUP']; } if ($primary_group == 0) { $primary_group = $default_group; } else { $primary_group = import_id_remap_get('group', strval($primary_group)); } $custom_fields = array(ocf_make_boiler_custom_field('im_icq') => $row['ICQ'], ocf_make_boiler_custom_field('im_aim') => $row['AIM'], ocf_make_boiler_custom_field('im_msn') => $row['MSN'], ocf_make_boiler_custom_field('im_yahoo') => $row['YIM']); if ($row['websiteUrl'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = $row['websiteUrl']; } $signature = $this->fix_links($row['signature'], $db, $table_prefix, $file_base); $validated = 1; $reveal_age = 0; if ($row['birthdate'] != '') { $birthdate = $row['birthdate']; $birthdata = explode('-', $birthdate); $bday_day = isset($birthdata[0]) && $birthdata[0] != '' ? $birthdata[0] : NULL; $bday_month = isset($birthdata[1]) && $birthdata[1] != '' ? $birthdata[1] : NULL; $bday_year = isset($birthdata[2]) && $birthdata[2] != '' ? $birthdata[2] : NULL; } else { list($bday_day, $bday_month, $bday_year) = array(NULL, NULL, NULL); } $views_signatures = 1; $preview_posts = 1; $track_posts = $row['notifyAnnouncements']; $title = ''; // These are done in the members-files stage $avatar_url = ''; $photo_url = ''; $photo_thumb_url = ''; $password = $row['passwd']; $type = 'smf'; $salt = $row['passwordSalt']; if ($row['dateRegistered'] == 0) { $row['dateRegistered'] = time(); } $id_new = ocf_make_member($row['memberName'], $password, $row['emailAddress'], NULL, $bday_day, $bday_month, $bday_year, $custom_fields, strval($row['timeOffset']), $primary_group, $validated, $row['dateRegistered'], $row['lastLogin'], '', $avatar_url, $signature, 0, $preview_posts, $reveal_age, $title, $photo_url, $photo_thumb_url, $views_signatures, $track_posts, $language, $row['instantMessages'], 1, '', '', '', false, $type, $salt, 1); // Fix usergroup leadership $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => -$row['muid'])); import_id_remap_put('member', strval($row['muid']), $id_new); // Set up usergroup membership foreach ($secondary_groups as $s) { ocf_add_member_to_group($id_new, $s, 1); } } $row_start += 200; } while (count($rows) > 0); }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_members($db, $table_prefix, $file_base) { $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'users u LEFT JOIN ' . $table_prefix . 'banlist b ON u.user_id=b.ban_userid WHERE u.user_type<>2 ORDER BY u.user_id', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('member', strval($row['user_id']))) { continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['username']); if (!is_null($test)) { import_id_remap_put('member', strval($row['user_id']), $test); continue; } $language = ''; if ($row['user_lang'] != '') { switch ($language) { case 'english': $language = 'EN'; break; } } $primary_group = import_id_remap_get('group', strval($row['group_id'])); $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'user_group WHERE user_id=' . strval((int) $row['user_id']), 200, $row_start); $secondary_groups = array(); foreach ($rows2 as $row2) { if ($row2['group_id'] != $row['group_id']) { $g = import_id_remap_get('group', strval($row2['group_id']), true); if (!is_null($g)) { $secondary_groups[] = array($g, $row2['user_pending']); } } } $custom_fields = array(ocf_make_boiler_custom_field('im_icq') => $row['user_icq'], ocf_make_boiler_custom_field('im_aim') => $row['user_aim'], ocf_make_boiler_custom_field('im_msn') => $row['user_msnm'], ocf_make_boiler_custom_field('im_yahoo') => $row['user_yim'], ocf_make_boiler_custom_field('interests') => $row['user_interests'], ocf_make_boiler_custom_field('location') => $row['user_from'], ocf_make_boiler_custom_field('occupation') => $row['user_occ']); if ($row['user_website'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = strlen($row['user_website']) > 0 ? '[url]' . $row['user_website'] . '[/url]' : ''; } $signature = $this->fix_links($row['user_sig'], $row['user_sig_bbcode_uid'], $db, $table_prefix); $validated = 1; $reveal_age = 0; if (strpos($row['user_birthday'], '-') === false) { list($bday_day, $bday_month, $bday_year) = array(NULL, NULL, NULL); } else { $bday = explode('-', $row['user_birthday']); list($bday_day, $bday_month, $bday_year) = array(intval(trim($bday[0])), intval(trim($bday[1])), intval(trim($bday[2]))); } $views_signatures = 1; $preview_posts = 1; $track_posts = $row['user_notify']; $title = ''; // These are done in the members-files stage $avatar_url = ''; $photo_url = ''; $photo_thumb_url = ''; $password = $row['user_password']; $type = 'phpbb3'; $salt = ''; $id_new = ocf_make_member($row['username'], $password, $row['user_email'], NULL, $bday_day, $bday_month, $bday_year, $custom_fields, strval($row['user_timezone']), $primary_group, $validated, $row['user_regdate'], $row['user_lastvisit'], '', $avatar_url, $signature, !is_null($row['ban_id']) ? 1 : 0, $preview_posts, $reveal_age, $title, $photo_url, $photo_thumb_url, $views_signatures, $track_posts, $language, 1, $row['user_allow_massemail'], '', '', '', false, $type, $salt, 1); // CPF values $cpf_rows = collapse_2d_complexity('field_name', 'field_type', $db->query('SELECT field_name,field_type FROM ' . $table_prefix . 'profile_fields f')); $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'profile_fields_data WHERE user_id=' . strval((int) $row['user_id']), 1); $row2 = array(); if (array_key_exists(0, $rows2)) { foreach ($rows2[0] as $key => $val) { if (substr($key, 0, 3) == 'pf_') { if (is_null($val)) { if ($cpf_rows[substr($key, 3)] == FIELD_INT) { $val = NULL; } elseif ($cpf_rows[substr($key, 3)] == FIELD_BOOL) { $val = NULL; } elseif ($cpf_rows[substr($key, 3)] == FIELD_DATE) { $val = NULL; } else { $val = ''; } } $row2['field_' . strval(import_id_remap_get('cpf', substr($key, 3)))] = $val; } } $GLOBALS['FORUM_DB']->query_update('f_member_custom_fields', $row2, array('mf_member_id' => $id_new), '', 1); } // Fix usergroup leadership $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => -$row['user_id'])); import_id_remap_put('member', strval($row['user_id']), $id_new); // Set up usergroup membership foreach ($secondary_groups as $s) { list($group, $userpending) = $s; ocf_add_member_to_group($id_new, $group, 1 - $userpending); } } $row_start += 200; } while (count($rows) > 0); }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_members($db, $table_prefix, $file_base) { $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT u.uid AS \'muid\',u.*,b.* FROM ' . $table_prefix . 'users u LEFT JOIN ' . $table_prefix . 'banned b ON u.uid=b.uid WHERE u.uid<>-1 ORDER BY u.uid', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('member', strval($row['muid']))) { continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['username']); if (!is_null($test)) { import_id_remap_put('member', strval($row['muid']), $test); continue; } $language = ''; if ($row['language'] != '') { switch ($language) { case 'english': default: $language = 'EN'; break; } } $primary_group = $row['usergroup']; $_secondary_groups = explode(',', $row['additionalgroups']); $secondary_groups = array(); foreach ($_secondary_groups as $_sec_group) { $sec_group = import_id_remap_get('group', $_sec_group, true); if (!is_null($sec_group)) { $secondary_groups[] = $sec_group; } } //array_map('intval',); $primary_group = import_id_remap_get('group', strval($row['usergroup'])); if ($row['usergroup'] == 4) { $secondary_groups[] = db_get_first_id() + 1; } $custom_fields = array(ocf_make_boiler_custom_field('im_icq') => $row['icq'], ocf_make_boiler_custom_field('im_aim') => $row['aim'], ocf_make_boiler_custom_field('im_msn') => $row['msn'], ocf_make_boiler_custom_field('im_yahoo') => $row['yahoo']); if ($row['website'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = strlen($row['website']) > 0 ? '[url]' . $row['website'] . '[/url]' : ''; } $signature = $this->fix_links($row['signature'], $db, $table_prefix); $validated = 1; $reveal_age = 0; if ($row['birthday'] != '') { $birthdate = date('Y-m-d', strtotime($row['birthday'])); $birthdata = array_map('intval', explode('-', $birthdate)); $bday_day = isset($birthdata[0]) && $birthdata[0] != 0 ? $birthdata[0] : NULL; $bday_month = isset($birthdata[1]) && $birthdata[1] != 0 ? $birthdata[1] : NULL; $bday_year = isset($birthdata[2]) && $birthdata[2] != 0 ? $birthdata[2] : NULL; } else { list($bday_day, $bday_month, $bday_year) = array(NULL, NULL, NULL); } $views_signatures = 1; $preview_posts = 1; $track_posts = $row['allownotices']; $title = $row['usertitle']; $title = @html_entity_decode($title, ENT_QUOTES, get_charset()); // These are done in the members-files stage $avatar_url = ''; $photo_url = ''; $photo_thumb_url = ''; $password = $row['password']; $type = 'md5'; $salt = $row['salt']; $id_new = ocf_make_member($row['username'], $password, $row['email'], NULL, $bday_day, $bday_month, $bday_year, $custom_fields, strval($row['timezone']), $primary_group, $validated, $row['regdate'], $row['lastvisit'], '', $avatar_url, $signature, $row['lifted'] > time() ? 1 : 0, $preview_posts, $reveal_age, $title, $photo_url, $photo_thumb_url, $views_signatures, $track_posts, $language, $row['receivepms'], $row['receivepms'], '', '', '', false, $type, $salt, 1); // Fix usergroup leadership $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => -$row['muid'])); import_id_remap_put('member', strval($row['muid']), $id_new); // Set up usergroup membership foreach ($secondary_groups as $s) { ocf_add_member_to_group($id_new, $s, 1); } } $row_start += 200; } while (count($rows) > 0); }
/** * Edit a usergroup subscription. * * @param AUTO_LINK The ID * @param SHORT_TEXT The title * @param LONG_TEXT The description * @param SHORT_TEXT The cost * @param integer The length * @param SHORT_TEXT The units for the length * @set y m d w * @param ?GROUP The usergroup that purchasing gains membership to (NULL: super members) * @param BINARY Whether this is applied to primary usergroup membership * @param BINARY Whether this is currently enabled * @param ?LONG_TEXT The text of the e-mail to send out when a subscription is start (NULL: default) * @param ?LONG_TEXT The text of the e-mail to send out when a subscription is ended (NULL: default) * @param ?LONG_TEXT The text of the e-mail to send out when a subscription cannot be renewed because the subproduct is gone (NULL: default) */ function edit_usergroup_subscription($id, $title, $description, $cost, $length, $length_units, $group_id, $uses_primary, $enabled, $mail_start, $mail_end, $mail_uhoh) { $dbs_bak = $GLOBALS['NO_DB_SCOPE_CHECK']; $GLOBALS['NO_DB_SCOPE_CHECK'] = true; $rows = $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_select('f_usergroup_subs', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; // If usergroup has changed, do a move if ($myrow['s_group_id'] != $group_id) { require_code('ocf_groups_action'); require_code('ocf_groups_action2'); $product = 'USERGROUP' . strval($id); $subscriptions = $GLOBALS['SITE_DB']->query_select('subscriptions', array('*'), array('s_type_code' => $product)); foreach ($subscriptions as $sub) { $member_id = $sub['s_member_id']; if (get_value('unofficial_ecommerce') == '1' && get_forum_type() != 'ocf') { $GLOBALS['FORUM_DB']->remove_member_from_group($member_id, $group_id); $GLOBALS['FORUM_DB']->add_member_to_group($member_id, $group_id); } else { $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_delete('f_group_members', array('gm_group_id' => $group_id, 'gm_member_id' => $member_id), '', 1); ocf_add_member_to_group($member_id, $group_id); } } } $_title = $myrow['s_title']; $_description = $myrow['s_description']; $_mail_start = $myrow['s_mail_start']; $_mail_end = $myrow['s_mail_end']; $_mail_uhoh = $myrow['s_mail_uhoh']; $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_update('f_usergroup_subs', array('s_title' => lang_remap($_title, $title, $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']), 's_description' => lang_remap($_description, $description, $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']), 's_cost' => $cost, 's_length' => $length, 's_length_units' => $length_units, 's_group_id' => $group_id, 's_uses_primary' => $uses_primary, 's_enabled' => $enabled, 's_mail_start' => lang_remap($_mail_start, $mail_start, $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']), 's_mail_end' => lang_remap($_mail_end, $mail_end, $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']), 's_mail_uhoh' => lang_remap($_mail_uhoh, $mail_uhoh, $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB'])), array('id' => $id), '', 1); log_it('EDIT_USERGROUP_SUBSCRIPTION', strval($id), $title); $GLOBALS['NO_DB_SCOPE_CHECK'] = $dbs_bak; }
/** * Standard aed_module edit actualiser. * * @param ID_TEXT The entry being edited * @return ?tempcode Confirm message (NULL: continue) */ function edit_actualisation($id) { require_code('themes2'); list($group_leader, $promotion_target, $promotion_threshold) = $this->read_in_data(); if (!is_null($group_leader) && post_param_integer('confirm', 0) == 0 && !in_array(intval($id), $GLOBALS['FORUM_DRIVER']->get_members_groups($group_leader))) { require_code('templates_confirm_screen'); return form_confirm_screen(get_page_title('EDIT_GROUP'), paragraph(do_lang_tempcode('MAKE_MEMBER_GROUP_LEADER', post_param('group_leader'))), '__ed', '_ed', array('confirm' => 1)); } $was_club = $GLOBALS['FORUM_DB']->query_value('f_groups', 'g_is_private_club', array('id' => intval($id))) == 1; $rank_img = get_theme_img_code('ocf_rank_images', true, 'file', 'theme_img_code', $GLOBALS['FORUM_DB']); ocf_edit_group(intval($id), post_param('name'), post_param_integer('is_default', 0), post_param_integer('is_super_admin', 0), post_param_integer('is_super_moderator', 0), post_param('title'), $rank_img, $promotion_target, $promotion_threshold, $group_leader, post_param_integer('flood_control_submit_secs'), post_param_integer('flood_control_access_secs'), post_param_integer('max_daily_upload_mb'), post_param_integer('max_attachments_per_post'), post_param_integer('max_avatar_width', 100), post_param_integer('max_avatar_height', 100), post_param_integer('max_post_length_comcode'), post_param_integer('max_sig_length_comcode', 10000), post_param_integer('gift_points_base', 0), post_param_integer('gift_points_per_day', 0), post_param_integer('enquire_on_new_ips', 0), post_param_integer('is_presented_at_install', 0), post_param_integer('hidden', 0), post_param_integer('order'), post_param_integer('rank_image_pri_only', 0), post_param_integer('open_membership', 0), post_param_integer('is_private_club', 0)); if (addon_installed('ecommerce')) { require_lang('ecommerce'); $this->extra_donext_whatever = array(array('ecommerce', array('admin_ecommerce', array('type' => 'ad', 'group_id' => $id), '_SELF'), do_lang_tempcode('ADD_USERGROUP_SUBSCRIPTION'))); $this->extra_donext_whatever_title = do_lang_tempcode('MODULE_TRANS_NAME_subscriptions'); } if (!is_null($group_leader) && !in_array(intval($id), $GLOBALS['FORUM_DRIVER']->get_members_groups($group_leader))) { ocf_add_member_to_group($group_leader, intval($id)); } $absorb = post_param_integer('absorb', -1); if ($absorb != -1) { ocf_group_absorb_privileges_of(intval($id), $absorb); } if (post_param_integer('is_private_club', 0) == 1 && !$was_club) { $GLOBALS['SITE_DB']->query_delete('gsp', array('group_id' => intval($id))); $GLOBALS['SITE_DB']->query_delete('group_zone_access', array('group_id' => intval($id))); $GLOBALS['SITE_DB']->query_delete('group_category_access', array('group_id' => intval($id))); $GLOBALS['SITE_DB']->query_delete('group_page_access', array('group_id' => intval($id))); } return NULL; }