]> git.mxchange.org Git - friendica.git/commitdiff
Remove contact drop feature
authorHypolite Petovan <hypolite@mrpetovan.com>
Thu, 23 Sep 2021 03:05:13 +0000 (23:05 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 2 Oct 2021 20:04:28 +0000 (16:04 -0400)
- Feature was confusing, sometimes ineffective and overall overlapping with unfollow/block

src/Model/Contact.php
src/Module/Contact.php
static/routes.config.php
view/templates/contact_edit.tpl
view/templates/contacts-template.tpl
view/theme/frio/css/style.css
view/theme/frio/templates/contact_edit.tpl
view/theme/frio/templates/contact_template.tpl
view/theme/frio/templates/contacts-template.tpl
view/theme/vier/templates/contact_edit.tpl

index ae5c6483c7d8927cf2afc8fddc0d0175759d80ed..bc8a6cbe7bce8fdab50bbcdd7949ac845e1fb552 100644 (file)
@@ -994,7 +994,6 @@ class Contact
                $pm_url = '';
                $status_link = '';
                $photos_link = '';
-               $contact_drop_link = '';
                $poke_link = '';
 
                if ($uid == 0) {
@@ -1046,10 +1045,6 @@ class Contact
 
                $posts_link = DI::baseUrl() . '/contact/' . $contact['id'] . '/conversations';
 
-               if (!$contact['self']) {
-                       $contact_drop_link = DI::baseUrl() . '/contact/' . $contact['id'] . '/drop?confirm=1';
-               }
-
                $follow_link = '';
                $unfollow_link = '';
                if (!$contact['self'] && Protocol::supportsFollow($contact['network'])) {
@@ -1060,10 +1055,6 @@ class Contact
                        }
                }
 
-               if (!empty($follow_link) || !empty($unfollow_link)) {
-                       $contact_drop_link = '';
-               }
-
                /**
                 * Menu array:
                 * "name" => [ "Label", "link", (bool)Should the link opened in a new tab? ]
@@ -1083,7 +1074,6 @@ class Contact
                                'photos'  => [DI::l10n()->t('View Photos')   , $photos_link      , true],
                                'network' => [DI::l10n()->t('Network Posts') , $posts_link       , false],
                                'edit'    => [DI::l10n()->t('View Contact')  , $contact_url      , false],
-                               'drop'    => [DI::l10n()->t('Drop Contact')  , $contact_drop_link, false],
                                'pm'      => [DI::l10n()->t('Send PM')       , $pm_url           , false],
                                'poke'    => [DI::l10n()->t('Poke')          , $poke_link        , false],
                                'follow'  => [DI::l10n()->t('Connect/Follow'), $follow_link      , true],
index 37569ee77e1ab25424fb0a96968ff306c0e48a56..3b253b85c158f451c825d8a2148cb3161e6e5906 100644 (file)
@@ -87,12 +87,6 @@ class Contact extends BaseModule
                                self::toggleIgnoreContact($cdata['public']);
                                $count_actions++;
                        }
-
-                       if (!empty($_POST['contacts_batch_drop']) && $cdata['user']
-                               && self::dropContact($cdata['user'], local_user())
-                       ) {
-                               $count_actions++;
-                       }
                }
                if ($count_actions > 0) {
                        info(DI::l10n()->tt('%d contact edited.', '%d contacts edited.', $count_actions));
@@ -230,31 +224,6 @@ class Contact extends BaseModule
                Model\Contact\User::setIgnored($contact_id, local_user(), $ignored);
        }
 
-       /**
-        * @param int $contact_id Id for contact with uid != 0
-        * @param int $uid        Id for user we want to drop the contact for
-        * @return bool
-        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
-        * @throws \ImagickException
-        */
-       private static function dropContact(int $contact_id, int $uid): bool
-       {
-               $contact = Model\Contact::getContactForUser($contact_id, $uid);
-               if (!DBA::isResult($contact)) {
-                       return false;
-               }
-
-               $owner = Model\User::getOwnerDataById($uid);
-               if (!DBA::isResult($owner)) {
-                       return false;
-               }
-
-               Model\Contact::terminateFriendship($owner, $contact, true);
-               Model\Contact::remove($contact['id']);
-
-               return true;
-       }
-
        public static function content(array $parameters = [], $update = 0)
        {
                if (!local_user()) {
@@ -426,38 +395,6 @@ class Contact extends BaseModule
                                DI::baseUrl()->redirect('contact/' . $cdata['public']);
                                // NOTREACHED
                        }
-
-                       if ($cmd === 'drop' && $cdata['user']) {
-                               // Check if we should do HTML-based delete confirmation
-                               if (!empty($_REQUEST['confirm'])) {
-                                       DI::page()['aside'] = '';
-
-                                       return Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_drop_confirm.tpl'), [
-                                               '$l10n' => [
-                                                       'header' => DI::l10n()->t('Drop contact'),
-                                                       'message' => DI::l10n()->t('Do you really want to delete this contact?'),
-                                                       'confirm' => DI::l10n()->t('Yes'),
-                                                       'cancel' => DI::l10n()->t('Cancel'),
-                                               ],
-                                               '$contact' => self::getContactTemplateVars($orig_record),
-                                               '$method' => 'get',
-                                               '$confirm_url' => DI::args()->getCommand(),
-                                               '$confirm_name' => 't',
-                                               '$confirm_value' => BaseModule::getFormSecurityToken('contact_action'),
-                                       ]);
-                               }
-                               // Now check how the user responded to the confirmation query
-                               if (!empty($_REQUEST['canceled'])) {
-                                       DI::baseUrl()->redirect('contact');
-                               }
-
-                               if (self::dropContact($cdata['user'], local_user())) {
-                                       info(DI::l10n()->t('Contact has been removed.'));
-                               }
-
-                               DI::baseUrl()->redirect('contact');
-                               // NOTREACHED
-                       }
                }
 
                $_SESSION['return_path'] = DI::args()->getQueryString();
