relationship direction was too confusing to work with. instead of "in,out,both" it's now declared by role e.g. "vip,fan,bud".

This commit is contained in:
Mike Macgirvin 2010-09-21 19:51:08 -07:00
parent 399b6828f6
commit 188dc1fcf8
8 changed files with 25 additions and 28 deletions

View File

@ -11,10 +11,7 @@ define ( 'REGISTER_CLOSED', 0);
define ( 'REGISTER_APPROVE', 1); define ( 'REGISTER_APPROVE', 1);
define ( 'REGISTER_OPEN', 2); define ( 'REGISTER_OPEN', 2);
define ( 'DIRECTION_NONE', 0); // No relationship // relationship types
define ( 'DIRECTION_IN', 1); // VIP e.g. has FAN
define ( 'DIRECTION_OUT', 2); // FAN to a VIP
define ( 'DIRECTION_BOTH', 3); // Mutual Friends
define ( 'REL_VIP', 1); define ( 'REL_VIP', 1);
define ( 'REL_FAN', 2); define ( 'REL_FAN', 2);

View File

@ -10,8 +10,8 @@ function can_write_wall(&$a,$owner) {
AND `readonly` = 0 AND `rel` IN ( %d , %d ) LIMIT 1", AND `readonly` = 0 AND `rel` IN ( %d , %d ) LIMIT 1",
intval($owner), intval($owner),
intval($_SESSION['visitor_id']), intval($_SESSION['visitor_id']),
intval(DIRECTION_OUT), intval(REL_VIP),
intval(DIRECTION_BOTH) intval(REL_BUD)
); );
if(count($r)) if(count($r))
return true; return true;

View File

