Ejemplo n.º 1
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_custom_profile_fields($db, $table_prefix, $file_base)
 {
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'profilefield');
     $members = $db->query('SELECT * FROM ' . $table_prefix . 'userfield');
     foreach ($rows as $row) {
         if (import_check_if_imported('cpf', strval($row['profilefieldid']))) {
             continue;
         }
         $type = 'short_text';
         if ($row['type'] == 'input') {
             $type = 'short_text';
         } elseif ($row['type'] == 'textarea') {
             $type = 'long_text';
         }
         if (!array_key_exists('title', $row)) {
             $row['title'] = $db->query_value_null_ok_full('SELECT text FROM ' . $table_prefix . 'phrase WHERE ' . db_string_equal_to('product', 'vbulletin') . ' AND ' . db_string_equal_to('varname', 'field' . strval($row['profilefieldid']) . '_title'));
             $row['description'] = $db->query_value_null_ok_full('SELECT text FROM ' . $table_prefix . 'phrase WHERE ' . db_string_equal_to('product', 'vbulletin') . ' AND ' . db_string_equal_to('varname', 'field' . strval($row['profilefieldid']) . '_desc'));
         }
         $id_new = $GLOBALS['FORUM_DB']->query_value_null_ok('f_custom_fields f LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON f.cf_name=t.id', 'f.id', array('text_original' => $row['title']));
         if (is_null($id_new)) {
             $id_new = ocf_make_custom_field($row['title'], 0, $row['description'], '', 1 - $row['hidden'], 1 - $row['hidden'], $row['editable'], 0, $type, $row['required'], $row['memberlist'], $row['memberlist'], $row['displayorder'], '', true);
         }
         foreach ($members as $member) {
             $v = $member['field' . strval($row['profilefieldid'])];
             $member_id = import_id_remap_get('member', strval($member['userid']), true);
             if ($v != '' && !is_null($member_id)) {
                 ocf_set_custom_field($member_id, $id_new, $v);
             }
         }
         import_id_remap_put('cpf', strval($row['profilefieldid']), $id_new);
     }
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
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();
     $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);
 }
Ejemplo n.º 4
0
 /**
  * Set a custom profile field's value. It should not be called directly.
  *
  * @param  MEMBER			The member id
  * @param  string			The field name
  * @param  string			The value
  */
 function set_custom_field($member, $field, $amount)
 {
     // Check member exists
     $username = $this->get_username($member);
     if (is_null($username)) {
         return;
     }
     require_code('ocf_members_action');
     require_code('ocf_members_action2');
     $field_bits = $this->connection->query_select('f_custom_fields f LEFT JOIN ' . $this->connection->get_table_prefix() . 'translate t ON t.id=f.cf_name', array('f.id', 'f.cf_type'), array('text_original' => 'ocp_' . $field));
     if (!array_key_exists(0, $field_bits)) {
         $this->install_create_custom_field($field, 10);
         $field_bits = $this->connection->query_select('f_custom_fields f LEFT JOIN ' . $this->connection->get_table_prefix() . 'translate t ON t.id=f.cf_name', array('f.id', 'f.cf_type'), array('text_original' => 'ocp_' . $field));
         if (!array_key_exists(0, $field_bits)) {
             return;
         }
         // Possible on an MSN, and there's an inconsistency (e.g. no points addon)
     }
     $field_type = $field_bits[0]['cf_type'];
     $field_id = $field_bits[0]['id'];
     if ($field_type == 'integer') {
         ocf_set_custom_field($member, $field_id, intval($amount));
     } else {
         ocf_set_custom_field($member, $field_id, $amount);
     }
 }
