1
0
Fork 0

Merge pull request #1509 from annando/1504-code-rework

Code reworks: replaced hardcoded network text with the corresponding constants
This commit is contained in:
fabrixxm 2015-04-12 08:45:31 +02:00
commit 1731db45c2
7 changed files with 25 additions and 22 deletions

View file

@ -78,19 +78,19 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
if(x($options,'networks')) {
switch($options['networks']) {
case 'DFRN_ONLY':
$networks = array('dfrn');
$networks = array(NETWORK_DFRN);
break;
case 'PRIVATE':
if(is_array($a->user) && $a->user['prvnets'])
$networks = array('dfrn','mail','dspr');
$networks = array(NETWORK_DFRN,NETWORK_MAIL,NETWORK_DIASPORA);
else
$networks = array('dfrn','face','mail', 'dspr');
$networks = array(NETWORK_DFRN,NETWORK_FACEBOOK,NETWORK_MAIL, NETWORK_DIASPORA);
break;
case 'TWO_WAY':
if(is_array($a->user) && $a->user['prvnets'])
$networks = array('dfrn','mail','dspr');
$networks = array(NETWORK_DFRN,NETWORK_MAIL,NETWORK_DIASPORA);
else
$networks = array('dfrn','face','mail','dspr','stat');
$networks = array(NETWORK_DFRN,NETWORK_FACEBOOK,NETWORK_MAIL,NETWORK_DIASPORA,NETWORK_OSTATUS);
break;
default:
break;
@ -181,12 +181,12 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
$sql_extra .= sprintf(" AND `rel` = %d ", intval(CONTACT_IS_FRIEND));
}
if($privmail) {
$sql_extra .= " AND `network` IN ( 'dfrn', 'dspr' ) ";
}
elseif($privatenet) {
$sql_extra .= " AND `network` IN ( 'dfrn', 'mail', 'face', 'dspr' ) ";
}
if($privmail)
$sql_extra .= sprintf(" AND `network` IN ('%s' , '%s') ",
NETWORK_DFRN, NETWORK_DIASPORA);
elseif($privatenet)
$sql_extra .= sprintf(" AND `network` IN ('%s' , '%s', '%s', '%s') ",
NETWORK_DFRN, NETWORK_MAIL, NETWORK_FACEBOOK, NETWORK_DIASPORA);
$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'])) {
$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'];
$sparkle = ' class="sparkle" ';
}

View file

@ -920,7 +920,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
if($redirect) {
$a = get_app();
$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;
$url = $redirect_url;
$sparkle = ' sparkle';

View file

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

View file

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

View file

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

View file

@ -37,7 +37,8 @@ function profperm_content(&$a) {
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
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(local_user())
);
@ -132,8 +133,9 @@ function profperm_content(&$a) {
$o .= '<div id="prof-all-contacts">';
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 and `pending` = 0 and `self` = 0
AND `network` = 'dfrn' ORDER BY `name` ASC",
intval(local_user())
AND `network` = '%s' ORDER BY `name` ASC",
intval(local_user()),
dbesc(NETWORK_DFRN)
);
if(count($r)) {