@ -151,16 +151,16 @@ function contacts_content(&$a) {
$tpl = file_get_contents("view/contact_edit.tpl"); $tpl = file_get_contents("view/contact_edit.tpl");
switch($r[0]['rel']) { switch($r[0]['rel']) {
case DIRECTION_BOTH: case REL_BUD:
$dir_icon = 'images/lrarrow.gif'; $dir_icon = 'images/lrarrow.gif';
$alt_text = t('Mutual Friendship'); $alt_text = t('Mutual Friendship');
break; break;
case DIRECTION_IN; case REL_VIP;
$dir_icon = 'images/larrow.gif'; $dir_icon = 'images/larrow.gif';
$alt_text = t('is a fan of yours'); $alt_text = t('is a fan of yours');
break; break;
case DIRECTION_OUT; case REL_FAN;
$dir_icon = 'images/rarrow.gif'; $dir_icon = 'images/rarrow.gif';
$alt_text = t('you are a fan of'); $alt_text = t('you are a fan of');
break; break;
@ -186,7 +186,7 @@ function contacts_content(&$a) {
'$name' => $r[0]['name'], '$name' => $r[0]['name'],
'$dir_icon' => $dir_icon, '$dir_icon' => $dir_icon,
'$alt_text' => $alt_text, '$alt_text' => $alt_text,
'$url' => (($r[0]['rel'] != DIRECTION_OUT) ? "redir/{$r[0]['id']}" : $r[0]['url'] ) '$url' => (($r[0]['rel'] != REL_FAN) ? "redir/{$r[0]['id']}" : $r[0]['url'] )
)); ));
@ -220,16 +220,16 @@ function contacts_content(&$a) {
switch($sort_type) { switch($sort_type) {
case DIRECTION_BOTH : case REL_BUD :
$sql_extra2 = " AND `dfrn-id` != '' AND `issued-id` != '' "; $sql_extra2 = " AND `dfrn-id` != '' AND `issued-id` != '' ";
break; break;
case DIRECTION_IN : case REL_VIP :
$sql_extra2 = " AND `dfrn-id` = '' AND `issued-id` != '' "; $sql_extra2 = " AND `dfrn-id` = '' AND `issued-id` != '' ";
break; break;
case DIRECTION_OUT : case REL_FAN :
$sql_extra2 = " AND `dfrn-id` != '' AND `issued-id` = '' "; $sql_extra2 = " AND `dfrn-id` != '' AND `issued-id` = '' ";
break; break;
case DIRECTION_NONE : case 0 :
default: default:
$sql_extra2 = ''; $sql_extra2 = '';
break; break;
@ -256,15 +256,15 @@ function contacts_content(&$a) {
continue; continue;
switch($rr['rel']) { switch($rr['rel']) {
case DIRECTION_BOTH: case REL_BUD:
$dir_icon = 'images/lrarrow.gif'; $dir_icon = 'images/lrarrow.gif';
$alt_text = t('Mutual Friendship'); $alt_text = t('Mutual Friendship');
break; break;
case DIRECTION_IN; case REL_VIP;
$dir_icon = 'images/larrow.gif'; $dir_icon = 'images/larrow.gif';
$alt_text = t('is a fan of yours'); $alt_text = t('is a fan of yours');
break; break;
case DIRECTION_OUT; case REL_FAN;
$dir_icon = 'images/rarrow.gif'; $dir_icon = 'images/rarrow.gif';
$alt_text = t('you are a fan of'); $alt_text = t('you are a fan of');
break; break;
@ -280,7 +280,7 @@ function contacts_content(&$a) {
'$dir_icon' => $dir_icon, '$dir_icon' => $dir_icon,
'$thumb' => $rr['thumb'], '$thumb' => $rr['thumb'],
'$name' => $rr['name'], '$name' => $rr['name'],
'$url' => (($rr['rel'] != DIRECTION_OUT) ? "redir/{$rr['id']}" : $rr['url'] ) '$url' => (($rr['rel'] != REL_FAN) ? "redir/{$rr['id']}" : $rr['url'] )
)); ));
} }
$o .= '<div id="contact-edit-end"></div>'; $o .= '<div id="contact-edit-end"></div>';

View File

@ -127,9 +127,9 @@ function dfrn_confirm_post(&$a) {
$thumb = $a->get_baseurl() . '/images/default-profile-sm.jpg'; $thumb = $a->get_baseurl() . '/images/default-profile-sm.jpg';
} }
$new_relation = DIRECTION_OUT; $new_relation = REL_FAN;
if(($relation == DIRECTION_IN) || ($duplex)) if(($relation == REL_VIP) || ($duplex))
$new_relation = DIRECTION_BOTH; $new_relation = REL_BUD;
$r = q("UPDATE `contact` SET $r = q("UPDATE `contact` SET
`photo` = '%s', `photo` = '%s',
@ -362,9 +362,9 @@ function dfrn_confirm_post(&$a) {
$thumb = $a->get_baseurl() . '/images/default-profile-sm.jpg'; $thumb = $a->get_baseurl() . '/images/default-profile-sm.jpg';
} }
$new_relation = DIRECTION_IN; $new_relation = REL_VIP;
if(($relation == DIRECTION_OUT) || ($duplex)) if(($relation == REL_FAN) || ($duplex))
$new_relation = DIRECTION_BOTH; $new_relation = REL_BUD;
$r = q("UPDATE `contact` SET `photo` = '%s', $r = q("UPDATE `contact` SET `photo` = '%s',
`thumb` = '%s', `thumb` = '%s',

View File

@ -189,7 +189,7 @@ function display_content(&$a) {
$template = $wallwall; $template = $wallwall;
$commentww = 'ww'; $commentww = 'ww';
// If it is our contact, use a friendly redirect link // If it is our contact, use a friendly redirect link
if(($item['owner-link'] == $item['url']) && ($item['rel'] == DIRECTION_IN || $item['rel'] == DIRECTION_BOTH)) if(($item['owner-link'] == $item['url']) && ($item['rel'] == REL_VIP || $item['rel'] == REL_BUD))
$owner_url = $redirect_url; $owner_url = $redirect_url;
$owner_url = $redirect_url; $owner_url = $redirect_url;

View File

@ -696,7 +696,7 @@ function photos_content(&$a) {
$profile_url = $item['url']; $profile_url = $item['url'];
if(local_user() && ($item['contact-uid'] == get_uid()) if(local_user() && ($item['contact-uid'] == get_uid())
&& ($item['rel'] == DIRECTION_IN || $item['rel'] == DIRECTION_BOTH) && (! $item['self'] )) && ($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self'] ))
$profile_url = $redirect_url; $profile_url = $redirect_url;
$profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']); $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);

View File

@ -326,7 +326,7 @@ function profile_content(&$a, $update = 0) {
// I can go directly to their profile as an authenticated guest. // I can go directly to their profile as an authenticated guest.
if(local_user() && ($item['contact-uid'] == $_SESSION['uid']) if(local_user() && ($item['contact-uid'] == $_SESSION['uid'])
&& ($item['rel'] == DIRECTION_IN || $item['rel'] == DIRECTION_BOTH) && (! $item['self'] )) && ($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self'] ))
$profile_url = $redirect_url; $profile_url = $redirect_url;

View File

@ -38,7 +38,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
// to one recipient. By default our selector allows multiple selects amongst all contacts. // to one recipient. By default our selector allows multiple selects amongst all contacts.
if($privmail) { if($privmail) {
$sql_extra = sprintf(" AND `rel` = %d ", intval(DIRECTION_BOTH)); $sql_extra = sprintf(" AND `rel` = %d ", intval(REL_BUD));
$o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" >\r\n"; $o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" >\r\n";
} }
else { else {