]> git.mxchange.org Git - friendica.git/commitdiff
Remove confirm template obsolete uses (except for contacts)
authorHypolite Petovan <hypolite@mrpetovan.com>
Wed, 9 Sep 2020 04:12:36 +0000 (00:12 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 12 Sep 2020 13:09:15 +0000 (09:09 -0400)
- Remove obsolete explode_querystring() function
- Remove $extra_inputs template variable

boot.php
mod/item.php
mod/message.php
mod/photos.php
mod/settings.php
src/Content/Pager.php
src/Core/Addon.php
src/Module/Contact.php
view/templates/confirm.tpl
view/theme/frio/templates/confirm.tpl

index 95a9ff13d035f5767ccfc1b1710c3b63ada97ba6..24e7559515455782e649dd37c7d868bb4f0b53c2 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -382,38 +382,6 @@ function is_site_admin()
        return local_user() && $admin_email && in_array($a->user['email'] ?? '', $adminlist);
 }
 
-function explode_querystring($query)
-{
-       $arg_st = strpos($query, '?');
-       if ($arg_st !== false) {
-               $base = substr($query, 0, $arg_st);
-               $arg_st += 1;
-       } else {
-               $base = '';
-               $arg_st = 0;
-       }
-
-       $args = explode('&', substr($query, $arg_st));
-       foreach ($args as $k => $arg) {
-               /// @TODO really compare type-safe here?
-               if ($arg === '') {
-                       unset($args[$k]);
-               }
-       }
-       $args = array_values($args);
-
-       if (!$base) {
-               $base = $args[0];
-               unset($args[0]);
-               $args = array_values($args);
-       }
-
-       return [
-               'base' => $base,
-               'args' => $args,
-       ];
-}
-
 /**
  * Returns the complete URL of the current page, e.g.: http(s)://something.com/network
  *
index 3474bea90c88a0ab51d7999f638743b4426b89cb..911a9530c9b72eb61a35b67777c3c33bf55c3787 100644 (file)
@@ -904,40 +904,8 @@ function drop_item(int $id, string $return = '')
        }
 
        if ((local_user() == $item['uid']) || $contact_id) {
-               // Check if we should do HTML-based delete confirmation
-               if (!empty($_REQUEST['confirm'])) {
-                       // <form> can't take arguments in its "action" parameter
-                       // so add any arguments as hidden inputs
-                       $query = explode_querystring(DI::args()->getQueryString());
-                       $inputs = [];
-
-                       foreach ($query['args'] as $arg) {
-                               if (strpos($arg, 'confirm=') === false) {
-                                       $arg_parts = explode('=', $arg);
-                                       $inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]];
-                               }
-                       }
-
-                       return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
-                               '$method' => 'get',
-                               '$message' => DI::l10n()->t('Do you really want to delete this item?'),
-                               '$extra_inputs' => $inputs,
-                               '$confirm' => DI::l10n()->t('Yes'),
-                               '$confirm_url' => $query['base'],
-                               '$confirm_name' => 'confirmed',
-                               '$cancel' => DI::l10n()->t('Cancel'),
-                       ]);
-               }
-               // Now check how the user responded to the confirmation query
-               if (!empty($_REQUEST['canceled'])) {
-                       DI::baseUrl()->redirect('display/' . $item['guid']);
-               }
-
-               $is_comment = $item['gravity'] == GRAVITY_COMMENT;
-               $parentitem = null;
                if (!empty($item['parent'])) {
-                       $fields = ['guid'];
-                       $parentitem = Item::selectFirstForUser(local_user(), $fields, ['id' => $item['parent']]);
+                       $parentitem = Item::selectFirstForUser(local_user(), ['guid'], ['id' => $item['parent']]);
                }
 
                // delete the item
@@ -949,7 +917,7 @@ function drop_item(int $id, string $return = '')
                $return_url = str_replace("update_", "", $return_url);
 
                // Check if delete a comment
-               if ($is_comment) {
+               if ($item['gravity'] == GRAVITY_COMMENT) {
                        // Return to parent guid
                        if (!empty($parentitem)) {
                                DI::baseUrl()->redirect('display/' . $parentitem['guid']);
index 6326bb9ea5ffb282e4b3b85645d9e8e89492f5a3..4f680aa0b7b7ebd448eecb65c3df326a1d8c6f77 100644 (file)
@@ -141,36 +141,6 @@ function message_content(App $a)
                        return;
                }
 
-               // Check if we should do HTML-based delete confirmation
-               if (!empty($_REQUEST['confirm'])) {
-                       // <form> can't take arguments in its "action" parameter
-                       // so add any arguments as hidden inputs
-                       $query = explode_querystring(DI::args()->getQueryString());
-                       $inputs = [];
-                       foreach ($query['args'] as $arg) {
-                               if (strpos($arg, 'confirm=') === false) {
-                                       $arg_parts = explode('=', $arg);
-                                       $inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]];
-                               }
-                       }
-
-                       //DI::page()['aside'] = '';
-                       return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
-                               '$method' => 'get',
-                               '$message' => DI::l10n()->t('Do you really want to delete this message?'),
-                               '$extra_inputs' => $inputs,
-                               '$confirm' => DI::l10n()->t('Yes'),
-                               '$confirm_url' => $query['base'],
-                               '$confirm_name' => 'confirmed',
-                               '$cancel' => DI::l10n()->t('Cancel'),
-                       ]);
-               }
-
-               // Now check how the user responded to the confirmation query
-               if (!empty($_REQUEST['canceled'])) {
-                       DI::baseUrl()->redirect('message');
-               }
-
                $cmd = $a->argv[1];
                if ($cmd === 'drop') {
                        $message = DBA::selectFirst('mail', ['convid'], ['id' => $a->argv[2], 'uid' => local_user()]);
index f078473a95e0225c98ac31bf26de8ba6e9601108..3b2fa0c3a8d80c40a8024253735248e1a168f674 100644 (file)
@@ -1039,7 +1039,6 @@ function photos_content(App $a)
                        return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
                                '$method' => 'post',
                                '$message' => DI::l10n()->t('Do you really want to delete this photo album and all its photos?'),
-                               '$extra_inputs' => [],
                                '$confirm' => DI::l10n()->t('Delete Album'),
                                '$confirm_url' => $drop_url,
                                '$confirm_name' => 'dropalbum',
@@ -1146,7 +1145,6 @@ function photos_content(App $a)
                        return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
                                '$method' => 'post',
                                '$message' => DI::l10n()->t('Do you really want to delete this photo?'),
-                               '$extra_inputs' => [],
                                '$confirm' => DI::l10n()->t('Delete Photo'),
                                '$confirm_url' => $drop_url,
                                '$confirm_name' => 'delete',
index 39667af92fffc8d0ebdf52677a15a4eff1047af3..92a7bb461ff781cb795c4eafb6ee42f3aef5ed51 100644 (file)
@@ -829,26 +829,6 @@ function settings_content(App $a)
 
        $stpl = Renderer::getMarkupTemplate('settings/settings.tpl');
 
-       // Private/public post links for the non-JS ACL form
-       $private_post = 1;
-       if (!empty($_REQUEST['public']) && !$_REQUEST['public']) {
-               $private_post = 0;
-       }
-
-       $query_str = DI::args()->getQueryString();
-       if (strpos($query_str, 'public=1') !== false) {
-               $query_str = str_replace(['?public=1', '&public=1'], ['', ''], $query_str);
-       }
-
-       // I think $a->query_string may never have ? in it, but I could be wrong
-       // It looks like it's from the index.php?q=[etc] rewrite that the web
-       // server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61
-       if (strpos($query_str, '?') === false) {
-               $public_post_link = '?public=1';
-       } else {
-               $public_post_link = '&public=1';
-       }
-
        /* Installed langs */
        $lang_choices = DI::l10n()->getAvailableLanguages();
 
