Fix formatting and PHP notices in contacts
- Use x() and defaults() to fix undefined indexes - Fix variable and constant name typos - Remove unused variables and commented out code - Add back undefined variables
This commit is contained in:
parent
d0d4e3813b
commit
f7165156f1
3 changed files with 139 additions and 143 deletions
|
@ -35,8 +35,9 @@ function contacts_init(App $a) {
|
||||||
|
|
||||||
require_once 'include/contact_widgets.php';
|
require_once 'include/contact_widgets.php';
|
||||||
|
|
||||||
if ($_GET['nets'] == "all") {
|
$nets = defaults($_GET, 'nets', '');
|
||||||
$_GET['nets'] = "";
|
if ($nets == "all") {
|
||||||
|
$nets = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! x($a->page,'aside')) {
|
if (! x($a->page,'aside')) {
|
||||||
|
@ -63,22 +64,22 @@ function contacts_init(App $a) {
|
||||||
'$account_type' => Contact::getAccountType($a->data['contact'])
|
'$account_type' => Contact::getAccountType($a->data['contact'])
|
||||||
));
|
));
|
||||||
|
|
||||||
$finpeople_widget = '';
|
$findpeople_widget = '';
|
||||||
$follow_widget = '';
|
$follow_widget = '';
|
||||||
$networks_widget = '';
|
$networks_widget = '';
|
||||||
} else {
|
} else {
|
||||||
$vcard_widget = '';
|
$vcard_widget = '';
|
||||||
$networks_widget .= networks_widget('contacts',$_GET['nets']);
|
$networks_widget = networks_widget('contacts', $nets);
|
||||||
if (isset($_GET['add'])) {
|
if (isset($_GET['add'])) {
|
||||||
$follow_widget = follow_widget($_GET['add']);
|
$follow_widget = follow_widget($_GET['add']);
|
||||||
} else {
|
} else {
|
||||||
$follow_widget = follow_widget();
|
$follow_widget = follow_widget();
|
||||||
}
|
}
|
||||||
|
|
||||||
$findpeople_widget .= findpeople_widget();
|
$findpeople_widget = findpeople_widget();
|
||||||
}
|
}
|
||||||
|
|
||||||
$groups_widget .= Group::sidebarWidget('contacts','group','full',0,$contact_id);
|
$groups_widget = Group::sidebarWidget('contacts','group','full',0,$contact_id);
|
||||||
|
|
||||||
$a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"),array(
|
$a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"),array(
|
||||||
'$vcard_widget' => $vcard_widget,
|
'$vcard_widget' => $vcard_widget,
|
||||||
|
@ -515,8 +516,6 @@ function contacts_content(App $a) {
|
||||||
|
|
||||||
require_once 'include/contact_selectors.php';
|
require_once 'include/contact_selectors.php';
|
||||||
|
|
||||||
$tpl = get_markup_template("contact_edit.tpl");
|
|
||||||
|
|
||||||
switch($contact['rel']) {
|
switch($contact['rel']) {
|
||||||
case CONTACT_IS_FRIEND:
|
case CONTACT_IS_FRIEND:
|
||||||
$dir_icon = 'images/lrarrow.gif';
|
$dir_icon = 'images/lrarrow.gif';
|
||||||
|
@ -577,6 +576,7 @@ function contacts_content(App $a) {
|
||||||
|
|
||||||
$lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < datetime_convert('','','now')) ? t('Communications lost with this contact!') : '');
|
$lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < datetime_convert('','','now')) ? t('Communications lost with this contact!') : '');
|
||||||
|
|
||||||
|
$fetch_further_information = null;
|
||||||
if ($contact['network'] == NETWORK_FEED) {
|
if ($contact['network'] == NETWORK_FEED) {
|
||||||
$fetch_further_information = array('fetch_further_information',
|
$fetch_further_information = array('fetch_further_information',
|
||||||
t('Fetch further information for feeds'),
|
t('Fetch further information for feeds'),
|
||||||
|
@ -587,12 +587,19 @@ function contacts_content(App $a) {
|
||||||
'3' => t('Fetch keywords'),
|
'3' => t('Fetch keywords'),
|
||||||
'2' => t('Fetch information and keywords')));
|
'2' => t('Fetch information and keywords')));
|
||||||
}
|
}
|
||||||
if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL)))
|
|
||||||
|
$poll_interval = null;
|
||||||
|
if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL))) {
|
||||||
$poll_interval = contact_poll_interval($contact['priority'],(! $poll_enabled));
|
$poll_interval = contact_poll_interval($contact['priority'],(! $poll_enabled));
|
||||||
|
}
|
||||||
|
|
||||||
if ($contact['network'] == NETWORK_DFRN)
|
$profile_select = null;
|
||||||
|
if ($contact['network'] == NETWORK_DFRN) {
|
||||||
$profile_select = contact_profile_assign($contact['profile-id'],(($contact['network'] !== NETWORK_DFRN) ? true : false));
|
$profile_select = contact_profile_assign($contact['profile-id'],(($contact['network'] !== NETWORK_DFRN) ? true : false));
|
||||||
|
}
|
||||||
|
|
||||||
|
$follow = '';
|
||||||
|
$follow_text = '';
|
||||||
if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS))) {
|
if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS))) {
|
||||||
if ($contact['rel'] == CONTACT_IS_FOLLOWER) {
|
if ($contact['rel'] == CONTACT_IS_FOLLOWER) {
|
||||||
$follow = System::baseUrl(true)."/follow?url=".urlencode($contact["url"]);
|
$follow = System::baseUrl(true)."/follow?url=".urlencode($contact["url"]);
|
||||||
|
@ -606,7 +613,7 @@ function contacts_content(App $a) {
|
||||||
// Load contactact related actions like hide, suggest, delete and others
|
// Load contactact related actions like hide, suggest, delete and others
|
||||||
$contact_actions = contact_actions($contact);
|
$contact_actions = contact_actions($contact);
|
||||||
|
|
||||||
|
$tpl = get_markup_template("contact_edit.tpl");
|
||||||
$o .= replace_macros($tpl, array(
|
$o .= replace_macros($tpl, array(
|
||||||
//'$header' => t('Contact Editor'),
|
//'$header' => t('Contact Editor'),
|
||||||
'$header' => t("Contact"),
|
'$header' => t("Contact"),
|
||||||
|
@ -618,9 +625,7 @@ function contacts_content(App $a) {
|
||||||
'$lbl_info2' => t('Their personal note'),
|
'$lbl_info2' => t('Their personal note'),
|
||||||
'$reason' => trim(notags($contact['reason'])),
|
'$reason' => trim(notags($contact['reason'])),
|
||||||
'$infedit' => t('Edit contact notes'),
|
'$infedit' => t('Edit contact notes'),
|
||||||
'$common_text' => $common_text,
|
|
||||||
'$common_link' => 'common/loc/' . local_user() . '/' . $contact['id'],
|
'$common_link' => 'common/loc/' . local_user() . '/' . $contact['id'],
|
||||||
'$all_friends' => $all_friends,
|
|
||||||
'$relation_text' => $relation_text,
|
'$relation_text' => $relation_text,
|
||||||
'$visit' => sprintf( t('Visit %s\'s profile [%s]'),$contact['name'],$contact['url']),
|
'$visit' => sprintf( t('Visit %s\'s profile [%s]'),$contact['name'],$contact['url']),
|
||||||
'$blockunblock' => t('Block/Unblock contact'),
|
'$blockunblock' => t('Block/Unblock contact'),
|
||||||
|
@ -658,7 +663,6 @@ function contacts_content(App $a) {
|
||||||
'$photo' => $contact['photo'],
|
'$photo' => $contact['photo'],
|
||||||
'$name' => htmlentities($contact['name']),
|
'$name' => htmlentities($contact['name']),
|
||||||
'$dir_icon' => $dir_icon,
|
'$dir_icon' => $dir_icon,
|
||||||
'$alt_text' => $alt_text,
|
|
||||||
'$sparkle' => $sparkle,
|
'$sparkle' => $sparkle,
|
||||||
'$url' => $url,
|
'$url' => $url,
|
||||||
'$profileurllabel' => t('Profile URL'),
|
'$profileurllabel' => t('Profile URL'),
|
||||||
|
@ -688,36 +692,33 @@ function contacts_content(App $a) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$blocked = false;
|
$blocked = false;
|
||||||
$hidden = false;
|
$hidden = false;
|
||||||
$ignored = false;
|
$ignored = false;
|
||||||
$all = false;
|
$archived = false;
|
||||||
|
$all = false;
|
||||||
|
|
||||||
if(($a->argc == 2) && ($a->argv[1] === 'all')) {
|
if(($a->argc == 2) && ($a->argv[1] === 'all')) {
|
||||||
$sql_extra = '';
|
$sql_extra = '';
|
||||||
$all = true;
|
$all = true;
|
||||||
}
|
} elseif(($a->argc == 2) && ($a->argv[1] === 'blocked')) {
|
||||||
elseif(($a->argc == 2) && ($a->argv[1] === 'blocked')) {
|
|
||||||
$sql_extra = " AND `blocked` = 1 ";
|
$sql_extra = " AND `blocked` = 1 ";
|
||||||
$blocked = true;
|
$blocked = true;
|
||||||
}
|
} elseif(($a->argc == 2) && ($a->argv[1] === 'hidden')) {
|
||||||
elseif(($a->argc == 2) && ($a->argv[1] === 'hidden')) {
|
|
||||||
$sql_extra = " AND `hidden` = 1 ";
|
$sql_extra = " AND `hidden` = 1 ";
|
||||||
$hidden = true;
|
$hidden = true;
|
||||||
}
|
} elseif(($a->argc == 2) && ($a->argv[1] === 'ignored')) {
|
||||||
elseif(($a->argc == 2) && ($a->argv[1] === 'ignored')) {
|
|
||||||
$sql_extra = " AND `readonly` = 1 ";
|
$sql_extra = " AND `readonly` = 1 ";
|
||||||
$ignored = true;
|
$ignored = true;
|
||||||
}
|
} elseif(($a->argc == 2) && ($a->argv[1] === 'archived')) {
|
||||||
elseif(($a->argc == 2) && ($a->argv[1] === 'archived')) {
|
|
||||||
$sql_extra = " AND `archive` = 1 ";
|
$sql_extra = " AND `archive` = 1 ";
|
||||||
$archived = true;
|
$archived = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
$sql_extra = " AND `blocked` = 0 ";
|
$sql_extra = " AND `blocked` = 0 ";
|
||||||
|
}
|
||||||
|
|
||||||
$search = ((x($_GET,'search')) ? notags(trim($_GET['search'])) : '');
|
$search = x($_GET, 'search') ? notags(trim($_GET['search'])) : '';
|
||||||
$nets = ((x($_GET,'nets')) ? notags(trim($_GET['nets'])) : '');
|
$nets = x($_GET, 'nets') ? notags(trim($_GET['nets'])) : '';
|
||||||
|
|
||||||
$tabs = array(
|
$tabs = array(
|
||||||
array(
|
array(
|
||||||
|
@ -786,25 +787,25 @@ function contacts_content(App $a) {
|
||||||
$tab_tpl = get_markup_template('common_tabs.tpl');
|
$tab_tpl = get_markup_template('common_tabs.tpl');
|
||||||
$t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
|
$t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$searching = false;
|
$searching = false;
|
||||||
if($search) {
|
$search_hdr = null;
|
||||||
|
if ($search) {
|
||||||
$search_hdr = $search;
|
$search_hdr = $search;
|
||||||
$search_txt = dbesc(protect_sprintf(preg_quote($search)));
|
$search_txt = dbesc(protect_sprintf(preg_quote($search)));
|
||||||
$searching = true;
|
$searching = true;
|
||||||
}
|
}
|
||||||
$sql_extra .= (($searching) ? " AND (name REGEXP '$search_txt' OR url REGEXP '$search_txt' OR nick REGEXP '$search_txt') " : "");
|
$sql_extra .= (($searching) ? " AND (name REGEXP '$search_txt' OR url REGEXP '$search_txt' OR nick REGEXP '$search_txt') " : "");
|
||||||
|
|
||||||
if($nets)
|
if ($nets) {
|
||||||
$sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets));
|
$sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets));
|
||||||
|
}
|
||||||
|
|
||||||
$sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : '');
|
$sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : '');
|
||||||
|
|
||||||
|
|
||||||
$r = q("SELECT COUNT(*) AS `total` FROM `contact`
|
$r = q("SELECT COUNT(*) AS `total` FROM `contact`
|
||||||
WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ",
|
WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ",
|
||||||
intval($_SESSION['uid']));
|
intval($_SESSION['uid'])
|
||||||
|
);
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($r)) {
|
||||||
$a->set_pager_total($r[0]['total']);
|
$a->set_pager_total($r[0]['total']);
|
||||||
$total = $r[0]['total'];
|
$total = $r[0]['total'];
|
||||||
|
@ -834,7 +835,7 @@ function contacts_content(App $a) {
|
||||||
'$total' => $total,
|
'$total' => $total,
|
||||||
'$search' => $search_hdr,
|
'$search' => $search_hdr,
|
||||||
'$desc' => t('Search your contacts'),
|
'$desc' => t('Search your contacts'),
|
||||||
'$finding' => (($searching) ? sprintf(t('Results for: %s'),$search) : ""),
|
'$finding' => $searching ? t('Results for: %s', $search) : "",
|
||||||
'$submit' => t('Find'),
|
'$submit' => t('Find'),
|
||||||
'$cmd' => $a->cmd,
|
'$cmd' => $a->cmd,
|
||||||
'$contacts' => $contacts,
|
'$contacts' => $contacts,
|
||||||
|
@ -849,7 +850,6 @@ function contacts_content(App $a) {
|
||||||
),
|
),
|
||||||
'$h_batch_actions' => t('Batch Actions'),
|
'$h_batch_actions' => t('Batch Actions'),
|
||||||
'$paginate' => paginate($a),
|
'$paginate' => paginate($a),
|
||||||
|
|
||||||
));
|
));
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
|
@ -927,12 +927,11 @@ function contact_posts($a, $contact_id) {
|
||||||
$contact = $r[0];
|
$contact = $r[0];
|
||||||
$a->page['aside'] = "";
|
$a->page['aside'] = "";
|
||||||
profile_load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
|
profile_load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
|
||||||
} else
|
}
|
||||||
$profile = "";
|
|
||||||
|
|
||||||
$tab_str = contacts_tab($a, $contact_id, 1);
|
$tab_str = contacts_tab($a, $contact_id, 1);
|
||||||
|
|
||||||
$o .= $tab_str;
|
$o = $tab_str;
|
||||||
|
|
||||||
$o .= Contact::getPostsFromUrl($contact["url"]);
|
$o .= Contact::getPostsFromUrl($contact["url"]);
|
||||||
|
|
||||||
|
|
112
mod/crepair.php
112
mod/crepair.php
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file mod/crepair.php
|
* @file mod/crepair.php
|
||||||
*/
|
*/
|
||||||
|
@ -10,65 +11,68 @@ use Friendica\Model\Contact;
|
||||||
require_once 'include/contact_selectors.php';
|
require_once 'include/contact_selectors.php';
|
||||||
require_once 'mod/contacts.php';
|
require_once 'mod/contacts.php';
|
||||||
|
|
||||||
function crepair_init(App $a) {
|
function crepair_init(App $a)
|
||||||
if (! local_user()) {
|
{
|
||||||
|
if (!local_user()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contact_id = 0;
|
$contact_id = 0;
|
||||||
|
|
||||||
if(($a->argc == 2) && intval($a->argv[1])) {
|
if (($a->argc == 2) && intval($a->argv[1])) {
|
||||||
$contact_id = intval($a->argv[1]);
|
$contact_id = intval($a->argv[1]);
|
||||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
|
||||||
intval(local_user()),
|
intval(local_user()),
|
||||||
intval($contact_id)
|
intval($contact_id)
|
||||||
);
|
);
|
||||||
if (! DBM::is_result($r)) {
|
if (!DBM::is_result($r)) {
|
||||||
$contact_id = 0;
|
$contact_id = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! x($a->page,'aside'))
|
if (!x($a->page, 'aside')) {
|
||||||
$a->page['aside'] = '';
|
$a->page['aside'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
if($contact_id) {
|
if ($contact_id) {
|
||||||
$a->data['contact'] = $r[0];
|
$a->data['contact'] = $r[0];
|
||||||
$contact = $r[0];
|
$contact = $r[0];
|
||||||
profile_load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
|
profile_load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function crepair_post(App $a) {
|
function crepair_post(App $a)
|
||||||
if (! local_user()) {
|
{
|
||||||
|
if (!local_user()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
|
$cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
|
||||||
|
|
||||||
if($cid) {
|
if ($cid) {
|
||||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||||
intval($cid),
|
intval($cid),
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! DBM::is_result($r)) {
|
if (!DBM::is_result($r)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contact = $r[0];
|
$contact = $r[0];
|
||||||
|
|
||||||
$name = ((x($_POST,'name')) ? $_POST['name'] : $contact['name']);
|
$name = defaults($_POST, 'name' , $contact['name']);
|
||||||
$nick = ((x($_POST,'nick')) ? $_POST['nick'] : '');
|
$nick = defaults($_POST, 'nick' , '');
|
||||||
$url = ((x($_POST,'url')) ? $_POST['url'] : '');
|
$url = defaults($_POST, 'url' , '');
|
||||||
$request = ((x($_POST,'request')) ? $_POST['request'] : '');
|
$request = defaults($_POST, 'request' , '');
|
||||||
$confirm = ((x($_POST,'confirm')) ? $_POST['confirm'] : '');
|
$confirm = defaults($_POST, 'confirm' , '');
|
||||||
$notify = ((x($_POST,'notify')) ? $_POST['notify'] : '');
|
$notify = defaults($_POST, 'notify' , '');
|
||||||
$poll = ((x($_POST,'poll')) ? $_POST['poll'] : '');
|
$poll = defaults($_POST, 'poll' , '');
|
||||||
$attag = ((x($_POST,'attag')) ? $_POST['attag'] : '');
|
$attag = defaults($_POST, 'attag' , '');
|
||||||
$photo = ((x($_POST,'photo')) ? $_POST['photo'] : '');
|
$photo = defaults($_POST, 'photo' , '');
|
||||||
$remote_self = ((x($_POST,'remote_self')) ? $_POST['remote_self'] : false);
|
$remote_self = defaults($_POST, 'remote_self', false);
|
||||||
$nurl = normalise_link($url);
|
$nurl = normalise_link($url);
|
||||||
|
|
||||||
$r = q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `url` = '%s', `nurl` = '%s', `request` = '%s', `confirm` = '%s', `notify` = '%s', `poll` = '%s', `attag` = '%s' , `remote_self` = %d
|
$r = q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `url` = '%s', `nurl` = '%s', `request` = '%s', `confirm` = '%s', `notify` = '%s', `poll` = '%s', `attag` = '%s' , `remote_self` = %d
|
||||||
WHERE `id` = %d AND `uid` = %d",
|
WHERE `id` = %d AND `uid` = %d",
|
||||||
|
@ -101,26 +105,24 @@ function crepair_post(App $a) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function crepair_content(App $a)
|
||||||
|
{
|
||||||
function crepair_content(App $a) {
|
if (!local_user()) {
|
||||||
|
notice(t('Permission denied.') . EOL);
|
||||||
if (! local_user()) {
|
|
||||||
notice( t('Permission denied.') . EOL);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
|
$cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
|
||||||
|
|
||||||
if($cid) {
|
if ($cid) {
|
||||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||||
intval($cid),
|
intval($cid),
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! DBM::is_result($r)) {
|
if (!DBM::is_result($r)) {
|
||||||
notice( t('Contact not found.') . EOL);
|
notice(t('Contact not found.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,45 +133,44 @@ function crepair_content(App $a) {
|
||||||
|
|
||||||
$returnaddr = "contacts/$cid";
|
$returnaddr = "contacts/$cid";
|
||||||
|
|
||||||
$allow_remote_self = Config::get('system','allow_users_remote_self');
|
$allow_remote_self = Config::get('system', 'allow_users_remote_self');
|
||||||
|
|
||||||
// Disable remote self for everything except feeds.
|
// Disable remote self for everything except feeds.
|
||||||
// There is an issue when you repeat an item from maybe twitter and you got comments from friendica and twitter
|
// There is an issue when you repeat an item from maybe twitter and you got comments from friendica and twitter
|
||||||
// Problem is, you couldn't reply to both networks.
|
// Problem is, you couldn't reply to both networks.
|
||||||
if (!in_array($contact['network'], array(NETWORK_FEED, NETWORK_DFRN, NETWORK_DIASPORA)))
|
if (!in_array($contact['network'], array(NETWORK_FEED, NETWORK_DFRN, NETWORK_DIASPORA))) {
|
||||||
$allow_remote_self = false;
|
$allow_remote_self = false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($contact['network'] == NETWORK_FEED)
|
if ($contact['network'] == NETWORK_FEED) {
|
||||||
$remote_self_options = array('0'=>t('No mirroring'), '1'=>t('Mirror as forwarded posting'), '2'=>t('Mirror as my own posting'));
|
$remote_self_options = array('0' => t('No mirroring'), '1' => t('Mirror as forwarded posting'), '2' => t('Mirror as my own posting'));
|
||||||
else
|
} else {
|
||||||
$remote_self_options = array('0'=>t('No mirroring'), '2'=>t('Mirror as my own posting'));
|
$remote_self_options = array('0' => t('No mirroring'), '2' => t('Mirror as my own posting'));
|
||||||
|
}
|
||||||
|
|
||||||
$update_profile = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DSPR, NETWORK_OSTATUS));
|
$update_profile = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS));
|
||||||
|
|
||||||
$tab_str = contacts_tab($a, $contact['id'], 5);
|
$tab_str = contacts_tab($a, $contact['id'], 5);
|
||||||
|
|
||||||
|
|
||||||
$tpl = get_markup_template('crepair.tpl');
|
$tpl = get_markup_template('crepair.tpl');
|
||||||
$o .= replace_macros($tpl, array(
|
$o = replace_macros($tpl, array(
|
||||||
//'$title' => t('Repair Contact Settings'),
|
'$tab_str' => $tab_str,
|
||||||
'$tab_str' => $tab_str,
|
'$warning' => $warning,
|
||||||
'$warning' => $warning,
|
'$info' => $info,
|
||||||
'$info' => $info,
|
'$returnaddr' => $returnaddr,
|
||||||
'$returnaddr' => $returnaddr,
|
'$return' => t('Return to contact editor'),
|
||||||
'$return' => t('Return to contact editor'),
|
'$update_profile' => $update_profile,
|
||||||
'$update_profile' => update_profile,
|
'$udprofilenow' => t('Refetch contact data'),
|
||||||
'$udprofilenow' => t('Refetch contact data'),
|
'$contact_id' => $contact['id'],
|
||||||
'$contact_id' => $contact['id'],
|
'$lbl_submit' => t('Submit'),
|
||||||
'$lbl_submit' => t('Submit'),
|
|
||||||
|
|
||||||
'$label_remote_self' => t('Remote Self'),
|
'$label_remote_self' => t('Remote Self'),
|
||||||
'$allow_remote_self' => $allow_remote_self,
|
'$allow_remote_self' => $allow_remote_self,
|
||||||
'$remote_self' => array('remote_self',
|
'$remote_self' => array('remote_self',
|
||||||
t('Mirror postings from this contact'),
|
t('Mirror postings from this contact'),
|
||||||
$contact['remote_self'],
|
$contact['remote_self'],
|
||||||
t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'),
|
t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'),
|
||||||
$remote_self_options
|
$remote_self_options
|
||||||
),
|
),
|
||||||
|
|
||||||
'$name' => array('name', t('Name') , htmlentities($contact['name'])),
|
'$name' => array('name', t('Name') , htmlentities($contact['name'])),
|
||||||
'$nick' => array('nick', t('Account Nickname'), htmlentities($contact['nick'])),
|
'$nick' => array('nick', t('Account Nickname'), htmlentities($contact['nick'])),
|
||||||
|
@ -183,5 +184,4 @@ function crepair_content(App $a) {
|
||||||
));
|
));
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,90 +7,87 @@
|
||||||
* Author: Rabuzarus <https://github.com/rabuzarus>
|
* Author: Rabuzarus <https://github.com/rabuzarus>
|
||||||
* License: GNU AFFERO GENERAL PUBLIC LICENSE (Version 3)
|
* License: GNU AFFERO GENERAL PUBLIC LICENSE (Version 3)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\GContact;
|
use Friendica\Model\GContact;
|
||||||
|
|
||||||
function hovercard_init(App $a) {
|
function hovercard_init(App $a)
|
||||||
|
{
|
||||||
// Just for testing purposes
|
// Just for testing purposes
|
||||||
$_GET["mode"] = "minimal";
|
$_GET['mode'] = 'minimal';
|
||||||
}
|
}
|
||||||
|
|
||||||
function hovercard_content() {
|
function hovercard_content()
|
||||||
$profileurl = (x($_REQUEST,'profileurl') ? $_REQUEST['profileurl'] : "");
|
{
|
||||||
$datatype = (x($_REQUEST,'datatype') ?$_REQUEST['datatype'] : "json");
|
$profileurl = defaults($_REQUEST, 'profileurl', '');
|
||||||
|
$datatype = defaults($_REQUEST, 'datatype' , 'json');
|
||||||
|
|
||||||
// Get out if the system doesn't have public access allowed
|
// Get out if the system doesn't have public access allowed
|
||||||
if(intval(Config::get('system','block_public')))
|
if (intval(Config::get('system', 'block_public'))) {
|
||||||
http_status_exit(401);
|
http_status_exit(401);
|
||||||
|
}
|
||||||
|
|
||||||
// Return the raw content of the template. We use this to make templates usable for js functions.
|
// Return the raw content of the template. We use this to make templates usable for js functions.
|
||||||
// Look at hovercard.js (function getHoverCardTemplate()).
|
// Look at hovercard.js (function getHoverCardTemplate()).
|
||||||
// This part should be moved in it's own module. Maybe we could make more templates accessabel.
|
// This part should be moved in its own module. Maybe we could make more templates accessible.
|
||||||
// (We need to discuss possible security lacks before doing this)
|
// (We need to discuss possible security leaks before doing this)
|
||||||
if ($datatype == "tpl") {
|
if ($datatype == 'tpl') {
|
||||||
$templatecontent = get_template_content("hovercard.tpl");
|
$templatecontent = get_template_content('hovercard.tpl');
|
||||||
echo $templatecontent;
|
echo $templatecontent;
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a contact is connected the url is internally changed to "redir/CID". We need the pure url to search for
|
// If a contact is connected the url is internally changed to 'redir/CID'. We need the pure url to search for
|
||||||
// the contact. So we strip out the contact id from the internal url and look in the contact table for
|
// the contact. So we strip out the contact id from the internal url and look in the contact table for
|
||||||
// the real url (nurl)
|
// the real url (nurl)
|
||||||
if (local_user() && strpos($profileurl, "redir/") === 0) {
|
$cid = 0;
|
||||||
|
if (local_user() && strpos($profileurl, 'redir/') === 0) {
|
||||||
$cid = intval(substr($profileurl, 6));
|
$cid = intval(substr($profileurl, 6));
|
||||||
$r = dba::select('contact', array('nurl', 'self'), array('id' => $cid), array('limit' => 1));
|
$r = dba::select('contact', array('nurl'), array('id' => $cid), array('limit' => 1));
|
||||||
$profileurl = ($r["nurl"] ? $r["nurl"] : "");
|
$profileurl = defaults($r, 'nurl', '');
|
||||||
$self = ($r["self"] ? $r["self"] : "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$contact = [];
|
||||||
// if it's the url containing https it should be converted to http
|
// if it's the url containing https it should be converted to http
|
||||||
$nurl = normalise_link(GContact::cleanContactUrl($profileurl));
|
$nurl = normalise_link(GContact::cleanContactUrl($profileurl));
|
||||||
if($nurl) {
|
if ($nurl) {
|
||||||
// Search for contact data
|
// Search for contact data
|
||||||
$contact = Contact::getDetailsByURL($nurl);
|
$contact = Contact::getDetailsByURL($nurl);
|
||||||
}
|
}
|
||||||
if(!is_array($contact))
|
if (!count($contact)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the photo_menu - the menu if possible contact actions
|
// Get the photo_menu - the menu if possible contact actions
|
||||||
if(local_user())
|
if (local_user()) {
|
||||||
$actions = Contact::photoMenu($contact);
|
$actions = Contact::photoMenu($contact);
|
||||||
|
}
|
||||||
|
|
||||||
// Move the contact data to the profile array so we can deliver it to
|
// Move the contact data to the profile array so we can deliver it to
|
||||||
//
|
|
||||||
$profile = array(
|
$profile = array(
|
||||||
'name' => $contact["name"],
|
'name' => $contact['name'],
|
||||||
'nick' => $contact["nick"],
|
'nick' => $contact['nick'],
|
||||||
'addr' => (($contact["addr"] != "") ? $contact["addr"] : $contact["url"]),
|
'addr' => defaults($contact, 'addr', $contact['url']),
|
||||||
'thumb' => proxy_url($contact["thumb"], false, PROXY_SIZE_THUMB),
|
'thumb' => proxy_url($contact['thumb'], false, PROXY_SIZE_THUMB),
|
||||||
'url' => ($cid ? ("redir/".$cid) : zrl($contact["url"])),
|
'url' => $cid ? ('redir/' . $cid) : zrl($contact['url']),
|
||||||
'nurl' => $contact["nurl"], // We additionally store the nurl as identifier
|
'nurl' => $contact['nurl'], // We additionally store the nurl as identifier
|
||||||
// 'alias' => $contact["alias"],
|
'location' => $contact['location'],
|
||||||
'location' => $contact["location"],
|
'gender' => $contact['gender'],
|
||||||
'gender' => $contact["gender"],
|
'about' => $contact['about'],
|
||||||
'about' => $contact["about"],
|
'network' => format_network_name($contact['network'], $contact['url']),
|
||||||
'network' => format_network_name($contact["network"], $contact["url"]),
|
'tags' => $contact['keywords'],
|
||||||
'tags' => $contact["keywords"],
|
'bd' => $contact['birthday'] <= '0001-01-01' ? '' : $contact['birthday'],
|
||||||
// 'nsfw' => intval($contact["nsfw"]),
|
|
||||||
// 'server_url' => $contact["server_url"],
|
|
||||||
'bd' => (($contact["birthday"] <= '0001-01-01') ? "" : $contact["birthday"]),
|
|
||||||
// 'generation' => $contact["generation"],
|
|
||||||
'account_type' => Contact::getAccountType($contact),
|
'account_type' => Contact::getAccountType($contact),
|
||||||
'actions' => $actions,
|
'actions' => $actions,
|
||||||
);
|
);
|
||||||
if($datatype == "html") {
|
if ($datatype == 'html') {
|
||||||
$t = get_markup_template("hovercard.tpl");
|
$tpl = get_markup_template('hovercard.tpl');
|
||||||
|
$o = replace_macros($tpl, array(
|
||||||
$o = replace_macros($t, array(
|
|
||||||
'$profile' => $profile,
|
'$profile' => $profile,
|
||||||
));
|
));
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
json_return_and_die($profile);
|
json_return_and_die($profile);
|
||||||
}
|
}
|
||||||
|
@ -104,15 +101,15 @@ function hovercard_content() {
|
||||||
*
|
*
|
||||||
* @return string|bool Output the raw content if existent, otherwise false
|
* @return string|bool Output the raw content if existent, otherwise false
|
||||||
*/
|
*/
|
||||||
function get_template_content($template, $root = "") {
|
function get_template_content($template, $root = '')
|
||||||
|
{
|
||||||
// We load the whole template system to get the filename.
|
// We load the whole template system to get the filename.
|
||||||
// Maybe we can do it a little bit smarter if I get time.
|
// Maybe we can do it a little bit smarter if I get time.
|
||||||
$t = get_markup_template($template, $root);
|
$t = get_markup_template($template, $root);
|
||||||
$filename = $t->filename;
|
$filename = $t->filename;
|
||||||
|
|
||||||
// Get the content of the template file
|
// Get the content of the template file
|
||||||
if(file_exists($filename)) {
|
if (file_exists($filename)) {
|
||||||
$content = file_get_contents($filename);
|
$content = file_get_contents($filename);
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
|
|
Loading…
Reference in a new issue