]> git.mxchange.org Git - friendica.git/blobdiff - object/Item.php
Merge pull request #3904 from annando/worker-space2
[friendica.git] / object / Item.php
index f81b8ea4e8a13be43206444663bc8bb92685e6d9..80bbf255dd8eae6a7b43efc95775ea13e359941d 100644 (file)
@@ -2,9 +2,13 @@
 if(class_exists('Item'))
        return;
 
+use Friendica\Core\Config;
+use Friendica\Core\PConfig;
+use Friendica\Database\DBM;
+use Friendica\Protocol\Diaspora;
+
 require_once('object/BaseObject.php');
 require_once('include/text.php');
-require_once('include/diaspora.php');
 require_once('boot.php');
 
 /**
@@ -52,7 +56,7 @@ class Item extends BaseObject {
                $ssl_state = ((local_user()) ? true : false);
                $this->redirect_url = 'redir/' . $this->get_data_value('cid') ;
 
-               if (get_config('system','thread_allow') && $a->theme_thread_allow && !$this->is_toplevel()) {
+               if (Config::get('system','thread_allow') && $a->theme_thread_allow && !$this->is_toplevel()) {
                        $this->threaded = true;
                }
 
@@ -68,6 +72,11 @@ class Item extends BaseObject {
                                        continue;
                                }
 
+                               // You can always comment on Diaspora items
+                               if (($item['network'] == NETWORK_DIASPORA) && (local_user() == $item['uid'])) {
+                                       $item['writable'] = true;
+                               }
+
                                $item['pagedrop'] = $data['pagedrop'];
                                $child = new Item($item);
                                $this->add_child($child);
@@ -91,7 +100,12 @@ class Item extends BaseObject {
 
                $item = $this->get_data();
                $edited = false;
-               if (strcmp($item['created'], $item['edited'])<>0) {
+               // If the time between "created" and "edited" differs we add
+               // a notice that the post was edited.
+               // Note: In some networks reshared items seem to have (sometimes) a difference
+               // between creation time and edit time of a second. Thats why we add the notice
+               // only if the difference is more than 1 second.
+               if (strtotime($item['edited']) - strtotime($item['created']) > 1) {
                        $edited = array(
                                'label'    => t('This entry was edited'),
                                'date'     => datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r'),
@@ -242,7 +256,7 @@ class Item extends BaseObject {
                                        'starred'   =>  t('starred'),
                                );
                                $r = dba::select('thread', array('ignored'), array('uid' => $item['uid'], 'iid' => $item['id']), array('limit' => 1));
-                               if (dbm::is_result($r)) {
+                               if (DBM::is_result($r)) {
                                        $ignore = array(
                                                'do'        => t("ignore thread"),
                                                'undo'      => t("unignore thread"),
@@ -319,18 +333,6 @@ class Item extends BaseObject {
                        unset($buttons["like"]);
                }
 
-               // Diaspora isn't able to do likes on comments - but Hubzilla does
-               /// @todo When Diaspora will pass this information we will remove these lines
-               if (($item["item_network"] == NETWORK_DIASPORA) && ($indent == 'comment') &&
-                       !Diaspora::is_redmatrix($item["owner-link"]) && isset($buttons["like"])) {
-                       unset($buttons["like"]);
-               }
-
-               // Facebook can like comments - but it isn't programmed in the connector yet.
-               if (($item["item_network"] == NETWORK_FACEBOOK) && ($indent == 'comment') && isset($buttons["like"])) {
-                       unset($buttons["like"]);
-               }
-
                $tmp_item = array(
                        'template'        => $this->get_template(),
                        'type'            => implode("",array_slice(explode("/",$item['verb']),-1)),
@@ -665,7 +667,7 @@ class Item extends BaseObject {
         */
        private function get_comment_box($indent) {
                $a = $this->get_app();
-               if (!$this->is_toplevel() && !(get_config('system','thread_allow') && $a->theme_thread_allow)) {
+               if (!$this->is_toplevel() && !(Config::get('system','thread_allow') && $a->theme_thread_allow)) {
                        return '';
                }
 
@@ -684,7 +686,7 @@ class Item extends BaseObject {
                         * This should be better if done by a hook
                         */
                        if (in_array('qcomment',$a->plugins)) {
-                               $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null);
+                               $qc = ((local_user()) ? PConfig::get(local_user(),'qcomment','words') : null);
                                $qcomment = (($qc) ? explode("\n",$qc) : null);
                        }
                        $comment_box = replace_macros($template,array(