function pcp_output_age($field_name, $view_userdata, $map_name = '') { global $board_config, $phpbb_root_path, $phpEx, $lang, $images, $userdata; global $values_list, $tables_linked, $classes_fields, $user_maps, $user_fields; // use user_birthday $pm_display = pcp_get_class_check('pm', $view_userdata); $txt = ''; $img = ''; $res = ''; if (!empty($view_userdata['user_birthday']) && $view_userdata['user_id'] != ANONYMOUS) { $temp_url = $pm_display ? append_sid("./privmsg.{$phpEx}?mode=post&" . POST_USERS_URL . '=' . $view_userdata['user_id']) : ''; $img = intval(substr($view_userdata['user_birthday'], 4, 4)) == date('md', cal_date(time(), $board_config['board_timezone'])) ? $pm_display ? '<a href="' . $temp_url . '"><img src="' . $images['icon_birthday'] . '" border="0" alt="' . $lang['Happy_birthday'] . '" title="' . $lang['Happy_birthday'] . '" /></a>' : '<img src="' . $images['icon_birthday'] . '" border="0" alt="' . $lang['Happy_birthday'] . '" title="' . $lang['Happy_birthday'] . '" />' : ''; $txt = date('Y', cal_date(time(), $board_config['board_timezone'])) - intval(substr($view_userdata['user_birthday'], 0, 4)); if (intval(substr($view_userdata['user_birthday'], 4, 4)) > date('md', cal_date(time(), $board_config['board_timezone']))) { $txt--; } if ($txt < 0) { $txt = ''; $img = ''; } // result $res = pcp_output_format($field_name, $txt, $img, $map_name); } return $res; }
if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not get buddy information', '', __LINE__, __FILE__, $sql); } while ($row = $db->sql_fetchrow($result)) { if ($row['user_id'] == $user_id) { $view_userdata['user_my_friend'] = !$row['buddy_ignore']; $view_userdata['user_my_ignore'] = $row['buddy_ignore']; $view_userdata['user_my_visible'] = $row['buddy_visible']; } else { $view_userdata['user_friend'] = !$row['buddy_ignore']; $view_userdata['user_ignore'] = $row['buddy_ignore']; $view_userdata['user_visible'] = $row['buddy_visible']; } } $view_userdata['user_online'] = $view_userdata['user_session_time'] >= time() - 300; $view_userdata['user_pm'] = pcp_get_class_check('pm', $view_userdata); /* Old Fix - which is superceeded by the corrected (original) code above while ( $row = $db->sql_fetchrow($result) ) { if ( $row['user_id'] != $user_id ) { $view_userdata['user_friend'] = !$row['buddy_ignore']; $view_userdata['user_ignore'] = $row['buddy_ignore']; $view_userdata['user_visible'] = $row['buddy_visible']; } else { $view_userdata['user_my_friend'] = !$row['buddy_ignore']; $view_userdata['user_my_ignore'] = $row['buddy_ignore']; $view_userdata['user_my_visible'] = $row['buddy_visible'];
function pcp_output($field_name, $view_userdata, $map_name = '', $legend_only = false) { global $board_config, $phpbb_root_path, $phpEx, $lang, $images, $userdata; global $values_list, $tables_linked, $classes_fields, $user_maps, $user_fields; $res = ''; // no field, exit if (empty($field_name)) { return ''; } // fix user id $user_id = $userdata['user_id']; if (!$userdata['session_logged_in']) { $user_id = ANONYMOUS; } // values overwritten in maps if (!empty($user_maps[$map_name]['fields'][$field_name])) { @reset($user_maps[$map_name]['fields'][$field_name]); while (list($field_def, $field_def_value) = @each($user_maps[$map_name]['fields'][$field_name])) { $user_fields[$field_name][$field_def] = $field_def_value; } } // get field def $field_data = array(); if (isset($user_fields[$field_name])) { $field_data = $user_fields[$field_name]; } // default values if (empty($field_data['lang_key'])) { $field_data['lang_key'] = ucfirst($field_name); } if (empty($field_data['class'])) { $field_data['class'] = 'generic'; } if (empty($field_data['type'])) { $field_data['type'] = 'VARCHAR'; } // legend only if ($legend_only) { return mods_settings_get_lang($field_data['lang_key']); } // get class def $class_data = array(); if (isset($classes_fields[$field_data['class']])) { $class_data = $classes_fields[$field_data['class']]; } // check the data classes if (!pcp_get_class_check($field_data['class'], $view_userdata)) { return ''; } // process special display if (!empty($field_data['dsp_func'])) { $func = $field_data['dsp_func']; $res = function_exists($func) ? $func($field_name, $view_userdata, $map_name) : $lang['PCP_err_field_dsp_func_unknown']; } else { // value $txt = ''; $img = ''; $lnk = $field_data['link']; $res = ''; $constant_link = $field_data['lnk'] && !isset($view_userdata[$field_name]) && ($field_data['txt'] && !empty($field_data['title']) || $field_data['img'] && !empty($field_data['image'])); if ($view_userdata['user_id'] != ANONYMOUS && (!empty($view_userdata[$field_name]) || $field_data['leg'] && !$field_data['txt'] && !$field_data['img'] || $constant_link)) { $title = isset($field_data['title']) ? mods_settings_get_lang($field_data['title']) : $view_userdata[$field_name]; $alt = mods_settings_get_lang($field_data['lang_key']); switch ($field_data['type']) { case 'DATE': $txt = !empty($view_userdata[$field_name]) ? create_date($lang['DATE_FORMAT'], $view_userdata[$field_name], $userdata['user_timezone']) : ''; $img .= isset($images[$field_data['image']]) ? '<img src="' . $images[$field_data['image']] . '" border="0" alt="' . $alt . '" title="' . $title . '" />' : ''; break; case 'DATETIME': $txt = !empty($view_userdata[$field_name]) ? create_date($userdata['user_dateformat'], $view_userdata[$field_name], $userdata['user_timezone']) : ''; $img .= isset($images[$field_data['image']]) ? '<img src="' . $images[$field_data['image']] . '" border="0" alt="' . $alt . '" title="' . $title . '" />' : ''; break; case 'BIRTHDAY': $pm_display = pcp_get_class_check('pm', $view_userdata); if (!empty($view_userdata[$field_name])) { $temp_url = $pm_display ? append_sid("./privmsg.{$phpEx}?mode=post&" . POST_USERS_URL . '=' . $view_userdata['user_id']) : ''; $txt = create_birthday_date($lang['DATE_FORMAT'], $view_userdata[$field_name], $userdata['user_timezone']); $img = intval(substr($view_userdata[$field_name], 4, 4)) == date('md', cal_date(time(), $board_config['board_timezone'])) ? $pm_display ? '<a href="' . $temp_url . '"><img src="' . $images['icon_birthday'] . '" border="0" align="absbottom" alt="' . $lang['Happy_birthday'] . '" title="' . $lang['Happy_birthday'] . '" /></a>' : '<img src="' . $images['icon_birthday'] . '" border="0" align="absbottom" alt="' . $lang['Happy_birthday'] . '" title="' . $lang['Happy_birthday'] . '" />' : ''; } break; default: $txt = $view_userdata[$field_name]; if ($field_data['lnk'] && !isset($view_userdata[$field_name])) { $txt = $title; } $img .= isset($images[$field_data['image']]) ? '<img src="' . $images[$field_data['image']] . '" border="0" alt="' . $alt . '" title="' . $title . '" />' : ''; break; } // res $res = pcp_output_format($field_name, $txt, $img, $map_name, $lnk, $view_userdata); } } return $res; }