0) { drupal_set_message(t('The following error occured: '. xmlrpc_error_msg()), 'error'); return ''; } if (drupal_substr($user_name, -1) == 's') { $title = drupal_ucfirst($user_name) .'\' Friends'; } else { $title = drupal_ucfirst($user_name) .'\'s Friends'; } drupal_set_title($title); drupal_set_breadcrumb(''); $output = t('
'); // print friends if (sizeof($friends) > 0) { usort($friends, "_cmp_names"); //$output .= t('
Friends
'); foreach ($friends as $friend) { $output .= t('
'); $output .= t('
'); if ($friend['icon'] != "") { $image = origo_home_get_service_dir('pictures') . $friend['name'] .'/100_'. $friend['icon']; } else { $image = base_path() . drupal_get_path('module', 'origo_home') .'/img/user_m_medium.png'; } $output .= l(''. $friend['name'] .'', 'users/'. $friend['name'], array('html' => TRUE)); $output .= t('
'); // end icon $output .= t('
'); $output .= t('
'); $output .= t('Username: '); $output .= t(''); $output .= l($friend['name'], 'users/'. $friend['name'], array('attributes' => array('rel' => 'contact'))); $output .= t(''); $output .= t('
'); if (trim($friend['real_name']) != "") { $output .= t('
'); $output .= t('Name: '); $output .= t(''); $output .= t($friend['real_name']); $output .= t(''); $output .= t('
'); } $output .= t('
'); // end name $output .= t('
'); $output .= t('
'); $output .= l('[View Profile]', 'users/'. $friend['name'], array('rel' => 'contact')); $output .= t('
'); $output .= t('
'); $output .= l('[View Friends]', 'friends/'. $friend['name'], array('rel' => 'contact')); $output .= t('
'); if ($visitor->name == $user_name) { $output .= t('
'); $output .= l('[Remove from Friends]', 'remove_friend/'. $friend['name']); $output .= t('
'); } if ($visitor->name != $friend['name']) { $output .= t('
'); $output .= l('[Send Message]', 'message/'. $friend['name']); $output .= t('
'); } $output .= t('
'); // end operations $output .= t('
'); // end friend } } $output .= t('
'); $output .= l('Find more friends on Origo', 'search/user'); return $output; } /** * Request Friendship Page * * @param String $friend_name Name of friend to request friendship for * @return String Request Friendship Form */ function origo_home_request_friendship_page($friend_name) { $output = t('Do you want to add '. $friend_name .' as your friend?
'); $output .= t('An e-mail will be sent to '. $friend_name .' so that '. $friend_name .' can confirm your request.
'); $output .= t('Your request will be valid for 14 days.

'); $output .= drupal_get_form('origo_home_request_friendship_form', $friend_name); return $output; } function origo_home_request_friendship_form(&$form_state, $friend_name) { $form['friend_name'] = array( '#type' => 'hidden', '#value' => $friend_name, ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Request Friendship'), ); return $form; } function origo_home_request_friendship_form_submit($form, &$form_state) { global $user; if ($form_state['values']['op'] == t('Request Friendship')) { origo_auth_xmlrpc_session(variable_get('origo_api', ''), 'user.request_friendship', $form_state['values']['friend_name']); if ((int)xmlrpc_errno() > 0) { drupal_set_message(t('The following error has occured: '. xmlrpc_error_msg()), 'error'); } else { drupal_set_message(t('Friendship requested. User '. $form_state['values']['friend_name'] .' will receive an e-mail to confirm your request.')); drupal_goto('friends/'. $user->name); } } } /** * Confirm Friendship Request Page * * @param String $friend_name * @return String Confirm Friendship Form */ function origo_home_confirm_friendship_page($friend_name) { $output = t('Do you confirm the friendship request of '. $friend_name .' and add '. $friend_name .' as your friend?

'); $output .= drupal_get_form('origo_home_confirm_friendship_form', $friend_name); return $output; } function origo_home_confirm_friendship_form(&$form_state, $friend_name) { $form['friend_name'] = array( '#type' => 'hidden', '#value' => $friend_name, ); $form['confirm'] = array( '#type' => 'submit', '#value' => t('Confirm Request'), ); $form['reject'] = array( '#type' => 'submit', '#value' => t('Reject Request'), ); return $form; } function origo_home_confirm_friendship_form_submit($form, &$form_state) { global $user; if ($form_state['values']['op'] == t('Confirm Request')) { origo_auth_xmlrpc_session(variable_get('origo_api', ''), 'user.process_friendship_request', $form_state['values']['friend_name'], TRUE); if ((int)xmlrpc_errno() > 0) { drupal_set_message(t('The following error has occured: '. xmlrpc_error_msg()), 'error'); } else { drupal_set_message(t('Successfully added '. $form_state['values']['friend_name'] .' as your friend.')); drupal_goto('friends/'. $user->name); } } elseif ($form_state['values']['op'] == t('Reject Request')) { origo_auth_xmlrpc_session(variable_get('origo_api', ''), 'user.process_friendship_request', $form_state['values']['friend_name'], FALSE); if ((int)xmlrpc_errno() > 0) { drupal_set_message(t('The following error has occured: '. xmlrpc_error_msg()), 'error'); } else { drupal_set_message(t('Rejected '. $form_state['values']['friend_name'] .'\'s request.')); drupal_goto('friends/'. $user->name); } } } /** * Remove Friendship Page * * @param String $friend_name * @return String Remove Friendship Form */ function origo_home_remove_friendship_page($friend_name) { $output = t('Do you really want to remove '. $friend_name .' from your friends?

'); $output .= drupal_get_form('origo_home_remove_friendship_form', $friend_name); return $output; } function origo_home_remove_friendship_form(&$form_state, $friend_name) { $form['friend_name'] = array( '#type' => 'hidden', '#value' => $friend_name, ); $form['confirm'] = array( '#type' => 'submit', '#value' => t('Remove Friendship'), ); return $form; } function origo_home_remove_friendship_form_submit($form, &$form_state) { global $user; if ($form_state['values']['op'] == t('Remove Friendship')) { origo_auth_xmlrpc_session(variable_get('origo_api', ''), 'user.remove_friendship', $form_state['values']['friend_name']); if ((int)xmlrpc_errno() > 0) { drupal_set_message(t('The following error has occured: '. xmlrpc_error_msg()), 'error'); } else { drupal_set_message(t('Successfully removed '. $form_state['values']['friend_name'] .' from your friends.')); drupal_goto('friends/'. $user->name); } } }