]> git.mxchange.org Git - friendica.git/commitdiff
Add contact block reason form and display in admin page
authorHypolite Petovan <hypolite@mrpetovan.com>
Wed, 15 May 2019 23:30:13 +0000 (19:30 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Wed, 15 May 2019 23:30:13 +0000 (19:30 -0400)
src/Module/Admin/Blocklist/Contact.php
view/templates/admin/blocklist/contact.tpl
view/theme/frio/templates/admin/blocklist/contact.tpl

index 1ec6e00df0d879a3aa2819ba89fec296aecbf6a5..60fe04bf7a721b74f2eb273a76452b4ab5c2fa21 100644 (file)
@@ -15,18 +15,19 @@ class Contact extends BaseAdminModule
        {
                parent::post();
 
-               $contact_url = defaults($_POST, 'contact_url', '');
-               $contacts    = defaults($_POST, 'contacts', []);
+               $contact_url  = defaults($_POST, 'contact_url', '');
+               $block_reason = defaults($_POST, 'contact_block_reason', '');
+               $contacts     = defaults($_POST, 'contacts', []);
 
                parent::checkFormSecurityTokenRedirectOnError('/admin/blocklist/contact', 'admin_contactblock');
 
                if (!empty($_POST['page_contactblock_block'])) {
                        $contact_id = Model\Contact::getIdForURL($contact_url);
                        if ($contact_id) {
-                               Model\Contact::block($contact_id);
+                               Model\Contact::block($contact_id, $block_reason);
                                notice(L10n::t('The contact has been blocked from the node'));
                        } else {
-                               notice(L10n::t("Could not find any contact entry for this URL \x28%s\x29", $contact_url));
+                               notice(L10n::t('Could not find any contact entry for this URL (%s)', $contact_url));
                        }
                }
 
@@ -34,7 +35,7 @@ class Contact extends BaseAdminModule
                        foreach ($contacts as $uid) {
                                Model\Contact::unblock($uid);
                        }
-                       notice(L10n::tt("%s contact unblocked", "%s contacts unblocked", count($contacts)));
+                       notice(L10n::tt('%s contact unblocked', '%s contacts unblocked', count($contacts)));
                }
 
                self::getApp()->internalRedirect('admin/blocklist/contact');
@@ -69,9 +70,9 @@ class Contact extends BaseAdminModule
 
                        '$h_contacts'  => L10n::t('Blocked Remote Contacts'),
                        '$h_newblock'  => L10n::t('Block New Remote Contact'),
-                       '$th_contacts' => [L10n::t('Photo'), L10n::t('Name'), L10n::t('Address'), L10n::t('Profile URL')],
+                       '$th_contacts' => [L10n::t('Photo'), L10n::t('Name'), L10n::t('Reason')],
 
-                       '$form_security_token' => parent::getFormSecurityToken("admin_contactblock"),
+                       '$form_security_token' => parent::getFormSecurityToken('admin_contactblock'),
 
                        // values //
                        '$baseurl'    => $a->getBaseURL(true),
@@ -79,7 +80,8 @@ class Contact extends BaseAdminModule
                        '$contacts'   => $contacts,
                        '$total_contacts' => L10n::tt('%s total blocked contact', '%s total blocked contacts', $total),
                        '$paginate'   => $pager->renderFull($total),
-                       '$contacturl' => ['contact_url', L10n::t("Profile URL"), '', L10n::t("URL of the remote contact to block.")],
+                       '$contacturl' => ['contact_url', L10n::t('Profile URL'), '', L10n::t('URL of the remote contact to block.')],
+                       '$contact_block_reason' => ['contact_block_reason', L10n::t('Block Reason')],
                ]);
                return $o;
        }
index 228ad6903f01f8712f5e291cb1bb191a1cbd9ff5..78b4cd78fea93593aba3f36552fb9dffb914ee28 100644 (file)
@@ -25,7 +25,6 @@
                                                {{$th}}
                                        </th>
                                        {{/foreach}}
-                                       <th></th>
                                </tr>
                        </thead>
                        <tbody>
                                <tr>
                                        <td class="checkbox"><input type="checkbox" class="contacts_ckbx" id="id_contact_{{$contact.id}}" name="contacts[]" value="{{$contact.id}}"/></td>
                                        <td><img class="icon" src="{{$contact.micro}}" alt="{{$contact.nickname}}" title="{{$contact.nickname}}"></td>
-                                       <td class="name">{{$contact.name}}</td>
-                                       <td class="addr">{{$contact.addr}}</td>
-                                       <td class="addr"><a href="{{$contact.url}}" title="{{$contact.nickname}}" >{{$contact.url}}</a></td>
+                                       <td class="name">
+                                               {{$contact.name}}<br>
+                                               <a href="{{$contact.url}}" title="{{$contact.nickname}}">{{$contact.addr}}</a>
+                                       </td>
+                                       <td class="reason">{{if $contact.block_reason}}{{$contact.block_reason}}{{else}}N/A{{/if}}</td>
                                </tr>
                                {{/foreach}}
                        </tbody>
@@ -55,6 +56,7 @@
                        <tbody>
                                <tr>
                                        <td>{{include file="field_input.tpl" field=$contacturl}}</td>
+                                       <td>{{include file="field_textarea.tpl" field=$contact_block_reason}}</td>
                                </tr>
                        </tbody>
                </table>
index 53fde9aefbf8bf7f2b145275f50a550284841350..1f43b412b786c613bdabea15cf880c136f262252 100644 (file)
@@ -22,6 +22,7 @@
                                        <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
 
                                        {{include file="field_input.tpl" field=$contacturl}}
+                                       {{include file="field_textarea.tpl" field=$contact_block_reason}}
 
                                        <div class="admin-settings-submit-wrapper form-group pull-right">
                                                <button type="submit" class="btn btn-primary" name="page_contactblock_block" value="1">{{$submit}}</button>
@@ -55,7 +56,6 @@
                                                                                {{$th}}
                                                                        </th>
                                                                {{/foreach}}
-                                                               <th></th>
                                                        </tr>
                                                </thead>
                                                <tbody>
                                                                                </div>
                                                                        </td>
                                                                        <td><img class="icon" src="{{$contact.micro}}" alt="{{$contact.nickname}}" title="{{$contact.addr}}"></td>
-                                                                       <td class="name">{{$contact.name}}</td>
-                                                                       <td class="addr" colspan="3"><a href="{{$contact.url}}" title="{{$contact.addr}}" >{{$contact.url}}</a></td>
+                                                                       <td class="name">
+                                                                               {{$contact.name}}<br>
+                                                                               <a href="{{$contact.url}}" title="{{$contact.nickname}}">{{$contact.addr}}</a>
+                                                                       </td>
+                                                                       <td class="reason">{{if $contact.block_reason}}{{$contact.block_reason}}{{else}}N/A{{/if}}</td>
                                                                </tr>
                                                        {{/foreach}}
                                                </tbody>
@@ -82,7 +85,7 @@
                                                                                <label for="contactblock-select"></label>
                                                                        </div>
                                                                </td>
-                                                               <td colspan="5">
+                                                               <td colspan="3">
                                                                        {{$total_contacts}}
                                                                        <div class="admin-settings-submit-wrapper form-group pull-right">
                                                                                <button type="submit" class="btn btn-small btn-default pull-right" name="page_contactblock_unblock" value="1">{{$unblock}}</button>