Ejemplo n.º 5
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_custom_profile_fields($db, $table_prefix, $file_base)
 {
     $where = '*';
     if (either_param('importer') == 'ipb2') {
         $where = 'pf_position as forder,pf_type as ftype,pf_id as fid,pf_title as ftitle,pf_desc as fdesc,pf_member_hide as fhide,pf_member_edit as fedit,pf_show_on_reg as freq';
     }
     $rows = $db->query('SELECT ' . $where . ' FROM ' . $table_prefix . 'pfields_data');
     $members = $db->query('SELECT * FROM ' . $table_prefix . 'pfields_content');
     foreach ($rows as $row) {
         if (import_check_if_imported('cpf', strval($row['fid']))) {
             continue;
         }
         $type = 'short_text';
         if ($row['ftype'] == 'text') {
             $type = 'short_text';
         } elseif ($row['ftype'] == 'area') {
             $type = 'long_text';
         }
         $id_new = $GLOBALS['FORUM_DB']->query_value_null_ok('f_custom_fields f LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON f.cf_name=t.id', 'f.id', array('text_original' => $row['ftitle']));
         if (is_null($id_new)) {
             $id_new = ocf_make_custom_field($row['ftitle'], 0, $row['fdesc'], '', 1 - $row['fhide'], 1 - $row['fhide'], $row['fedit'], 0, $type, $row['freq'], 0, 0, $row['forder'], '', true);
         }
         foreach ($members as $member) {
             ocf_set_custom_field($member['member_id'], $id_new, @html_entity_decode($member['field_' . strval($row['fid'])], ENT_QUOTES, get_charset()));
         }
         import_id_remap_put('cpf', strval($row['fid']), $id_new);
     }
 }
Ejemplo n.º 6
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_custom_profile_fields($db, $table_prefix, $file_base)
 {
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'profilefields');
     $members = $db->query('SELECT * FROM ' . $table_prefix . 'userfields');
     foreach ($rows as $row) {
         if (import_check_if_imported('cpf', strval($row['fid']))) {
             continue;
         }
         $type = 'short_text';
         if ($row['type'] == 'text') {
             $type = 'short_text';
         } elseif ($row['type'] == 'textarea') {
             $type = 'long_text';
         }
         $id_new = $GLOBALS['FORUM_DB']->query_value_null_ok('f_custom_fields f LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON f.cf_name=t.id', 'f.id', array('text_original' => $row['name']));
         if (is_null($id_new)) {
             $id_new = ocf_make_custom_field($row['name'], 0, $row['description'], '', 1 - $row['hidden'], 1 - $row['hidden'], $row['editable'], 0, $type, $row['required'], 0, 0, $row['disporder'], '', true);
         }
         foreach ($members as $member) {
             $v = $member['fid' . strval($row['fid'])];
             $member_id = import_id_remap_get('member', strval($member['ufid']), true);
             if ($v != '' && !is_null($member_id)) {
                 ocf_set_custom_field($member_id, $id_new, $v);
             }
         }
         import_id_remap_put('cpf', strval($row['fid']), $id_new);
     }
 }
Ejemplo n.º 7
0
/**
 * Edit a member.
 *
 * @param  AUTO_LINK			The ID of the member.
 * @param  ?SHORT_TEXT		The e-mail address. (NULL: don't change)
 * @param  ?BINARY			Whether posts are previewed before they are made. (NULL: don't change)
 * @param  ?integer			Day of date of birth. (NULL: don't change) (-1: deset)
 * @param  ?integer			Month of date of birth. (NULL: don't change) (-1: deset)
 * @param  ?integer			Year of date of birth. (NULL: don't change) (-1: deset)
 * @param  ?ID_TEXT			The member timezone. (NULL: don't change)
 * @param  ?GROUP				The members primary (NULL: don't change).
 * @param  array				A map of custom fields values (field-id=>value).
 * @param  ?ID_TEXT			The members default theme. (NULL: don't change)
 * @param  ?BINARY			Whether the members age may be shown. (NULL: don't change)
 * @param  ?BINARY			Whether the member sees signatures in posts. (NULL: don't change)
 * @param  ?BINARY			Whether the member automatically is enabled for notifications for content they contribute to. (NULL: don't change)
 * @param  ?LANGUAGE_NAME	The members language. (NULL: don't change)
 * @param  ?BINARY			Whether the member allows e-mails via the site. (NULL: don't change)
 * @param  ?BINARY			Whether the member allows e-mails from staff via the site. (NULL: don't change)
 * @param  ?BINARY			Whether the profile has been validated (NULL: do not change this). (NULL: don't change)
 * @param  ?string			The username. (NULL: don't change)
 * @param  ?string			The password. (NULL: don't change)
 * @param  ?BINARY			Whether the member likes to view zones without menus, when a choice is available. (NULL: don't change)
 * @param  ?BINARY			Whether the member username will be highlighted. (NULL: don't change)
 * @param  ?SHORT_TEXT		Usergroups that may PT the member. (NULL: don't change)
 * @param  ?LONG_TEXT		Rules that other members must agree to before they may start a PT with the member. (NULL: don't change)
 * @param  ?TIME				When the member is on probation until (NULL: don't change)
 * @param  ?TIME				When the member joined (NULL: don't change)
 * @param  ?URLPATH			Avatar (NULL: don't change)
 * @param  ?LONG_TEXT		Signature (NULL: don't change)
 * @param  ?BINARY			Banned status (NULL: don't change)
 * @param  ?URLPATH			Photo URL (NULL: don't change)
 * @param  ?URLPATH			URL of thumbnail of photo (NULL: don't change)
 * @param  ?SHORT_TEXT		Password salt (NULL: don't change)
 * @param  ?ID_TEXT			Password compatibility scheme (NULL: don't change)
 * @param  boolean			Whether to skip security checks and most of the change-triggered emails
 */
