]> git.mxchange.org Git - friendica.git/commitdiff
[frio] Add jotnet fields to compose page
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 15 Jul 2019 02:48:08 +0000 (22:48 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Tue, 30 Jul 2019 00:31:47 +0000 (20:31 -0400)
- Move hardcoded descriptions to translation strings

src/Module/Item/Compose.php
view/templates/item/compose-footer.tpl
view/templates/item/compose.tpl

index 750a29c49a2a59e33dbf2d8f368761f6e0fa47ad..3fe6d9402473facb36d31cb7cfa0a43e1095e51e 100644 (file)
@@ -4,9 +4,11 @@ namespace Friendica\Module\Item;
 
 use Friendica\BaseModule;
 use Friendica\Content\Feature;
+use Friendica\Core\Config;
 use Friendica\Core\Hook;
 use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
+use Friendica\Database\DBA;
 use Friendica\Model\Contact;
 use Friendica\Model\FileTag;
 use Friendica\Model\Group;
@@ -50,18 +52,20 @@ class Compose extends BaseModule
                        }
                }
 
-               $user = User::getById(local_user(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'default-location']);
+               $user = User::getById(local_user(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'hidewall', 'default-location']);
 
                switch ($posttype) {
                        case Item::PT_PERSONAL_NOTE:
                                $compose_title = L10n::t('Compose new personal note');
                                $type = 'note';
+                               $doesFederate = false;
                                $contact_allow = $a->contact['id'];
                                $group_allow = '';
                                break;
                        default:
                                $compose_title = L10n::t('Compose new post');
                                $type = 'post';
+                               $doesFederate = true;
                                $contact_allow = implode(',', expand_acl($user['allow_cid']));
                                $group_allow = implode(',', expand_acl($user['allow_gid'])) ?: Group::FOLLOWERS;
                                break;
@@ -111,6 +115,32 @@ class Compose extends BaseModule
 
                $acl = array_merge($acl_groups, $acl_contacts);
 
+               $jotnets_fields = [];
+               $mail_enabled = false;
+               $pubmail_enabled = false;
+               if (function_exists('imap_open') && !Config::get('system', 'imap_disabled')) {
+                       $mailacct = DBA::selectFirst('mailacct', ['pubmail'], ['`uid` = ? AND `server` != ""', local_user()]);
+                       if (DBA::isResult($mailacct)) {
+                               $mail_enabled = true;
+                               $pubmail_enabled = !empty($mailacct['pubmail']);
+                       }
+               }
+
+               if (empty($user['hidewall'])) {
+                       if ($mail_enabled) {
+                               $jotnets_fields[] = [
+                                       'type' => 'checkbox',
+                                       'field' => [
+                                               'pubmail_enable',
+                                               L10n::t('Post to Email'),
+                                               $pubmail_enabled
+                                       ]
+                               ];
+                       }
+
+                       Hook::callAll('jot_networks', $jotnets_fields);
+               }
+
                $jotplugins = '';
                Hook::callAll('jot_tool', $jotplugins);
 
@@ -159,6 +189,11 @@ class Compose extends BaseModule
                        '$wait'         => L10n::t('Please wait'),
                        '$placeholdertitle' => L10n::t('Set title'),
                        '$placeholdercategory' => (Feature::isEnabled(local_user(),'categories') ? L10n::t('Categories (comma-separated list)') : ''),
+                       '$public_title'  => L10n::t('Public'),
+                       '$public_desc'  => L10n::t('This post will be sent to all your followers and can be seen in the community pages and by anyone with its link.'),
+                       '$custom_title' => L10n::t('Custom'),
+                       '$custom_desc'  => L10n::t('This post will be sent only to the people in the first box, to the exception of the people mentioned in the second box. It won\'t be visible in the community pages nor with its link, and can\'t be sent to connectors (Twitter, Pump.io, etc...).'),
+                       '$emailcc'      => L10n::t('CC: email addresses'),
                        '$title'        => $title,
                        '$category'     => $category,
                        '$body'         => $body,
@@ -169,6 +204,8 @@ class Compose extends BaseModule
                        '$contact_deny' => $contact_deny,
                        '$group_deny'   => $group_deny,
                        '$jotplugins'   => $jotplugins,
+                       '$doesFederate' => $doesFederate,
+                       '$jotnets_fields'=> $jotnets_fields,
                        '$sourceapp'    => L10n::t($a->sourcename),
                        '$rand_num'     => Crypto::randomDigits(12)
                ]);
index 8a854238a17fc51624da31cd1df64a94f105579e..dc55cd9e4eb38d159129e26f32cbdb7d38328a5b 100644 (file)
                        $contact_allow_input.prop('disabled', true);
                        $group_deny_input.prop('disabled', true);
                        $contact_deny_input.prop('disabled', true);
