/** * Prepare any data needed for the output * * @param string The id of the block * @param array Options specific to the block */ function prepare_output($id = '', $options = array()) { global $show, $vbphrase; if (is_array($options)) { $options = array_merge($this->option_defaults, $options); } else { $options = $this->option_defaults; } $options['simple'] = $this->profile->prepared['myprofile'] ? $options['simple'] : false; $this->build_field_data($options['simple']); if ($options['category'] == 'all') { $categories = $this->categories; $show['profile_category_title'] = true; $enable_ajax_edit = true; } else { $categories = isset($this->categories["{$options['category']}"]) ? array($options['category'] => $this->categories["{$options['category']}"]) : array(); $show['profile_category_title'] = false; $enable_ajax_edit = false; } $profilefields = ''; foreach ($categories as $profilefieldcategoryid => $profilefield_items) { $category = array('title' => $profilefieldcategoryid == 0 ? construct_phrase($vbphrase['about_x'], $this->profile->userinfo['username']) : $vbphrase["category{$profilefieldcategoryid}_title"], 'description' => $vbphrase["category{$profilefieldcategoryid}_desc"], 'fields' => ''); foreach ($profilefield_items as $profilefield) { $field_value = $this->profile->userinfo["field{$profilefield['profilefieldid']}"]; fetch_profilefield_display($profilefield, $field_value); // can edit if viewing own profile and field is actually editable $show['profilefield_edit'] = (!$options['simple'] and $enable_ajax_edit and $this->registry->userinfo['userid'] == $this->profile->userinfo['userid'] and ($profilefield['editable'] == 1 or $profilefield['editable'] == 2 and empty($field_value)) and $this->registry->userinfo['permissions']['genericpermissions'] & $this->registry->bf_ugp_genericpermissions['canmodifyprofile']); if ($show['profilefield_edit'] and $profilefield['value'] == '') { // this field is to be editable but there's no value -- we need to show the field $profilefield['value'] = $vbphrase['n_a']; } ($hook = vBulletinHook::fetch_hook('member_profileblock_profilefieldbit')) ? eval($hook) : false; if ($profilefield['value'] != '') { $show['extrainfo'] = true; $templater = vB_Template::create('memberinfo_profilefield'); $templater->register('profilefield', $profilefield); $category['fields'] .= $templater->render(); } } ($hook = vBulletinHook::fetch_hook('member_profileblock_profilefield_category')) ? eval($hook) : false; if ($category['fields']) { $templater = vB_Template::create('memberinfo_profilefield_category'); $templater->register('category', $category); $profilefields .= $templater->render(); } } $this->block_data['fields'] = $profilefields; }
$userdata->set_existing($vbulletin->userinfo); $userdata->set_userfields($vbulletin->GPC['userfield']); $userdata->save(); // fetch profilefield data $profilefield = $db->query_first(" SELECT profilefield.* FROM " . TABLE_PREFIX . "profilefield AS profilefield WHERE profilefieldid = " . $vbulletin->GPC['fieldid'] ); // get displayable profilefield value $new_value = (isset($userdata->userfield['field' . $vbulletin->GPC['fieldid']]) ? $userdata->userfield['field' . $vbulletin->GPC['fieldid']] : $vbulletin->userinfo['field' . $vbulletin->GPC['fieldid']] ); fetch_profilefield_display($profilefield, $new_value); // output XML $xml = new vB_AJAX_XML_Builder($vbulletin, 'text/xml'); $xml->add_group('response'); $returnvalue = $profilefield['value'] == '' ? $vbphrase['n_a'] : $profilefield['value']; $xml->add_tag('value', process_replacement_vars($returnvalue)); if ($profilefield['editable'] == 2 AND !empty($new_value)) { // this field is no longer editable $xml->add_tag('uneditable', '1'); } $xml->close_group(); $xml->print_xml();
function do_get_profile() { global $vbulletin, $db, $show, $vbphrase, $permissions, $imodcache; $vbulletin->input->clean_array_gpc('r', array('userid' => TYPE_UINT)); if (!$vbulletin->userinfo['userid'] && !$vbulletin->GPC['userid']) { json_error(ERR_INVALID_LOGGEDIN, RV_NOT_LOGGED_IN); } if (!($permissions['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['canview']) or !($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canviewmembers'])) { json_error(ERR_NO_PERMISSION); } if (!$vbulletin->GPC['userid']) { $vbulletin->GPC['userid'] = $vbulletin->userinfo['userid']; } $fetch_userinfo_options = FETCH_USERINFO_AVATAR | FETCH_USERINFO_LOCATION | FETCH_USERINFO_PROFILEPIC | FETCH_USERINFO_SIGPIC | FETCH_USERINFO_USERCSS | FETCH_USERINFO_ISFRIEND; $userinfo = verify_id('user', $vbulletin->GPC['userid'], 1, $fetch_userinfo_options); if ($userinfo['usergroupid'] == 4 and !($permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'])) { json_error(ERR_NO_PERMISSION); } $posts = $userinfo['posts']; $joindate = vbdate($vbulletin->options['dateformat'], $userinfo['joindate']); $out = array('username' => html_entity_decode($userinfo['username']), 'online' => fetch_online_status($userinfo, false), 'avatar_upload' => $vbulletin->options['avatarenabled'] && $permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canuseavatar'], 'posts' => $posts, 'joindate' => $joindate); $avatarurl_info = fetch_avatar_url($userinfo['userid']); if ($avatarurl_info) { $out['avatarurl'] = process_avatarurl($avatarurl_info[0]); } cache_moderators(); $canbanuser = ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'] or can_moderate(0, 'canbanusers')); if ($canbanuser) { $out['ban'] = true; } $groups = array(); // About $out_group = array('name' => 'about', 'values' => array(array('name' => prepare_utf8_string($vbphrase['posts']), 'value' => strval(vb_number_format($userinfo['posts']))), array('name' => prepare_utf8_string($vbphrase['join_date']), 'value' => vbdate($vbulletin->options['dateformat'], $userinfo['joindate'])))); if (function_exists('itrader_user')) { itrader_user($userinfo); $out_group['values'][] = array('name' => 'iTrader', 'value' => vb_number_format($userinfo['tradescore']) . ', ' . $userinfo['tradepcnt'] . '%'); $out += array('itrader_score' => vb_number_format($userinfo['tradescore']), 'itrader_percent' => $userinfo['tradepcnt'] . '%'); } $groups[] = $out_group; $profileobj = new vB_UserProfile($vbulletin, $userinfo); $blockfactory = new vB_ProfileBlockFactory($vbulletin, $profileobj); $profileblock =& $blockfactory->fetch('ProfileFields'); $profileblock->build_field_data(false); $profile = $profileblock->categories[0]; // Additional information if (count($profile)) { $out_group = array('name' => 'additional'); foreach ($profile as $profilefield) { $field_value = $userinfo["field{$profilefield['profilefieldid']}"]; fetch_profilefield_display($profilefield, $field_value); if (!strlen(trim($field_value))) { continue; } $out_group['values'][] = array('name' => prepare_utf8_string($profilefield['title']), 'value' => prepare_utf8_string($profilefield['value'])); } if (count($out_group['values'])) { $groups[] = $out_group; } } $out['groups'] = $groups; return $out; }