]> git.mxchange.org Git - friendica.git/commitdiff
Merge remote-tracking branch 'upstream/develop' into archive-contact
authorMichael <heluecht@pirati.ca>
Mon, 4 Dec 2017 19:05:53 +0000 (19:05 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 4 Dec 2017 19:05:53 +0000 (19:05 +0000)
1  2 
include/items.php
src/Object/Contact.php

diff --combined include/items.php
index 73a5ad9cc2d15b40419ffba6992a4e54b25b0d19,cbc7af56553f4ce20a8bd9715acefe1ebe9169bd..f0470feb7e0570f30249b064bd2c0eae9e118665
@@@ -4,6 -4,7 +4,7 @@@
   */
  use Friendica\App;
  use Friendica\ParseUrl;
+ use Friendica\Content\Feature;
  use Friendica\Core\Config;
  use Friendica\Core\PConfig;
  use Friendica\Core\Worker;
@@@ -1165,10 -1166,6 +1166,10 @@@ function item_set_last_item($arr) 
        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']) {
@@@ -2359,7 -2356,7 +2360,7 @@@ function posted_dates($uid, $wall) 
  function posted_date_widget($url, $uid, $wall) {
        $o = '';
  
-       if (! feature_enabled($uid, 'archives')) {
+       if (! Feature::isEnabled($uid, 'archives')) {
                return $o;
        }
  
diff --combined src/Object/Contact.php
index 56204395ca4739b8d071e44a26b8665ec96d3347,fc1b26aba6344688addcea5471b84e5afaefc15e..af84899586ec669bebbbf7854709103374baf4f9
@@@ -28,6 -28,52 +28,52 @@@ require_once 'include/text.php'
   */
  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);