$fields = ['failed' => false, 'last_contact' => DateTimeFormat::utcNow(), 'updated' => $last_updated];
DBA::update('contact', $fields, ['nurl' => Strings::normaliseLink($data['url'])]);
}
+
+ /**
+ * Returns a random, global contact of the current node
+ *
+ * @return string The profile URL
+ * @throws Exception
+ */
+ public static function getRandomUrl()
+ {
+ $r = DBA::selectFirst('contact', ['url'], [
+ "`uid` = ? AND `network` = ? AND NOT `failed` AND `last-item` > ?",
+ 0, Protocol::DFRN, DateTimeFormat::utc('now - 1 month'),
+ ], ['order' => ['RAND()']]);
+
+ if (DBA::isResult($r)) {
+ return $r['url'];
+ }
+
+ return '';
+ }
}
/// @TODO Check all calling-findings of this function if they properly use DBA::isResult()
return $r;
}
-
- /**
- * Returns a random, global contact of the current node
- *
- * @return string The profile URL
- * @throws Exception
- */
- public static function getRandomUrl()
- {
- $r = DBA::selectFirst('gcontact', ['url'], [
- '`network` = ?
- AND NOT `failed`
- AND `updated` > ?',
- Protocol::DFRN,
- DateTimeFormat::utc('now - 1 month'),
- ], ['order' => ['RAND()']]);
-
- if (DBA::isResult($r)) {
- return $r['url'];
- }
-
- return '';
- }
}
use Friendica\BaseModule;
use Friendica\DI;
use Friendica\Model\Contact;
-use Friendica\Model\GContact;
/**
* Redirects to a random Friendica profile this node knows about
{
$a = DI::app();
- $contactUrl = GContact::getRandomUrl();
+ $contactUrl = Contact::getRandomUrl();
if ($contactUrl) {
$link = Contact::magicLink($contactUrl);
{{* Additional links *}}
<div class="side-link" id="side-match-link"><a href="match" >{{$nv.similar}}</a></div>
<div class="side-link" id="side-suggest-link"><a href="suggest" >{{$nv.suggest}}</a></div>
+ <div class="side-link" id="side-random-profile-link" ><a href="randprof" target="extlink" >{{$nv.random}}</a></div>
{{if $nv.inv}}
<div class="side-link" id="side-invite-link" ><button type="button" class="btn-link" onclick="addToModal('invite'); return false;">{{$nv.inv}}</button></div>