Merge pull request #5732 from annando/fix-picture-posts
authorHypolite Petovan <mrpetovan@eml.cc>
Thu, 6 Sep 2018 23:00:44 +0000 (19:00 -0400)
committerGitHub <noreply@github.com>
Thu, 6 Sep 2018 23:00:44 +0000 (19:00 -0400)
Fix: Posts with pictures will now look good again on connector networks

13 files changed:
doc/Quick-Start-groupsandpages.md
mod/dfrn_notify.php
mod/lockview.php
src/Model/Event.php
src/Module/Proxy.php
src/Protocol/Diaspora.php
src/Protocol/OStatus.php
view/theme/frio/js/mod_photos.js
view/theme/frio/js/modal.js
view/theme/frio/templates/album_edit.tpl
view/theme/frio/templates/events_js.tpl
view/theme/frio/templates/photo_album.tpl
view/theme/frio/theme.php

index 652407d..d4680f6 100644 (file)
@@ -15,6 +15,6 @@ Remember the link at the top of this page will bring you back here.
 
 Once you've added some groups, <a href="help/Quick-Start-andfinally">move on to the next section</a>.
 
-<iframe src="http://dir.friendica.com/directory/forum" width="950" height="600"></iframe>
+<iframe src="http://dir.friendica.social/directory" width="950" height="600"></iframe>
 
 
index f653fac..666c388 100644 (file)
@@ -182,7 +182,7 @@ function dfrn_notify_post(App $a) {
 
 function dfrn_dispatch_public($postdata)
 {
-       $msg = Diaspora::decodeRaw([], $postdata);
+       $msg = Diaspora::decodeRaw([], $postdata, true);
        if (!$msg) {
                // We have to fail silently to be able to hand it over to the salmon parser
                return false;
index 893764c..0d87e15 100644 (file)
@@ -8,27 +8,31 @@ use Friendica\Core\L10n;
 use Friendica\Database\DBA;
 use Friendica\Model\Item;
 
-function lockview_content(App $a) {
-
+function lockview_content(App $a)
+{
        $type = (($a->argc > 1) ? $a->argv[1] : 0);
        if (is_numeric($type)) {
                $item_id = intval($type);
-               $type='item';
+               $type = 'item';
        } else {
                $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
        }
 
-       if (!$item_id)
+       if (!$item_id) {
                killme();
+       }
 
-       if (!in_array($type, ['item','photo','event']))
+       if (!in_array($type, ['item','photo','event'])) {
                killme();
+       }
 
-       $fields = ['uid', 'private', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
+       $fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
        $condition = ['id' => $item_id];
+
        if ($type != 'item') {
                $item = DBA::selectFirst($type, $fields, $condition);
        } else {
+               $fields[] = 'private';
                $item = Item::selectFirst($fields, $condition);
        }
 
@@ -43,18 +47,20 @@ function lockview_content(App $a) {
                killme();
        }
 
-
-       if (($item['private'] == 1) && empty($item['allow_cid']) && empty($item['allow_gid'])
-               && empty($item['deny_cid']) && empty($item['deny_gid'])) {
-
+       if ($item['private'] == 1
+               && empty($item['allow_cid'])
+               && empty($item['allow_gid'])
+               && empty($item['deny_cid'])
+               && empty($item['deny_gid']))
+       {
                echo L10n::t('Remote privacy information not available.') . '<br />';
                killme();
        }
 
-       $allowed_users = expand_acl($item['allow_cid']);
+       $allowed_users  = expand_acl($item['allow_cid']);
        $allowed_groups = expand_acl($item['allow_gid']);
-       $deny_users = expand_acl($item['deny_cid']);
-       $deny_groups = expand_acl($item['deny_gid']);
+       $deny_users     = expand_acl($item['deny_cid']);
+       $deny_groups    = expand_acl($item['deny_gid']);
 
        $o = L10n::t('Visible to:') . '<br />';
        $l = [];
@@ -63,36 +69,44 @@ function lockview_content(App $a) {
                $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
                        DBA::escape(implode(', ', $allowed_groups))
                );
-               if (DBA::isResult($r))
-                       foreach($r as $rr)
+               if (DBA::isResult($r)) {
+                       foreach ($r as $rr) {
                                $l[] = '<b>' . $rr['name'] . '</b>';
+                       }
+               }
        }
+
        if (count($allowed_users)) {
                $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
-                       DBA::escape(implode(', ',$allowed_users))
+                       DBA::escape(implode(', ', $allowed_users))
                );
-               if (DBA::isResult($r))
-                       foreach($r as $rr)
+               if (DBA::isResult($r)) {
+                       foreach ($r as $rr) {
                                $l[] = $rr['name'];
-
+                       }
+               }
        }
 
        if (count($deny_groups)) {
                $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
                        DBA::escape(implode(', ', $deny_groups))
                );
-               if (DBA::isResult($r))
-                       foreach($r as $rr)
+               if (DBA::isResult($r)) {
+                       foreach ($r as $rr) {
                                $l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
+                       }
+               }
        }
+
        if (count($deny_users)) {
                $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
-                       DBA::escape(implode(', ',$deny_users))
+                       DBA::escape(implode(', ', $deny_users))
                );
-               if (DBA::isResult($r))
-                       foreach($r as $rr)
+               if (DBA::isResult($r)) {
+                       foreach ($r as $rr) {
                                $l[] = '<strike>' . $rr['name'] . '</strike>';
-
+                       }
+               }
        }
 
        echo $o . implode(', ', $l);
index 992b77b..016d1f8 100644 (file)
@@ -12,6 +12,7 @@ use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
+use Friendica\Model\Contact;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Map;
 
@@ -589,6 +590,12 @@ class Event extends BaseObject
                                $title = strip_tags(html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
                        }
 
+                       $author_link = $event['author-link'];
+                       $plink       = $event['plink'];
+
+                       $event['author-link'] = Contact::magicLink($author_link);
+                       $event['plink']       = Contact::magicLink($author_link, $plink);
+
                        $html = self::getHTML($event);
                        $event['desc']     = BBCode::convert($event['desc']);
                        $event['location'] = BBCode::convert($event['location']);
index 7983e01..0de45b3 100644 (file)
@@ -8,6 +8,7 @@ namespace Friendica\Module;
 use Friendica\App;
 use Friendica\BaseModule;
 use Friendica\Core\Config;
+use Friendica\Core\L10n;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Model\Photo;
index c25eb96..7af8dbd 100644 (file)
@@ -365,15 +365,16 @@ class Diaspora
        /**
         * @brief: Decodes incoming Diaspora message in the new format
         *
-        * @param array  $importer Array of the importer user
-        * @param string $raw      raw post message
+        * @param array   $importer Array of the importer user
+        * @param string  $raw      raw post message
+        * @param boolean $no_exit  Don't do an http exit on error
         *
         * @return array
         * 'message' -> decoded Diaspora XML message
         * 'author' -> author diaspora handle
         * 'key' -> author public key (converted to pkcs#8)
         */
-       public static function decodeRaw(array $importer, $raw)
+       public static function decodeRaw(array $importer, $raw, $no_exit = false)
        {
                $data = json_decode($raw);
 
@@ -388,7 +389,11 @@ class Diaspora
 
                        if (!is_object($j_outer_key_bundle)) {
                                logger('Outer Salmon did not verify. Discarding.');
-                               System::httpExit(400);
+                               if ($no_exit) {
+                                       return false;
+                               } else {
+                                       System::httpExit(400);
+                               }
                        }
 
                        $outer_iv = base64_decode($j_outer_key_bundle->iv);
@@ -403,7 +408,11 @@ class Diaspora
 
                if (!is_object($basedom)) {
                        logger('Received data does not seem to be an XML. Discarding. '.$xml);
-                       System::httpExit(400);
+                       if ($no_exit) {
+                               return false;
+                       } else {
+                               System::httpExit(400);
+                       }
                }
 
                $base = $basedom->children(NAMESPACE_SALMON_ME);
@@ -425,19 +434,31 @@ class Diaspora
                $author_addr = base64_decode($key_id);
                if ($author_addr == '') {
                        logger('No author could be decoded. Discarding. Message: ' . $xml);
-                       System::httpExit(400);
+                       if ($no_exit) {
+                               return false;
+                       } else {
+                               System::httpExit(400);
+                       }
                }
 
                $key = self::key($author_addr);
                if ($key == '') {
                        logger("Couldn't get a key for handle " . $author_addr . ". Discarding.");
-                       System::httpExit(400);
+                       if ($no_exit) {
+                               return false;
+                       } else {
+                               System::httpExit(400);
+                       }
                }
 
                $verify = Crypto::rsaVerify($signed_data, $signature, $key);
                if (!$verify) {
                        logger('Message did not verify. Discarding.');
-                       System::httpExit(400);
+                       if ($no_exit) {
+                               return false;
+                       } else {
+                               System::httpExit(400);
+                       }
                }
 
                return ['message' => (string)base64url_decode($base->data),
index 551b4ad..ece265c 100644 (file)
@@ -74,6 +74,16 @@ class OStatus
                $author["contact-id"] = $contact["id"];
 
                $contact = null;
+
+/*
+               This here would be better, but we would get problems with contacts from the statusnet addon
+               This is kept here as a reminder for the future
+
+               $cid = Contact::getIdForURL($author["author-link"], $importer["uid"]);
+               if ($cid) {
+                       $contact = DBA::selectFirst('contact', [], ['id' => $cid]);
+               }
+*/
                if ($aliaslink != '') {
                        $condition = ["`uid` = ? AND `alias` = ? AND `network` != ? AND `rel` IN (?, ?)",
                                        $importer["uid"], $aliaslink, Protocol::STATUSNET,
@@ -219,7 +229,7 @@ class OStatus
                        $gcid = GContact::update($contact);
 
                        GContact::link($gcid, $contact["uid"], $contact["id"]);
-               } else {
+               } elseif ($contact["network"] != Protocol::DFRN) {
                        $contact = null;
                }
 
@@ -312,7 +322,7 @@ class OStatus
                        self::$conv_list = [];
                }
 
-               logger("Import OStatus message", LOGGER_DEBUG);
+               logger('Import OStatus message for user ' . $importer['uid'], LOGGER_DEBUG);
 
                if ($xml == "") {
                        return false;
index b8d03b5..7717338 100644 (file)
@@ -15,7 +15,14 @@ $(document).ready(function() {
 
        }).trigger('change');
 
+       // Click event listener for the album edit link/button.
+       $("body").on('click', '#album-edit-link', function() {
+               var modalUrl = $(this).attr("data-modal-url");
 
+               if (typeof modalUrl !== "undefined") {
+                       addToModal(modalUrl, 'photo-album-edit-wrapper');
+               }
+       });
 });
 
 $(window).load(function() {
index 2b3059e..9a15cab 100644 (file)
@@ -188,14 +188,25 @@ function loadModalTitle() {
        }
 }
 
-// This function loads html content from a friendica page
-// into a modal.
-function addToModal(url) {
+
+/**
+ * This function loads html content from a friendica page into a modal.
+ * 
+ * @param {string} url The url with html content.
+ * @param {string} id The ID of a html element (can be undefined).
+ * @returns {void}
+ */
+function addToModal(url, id) {
        var char = qOrAmp(url);
 
        url = url + char + 'mode=none';
        var modal = $('#modal').modal();
 
+       // Only search for an element if we have an ID.
+       if (typeof id !== "undefined") {
+               url = url + " div#" + id;
+       }
+
        modal
                .find('#modal-body')
                .load(url, function (responseText, textStatus) {
@@ -215,7 +226,7 @@ function addToModal(url) {
                });
 }
 
-// Add a element (by it's id) to a bootstrap modal.
+// Add an element (by its id) to a bootstrap modal.
 function addElmToModal(id) {
        var elm = $(id).html();
        var modal = $('#modal').modal();
index 583eb6d..f4a60b7 100644 (file)
@@ -1,14 +1,15 @@
 <div id="photo-album-edit-wrapper">
-<form name="photo-album-edit-form" id="photo-album-edit-form" action="photos/{{$nickname}}/album/{{$hexalbum}}" method="post" >
-       <label id="photo-album-edit-name-label" for="photo-album-edit-name" >{{$nametext}}</label>
-       <div class="pull-left photo-album-edit-name">
-       <input class="form-control" type="text" size="64" name="albumname" value="{{$album|escape:'html'}}" id="photo-album-edit-name" style="width: 100%;">
-       </div>
-       
-       <div class="pull-right">
-       <input class="btn-primary btn btn-small" id="photo-album-edit-submit" type="submit" name="submit" value="{{$submit|escape:'html'}}" />
-       <input class="btn-primary btn btn-small" id="photo-album-edit-drop" type="submit" name="dropalbum" value="{{$dropsubmit|escape:'html'}}" onclick="return confirmDelete();" />
-       </div>
-</form>
+       <form name="photo-album-edit-form" id="photo-album-edit-form" action="photos/{{$nickname}}/album/{{$hexalbum}}" method="post" >
+               <label id="photo-album-edit-name-label" for="photo-album-edit-name" >{{$nametext}}</label>
+               <div class="pull-left photo-album-edit-name">
+                       <input class="form-control" type="text" size="64" name="albumname" value="{{$album|escape:'html'}}" id="photo-album-edit-name">
+               </div>
+
+               <div class="pull-right">
+                       <input class="btn-primary btn btn-small" id="photo-album-edit-submit" type="submit" name="submit" value="{{$submit|escape:'html'}}" />
+                       <input class="btn-primary btn btn-small" id="photo-album-edit-drop" type="submit" name="dropalbum" value="{{$dropsubmit|escape:'html'}}" onclick="return confirmDelete();" />
+               </div>
+       </form>
+       <div class="clear"></div>
 </div>
 <div class="clear"></div>
index 31debbe..a4ca900 100644 (file)
@@ -3,11 +3,13 @@
        {{include file="section_title.tpl" title=$title pullright=1}}
 
        {{* The link to create a new event *}}
+       {{if $new_event.0}}
        <div class="pull-right" id="new-event-link">
                <button type="button" class="btn-link page-action faded-icon" onclick="addToModal('{{$new_event.0}}')" title="{{$new_event.1}}" data-toggle="tooltip">
                        <i class="fa fa-plus"></i>
                </button>
        </div>
+       {{/if}}
 
        {{* We create our own fullcallendar header (with title & calendar view *}}
        <div id="fc-header" class="clear">
index c991b03..235b9c4 100644 (file)
@@ -12,9 +12,9 @@
 
                {{if $edit}}
                <span class="icon-padding"> </span>
-               <a id="album-edit-link" class="page-action faded-icon" href="{{$edit.1}}" title="{{$edit.0}}" data-toggle="tooltip">
+               <button id="album-edit-link" class="btn-link page-action faded-icon" type="button" data-modal-url="{{$edit.1}}" title="{{$edit.0}}" data-toggle="tooltip">
                        <i class="fa fa-pencil"></i>
-               </a>
+               </button>
                {{/if}}
 
                {{if ! $noorder}}
index 4e01289..72e5ab0 100644 (file)
@@ -2,7 +2,7 @@
 /*
  * Name: frio
  * Description: Bootstrap V3 theme. The theme is currently under construction, so it is far from finished. For further information have a look at the <a href="https://github.com/friendica/friendica/tree/develop/view/theme/frio/README.md">ReadMe</a>.
- * Version: V.0.8
+ * Version: V.0.8.5
  * Author: Rabuzarus <https://friendica.kommune4.de/profile/rabuzarus>
  *
  */