@@ -859,13 +796,11 @@ class Contact extends BaseModule
                        '$cmd'        => DI::args()->getCommand(),
                        '$contacts'   => $contacts,
                        '$form_security_token'  => BaseModule::getFormSecurityToken('contact_batch_actions'),
-                       '$contact_drop_confirm' => DI::l10n()->t('Do you really want to delete this contact?'),
                        'multiselect' => 1,
                        '$batch_actions' => [
                                'contacts_batch_update'  => DI::l10n()->t('Update'),
                                'contacts_batch_block'   => DI::l10n()->t('Block') . '/' . DI::l10n()->t('Unblock'),
                                'contacts_batch_ignore'  => DI::l10n()->t('Ignore') . '/' . DI::l10n()->t('Unignore'),
-                               'contacts_batch_drop'    => DI::l10n()->t('Delete'),
                        ],
                        '$h_batch_actions' => DI::l10n()->t('Batch Actions'),
                        '$paginate'   => $pager->renderFull($total),
@@ -1156,23 +1091,13 @@ class Contact extends BaseModule
                        'id'    => 'toggle-ignore',
                ];
 
-               if ($contact['uid'] != 0) {
-                       if (Protocol::supportsRevokeFollow($contact['network']) && in_array($contact['rel'], [Model\Contact::FOLLOWER, Model\Contact::FRIEND])) {
-                               $contact_actions['revoke_follow'] = [
-                                       'label' => DI::l10n()->t('Revoke Follow'),
-                                       'url'   => 'contact/' . $contact['id'] . '/revoke',
-                                       'title' => DI::l10n()->t('Revoke the follow from this contact'),
-                                       'sel'   => '',
-                                       'id'    => 'revoke_follow',
-                               ];
-                       }
-
-                       $contact_actions['delete'] = [
-                               'label' => DI::l10n()->t('Delete'),
-                               'url'   => 'contact/' . $contact['id'] . '/drop?t=' . $formSecurityToken,
-                               'title' => DI::l10n()->t('Delete contact'),
+               if ($contact['uid'] != 0 && Protocol::supportsRevokeFollow($contact['network']) && in_array($contact['rel'], [Model\Contact::FOLLOWER, Model\Contact::FRIEND])) {
+                       $contact_actions['revoke_follow'] = [
+                               'label' => DI::l10n()->t('Revoke Follow'),
+                               'url'   => 'contact/' . $contact['id'] . '/revoke',
+                               'title' => DI::l10n()->t('Revoke the follow from this contact'),
                                'sel'   => '',
-                               'id'    => 'delete',
+                               'id'    => 'revoke_follow',
                        ];
                }
 
index a7b27fcb575faaa89baf4fe304210b3daf9ee8cf..2c9765b3c97a6e73a2542648a9dcef62f119ecca 100644 (file)
@@ -236,7 +236,6 @@ return [
                '/{id:\d+}/block'             => [Module\Contact::class,           [R::GET]],
                '/{id:\d+}/conversations'     => [Module\Contact::class,           [R::GET]],
                '/{id:\d+}/contacts[/{type}]' => [Module\Contact\Contacts::class,  [R::GET]],
-               '/{id:\d+}/drop'              => [Module\Contact::class,           [R::GET]],
                '/{id:\d+}/ignore'            => [Module\Contact::class,           [R::GET]],
                '/{id:\d+}/media'             => [Module\Contact\Media::class,     [R::GET]],
                '/{id:\d+}/poke'              => [Module\Contact\Poke::class,      [R::GET, R::POST]],
index 05779f3a46dbbe3323044b7c46457014e88ec8b6..84384c4795cc07f9e7b2250245b6c16d9cec8d16 100644 (file)
@@ -22,7 +22,6 @@
                                                        <li role="menuitem"><a href="#" title="{{$contact_actions.block.title}}" onclick="window.location.href='{{$contact_actions.block.url}}'; return false;">{{$contact_actions.block.label}}</a></li>
                                                        <li role="menuitem"><a href="#" title="{{$contact_actions.ignore.title}}" onclick="window.location.href='{{$contact_actions.ignore.url}}'; return false;">{{$contact_actions.ignore.label}}</a></li>
                                                        {{if $contact_actions.revoke_follow.url}}<li role="menuitem"><a href="{{$contact_actions.revoke_follow.url}}" title="{{$contact_actions.revoke_follow.title}}">{{$contact_actions.revoke_follow.label}}</a></li>{{/if}}
-                                                       {{if $contact_actions.delete.url}}<li role="menuitem"><a href="{{$contact_actions.delete.url}}" title="{{$contact_actions.delete.title}}" onclick="return confirmDelete();">{{$contact_actions.delete.label}}</a></li> {{/if}}
                                                </ul>
                                        </div>
 
index de03c0e72a24b7306883ea436ed3be7251e5125f..46ba629ff522420944457847229ffb151e68068a 100644 (file)
      return false;
     }
   });
