Code reworks: replaced hardcoded network text with the corresponding constants.

This commit is contained in:
Michael Vogel 2015-04-11 22:14:56 +02:00
parent dea1b067bd
commit 0e895e24f7
7 changed files with 21 additions and 18 deletions

View file

@ -78,19 +78,19 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
if(x($options,'networks')) { if(x($options,'networks')) {
switch($options['networks']) { switch($options['networks']) {
case 'DFRN_ONLY': case 'DFRN_ONLY':
$networks = array('dfrn'); $networks = array(NETWORK_DFRN);
break; break;
case 'PRIVATE': case 'PRIVATE':
if(is_array($a->user) && $a->user['prvnets']) if(is_array($a->user) && $a->user['prvnets'])
$networks = array('dfrn','mail','dspr'); $networks = array(NETWORK_DFRN,NETWORK_MAIL,NETWORK_DIASPORA);
else else
$networks = array('dfrn','face','mail', 'dspr'); $networks = array(NETWORK_DFRN,NETWORK_FACEBOOK,NETWORK_MAIL, NETWORK_DIASPORA);
break; break;
case 'TWO_WAY': case 'TWO_WAY':
if(is_array($a->user) && $a->user['prvnets']) if(is_array($a->user) && $a->user['prvnets'])
$networks = array('dfrn','mail','dspr'); $networks = array(NETWORK_DFRN,NETWORK_MAIL,NETWORK_DIASPORA);
else else
$networks = array('dfrn','face','mail','dspr','stat'); $networks = array(NETWORK_DFRN,NETWORK_FACEBOOK,NETWORK_MAIL,NETWORK_DIASPORA,NETWORK_OSTATUS);
break; break;
default: default:
break; break;
@ -182,10 +182,10 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
} }
if($privmail) { if($privmail) {
$sql_extra .= " AND `network` IN ( 'dfrn', 'dspr' ) "; $sql_extra .= " AND `network` IN ( NETWORK_DFRN, NETWORK_DIASPORA ) ";
} }
elseif($privatenet) { elseif($privatenet) {
$sql_extra .= " AND `network` IN ( 'dfrn', 'mail', 'face', 'dspr' ) "; $sql_extra .= " AND `network` IN ( NETWORK_DFRN, NETWORK_MAIL, NETWORK_FACEBOOK, NETWORK_DIASPORA ) ";
} }
$tabindex = ($tabindex > 0 ? "tabindex=\"$tabindex\"" : ""); $tabindex = ($tabindex > 0 ? "tabindex=\"$tabindex\"" : "");

View file

@ -908,7 +908,7 @@ function like_puller($a,$item,&$arr,$mode) {
if((activity_match($item['verb'],$verb)) && ($item['id'] != $item['parent'])) { if((activity_match($item['verb'],$verb)) && ($item['id'] != $item['parent'])) {
$url = $item['author-link']; $url = $item['author-link'];
if((local_user()) && (local_user() == $item['uid']) && ($item['network'] === 'dfrn') && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) { if((local_user()) && (local_user() == $item['uid']) && ($item['network'] === NETWORK_DFRN) && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) {
$url = $a->get_baseurl(true) . '/redir/' . $item['contact-id']; $url = $a->get_baseurl(true) . '/redir/' . $item['contact-id'];
$sparkle = ' class="sparkle" '; $sparkle = ' class="sparkle" ';
} }

View file

@ -920,7 +920,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
if($redirect) { if($redirect) {
$a = get_app(); $a = get_app();
$redirect_url = $a->get_baseurl() . '/redir/' . $contact['id']; $redirect_url = $a->get_baseurl() . '/redir/' . $contact['id'];
if(local_user() && ($contact['uid'] == local_user()) && ($contact['network'] === 'dfrn')) { if(local_user() && ($contact['uid'] == local_user()) && ($contact['network'] === NETWORK_DFRN)) {
$redir = true; $redir = true;
$url = $redirect_url; $url = $redirect_url;
$sparkle = ' sparkle'; $sparkle = ' sparkle';

View file

@ -33,7 +33,7 @@ function contacts_init(&$a) {
$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"),array( $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"),array(
'$name' => $a->data['contact']['name'], '$name' => $a->data['contact']['name'],
'$photo' => $a->data['contact']['photo'], '$photo' => $a->data['contact']['photo'],
'$url' => ($a->data['contact']['network'] == 'dfrn') ? $a->get_baseurl()."/redir/".$a->data['contact']['id'] : $a->data['contact']['url'] '$url' => ($a->data['contact']['network'] == NETWORK_DFRN) ? $a->get_baseurl()."/redir/".$a->data['contact']['id'] : $a->data['contact']['url']
)); ));
$follow_widget = ''; $follow_widget = '';
} }
@ -681,7 +681,7 @@ function contacts_content(&$a) {
default: default:
break; break;
} }
if(($rr['network'] === 'dfrn') && ($rr['rel'])) { if(($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
$url = "redir/{$rr['id']}"; $url = "redir/{$rr['id']}";
$sparkle = ' class="sparkle" '; $sparkle = ' class="sparkle" ';
} }

View file

@ -340,7 +340,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
`pending` = 0, `pending` = 0,
`duplex` = %d, `duplex` = %d,
`hidden` = %d, `hidden` = %d,
`network` = 'dfrn' WHERE `id` = %d `network` = '%s' WHERE `id` = %d
", ",
dbesc($photos[0]), dbesc($photos[0]),
dbesc($photos[1]), dbesc($photos[1]),
@ -351,6 +351,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($duplex), intval($duplex),
intval($hidden), intval($hidden),
dbesc(NETWORK_DFRN),
intval($contact_id) intval($contact_id)
); );
} }

View file

@ -1628,7 +1628,7 @@ function photos_content(&$a) {
if(local_user() && ($item['contact-uid'] == local_user()) if(local_user() && ($item['contact-uid'] == local_user())
&& ($item['network'] == 'dfrn') && (! $item['self'] )) { && ($item['network'] == NETWORK_DFRN) && (! $item['self'] )) {
$profile_url = $redirect_url; $profile_url = $redirect_url;
$sparkle = ' sparkle'; $sparkle = ' sparkle';
} }

View file

@ -37,7 +37,8 @@ function profperm_content(&$a) {
if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) { if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
$r = q("SELECT `id` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `self` = 0 $r = q("SELECT `id` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `self` = 0
AND `network` = 'dfrn' AND `id` = %d AND `uid` = %d LIMIT 1", AND `network` = '%s' AND `id` = %d AND `uid` = %d LIMIT 1",
dbesc(NETWORK_DFRN),
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
@ -130,10 +131,11 @@ function profperm_content(&$a) {
$o .= '<h3>' . t("All Contacts \x28with secure profile access\x29") . '</h3>'; $o .= '<h3>' . t("All Contacts \x28with secure profile access\x29") . '</h3>';
$o .= '</div>'; $o .= '</div>';
$o .= '<div id="prof-all-contacts">'; $o .= '<div id="prof-all-contacts">';
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 and `pending` = 0 and `self` = 0 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 and `pending` = 0 and `self` = 0
AND `network` = 'dfrn' ORDER BY `name` ASC", AND `network` = '%s' ORDER BY `name` ASC",
intval(local_user()) intval(local_user()),
dbesc(NETWORK_DFRN)
); );
if(count($r)) { if(count($r)) {