2011-03-22 03:33:06 +01:00
|
|
|
<?php
|
2015-05-10 09:10:27 +02:00
|
|
|
include_once('include/text.php');
|
2015-09-15 22:29:02 +02:00
|
|
|
require_once('include/socgraph.php');
|
|
|
|
require_once('include/contact_widgets.php');
|
2015-10-07 08:25:10 +02:00
|
|
|
require_once('mod/proxy.php');
|
2011-03-22 03:33:06 +01:00
|
|
|
|
2015-10-17 00:39:50 +02:00
|
|
|
/**
|
|
|
|
* @brief Controller for /match.
|
|
|
|
*
|
|
|
|
* It takes keywords from your profile and queries the directory server for
|
|
|
|
* matching keywords from other profiles.
|
|
|
|
*
|
2017-01-09 13:14:25 +01:00
|
|
|
* @param App $a
|
2015-10-17 00:39:50 +02:00
|
|
|
* @return void|string
|
|
|
|
*/
|
2017-01-09 13:14:25 +01:00
|
|
|
function match_content(App $a) {
|
2011-03-22 03:33:06 +01:00
|
|
|
|
2011-03-22 05:26:11 +01:00
|
|
|
$o = '';
|
2016-12-20 11:56:34 +01:00
|
|
|
if (! local_user()) {
|
2011-03-22 03:33:06 +01:00
|
|
|
return;
|
2016-12-20 11:56:34 +01:00
|
|
|
}
|
2011-03-22 03:33:06 +01:00
|
|
|
|
2015-09-15 22:29:02 +02:00
|
|
|
$a->page['aside'] .= findpeople_widget();
|
2015-10-23 00:12:00 +02:00
|
|
|
$a->page['aside'] .= follow_widget();
|
2015-09-15 22:29:02 +02:00
|
|
|
|
2016-12-20 12:45:16 +01:00
|
|
|
$_SESSION['return_url'] = App::get_baseurl() . '/' . $a->cmd;
|
2011-12-18 10:44:46 +01:00
|
|
|
|
2011-03-22 03:33:06 +01:00
|
|
|
$r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
|
|
|
|
intval(local_user())
|
|
|
|
);
|
2016-12-20 10:10:33 +01:00
|
|
|
if (! dbm::is_result($r)) {
|
2015-09-15 22:29:02 +02:00
|
|
|
return;
|
2016-12-20 10:10:33 +01:00
|
|
|
}
|
2017-01-26 15:23:30 +01:00
|
|
|
if (! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
|
2011-07-02 10:21:56 +02:00
|
|
|
notice( t('No keywords to match. Please add keywords to your default profile.') . EOL);
|
2011-03-22 03:33:06 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$params = array();
|
|
|
|
$tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
|
2015-08-23 11:05:10 +02:00
|
|
|
|
2017-01-26 15:23:30 +01:00
|
|
|
if ($tags) {
|
2011-03-22 03:33:06 +01:00
|
|
|
$params['s'] = $tags;
|
2017-01-26 15:23:30 +01:00
|
|
|
if ($a->pager['page'] != 1)
|
2011-03-22 05:26:11 +01:00
|
|
|
$params['p'] = $a->pager['page'];
|
2015-08-23 11:05:10 +02:00
|
|
|
|
2017-01-26 15:23:30 +01:00
|
|
|
if (strlen(get_config('system','directory')))
|
2015-08-23 11:05:10 +02:00
|
|
|
$x = post_url(get_server().'/msearch', $params);
|
2011-07-02 10:21:56 +02:00
|
|
|
else
|
2016-12-20 12:45:16 +01:00
|
|
|
$x = post_url(App::get_baseurl() . '/msearch', $params);
|
2011-03-22 03:44:00 +01:00
|
|
|
|
2011-03-22 03:33:06 +01:00
|
|
|
$j = json_decode($x);
|
|
|
|
|
2017-01-26 15:23:30 +01:00
|
|
|
if ($j->total) {
|
2011-03-22 05:26:11 +01:00
|
|
|
$a->set_pager_total($j->total);
|
|
|
|
$a->set_pager_itemspage($j->items_page);
|
|
|
|
}
|
2011-03-22 03:44:00 +01:00
|
|
|
|
2017-01-26 15:23:30 +01:00
|
|
|
if (count($j->results)) {
|
2011-12-18 10:44:46 +01:00
|
|
|
|
2015-10-18 17:12:48 +02:00
|
|
|
$id = 0;
|
|
|
|
|
2017-01-26 15:23:30 +01:00
|
|
|
foreach ($j->results as $jj) {
|
2015-09-15 22:29:02 +02:00
|
|
|
$match_nurl = normalise_link($jj->url);
|
|
|
|
$match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1",
|
|
|
|
intval(local_user()),
|
|
|
|
dbesc($match_nurl));
|
2015-10-18 17:12:48 +02:00
|
|
|
|
2015-09-15 22:29:02 +02:00
|
|
|
if (!count($match)) {
|
|
|
|
$jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo);
|
2016-12-20 12:45:16 +01:00
|
|
|
$connlnk = App::get_baseurl() . '/follow/?url=' . $jj->url;
|
2016-06-06 16:54:29 +02:00
|
|
|
$photo_menu = array(
|
|
|
|
'profile' => array(t("View Profile"), zrl($jj->url)),
|
|
|
|
'follow' => array(t("Connect/Follow"), $connlnk)
|
|
|
|
);
|
2015-10-18 17:12:48 +02:00
|
|
|
|
2015-11-06 00:47:54 +01:00
|
|
|
$contact_details = get_contact_details_by_url($jj->url, local_user());
|
|
|
|
|
2015-10-17 00:39:50 +02:00
|
|
|
$entry = array(
|
|
|
|
'url' => zrl($jj->url),
|
2015-11-06 00:47:54 +01:00
|
|
|
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $jj->url),
|
2015-10-17 00:39:50 +02:00
|
|
|
'name' => $jj->name,
|
2015-11-06 00:47:54 +01:00
|
|
|
'details' => $contact_details['location'],
|
|
|
|
'tags' => $contact_details['keywords'],
|
|
|
|
'about' => $contact_details['about'],
|
2016-10-01 22:03:27 +02:00
|
|
|
'account_type' => account_type($contact_details),
|
2015-10-18 17:12:48 +02:00
|
|
|
'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB),
|
2015-10-17 00:39:50 +02:00
|
|
|
'inttxt' => ' ' . t('is interested in:'),
|
|
|
|
'conntxt' => t('Connect'),
|
|
|
|
'connlnk' => $connlnk,
|
2015-10-18 17:12:48 +02:00
|
|
|
'img_hover' => $jj->tags,
|
|
|
|
'photo_menu' => $photo_menu,
|
|
|
|
'id' => ++$id,
|
2015-10-17 00:39:50 +02:00
|
|
|
);
|
2015-10-26 16:15:08 +01:00
|
|
|
$entries[] = $entry;
|
2015-09-15 22:29:02 +02:00
|
|
|
}
|
2011-03-22 03:33:06 +01:00
|
|
|
}
|
2015-10-17 00:39:50 +02:00
|
|
|
|
2015-10-18 17:12:48 +02:00
|
|
|
$tpl = get_markup_template('viewcontact_template.tpl');
|
2015-10-17 00:39:50 +02:00
|
|
|
|
|
|
|
$o .= replace_macros($tpl,array(
|
|
|
|
'$title' => t('Profile Match'),
|
2015-10-18 17:12:48 +02:00
|
|
|
'$contacts' => $entries,
|
2015-10-17 22:09:19 +02:00
|
|
|
'$paginate' => paginate($a),
|
2015-10-17 00:39:50 +02:00
|
|
|
));
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
2011-05-23 11:39:57 +02:00
|
|
|
info( t('No matches') . EOL);
|
2015-09-15 22:29:02 +02:00
|
|
|
}
|
2011-03-22 03:33:06 +01:00
|
|
|
|
|
|
|
}
|
2011-03-22 05:26:11 +01:00
|
|
|
|
2011-03-22 03:33:06 +01:00
|
|
|
return $o;
|
2011-05-23 11:39:57 +02:00
|
|
|
}
|