+
+                       $('.profile-jot-net input[type=checkbox]').each(function() {
+                               // Restores checkbox state if it had been saved
+                               if ($(this).attr('data-checked') !== undefined) {
+                                       $(this).prop('checked', $(this).attr('data-checked') === 'true');
+                               }
+                       });
+                       $('.profile-jot-net input').attr('disabled', false);
                });
 
                $('#visibility-custom-panel').on('show.bs.collapse', function() {
                        $contact_allow_input.prop('disabled', false);
                        $group_deny_input.prop('disabled', false);
                        $contact_deny_input.prop('disabled', false);
+
+                       $('.profile-jot-net input[type=checkbox]').each(function() {
+                               // Saves current checkbox state
+                               $(this)
+                                       .attr('data-checked', $(this).prop('checked'))
+                                       .prop('checked', false);
+                       });
+                       $('.profile-jot-net input').attr('disabled', 'disabled');
                });
 
                if (document.querySelector('input[name="visibility"]:checked').value === 'custom') {
index 9594645624f976090336ea3abffbfb6bb5695a08..8f31ac39d0cb325c031f97bbe561ada703e86353 100644 (file)
                        <h3>Visibility</h3>
                        <div class="panel-group" id="visibility-accordion" role="tablist" aria-multiselectable="true">
                                <div class="panel panel-success">
-                                       <div class="panel-heading" role="tab" id="visibility-public-heading" class="" role="button" data-toggle="collapse" data-parent="#visibility-accordion" href="#visibility-public-panel" aria-expanded="true" aria-controls="visibility-public-panel">
+                                       <div class="panel-heading" id="visibility-public-heading" role="button" data-toggle="collapse" data-parent="#visibility-accordion" href="#visibility-public-panel" aria-expanded="true" aria-controls="visibility-public-panel" tabindex="14">
                                                <label>
                                                        <input type="radio" name="visibility" id="visibility-public" value="public" {{if $visibility == 'public'}}checked{{/if}} style="display:none">
-                                                       <i class="fa fa-globe"></i> Public
+                                                       <i class="fa fa-globe"></i> {{$public_title}}
                                                </label>
                                        </div>
                                        <div id="visibility-public-panel" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="visibility-public-heading">
                                                <div class="panel-body">
-                                                       <p>This post will be sent to all your followers and can be seen in the community pages and by anyone with its link.</p>
+                                                       <p>{{$public_desc}}</p>
+                        {{if $doesFederate}}
+                                                       <div class="form-group">
+                                                               <label for="profile-jot-email" id="profile-jot-email-label">{{$emailcc}}</label>
+                                                               <input type="text" name="emailcc" id="profile-jot-email" class="form-control" title="{{$emtitle}}" />
+                                                       </div>
+                                                       <div id="profile-jot-email-end"></div>
+
+                            {{if $jotnets_fields}}
+                                {{if $jotnets_fields|count < 3}}
+                                                                       <div class="profile-jot-net">
+                                {{else}}
+                                                                       <details class="profile-jot-net">
+                                                                       <summary>{{$jotnets_summary}}</summary>
+                                {{/if}}
+
+                                {{foreach $jotnets_fields as $jotnets_field}}
+                                    {{if $jotnets_field.type == 'checkbox'}}
+                                        {{include file="field_checkbox.tpl" field=$jotnets_field.field}}
+                                    {{elseif $jotnets_field.type == 'select'}}
+                                        {{include file="field_select.tpl" field=$jotnets_field.field}}
+                                    {{/if}}
+                                {{/foreach}}
+
+                                {{if $jotnets_fields|count >= 3}}
+                                                                       </details>
+                                {{else}}
+                                                                       </div>
+                                {{/if}}
+                            {{/if}}
+                        {{/if}}
                                                </div>
                                        </div>
                                </div>
                                <div class="panel panel-info">
-                                       <div class="panel-heading" role="tab" id="visibility-custom-heading"  class="collapsed" role="button" data-toggle="collapse" data-parent="#visibility-accordion" href="#visibility-custom-panel" aria-expanded="true" aria-controls="visibility-custom-panel">
+                                       <div class="panel-heading collapsed" id="visibility-custom-heading" role="button" data-toggle="collapse" data-parent="#visibility-accordion" href="#visibility-custom-panel" aria-expanded="true" aria-controls="visibility-custom-panel" tabindex="15">
                                                <label>
                                                        <input type="radio" name="visibility" id="visibility-custom" value="custom" {{if $visibility == 'custom'}}checked{{/if}} style="display:none">
-                                                       <i class="fa fa-lock"></i> Custom
+                                                       <i class="fa fa-lock"></i> {{$custom_title}}
                                                </label>
                                        </div>
                                        <div id="visibility-custom-panel" class="panel-collapse collapse" role="tabpanel" aria-labelledby="visibility-custom-heading">
                                                <div class="panel-body">
-                                                       <p>This post will be sent only to the people in the first box, to the exception of the people mentioned in the second box.
-                                                               It won't be visible in the community pages nor with its link.</p>
+                                                       <p>{{$custom_desc}}</p>
 
                                                        <div class="form-group">
                                                                <label for="acl_allow">Deliver to:</label>