function ocf_edit_member($member_id, $email_address, $preview_posts, $dob_day, $dob_month, $dob_year, $timezone, $primary_group, $custom_fields, $theme, $reveal_age, $views_signatures, $auto_monitor_contrib_content, $language, $allow_emails, $allow_emails_from_staff, $validated = NULL, $username = NULL, $password = NULL, $zone_wide = 1, $highlighted_name = NULL, $pt_allow = '*', $pt_rules_text = '', $on_probation_until = NULL, $join_time = NULL, $avatar_url = NULL, $signature = NULL, $is_perm_banned = NULL, $photo_url = NULL, $photo_thumb_url = NULL, $salt = NULL, $password_compatibility_scheme = NULL, $skip_checks = false)
{
    require_code('type_validation');
    if (!$skip_checks) {
        $old_email_address = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_email_address');
        if (!is_null($email_address) && ($email_address != '' || $old_email_address != '' && !has_specific_permission(get_member(), 'member_maintenance')) && !is_valid_email_address($email_address)) {
            warn_exit(do_lang_tempcode('_INVALID_EMAIL_ADDRESS', escape_html($email_address)));
        }
    }
    if (!is_null($username) && $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_password_compat_scheme') != 'remote') {
        if (!$skip_checks) {
            ocf_check_name_valid($username, $member_id, $password);
            require_code('urls2');
            suggest_new_idmoniker_for('members', 'view', strval($member_id), $username);
        }
    }
    // Supplement custom field values given with defaults, and check constraints
    $all_fields = ocf_get_all_custom_fields_match($GLOBALS['OCF_DRIVER']->get_members_groups($member_id));
    foreach ($all_fields as $field) {
        $field_id = $field['id'];
        if (array_key_exists($field_id, $custom_fields)) {
            if (!$skip_checks) {
                if ($field['cf_public_view'] == 0 && $member_id != get_member() && !has_specific_permission(get_member(), 'view_any_profile_field')) {
                    access_denied('I_ERROR');
                }
                if ($field['cf_owner_view'] == 0 && $member_id == get_member() && !has_specific_permission(get_member(), 'view_any_profile_field')) {
                    access_denied('I_ERROR');
                }
                if ($field['cf_owner_set'] == 0 && $member_id == get_member() && !has_specific_permission(get_member(), 'view_any_profile_field')) {
                    access_denied('I_ERROR');
                }
            }
        }
    }
    // Set custom profile field values
    $all_fields_types = collapse_2d_complexity('id', 'cf_type', $all_fields);
    $changes = array();
    foreach ($custom_fields as $field => $value) {
        if (!array_key_exists($field, $all_fields_types)) {
            continue;
        }
        // Trying to set a field we're not allowed to (doesn't apply to our group)
        $change = ocf_set_custom_field($member_id, $field, $value, $all_fields_types[$field], true);
        if (!is_null($change)) {
            $changes = array_merge($changes, $change);
        }
    }
    if (count($changes) != 0) {
        $GLOBALS['FORUM_DB']->query_update('f_member_custom_fields', $changes, array('mf_member_id' => $member_id), '', 1);
    }
    $old_primary_group = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_primary_group');
    $_pt_rules_text = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_pt_rules_text');
    $_signature = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_signature');
    $update = array();
    if (!is_null($theme)) {
        $update['m_theme'] = $theme;
    }
    if (!is_null($preview_posts)) {
        $update['m_preview_posts'] = $preview_posts;
    }
    if (!is_null($dob_day)) {
        $update['m_dob_day'] = $dob_day == -1 ? NULL : $dob_day;
    }
    if (!is_null($dob_month)) {
        $update['m_dob_month'] = $dob_month == -1 ? NULL : $dob_month;
    }
    if (!is_null($dob_year)) {
        $update['m_dob_year'] = $dob_year == -1 ? NULL : $dob_year;
    }
    if (!is_null($timezone)) {
        $update['m_timezone_offset'] = $timezone;
    }
    if (!is_null($reveal_age)) {
        $update['m_reveal_age'] = $reveal_age;
    }
    if (!is_null($email_address)) {
        $update['m_email_address'] = $email_address;
    }
    if (!is_null($views_signatures)) {
        $update['m_views_signatures'] = $views_signatures;
    }
    if (!is_null($auto_monitor_contrib_content)) {
        $update['m_auto_monitor_contrib_content'] = $auto_monitor_contrib_content;
    }
    if (!is_null($language)) {
        $update['m_language'] = $language;
    }
    if (!is_null($allow_emails)) {
        $update['m_allow_emails'] = $allow_emails;
    }
    if (!is_null($allow_emails_from_staff)) {
        $update['m_allow_emails_from_staff'] = $allow_emails_from_staff;
    }
    if (!is_null($zone_wide)) {
        $update['m_zone_wide'] = $zone_wide;
    }
    if (!is_null($pt_allow)) {
        $update['m_pt_allow'] = $pt_allow;
    }
    if (!is_null($pt_rules_text)) {
        $update['m_pt_rules_text'] = lang_remap_comcode($_pt_rules_text, $pt_rules_text, $GLOBALS['FORUM_DB']);
    }
    if ($skip_checks || has_specific_permission(get_member(), 'probate_members')) {
        $update['m_on_probation_until'] = $on_probation_until;
    }
    if (!is_null($join_time)) {
        $update['m_join_time'] = $join_time;
    }
    if (!is_null($avatar_url)) {
        $update['m_avatar_url'] = $avatar_url;
    }
    if (!is_null($signature)) {
        $update['m_signature'] = lang_remap_comcode($_signature, $signature, $GLOBALS['FORUM_DB']);
    }
    if (!is_null($is_perm_banned)) {
        $update['m_is_perm_banned'] = $is_perm_banned;
    }
    if (!is_null($photo_url)) {
        $update['m_photo_url'] = $photo_url;
    }
    if (!is_null($photo_thumb_url)) {
        $update['m_photo_thumb_url'] = $photo_thumb_url;
    }
    $old_username = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_username');
    if (!is_null($username) && $username != $old_username && ($skip_checks || has_actual_page_access(get_member(), 'admin_ocf_join') || has_specific_permission($member_id, 'rename_self'))) {
        $update['m_username'] = $username;
        // Reassign personal galleries
        if (addon_installed('galleries')) {
            require_lang('galleries');
            $personal_galleries = $GLOBALS['SITE_DB']->query('SELECT fullname,parent_id FROM ' . get_table_prefix() . 'galleries WHERE name LIKE \'member_' . strval($member_id) . '_%\'');
            foreach ($personal_galleries as $gallery) {
                $parent_title = get_translated_text($GLOBALS['SITE_DB']->query_value('galleries', 'fullname', array('name' => $gallery['parent_id'])));
                if (get_translated_text($gallery['fullname']) == do_lang('PERSONAL_GALLERY_OF', $old_username, $parent_title)) {
                    lang_remap($gallery['fullname'], do_lang('PERSONAL_GALLERY_OF', $username, $parent_title), $GLOBALS['FORUM_DB']);
                }
            }
        }
        require_code('notifications');
        $subject = do_lang('USERNAME_CHANGED_MAIL_SUBJECT', $username, $old_username, NULL, get_lang($member_id));
        $mail = do_lang('USERNAME_CHANGED_MAIL', comcode_escape(get_site_name()), comcode_escape($username), comcode_escape($old_username), get_lang($member_id));
        dispatch_notification('ocf_username_changed', NULL, $subject, $mail, array($member_id));
        $subject = do_lang('STAFF_USERNAME_CHANGED_MAIL_SUBJECT', $username, $old_username, NULL, get_site_default_lang());
        $mail = do_lang('STAFF_USERNAME_CHANGED_MAIL', comcode_escape(get_site_name()), comcode_escape($username), comcode_escape($old_username), get_site_default_lang());
        dispatch_notification('ocf_username_changed_staff', NULL, $subject, $mail);
        // Fix cacheing for usernames
        $to_fix = array('f_forums/f_cache_last_username', 'f_posts/p_poster_name_if_guest', 'f_topics/t_cache_first_username', 'f_topics/t_cache_last_username');
        foreach ($to_fix as $fix) {
            list($table, $field) = explode('/', $fix);
            $GLOBALS['FORUM_DB']->query_update($table, array($field => $username), array($field => $old_username));
        }
    }
    if (!is_null($password)) {
        if (is_null($password_compatibility_scheme) && get_value('no_password_hashing') === '1') {
            $password_compatibility_scheme = 'plain';
            $update['m_password_change_code'] = '';
            $salt = '';
        }
        if (!is_null($salt) || !is_null($password_compatibility_scheme)) {
            if (!is_null($salt)) {
                $update['m_pass_salt'] = $salt;
            }
            if (!is_null($password_compatibility_scheme)) {
                $update['m_password_compat_scheme'] = $password_compatibility_scheme;
            }
            $update['m_pass_hash_salted'] = $password;
        } else {
            $update['m_password_change_code'] = '';
            $salt = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_pass_salt');
            $update['m_pass_hash_salted'] = md5($salt . md5($password));
            $update['m_password_compat_scheme'] = '';
        }
        if (!$skip_checks) {
            $part_b = '';
            if (!has_actual_page_access(get_member(), 'admin_ocf_join')) {
                $part_b = do_lang('PASSWORD_CHANGED_MAIL_BODY_2', get_ip_address());
            }
            $mail = do_lang('PASSWORD_CHANGED_MAIL_BODY', get_site_name(), $part_b, NULL, get_lang($member_id));
            $old_email_address = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_email_address');
            if ($old_email_address != $email_address) {
                $GLOBALS['FORUM_DB']->query_update('f_invites', array('i_email_address' => $old_email_address), array('i_email_address' => $email_address));
            }
            if ($member_id == get_member() || get_value('disable_password_change_mails_for_staff') !== '1') {
                if (get_page_name() != 'admin_ocf_join') {
                    require_code('notifications');
                    dispatch_notification('ocf_password_changed', NULL, do_lang('PASSWORD_CHANGED_MAIL_SUBJECT', NULL, NULL, NULL, get_lang($member_id)), $mail, array($member_id), NULL, 2);
                }
            }
        }
    }
    if (!is_null($validated)) {
        $update['m_validated_email_confirm_code'] = '';
        if (addon_installed('unvalidated')) {
            $update['m_validated'] = $validated;
        }
    }
    if (!is_null($highlighted_name)) {
        $update['m_highlighted_name'] = $highlighted_name;
    }
    if (!is_null($primary_group)) {
        $update['m_primary_group'] = $primary_group;
    }
    $old_validated = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_validated');
    $GLOBALS['FORUM_DB']->query_update('f_members', $update, array('id' => $member_id), '', 1);
    if (get_member() != $member_id) {
        log_it('EDIT_MEMBER_PROFILE', strval($member_id), $username);
    }
    if ($old_validated == 0 && $validated == 1) {
        require_code('mail');
        $_login_url = build_url(array('page' => 'login'), get_module_zone('login'), NULL, false, false, true);
        $login_url = $_login_url->evaluate();
        mail_wrap(do_lang('VALIDATED_MEMBER_SUBJECT', get_site_name(), NULL, get_lang($member_id)), do_lang('MEMBER_VALIDATED', get_site_name(), $username, $login_url, get_lang($member_id)), array($email_address), $username);
    }
    // Decache from run-time cache
    unset($GLOBALS['FORUM_DRIVER']->MEMBER_ROWS_CACHED[$member_id]);
    unset($GLOBALS['MEMBER_CACHE_FIELD_MAPPINGS'][$member_id]);
    unset($GLOBALS['TIMEZONE_MEMBER_CACHE'][$member_id]);
    unset($GLOBALS['USER_NAME_CACHE'][$member_id]);
}
Ejemplo n.º 8
0
 /**
  * The actualiser for merging members.
  *
  * @return tempcode		The UI
  */
 function actual()
 {
     $title = get_page_title('MERGE_MEMBERS');
     $to_username = post_param('to');
     $to_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($to_username);
     if (is_null($to_id) || is_guest($to_id)) {
         warn_exit(do_lang_tempcode('_USER_NO_EXIST', $to_username));
     }
     $from_username = post_param('from');
     $from_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($from_username);
     if (is_guest($from_id)) {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     if (is_null($from_id) || is_guest($from_id)) {
         warn_exit(do_lang_tempcode('_USER_NO_EXIST', $from_username));
     }
     if ($to_id == $from_id) {
         warn_exit(do_lang_tempcode('MERGE_SAME'));
     }
     $meta = $GLOBALS['SITE_DB']->query('SELECT m_table,m_name FROM ' . get_table_prefix() . 'db_meta WHERE ' . db_string_equal_to('m_type', 'USER') . ' OR ' . db_string_equal_to('m_type', '?USER') . ' OR ' . db_string_equal_to('m_type', '*USER'));
     foreach ($meta as $m) {
         $GLOBALS['SITE_DB']->query_update($m['m_table'], array($m['m_name'] => $to_id), array($m['m_name'] => $from_id), '', NULL, NULL, false, true);
     }
     $GLOBALS['FORUM_DB']->query_update('f_posts', array('p_poster_name_if_guest' => $to_username), array('p_poster' => $from_id));
     $new_post_count = $GLOBALS['FORUM_DRIVER']->get_member_row_field($from_id, 'm_cache_num_posts') + $GLOBALS['FORUM_DRIVER']->get_member_row_field($to_id, 'm_cache_num_posts');
     $GLOBALS['FORUM_DB']->query_update('f_members', array('m_cache_num_posts' => $new_post_count), array('id' => $to_id), '', 1);
     require_code('ocf_members_action');
     require_code('ocf_members_action2');
     $fields = ocf_get_custom_fields_member($from_id);
     foreach ($fields as $key => $val) {
         if ($val != '') {
             ocf_set_custom_field($to_id, $key, $val);
         }
     }
     ocf_delete_member($from_id);
     // Cache emptying ...
     ocf_require_all_forum_stuff();
     require_code('ocf_posts_action');
     require_code('ocf_posts_action2');
     require_code('ocf_topics_action2');
     require_code('ocf_forums_action2');
     // Members
     ocf_force_update_member_post_count($to_id);
     $num_warnings = $GLOBALS['FORUM_DB']->query_value('f_warnings', 'COUNT(*)', array('w_member_id' => $to_id));
     $GLOBALS['FORUM_DB']->query_update('f_members', array('m_cache_warnings' => $num_warnings), array('id' => $to_id), '', 1);
     // Topics and posts
     require_code('ocf_topics_action');
     $topics = $GLOBALS['FORUM_DB']->query_select('f_topics', array('id', 't_forum_id'), array('t_cache_first_member_id' => $from_id));
     foreach ($topics as $topic) {
         ocf_force_update_topic_cacheing($topic['id'], NULL, true, true);
     }
     $topics = $GLOBALS['FORUM_DB']->query_select('f_topics', array('id', 't_forum_id'), array('t_cache_last_member_id' => $from_id));
     foreach ($topics as $topic) {
         ocf_force_update_topic_cacheing($topic['id'], NULL, true, true);
     }
     // Forums
     require_code('ocf_posts_action2');
     $forums = $GLOBALS['FORUM_DB']->query_select('f_forums', array('id'), array('f_cache_last_member_id' => $from_id));
     foreach ($forums as $forum) {
         ocf_force_update_forum_cacheing($forum['id']);
     }
     // ---
     log_it('MERGE_MEMBERS', $from_username, $to_username);
     breadcrumb_set_parents(array(array('_SEARCH:admin_ocf_join:menu', do_lang_tempcode('MEMBERS')), array('_SELF:_SELF:misc', do_lang_tempcode('MERGE_MEMBERS'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     $username = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($to_id);
     return inform_screen($title, do_lang_tempcode('MERGED_MEMBERS', $username));
 }