]> git.mxchange.org Git - friendica.git/blobdiff - include/items.php
Replace remaining $a->page by DI::page()
[friendica.git] / include / items.php
index 25c857f1156a615a0efbbf914b0f815a37fb7fef..8dd6793d2cf097af817175314672b5b1589f27de 100644 (file)
@@ -3,26 +3,23 @@
  * @file include/items.php
  */
 
-use Friendica\BaseObject;
-use Friendica\Content\Feature;
 use Friendica\Core\Config;
 use Friendica\Core\Hook;
 use Friendica\Core\L10n;
 use Friendica\Core\Logger;
-use Friendica\Core\PConfig;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
 use Friendica\Core\System;
+use Friendica\Core\Session;
 use Friendica\Database\DBA;
+use Friendica\DI;
 use Friendica\Model\Item;
 use Friendica\Protocol\DFRN;
 use Friendica\Protocol\Feed;
 use Friendica\Protocol\OStatus;
-use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 use Friendica\Util\ParseUrl;
 use Friendica\Util\Strings;
-use Friendica\Util\Temporal;
 
 require_once __DIR__ . '/../mod/share.php';
 
@@ -41,7 +38,7 @@ function add_page_info_data(array $data, $no_photos = false)
                $data["type"] = "link";
        }
 
-       $data["title"] = defaults($data, "title", "");
+       $data["title"] = $data["title"] ?? '';
 
        if ((($data["type"] != "link") && ($data["type"] != "video") && ($data["type"] != "photo")) || ($data["title"] == $data["url"])) {
                return "";
@@ -326,7 +323,7 @@ function drop_items(array $items)
 {
        $uid = 0;
 
-       if (!local_user() && !remote_user()) {
+       if (!Session::isAuthenticated()) {
                return;
        }
 
@@ -343,7 +340,7 @@ function drop_items(array $items)
 
 function drop_item($id, $return = '')
 {
-       $a = BaseObject::getApp();
+       $a = DI::app();
 
        // locate item to be deleted
 
@@ -352,7 +349,7 @@ function drop_item($id, $return = '')
 
        if (!DBA::isResult($item)) {
                notice(L10n::t('Item not found.') . EOL);
-               $a->internalRedirect('network');
+               DI::baseUrl()->redirect('network');
        }
 
        if ($item['deleted']) {
@@ -362,14 +359,8 @@ function drop_item($id, $return = '')
        $contact_id = 0;
 
        // check if logged in user is either the author or owner of this item
-
-       if (!empty($_SESSION['remote'])) {
-               foreach ($_SESSION['remote'] as $visitor) {
-                       if ($visitor['uid'] == $item['uid'] && $visitor['cid'] == $item['contact-id']) {
-                               $contact_id = $visitor['cid'];
-                               break;
-                       }
-               }
+       if (Session::getRemoteContactID($item['uid']) == $item['contact-id']) {
+               $contact_id = $item['contact-id'];
        }
 
        if ((local_user() == $item['uid']) || $contact_id) {
@@ -377,7 +368,7 @@ function drop_item($id, $return = '')
                if (!empty($_REQUEST['confirm'])) {
                        // <form> can't take arguments in its "action" parameter
                        // so add any arguments as hidden inputs
-                       $query = explode_querystring($a->query_string);
+                       $query = explode_querystring(DI::args()->getQueryString());
                        $inputs = [];
 
                        foreach ($query['args'] as $arg) {
@@ -399,7 +390,7 @@ function drop_item($id, $return = '')
                }
                // Now check how the user responded to the confirmation query
                if (!empty($_REQUEST['canceled'])) {
-                       $a->internalRedirect('display/' . $item['guid']);
+                       DI::baseUrl()->redirect('display/' . $item['guid']);
                }
 
                $is_comment = ($item['gravity'] == GRAVITY_COMMENT) ? true : false;
@@ -421,28 +412,28 @@ function drop_item($id, $return = '')
                if ($is_comment) {
                        // Return to parent guid
                        if (!empty($parentitem)) {
-                               $a->internalRedirect('display/' . $parentitem['guid']);
+                               DI::baseUrl()->redirect('display/' . $parentitem['guid']);
                                //NOTREACHED
                        }
                        // In case something goes wrong
                        else {
-                               $a->internalRedirect('network');
+                               DI::baseUrl()->redirect('network');
                                //NOTREACHED
                        }
                }
                else {
                        // if unknown location or deleting top level post called from display
                        if (empty($return_url) || strpos($return_url, 'display') !== false) {
-                               $a->internalRedirect('network');
+                               DI::baseUrl()->redirect('network');
                                //NOTREACHED
                        } else {
-                               $a->internalRedirect($return_url);
+                               DI::baseUrl()->redirect($return_url);
                                //NOTREACHED
                        }
                }
        } else {
                notice(L10n::t('Permission denied.') . EOL);
-               $a->internalRedirect('display/' . $item['guid']);
+               DI::baseUrl()->redirect('display/' . $item['guid']);
                //NOTREACHED
        }
 }