*/
use Friendica\App;
use Friendica\ParseUrl;
+ use Friendica\Content\Feature;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\Worker;
if ($update) {
dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']),
array('id' => $arr['contact-id']));
+ $contact = dba::select('contact', [], ['id' => $arr['contact-id']], ['limit' => 1]);
+ if ($contact['term-date'] > NULL_DATE) {
+ Contact::unmarkForArchival($contact);
+ }
}
// Now do the same for the system wide contacts with uid=0
if (!$arr['private']) {
function posted_date_widget($url, $uid, $wall) {
$o = '';
- if (! feature_enabled($uid, 'archives')) {
+ if (! Feature::isEnabled($uid, 'archives')) {
return $o;
}
*/
class Contact extends BaseObject
{
+ /**
+ * Creates the self-contact for the provided user id
+ *
+ * @param int $uid
+ * @return bool Operation success
+ */
+ public static function createSelfFromUserId($uid)
+ {
+ // Only create the entry if it doesn't exist yet
+ if (dba::exists('contact', ['uid' => intval($uid), 'self'])) {
+ return true;
+ }
+
+ $user = dba::select('user', ['uid', 'username', 'nickname'], ['uid' => intval($uid)], ['limit' => 1]);
+ if (!DBM::is_result($user)) {
+ return false;
+ }
+
+ $return = dba::insert('contact', [
+ 'uid' => $user['uid'],
+ 'created' => datetime_convert(),
+ 'self' => 1,
+ 'name' => $user['username'],
+ 'nick' => $user['nickname'],
+ 'photo' => System::baseUrl() . '/photo/profile/' . $user['uid'] . '.jpg',
+ 'thumb' => System::baseUrl() . '/photo/avatar/' . $user['uid'] . '.jpg',
+ 'micro' => System::baseUrl() . '/photo/micro/' . $user['uid'] . '.jpg',
+ 'blocked' => 0,
+ 'pending' => 0,
+ 'url' => System::baseUrl() . '/profile/' . $user['nickname'],
+ 'nurl' => normalise_link(System::baseUrl() . '/profile/' . $user['nickname']),
+ 'addr' => $user['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3),
+ 'request' => System::baseUrl() . '/dfrn_request/' . $user['nickname'],
+ 'notify' => System::baseUrl() . '/dfrn_notify/' . $user['nickname'],
+ 'poll' => System::baseUrl() . '/dfrn_poll/' . $user['nickname'],
+ 'confirm' => System::baseUrl() . '/dfrn_confirm/' . $user['nickname'],
+ 'poco' => System::baseUrl() . '/poco/' . $user['nickname'],
+ 'name-date' => datetime_convert(),
+ 'uri-date' => datetime_convert(),
+ 'avatar-date' => datetime_convert(),
+ 'closeness' => 0
+ ]);
+
+ return $return;
+ }
+
/**
* @brief Marks a contact for removal
*
if ($contact['archive']) {
return;
}
-
+logger('Blubb-m: '.$contact['id'].' - '.System::callstack());
if ($contact['term-date'] <= NULL_DATE) {
dba::update('contact', array('term-date' => datetime_convert()), array('id' => $contact['id']));
*/
public static function unmarkForArchival(array $contact)
{
+//logger('Blubb-m: '.$contact['id'].' - '.System::callstack());
$condition = array('`id` = ? AND (`term-date` > ? OR `archive`)', $contact[`id`], NULL_DATE);
$exists = dba::exists('contact', $condition);