index a5e61bbf9f5827341ec669b5fac444f5a15bf5e8..477e535aecb193c9abe3a4a986677346eab7818f 100644 (file)
@@ -128,7 +128,7 @@ class Pager
        /**
         * Sets the base query string from a full query string.
         *
-        * Strips the 'page' parameter, and remove the 'q=' string for some reason.
+        * Strips the 'page' parameter
         *
         * @param string $queryString
         */
index 0462504e70a29d01457fa5a1d5ecf4fd56c011c5..8b95af328c26dd46cd05b08faedb77b268ea9436 100644 (file)
@@ -229,8 +229,6 @@ class Addon
         */
        public static function getInfo($addon)
        {
-               $a = DI::app();
-
                $addon = Strings::sanitizeFilePathItem($addon);
 
                $info = [
index 6e8778f1794a2cb4f035fd5f34dbf2b343dd4c68..03d67aa08944a5772451d2a973f55e092f0f5f4e 100644 (file)
@@ -436,17 +436,6 @@ class Contact extends BaseModule
                        if ($cmd === 'drop' && ($orig_record['uid'] != 0)) {
                                // Check if we should do HTML-based delete confirmation
                                if (!empty($_REQUEST['confirm'])) {
-                                       // <form> can't take arguments in its 'action' parameter
-                                       // so add any arguments as hidden inputs
-                                       $query = explode_querystring(DI::args()->getQueryString());
-                                       $inputs = [];
-                                       foreach ($query['args'] as $arg) {
-                                               if (strpos($arg, 'confirm=') === false) {
-                                                       $arg_parts = explode('=', $arg);
-                                                       $inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]];
-                                               }
-                                       }
-
                                        DI::page()['aside'] = '';
 
                                        return Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_drop_confirm.tpl'), [
@@ -454,9 +443,8 @@ class Contact extends BaseModule
                                                '$contact' => self::getContactTemplateVars($orig_record),
                                                '$method' => 'get',
                                                '$message' => DI::l10n()->t('Do you really want to delete this contact?'),
-                                               '$extra_inputs' => $inputs,
                                                '$confirm' => DI::l10n()->t('Yes'),
-                                               '$confirm_url' => $query['base'],
+                                               '$confirm_url' => DI::args()->getCommand(),
                                                '$confirm_name' => 'confirmed',
                                                '$cancel' => DI::l10n()->t('Cancel'),
                                        ]);
