]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
[CORE][UI] Made attachment actions and its subactions be able to identify attachments...
authorMiguel Dantas <biodantasgs@gmail.com>
Wed, 26 Jun 2019 02:27:51 +0000 (03:27 +0100)
committerDiogo Cordeiro <diogo@fc.up.pt>
Sat, 3 Aug 2019 16:31:41 +0000 (17:31 +0100)
README.md
actions/attachment.php
classes/File.php
lib/framework.php
lib/mediafile.php
lib/router.php

index f0bd960008c164b0f9acf4bd723e924e9ee5f8f1..290c9eed34eca301390346ec9b5d480932c165d1 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# GNU social 1.24.x
+# GNU social 1.25.x
 (c) 2010-2019 Free Software Foundation, Inc
 
 This is the README file for GNU social, the free
index 0e5c69d1a2606edb22e8d28d72ec526a803d662f..5fe801ad31b862edb75b1f6cdf68fe5b3a1f4c06 100644 (file)
@@ -59,8 +59,10 @@ class AttachmentAction extends ManagedAction
     {
         parent::prepare($args);
 
-        if ($id = $this->trimmed('attachment')) {
+        if (!empty($id = $this->trimmed('attachment'))) {
             $this->attachment = File::getKV($id);
+        } elseif (!empty($filehash = $this->trimmed('filehash'))) {
+            $this->attachment = File::getByHash($filehash);
         }
 
         if (!$this->attachment instanceof File) {
index 8df0c25e4ec1960f8f16c28e632d4aef2477c5cf..8ccae352e80a9a44b793bbb12a3f9b83a23ea769 100644 (file)
@@ -614,7 +614,7 @@ class File extends Managed_DataObject
         if ($use_local !== false) {
             if (is_string($this->filename) || !empty($this->filename)) {
                 // A locally stored file, so let's generate a URL for our instance.
-                return getAttachmentViewUrl();
+                return $this->getAttachmentViewUrl();
             }
             if ($use_local) {
                 // if the file wasn't stored locally (has filename) and we require a local URL
index 24ec1f7cd1131716de39fe418882b4835328e54c..c42ccbda048ed5e5e9c37e2fb973a5486239b509 100644 (file)
@@ -32,7 +32,7 @@ defined('GNUSOCIAL') || die();
 define('GNUSOCIAL_ENGINE', 'GNU social');
 define('GNUSOCIAL_ENGINE_URL', 'https://www.gnu.org/software/social/');
 
-define('GNUSOCIAL_BASE_VERSION', '1.24.1');
+define('GNUSOCIAL_BASE_VERSION', '1.25.0');
 define('GNUSOCIAL_LIFECYCLE', 'dev'); // 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release'
 
 define('GNUSOCIAL_VERSION', GNUSOCIAL_BASE_VERSION . '-' . GNUSOCIAL_LIFECYCLE);
index 76e5541ea0e970b2ca59b38c631b5e334633e81b..bbd7e31b2e08cfbe4f836692ebb9c23b3761e4d0 100644 (file)
@@ -161,7 +161,7 @@ class MediaFile
             // Well, let's just continue below.
         }
 
-        $fileurl = File::url($this->filename);
+        $fileurl = common_local_url('attachment_view', array('filehash' => $this->filehash));
 
         $file = new File;
 
index 2bffd84a3b1a3501eb9363dcebec784b5bc260a3..8b6e7b01f52f82167ee3001b1339d5881f74637d 100644 (file)
@@ -219,21 +219,17 @@ class Router
                         array('q' => '.+'));
             $m->connect('search/notice/rss', array('action' => 'noticesearchrss'));
 
-            $m->connect('attachment/:attachment',
-                        array('action' => 'attachment'),
-                        array('attachment' => '[0-9]+'));
-
-            $m->connect('attachment/:attachment/view',
-                        array('action' => 'attachment_view'),
-                        array('attachment' => '[0-9]+'));
-
-            $m->connect('attachment/:attachment/download',
-                        array('action' => 'attachment_download'),
-                        array('attachment' => '[0-9]+'));
-
-            $m->connect('attachment/:attachment/thumbnail',
-                        array('action' => 'attachment_thumbnail'),
-                        array('attachment' => '[0-9]+'));
+            foreach (['' => 'attachment',
+                      '/view' => 'attachment_view',
+                      '/download' => 'attachment_download',
+                      '/thumbnail' => 'attachment_thumbnail'] as $postfix => $action) {
+                foreach (['attachment' => '[0-9]+',
+                          'filehash' => '[A-Za-z0-9._-]+'] as $type => $match) {
+                    $m->connect("attachment/:{$type}{$postfix}",
+                                ['action' => $action],
+                                [$type => $match]);
+                }
+            }
 
             $m->connect('notice/new?replyto=:replyto&inreplyto=:inreplyto',
                         array('action' => 'newnotice'),