<?php
// $Id: user_relationships-pending_block.tpl.php,v 1.1.2.12 2010/01/03 19:19:11 alexk Exp $
/**
 * @file
 * Template for relationships requests block
 * List all pending requests and provide links to the actions that can be taken on those requests
 */

global $base_url;
global $theme_path;
 
if ($relationships) {
  $list = array();
  foreach ($relationships as $rtid => $relationship) {
    $tt_rel_name = ur_tt("user_relationships:rtid:$rtid:name", $relationship->name);
    $tt_rel_plural_name = ur_tt("user_relationships:rtid:$rtid:plural_name", $relationship->plural_name);
    if ($user->uid == $relationship->requester_id) {
	   $relation_to =& $relationship->requestee;
	      $name = "";
		  
	    $temp_user = user_load(array('name' => theme('username', $relation_to)));
		$picture = $temp_user->picture; 
		
		$name = "<div class='req_div'><a href='userprofile/".theme('username', $relation_to)."' />";
	   if($picture!="")
				{
				 $name .= "<div class='req_photo'><img  src=\"".$base_url."/".$picture."\" align=\"top\" height=\"32\" width=\"32\" border=\"0\"  /></div>";
				}
	  else if($temp_user->rpx_data['profile']['photo']!="" && $picture=="") {

	   $name .= "<div class='req_photo'><img  src=\"".$temp_user->rpx_data['profile']['photo']."\" align=\"top\" height=\"32\" width=\"32\" border=\"0\"  /></div>";
<?php

// $Id: user_relationships.tpl.php,v 1.1.2.10 2009/10/15 15:23:26 aufumy Exp $
//$relationships array is loaded in template_preprocess_user_relationships()
if ($relationships) {
    foreach ($relationships as $relationship) {
        $edit_access = $user->uid == $account->uid && user_access('maintain own relationships') || user_access('administer users');
        $this_user_str = $account->uid == $relationship->requestee_id ? 'requester' : 'requestee';
        $this_user = $relationship->{$this_user_str};
        $row = array(theme('username', $this_user), ur_tt("user_relationships:rtid:{$relationship->rtid}:name", $relationship->name) . ($relationship->is_oneway ? $this_user_str == 'requestee' ? t(' (You to Them)') : t(' (Them to You)') : NULL), $relationship->extra_for_display, $edit_access ? theme('user_relationships_remove_link', $account->uid, $relationship->rid) : '&nbsp;');
        if (variable_get('user_relationships_show_user_pictures', 0)) {
            array_unshift($row, theme('user_picture', $this_user));
        }
        $rows[] = $row;
    }
    print theme('table', array(), $rows, array('class' => 'user-relationships-listing-table')) . theme('pager', NULL, $relationships_per_page);
} else {
    print t('No relationships found');
}
 */
$output = '';
$pager_id = 0;
$section_headings = array('sent_requests' => t('Sent Requests'), 'received_requests' => t('Received Requests'));
foreach ($sections as $column => $section) {
    if (!isset(${$section})) {
        continue;
    }
    $rows = array();
    $rows[] = array(array('data' => $section_headings[$section], 'header' => TRUE, 'colspan' => 2));
    foreach (${$section} as $relationship) {
        $links = array();
        if ($section == 'sent_requests') {
            $links[] = theme('user_relationships_pending_request_cancel_link', $account->uid, $relationship->rid);
        } else {
            $links[] = theme('user_relationships_pending_request_approve_link', $account->uid, $relationship->rid);
            $links[] = theme('user_relationships_pending_request_disapprove_link', $account->uid, $relationship->rid);
        }
        $links = implode(' | ', $links);
        if ($relationship->requester_id == $account->uid) {
            $rows[] = array(t('@rel_name to !requestee', array('@rel_name' => ur_tt("user_relationships:rtid:{$relationship->rtid}:name", $relationship->name), '!requestee' => theme('username', $relationship->requestee))), $links);
        } else {
            $rows[] = array(t('@rel_name from !requester', array('@rel_name' => ur_tt("user_relationships:rtid:{$relationship->rtid}:name", $relationship->name), '!requester' => theme('username', $relationship->requester))), $links);
        }
    }
    $output .= theme('table', array(), $rows, array('class' => 'user-relationships-pending-listing-table')) . theme('pager', NULL, $relationships_per_page, $pager_id++);
}
if ($output == '') {
    $output = t('No pending relationships found');
}
print $output;
	  
        $rows[]   = array(t('@rel_name to '.$requestee_name, array('@rel_name' => ur_tt("user_relationships:rtid:$relationship->rtid:name", $relationship->name))), $links);
      }
      else {
	  
	 	$temp_user1 = user_load(array('name' => theme('username', $relationship->requester)));
		if($temp_user1->rpx_data['profile']['name']['givenName']!="")
		{
			 $requester_name = $temp_user1->rpx_data['profile']['name']['givenName']." ".$temp_user1->rpx_data['profile']['name']['familyName'];
		}
		else
		{
			$requester_name = theme('username', $relationship->requester);
		}
		
        $rows[]   = array(t('@rel_name from '.$requester_name, array('@rel_name' => ur_tt("user_relationships:rtid:$relationship->rtid:name", $relationship->name))), $links);
      }
    }

    $output .=
      theme('table', array(), $rows, array('class' => 'user-relationships-pending-listing-table')).
      theme('pager', NULL, $relationships_per_page, $pager_id++);
  }

  if ($output == '') {
    $output = t('No pending relationships found');
  }

  print $output;
?>
Ejemplo n.º 5
0
function commons_roots_user_relationships_request_relationship_direct_link($relate_to, $relationship_type)
{
    $string = t("Become %name's %rel_name", array('%name' => $relate_to->name, '%rel_name' => ur_tt("user_relationships:rtid:{$relationship_type->rtid}:name", $relationship_type->name), '%rel_plural_name' => ur_tt("user_relationships:rtid:{$relationship_type->rtid}:plural_name", $relationship_type->plural_name)));
    $class = 'user_relationships_popup_link';
    if ($relationship_type->name == 'follower') {
        $string = t('Follow');
        $class .= ' follow-link';
    }
    return l($string, "relationship/{$relate_to->uid}/request/{$relationship_type->rtid}", array('query' => drupal_get_destination(), 'html' => TRUE, 'attributes' => array('class' => $class)));
}
Ejemplo n.º 6
0
function commons_roots_user_relationships_remove_link($viewer, $relationship)
{
    $path = "user/{$viewer->uid}/relationships/{$relationship->rid}/remove";
    $options = array('title' => array('title' => t('Remove')), 'query' => drupal_get_destination(), 'attributes' => array('class' => 'user_relationships_popup_link'));
    if ($relationship->name == 'follower') {
        $options['attributes']['class'] .= ' follow-link';
        $output = l(t('Unfollow'), $path, $options);
    } else {
        $output = t('%relationship_name (!remove_link)', array('%relationship_name' => ur_tt("user_relationships:rtid:{$relationship->rtid}:name", $relationship->name) . ($relationship->is_oneway ? $relationship->requester_id == $viewer->uid ? t(' (You to Them)') : t(' (Them to You)') : NULL), '!remove_link' => l(t('Remove'), $path, $options)));
    }
    return $output;
}