index 496724e3d9c4209c5b9281e5f2613e8e6b13fb0f..ea50846990c03596dc3c69b1767514f3fe611659 100644 (file)
@@ -3,9 +3,6 @@
 <form action="{{$confirm_url}}" id="confirm-form" method="{{$method}}">
 
        <h3 id="confirm-message">{{$message}}</h3>
-       {{foreach $extra_inputs as $input}}
-       <input type="hidden" name="{{$input.name}}" value="{{$input.value}}" />
-       {{/foreach}}
 
        <input class="confirm-button" id="confirm-submit-button" type="submit" name="{{$confirm_name}}" value="{{$confirm}}" />
        <input class="confirm-button" id="confirm-cancel-button" type="submit" name="canceled" value="{{$cancel}}" />
index 36072a56b1b6227cd18dd394e43a6ff21ccc1876..d17b94d760cc95843a89980792663b2ae57ede48 100644 (file)
@@ -1,9 +1,6 @@
 
 <form action="{{$confirm_url}}" id="confirm-form" method="{{$method}}" class="generic-page-wrapper">
        <div id="confirm-message">{{$message}}</div>
-       {{foreach $extra_inputs as $input}}
-       <input type="hidden" name="{{$input.name}}" value="{{$input.value}}" />
-       {{/foreach}}
 
        <div class="form-group pull-right settings-submit-wrapper" >
                <button type="submit" name="{{$confirm_name}}" id="confirm-submit-button" class="btn btn-primary confirm-button" value="{{$confirm}}">{{$confirm}}</button>