name); if (drupal_substr($username, -1) == 's') { $title = drupal_ucfirst($username) .'\' Profile'; } else { $title = drupal_ucfirst($username) .'\'s Profile'; } drupal_set_title($title); drupal_set_breadcrumb(''); $error = ''; // get specific user data from origo DB $user_information = origo_auth_xmlrpc_session(variable_get('origo_api', ''), 'user.retrieve_information', $username); if ((int)xmlrpc_errno() > 0 || $user_information == FALSE) { if ($user_information == FALSE) { $error .= t('This user does not exist or has been disabled.
'); } else { $error .= t(xmlrpc_error_msg() .'
'); } } else { // clean up user information foreach ($user_information as $key => $value) { $user_information[$key] = htmlentities(utf8_decode($value)); } // get all projects for user $projects = origo_auth_xmlrpc_session(variable_get('origo_api', ''), 'project.list_of_user', $username); if ((int)xmlrpc_errno() > 0) { $error .= t(xmlrpc_error_msg() .'
'); } else { usort($projects, "_cmp_project_names"); } // get all bookmarked projects for user $bookmarks = origo_auth_xmlrpc_session(variable_get('origo_api', ''), 'user.list_bookmark', $username); if ((int)xmlrpc_errno() > 0) { $error .= t(xmlrpc_error_msg() .'
'); } else { usort($bookmarks, "_cmp_names"); } // get all friends for user $friends = origo_auth_xmlrpc_session(variable_get('origo_api', ''), 'user.list_friends', $username); if ((int)xmlrpc_errno() > 0) { $error .= t(xmlrpc_error_msg() .'
'); } else { shuffle($friends); } $already_friends = FALSE; if (!$is_self) { foreach ($friends as $friend) { if ($friend['name'] == $user->name) { $already_friends = TRUE; } } } // get all communities for user $communities = origo_auth_xmlrpc_session(variable_get('origo_api', ''), 'user.list_communities', $username); if ((int)xmlrpc_errno() > 0) { $error .= t(xmlrpc_error_msg() .'
'); } else { usort($communities, "_cmp_names"); } } // check if any xmlrpc errors occured if (drupal_strlen($error) > 0) { $error_msg = t('The following error(s) occured:
'); $error_msg .= t($error); drupal_set_message($error_msg, 'error'); return ''; } // Retrieve and merge all profile information $hookfields = array(); foreach (module_list() as $module) { // call hook *_origouser if ($data = module_invoke($module, 'origouser', 'view', $username)) { foreach ($data as $category => $items) { foreach ($items as $key => $item) { $hookfields[$category][$key] = $item; } } } } $output = t('
'); $output .= t('
'); $output .= t('
'); if ($user_information['icon'] != '') { $image_path = origo_home_get_service_dir('pictures') . $username .'/200_'. $user_information['icon']; } else { $image_path = base_path() . drupal_get_path('module', 'origo_home') .'/img/user_m_big.png"'; } // user icon $output .= t(''. $username .''); if ($is_self) { $output .= t('
') . l('[Edit User Icon]', 'users/'. $username .'/edit_user_icon') . t('
'); } $output .= t('
'); // add from $hookfields[$category='Picture'][$key] if (is_array($hookfields['Picture'])) { foreach ($hookfields['Picture'] as $key => $item) { $output .= $item; } } // Settings if ($is_self) { $output .= t('
Settings
'); $output .= t('
'); $output .= t('
') . l('[Edit Privacy Settings]', 'users/'. $username .'/additional_settings') . t('
'); $output .= t('
'); } // print projects if (sizeof($projects) > 0) { $output .= t('
Projects
'); $output .= t('
'); foreach ($projects as $project) { $project_name = _crop_line($project['project_name'], 22, "..."); $output .= t('
'); $output .= l($project_name, get_origo_project_link($project['project_name'])); $output .= t('
'); } $output .= t('
'); } // print bookmarks if (sizeof($bookmarks) > 0) { $output .= t('
'); if ($is_self) { $output .= t(''); } $output .= t('Bookmarks
'); $output .= t('
'); foreach ($bookmarks as $bookmark) { $bookmark_name = _crop_line($bookmark['name'], 22, "..."); $output .= t('
'); $output .= l($bookmark_name, get_origo_project_link($bookmark['name'])); $output .= t('
'); } $output .= t('
'); } // print communities if (sizeof($communities) > 0) { $output .= t('
'); if ($is_self) { $output .= t(''); } $output .= t('Communities
'); $output .= t('
'); foreach ($communities as $community) { $community_name = _crop_line($community['name'], 22, "..."); $output .= t('
'); $output .= l($community_name, 'communities/'. drupal_strtolower($community['name'])); $output .= t('
'); } $output .= t('
'); } // add from $hookfields[$category='Colleft'][$key] if (is_array($hookfields['Colleft'])) { foreach ($hookfields['Colleft'] as $key => $item) { $output .= $item; } } $output .= t('
'); // end colleft $output .= t('
'); $output .= t('
'); if ($is_self) { $output .= t(''); } // shows [Remove from Friends] elseif ($already_friends) { $output .= t(''); } // shows [Add to Friends] elseif ($user->uid > 0) { $output .= t(''); } if (user_access('origo admin access')) { // An Origo admin is viewing the profile module_load_include('inc', 'origo_home', 'origo_admin'); $output .= t(''); } if (drupal_strlen($user_information['first_name']) > 0 && drupal_strlen($user_information['last_name']) > 0) { $output .= t(''. $user_information['first_name'] .''); $output .= t(' '); $output .= t(''. $user_information['last_name'] .''); } elseif (drupal_strlen($user_information['first_name']) > 0) { $output .= t(''. $user_information['first_name'] .''); } elseif (drupal_strlen($user_information['last_name']) > 0) { $output .= t(''. $user_information['last_name'] .''); } else { $output .= t(''. $username .''); } $output .= t('
'); $output .= t('
'); $output .= t('
Member Since
'); $output .= t('
'); $output .= t(date('Y-m-d', $user_information['registration_date'])); $output .= t('
'); $birthday = explode(' ', $user_information['birthday']); $birthday = explode('/', $birthday[0]); $birthday = $birthday[2] .'-'. $birthday[0] .'-'. $birthday[1]; if ($birthday != '1900-01-01') { $output .= t('
Birthday
'); $output .= t('
'); $output .= t($birthday); $output .= t('
'); } if (drupal_strlen($user_information['homepage']) > 0) { $homepage_title = _crop_line($user_information['homepage'], 33, "..."); $output .= t('
Homepage
'); $output .= t('
'); $output .= l($homepage_title, _link_check($user_information['homepage']), array('attributes' => array('rel' => 'me', 'class' => 'url'))); $output .= t('
'); } if (drupal_strlen($user_information['blog']) > 0) { $blog_title = _crop_line($user_information['blog'], 33, "..."); $output .= t('
Blog
'); $output .= t('
'); $output .= l($blog_title, _link_check($user_information['blog']), array('attributes' => array('rel' => 'me', 'class' => 'url'))); $output .= t('
'); } if (drupal_strlen($user_information['ohloh_profile']) > 0) { // check if the whole url was entered. stripe out the name and display it $pos = strrchr($user_information['ohloh_profile'], "/"); if ($pos) { $ohloh_title = _crop_line(drupal_substr($pos, 1), 33, "..."); $ohloh_link = $user_information['ohloh_profile']; } else { // assume just the username was entered $ohloh_title = _crop_line($user_information['ohloh_profile'], 33, "..."); $ohloh_link = 'http://www.ohloh.net/accounts/'. $user_information['ohloh_profile']; } $output .= t('
Ohloh Profile
'); $output .= t('
'); $output .= l($ohloh_title, _link_check($ohloh_link), array('attributes' => array('rel' => 'me', 'class' => 'url'))); $output .= t('
'); } if (drupal_strlen($user_information['languages']) > 0) { $output .= t('
Languages
'); $output .= t('
'); $output .= t($user_information['languages']); $output .= t('
'); } if (drupal_strlen($user_information['message']) > 0) { $output .= t('
Message
'); $output .= t('
'); $output .= t(str_replace("\n", "
", $user_information['message'])); $output .= t('
'); } // add from $hookfields[$category='Personal Information'][$key] if (is_array($hookfields['Personal Information'])) { foreach ($hookfields['Personal Information'] as $key => $item) { $output .= $item; } } $output .= t('
'); // Icons $output .= t('
'); drupal_add_js(drupal_get_path('module', 'origo_home') .'/lib/jtip/jtip.js', 'module'); drupal_add_css(drupal_get_path('module', 'origo_home') .'/lib/jtip/jtip.css', 'module', 'all', FALSE); // vCard Icon $output .= l( 'vCard', 'users/'. $username .'/vcard', array( 'attributes' => array( 'rel' => 'me', 'id' => 'aaAi378', 'name' => 'vCard', 'class' => 'jTip jTip_element_ao3ue2ht jTip_width_150 jTip_opacity_95' ), 'html' => TRUE )) .' '; $apostroph = (drupal_substr($username, -1) == 's')?'\'':'\'s'; $output .= t(''); $ret = origo_auth_xml_rpc(variable_get('origo_api', ''), 'user.profile_visible', $username); if ((int)xmlrpc_errno() <= 0 && $ret['profile_visible'] == 1) { // the profile is visible by anyone, so it is hCard enabled // hCard Icon (microformats) $output .= l( '', 'http://microformats.org/wiki/hcard', array( 'attributes' => array( 'id' => '3728Au2', 'name' => 'microformats', 'class' => 'jTip jTip_element_feAu32D jTip_width_150 jTip_opacity_95' ), 'html' => TRUE )) .' '; $output .= t(''); } // add from $hookfields[$category='Personal Information Icons'][$key] if (is_array($hookfields['Personal Information Icons'])) { foreach ($hookfields['Personal Information Icons'] as $key => $item) { $output .= $item .' '; } } $output .= t('
'); $contact_data_present = (drupal_strlen($user_information['icq']) > 0) || (drupal_strlen($user_information['jabber']) > 0) || (drupal_strlen($user_information['aim']) > 0) || (drupal_strlen($user_information['yahoo']) > 0) || (drupal_strlen($user_information['msn']) > 0) || (drupal_strlen($user_information['skype']) > 0) || (drupal_strlen($user_information['sip']) > 0); if ($contact_data_present || $is_self || $user->uid > 0) { $output .= t('
'); if ($is_self) { $output .= t(''); } $output .= t('Contact
'); $output .= t('
'); } $output .= t('
Origo
'); $output .= t('
'); $output .= l('[Send Message]', 'message/'. $username); $output .= t('
'); if (drupal_strlen($user_information['icq']) > 0) { $output .= t('
ICQ
'); $output .= t('
'); $output .= t($user_information['icq']); $output .= t('
'); } if (drupal_strlen($user_information['jabber']) > 0) { $output .= t('
Jabber
'); $output .= t('
'); $output .= t($user_information['jabber']); $output .= t('
'); } if (drupal_strlen($user_information['aim']) > 0) { $output .= t('
AIM
'); $output .= t('
'); $output .= t($user_information['aim']); $output .= t('
'); } if (drupal_strlen($user_information['yahoo']) > 0) { $output .= t('
Yahoo
'); $output .= t('
'); $output .= t( $user_information['yahoo']); $output .= t('
'); } if (drupal_strlen($user_information['msn']) > 0) { $output .= t('
MSN
'); $output .= t('
'); $output .= t($user_information['msn']); $output .= t('
'); } if (drupal_strlen($user_information['skype']) > 0) { $output .= t('
Skype
'); $output .= t('
'); $output .= t($user_information['skype']); $output .= t('
'); } if (drupal_strlen($user_information['irc']) > 0) { $output .= t('
IRC
'); $output .= t('
'); $output .= t($user_information['irc']); $output .= t('
'); } if (drupal_strlen($user_information['sip']) > 0) { $output .= t('
SIP
'); $output .= t('
'); $output .= t($user_information['sip']); $output .= t('
'); } // add from $hookfields[$category='Contact'][$key] if (is_array($hookfields['Contact'])) { foreach ($hookfields['Contact'] as $key => $item) { $output .= $item; } } if ($contact_data_present || $is_self || $user->uid > 0) { $output .= t('
'); } // print friends if (sizeof($friends) > 0) { $min = min(6, sizeof($friends)); $output .= t('
'); if ($is_self) { $output .= t(''); } else { $output .= t(''); } $output .= t('Friends ('. $min .' of '. sizeof($friends) .')
'); $output .= t('
'); for ($counter = 0; $counter < $min; $counter++) { $output .= t('
'); $output .= t('
'); if ($friends[$counter]['icon'] != "") { $image_path = origo_home_get_service_dir('pictures') . $friends[$counter]['name'] .'/100_'. $friends[$counter]['icon']; } else { $image_path = base_path() . drupal_get_path('module', 'origo_home') .'/img/user_m_medium.png'; } $output .= l(''. $friends[$counter]['name'] .'', 'users/'. $friends[$counter]['name'], array('html' => TRUE)); $output .= t('
'); $output .= t('
'); $output .= l($friends[$counter]['name'], 'users/'. $friends[$counter]['name'], array('attributes' => array('rel' => 'contact'))); $output .= t('
'); $output .= t('
'); if ($counter == 2) { $output .= t('
'); $output .= t('
'); } } $output .= t('
'); // end friendrow } // add from $hookfields[$category='Friend'][$key] if (is_array($hookfields['Friend'])) { foreach ($hookfields['Friend'] as $key => $item) { $output .= $item; } } $output .= t('
'); // end colright $output .= t('
'); // end community return $output; } /** * Crop a line which would be too long. * * @param String $input * @param int $length * @param String $trail * @return String result */ function _crop_line($input, $length, $trail) { $temp = ""; if (drupal_strlen($input) > $length) { $result = drupal_substr($input, 0, $length - drupal_strlen($trail)); $result .= $trail; } else { $result = $input; } return $result; }