-  // add javascript confirm dialog to "drop" links. Plain html url have "?confirm=1" to show confirmation form, we need to remove it
-  $(".drop").each(function() {
-   $(this).attr('href', $(this).attr('href').replace("confirm=1","") );
-   $(this).click(function(e){
-    if (confirm("{{$contact_drop_confirm}}")) {
-     return true;
-    } else {
-     e.preventDefault();
-     return false;
-    }
-   });
-   
-  });
  });
  </script>
 
index bcf1557ae6dabeec3d05b96040801eaa5146c202..ed2bd66cf3415a1e314e6597601218aa58cf4c05 100644 (file)
@@ -2504,14 +2504,6 @@ ul li:hover .contact-wrapper .contact-action-link:hover {
 #directory-search-wrapper {
        padding: 10px 0;
 }
-#contact-drop-confirm .contact-actions,
-#contact-drop-confirm .contact-photo-overlay,
-#contact-drop-confirm .contact-photo-menu {
-       display: none;
-}
-#contact-drop-confirm #confirm-form {
-       margin-top: 20px;
-}
 
 /* contact-edit */
 #contact-edit-actions {
index aa9bedb872faf3014ce0de6f7d3704560008d80c..2085792c75957b4b8c9dde8b292465f24e35f384 100644 (file)
@@ -28,7 +28,6 @@
                                                        <li role="presentation"><a role="menuitem" href="{{$contact_actions.block.url}}" title="{{$contact_actions.block.title}}">{{$contact_actions.block.label}}</a></li>
                                                        <li role="presentation"><a role="menuitem" href="{{$contact_actions.ignore.url}}" title="{{$contact_actions.ignore.title}}">{{$contact_actions.ignore.label}}</a></li>
                             {{if $contact_actions.revoke_follow.url}}<li role="presentation"><button role="menuitem" type="button" class="btn-link" title="{{$contact_actions.revoke_follow.title}}" onclick="addToModal('{{$contact_actions.revoke_follow.url}}');">{{$contact_actions.revoke_follow.label}}</button></li>{{/if}}
