<?php
-require_once('include/Contact.php');
-require_once('include/socgraph.php');
-require_once('include/contact_selectors.php');
-require_once('include/Scrape.php');
-require_once('mod/proxy.php');
-require_once('include/Photo.php');
+use Friendica\App;
+use Friendica\Network\Probe;
+
+require_once 'include/Contact.php';
+require_once 'include/socgraph.php';
+require_once 'include/contact_selectors.php';
+require_once 'include/probe.php';
+require_once 'mod/proxy.php';
+require_once 'include/Photo.php';
function contacts_init(App $a) {
if (! local_user()) {
$contact_id = 0;
- if ((($a->argc == 2) && intval($a->argv[1])) OR (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) {
+ if((($a->argc == 2) && intval($a->argv[1])) OR (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) {
$contact_id = intval($a->argv[1]);
$r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
intval(local_user()),
}
}
- require_once('include/group.php');
- require_once('include/contact_widgets.php');
+ require_once 'include/group.php';
+ require_once 'include/contact_widgets.php';
if ($_GET['nets'] == "all") {
$_GET['nets'] = "";
);
$count_actions=0;
- foreach ($orig_records as $orig_record) {
+ foreach($orig_records as $orig_record) {
$contact_id = $orig_record['id'];
if (x($_POST, 'contacts_batch_update')) {
_contact_update($contact_id);
if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']);
- } else {
+ }
+ else {
goaway('contacts');
}
$ffi_keyword_blacklist = escape_tags(trim($_POST['ffi_keyword_blacklist']));
$priority = intval($_POST['poll']);
-
- if ($priority > 5 || $priority < 0) {
+ if($priority > 5 || $priority < 0)
$priority = 0;
- }
$info = escape_tags(trim($_POST['info']));
intval($contact_id),
intval(local_user())
);
- if ($r) {
+ if($r)
info( t('Contact updated.') . EOL);
- } else {
+ else
notice( t('Failed to update contact record.') . EOL);
- }
- $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($contact_id),
intval(local_user())
);
-
- if (dbm::is_result($r)) {
+ if($r && dbm::is_result($r))
$a->data['contact'] = $r[0];
- }
return;
if ($uid != local_user())
return;
- $data = probe_url($r[0]["url"]);
+ $data = Probe::uri($r[0]["url"], "", 0, false);
// "Feed" or "Unknown" is mostly a sign of communication problems
if ((in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) AND ($data["network"] != $r[0]["network"]))
$update["subhub"] = true;
}
- foreach ($updatefields AS $field)
+ foreach($updatefields AS $field)
if (isset($data[$field]) AND ($data[$field] != ""))
$update[$field] = $data[$field];
if (isset($data["priority"]) AND ($data["priority"] != 0))
$query = "`priority` = ".intval($data["priority"]);
- foreach ($update AS $key => $value) {
+ foreach($update AS $key => $value) {
if ($query != "")
$query .= ", ";
return;
}
- if ($a->argc == 3) {
+ if($a->argc == 3) {
$contact_id = intval($a->argv[1]);
- if (! $contact_id)
+ if(! $contact_id)
return;
$cmd = $a->argv[2];
intval(local_user())
);
- if (! count($orig_record)) {
+ if(! count($orig_record)) {
notice( t('Could not access contact record.') . EOL);
goaway('contacts');
return; // NOTREACHED
}
- if ($cmd === 'update') {
+ if($cmd === 'update') {
_contact_update($contact_id);
goaway('contacts/' . $contact_id);
// NOTREACHED
}
- if ($cmd === 'updateprofile') {
+ if($cmd === 'updateprofile') {
_contact_update_profile($contact_id);
goaway('crepair/' . $contact_id);
// NOTREACHED
}
- if ($cmd === 'block') {
+ if($cmd === 'block') {
$r = _contact_block($contact_id, $orig_record[0]);
if ($r) {
$blocked = (($orig_record[0]['blocked']) ? 0 : 1);
return; // NOTREACHED
}
- if ($cmd === 'ignore') {
+ if($cmd === 'ignore') {
$r = _contact_ignore($contact_id, $orig_record[0]);
if ($r) {
$readonly = (($orig_record[0]['readonly']) ? 0 : 1);
}
- if ($cmd === 'archive') {
+ if($cmd === 'archive') {
$r = _contact_archive($contact_id, $orig_record[0]);
if ($r) {
$archived = (($orig_record[0]['archive']) ? 0 : 1);
return; // NOTREACHED
}
- if ($cmd === 'drop') {
+ if($cmd === 'drop') {
// Check if we should do HTML-based delete confirmation
- if ($_REQUEST['confirm']) {
+ if($_REQUEST['confirm']) {
// <form> can't take arguments in its "action" parameter
// so add any arguments as hidden inputs
$query = explode_querystring($a->query_string);
$inputs = array();
- foreach ($query['args'] as $arg) {
- if (strpos($arg, 'confirm=') === false) {
+ foreach($query['args'] as $arg) {
+ if(strpos($arg, 'confirm=') === false) {
$arg_parts = explode('=', $arg);
$inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
}
$_SESSION['return_url'] = $a->query_string;
- if ((x($a->data,'contact')) && (is_array($a->data['contact']))) {
+ if((x($a->data,'contact')) && (is_array($a->data['contact']))) {
$contact_id = $a->data['contact']['id'];
$contact = $a->data['contact'];
'$baseurl' => App::get_baseurl(true),
));
- require_once('include/contact_selectors.php');
+ require_once 'include/contact_selectors.php';
$tpl = get_markup_template("contact_edit.tpl");
break;
}
- if (!in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA)))
+ if(!in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA)))
$relation_text = "";
$relation_text = sprintf($relation_text,htmlentities($contact['name']));
- if (($contact['network'] === NETWORK_DFRN) && ($contact['rel'])) {
+ if(($contact['network'] === NETWORK_DFRN) && ($contact['rel'])) {
$url = "redir/{$contact['id']}";
$sparkle = ' class="sparkle" ';
}
$insecure = t('Private communications are not available for this contact.');
- $last_update = (($contact['last-update'] == '0000-00-00 00:00:00')
+ $last_update = (($contact['last-update'] <= NULL_DATE)
? t('Never')
: datetime_convert('UTC',date_default_timezone_get(),$contact['last-update'],'D, j M Y, g:i A'));
- if ($contact['last-update'] !== '0000-00-00 00:00:00')
+ if ($contact['last-update'] > NULL_DATE) {
$last_update .= ' ' . (($contact['last-update'] <= $contact['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29"));
-
+ }
$lblsuggest = (($contact['network'] === NETWORK_DFRN) ? t('Suggest friends') : '');
$poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2));
// tabs
$tab_str = contacts_tab($a, $contact_id, 2);
- $lost_contact = (($contact['archive'] && $contact['term-date'] != '0000-00-00 00:00:00' && $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!') : '');
- if ($contact['network'] == NETWORK_FEED)
+ if ($contact['network'] == NETWORK_FEED) {
$fetch_further_information = array('fetch_further_information', t('Fetch further information for feeds'), $contact['fetch_further_information'], t('Fetch further information for feeds'),
array('0'=>t('Disabled'), '1'=>t('Fetch information'), '2'=>t('Fetch information and keywords')));
-
+ }
if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2)))
$poll_interval = contact_poll_interval($contact['priority'],(! $poll_enabled));
$ignored = false;
$all = false;
- if (($a->argc == 2) && ($a->argv[1] === 'all')) {
+ if(($a->argc == 2) && ($a->argv[1] === 'all')) {
$sql_extra = '';
$all = true;
}
- elseif (($a->argc == 2) && ($a->argv[1] === 'blocked')) {
+ elseif(($a->argc == 2) && ($a->argv[1] === 'blocked')) {
$sql_extra = " AND `blocked` = 1 ";
$blocked = true;
}
- elseif (($a->argc == 2) && ($a->argv[1] === 'hidden')) {
+ elseif(($a->argc == 2) && ($a->argv[1] === 'hidden')) {
$sql_extra = " AND `hidden` = 1 ";
$hidden = true;
}
- elseif (($a->argc == 2) && ($a->argv[1] === 'ignored')) {
+ elseif(($a->argc == 2) && ($a->argv[1] === 'ignored')) {
$sql_extra = " AND `readonly` = 1 ";
$ignored = true;
}
- elseif (($a->argc == 2) && ($a->argv[1] === 'archived')) {
+ elseif(($a->argc == 2) && ($a->argv[1] === 'archived')) {
$sql_extra = " AND `archive` = 1 ";
$archived = true;
}
$searching = false;
- if ($search) {
+ if($search) {
$search_hdr = $search;
$search_txt = dbesc(protect_sprintf(preg_quote($search)));
$searching = true;
}
$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_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : '');
*
* Available Pages are 'Status', 'Profile', 'Contacts' and 'Common Friends'
*
- * @param app $a
+ * @param App $a
* @param int $contact_id The ID of the contact
* @param int $active_tab 1 if tab should be marked as active
*
default:
break;
}
- if (($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
+ if(($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
$url = "redir/{$rr['id']}";
$sparkle = ' class="sparkle" ';
}
$contact_action = array();
// Provide friend suggestion only for Friendica contacts
- if ($contact['network'] === NETWORK_DFRN) {
+ if($contact['network'] === NETWORK_DFRN) {
$contact_actions['suggest'] = array(
'label' => t('Suggest friends'),
'url' => 'fsuggest/' . $contact['id'],
);
}
- if ($poll_enabled) {
+ if($poll_enabled) {
$contact_actions['update'] = array(
'label' => t('Update now'),
'url' => 'contacts/' . $contact['id'] . '/update',