-                                                       {{if $contact_actions.delete.url}}<li role="presentation"><button role="menuitem" type="button" class="btn-link" title="{{$contact_actions.delete.title}}" onclick="addToModal('{{$contact_actions.delete.url}}&confirm=1');">{{$contact_actions.delete.label}}</button></li>{{/if}}
                                                </ul>
                                        </li>
                                </ul>
index a950500cebfb234258a5a4a750646e0756fbb8dc..f72a4900fff38d430b31cb157335104594497554 100644 (file)
                                        <i class="fa fa-user" aria-hidden="true"></i>
                                </a>
                                {{/if}}
-                               {{if $contact.photo_menu.drop}}
-                               <button type="button" class="contact-action-link btn-link" onclick="addToModal('{{$contact.photo_menu.drop.1}}'); return false;" data-toggle="tooltip" title="{{$contact.photo_menu.drop.0}}">
-                                       <i class="fa fa-user-times" aria-hidden="true"></i>
-                               </button>
-                               {{/if}}
                                {{if $contact.photo_menu.follow}}
                                <a class="contact-action-link btn-link" href="{{$contact.photo_menu.follow.1}}" data-toggle="tooltip" title="{{$contact.photo_menu.follow.0}}">
                                        <i class="fa fa-user-plus" aria-hidden="true"></i>
@@ -198,11 +193,6 @@ We use this part to filter the contacts with jquery.textcomplete *}}
                                        <i class="fa fa-user" aria-hidden="true"></i>
                                </a>
                                {/if}
-                               {if $photo_menu.drop}
-                               <a class="contact-action-link btn-link" href="{$photo_menu.drop.1}" data-toggle="tooltip" title="{$photo_menu.drop.0}">
-                                       <i class="fa fa-user-times" aria-hidden="true"></i>
-                               </a>
-                               {/if}
                                {if $photo_menu.follow}
                                <a class="contact-action-link btn-link" href="{$photo_menu.follow.1}" data-toggle="tooltip" title="{$photo_menu.follow.0}">
                                        <i class="fa fa-user-plus" aria-hidden="true"></i>
index 15846bb620564e720328cbf06affa4b3164c817c..f13f108340a0edc11c03a5d840922e4367dd4e47 100644 (file)
@@ -1,8 +1,4 @@
 
-<script type="text/javascript">
-       var dropContact = "{{$contact_drop_confirm}}";
-</script>
-
 {{$tabs nofilter}}
 
 <div id="contacts" class="generic-page-wrapper">
index 44506d99bb76eedd8dd9330b10348ca0514984d0..32552942e769779d4c4de131d1ec5e6c0fab298d 100644 (file)
@@ -23,7 +23,6 @@
                                                        <li role="menuitem"><a href="#" title="{{$contact_actions.block.title}}" onclick="window.location.href='{{$contact_actions.block.url}}'; return false;">{{$contact_actions.block.label}}</a></li>
                                                        <li role="menuitem"><a href="#" title="{{$contact_actions.ignore.title}}" onclick="window.location.href='{{$contact_actions.ignore.url}}'; return false;">{{$contact_actions.ignore.label}}</a></li>
                                                        {{if $contact_actions.revoke_follow.url}}<li role="menuitem"><a href="{{$contact_actions.revoke_follow.url}}" title="{{$contact_actions.revoke_follow.title}}">{{$contact_actions.revoke_follow.label}}</a></li>{{/if}}
-                                                       {{if $contact_actions.delete.url}}<li role="menuitem"><a href="{{$contact_actions.delete.url}}" title="{{$contact_actions.delete.title}}" onclick="return confirmDelete();">{{$contact_actions.delete.label}}</a></li>{{/if}}
                                                </ul>
                                        </div>