]> git.mxchange.org Git - friendica.git/commitdiff
Scheduled posts are now listed and can be deleted
authorMichael <heluecht@pirati.ca>
Mon, 2 Aug 2021 17:03:06 +0000 (17:03 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 2 Aug 2021 17:03:06 +0000 (17:03 +0000)
src/Module/Profile/Schedule.php
static/routes.config.php
view/lang/C/messages.po
view/templates/profile/schedule.tpl [new file with mode: 0644]
view/theme/frio/templates/profile/schedule.tpl [new file with mode: 0644]

index 9ea5e0c6bed1defa599f61152ead91a96e714d44..bb2c91ef062b9f701ec8918147d15a4ba3263cbb 100644 (file)
 
 namespace Friendica\Module\Profile;
 
+use Friendica\BaseModule;
+use Friendica\Content\Text\BBCode;
+use Friendica\Core\Renderer;
+use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Model\Post;
 use Friendica\Module\BaseProfile;
 use Friendica\Network\HTTPException;
 
@@ -33,11 +38,46 @@ class Schedule extends BaseProfile
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
                }
 
+               if (!empty($parameters['id'])) {
+                       self::deleteSchedule($parameters['id']);
+               }
+
                $a = DI::app();
 
                $o = self::getTabsHTML($a, 'schedule', true, $a->user);
 
-               $o .= DI::l10n()->t('Currently here is no functionality here. Please use an app to have a look at your scheduled posts.');
+               $schedule = [];
+               $delayed = DBA::select('delayed-post', [], ['uid' => local_user()]);
+               while ($row = DBA::fetch($delayed)) {
+                       $parameter = Post\Delayed::getParametersForid($row['id']);
+                       if (empty($parameter)) {
+                               continue;
+                       }
+                       $schedule[] = [
+                               'id'           => $row['id'],
+                               'scheduled_at' => $row['delayed'],
+                               'content'      => BBCode::toPlaintext($parameter['item']['body'], false)
+                       ];
+               }
+               DBA::close($delayed);
+
+               $tpl = Renderer::getMarkupTemplate('profile/schedule.tpl');
+               $o .= Renderer::replaceMacros($tpl, [
+                       '$form_security_token' => BaseModule::getFormSecurityToken("profile_schedule"),
+                       '$baseurl'             => DI::baseUrl()->get(true),
+                       '$title'               => DI::l10n()->t('Scheduled Posts'),
+                       '$nickname'            => $parameters['nickname'] ?? '',
+                       '$scheduled_at'        => DI::l10n()->t('Scheduled'),
+                       '$content'             => DI::l10n()->t('Content'),
+                       '$delete'              => DI::l10n()->t('Remove post'),
+                       '$schedule'            => $schedule,
+               ]);
+
                return $o;
        }
+
+       private static function deleteSchedule($id)
+       {
+               DBA::delete('delayed-post', ['id' => $id, 'uid' => local_user()]);
+       }
 }
index 825be5a94576f51fa4dfc9ed7a78d96562d6aef2..18edde75070a1efc18bb34a87e24960f7986a137 100644 (file)
@@ -34,6 +34,7 @@ $profileRoutes = [
        ''                                         => [Module\Profile\Index::class,    [R::GET]],
        '/profile'                                 => [Module\Profile\Profile::class,  [R::GET]],
        '/schedule'                                => [Module\Profile\Schedule::class, [R::GET]],
+       '/schedule/delete/{id:\d+}'                => [Module\Profile\Schedule::class, [R::GET]],       
        '/contacts/common'                         => [Module\Profile\Common::class,   [R::GET]],
        '/contacts[/{type}]'                       => [Module\Profile\Contacts::class, [R::GET]],
        '/status[/{category}[/{date1}[/{date2}]]]' => [Module\Profile\Status::class,   [R::GET]],
index 2fb3c01f40d7b71aead04d0eb8f45cc5612f89f5..5403cfb10ca4aaab369afceea5edba447935fd8c 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: 2021.09-dev\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-08-02 12:15+0000\n"
+"POT-Creation-Date: 2021-08-02 17:00+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -845,7 +845,7 @@ msgstr ""
 #: src/Module/Invite.php:127 src/Module/Notifications/Notification.php:47
 #: src/Module/Notifications/Notification.php:76
 #: src/Module/Profile/Common.php:56 src/Module/Profile/Contacts.php:57
-#: src/Module/Profile/Schedule.php:33 src/Module/Register.php:62
+#: src/Module/Profile/Schedule.php:38 src/Module/Register.php:62
 #: src/Module/Register.php:75 src/Module/Register.php:193
 #: src/Module/Register.php:232 src/Module/Search/Directory.php:38
 #: src/Module/Settings/Delegation.php:42 src/Module/Settings/Delegation.php:70
@@ -7096,7 +7096,7 @@ msgstr ""
 msgid "Only You Can See This"
 msgstr ""
 
-#: src/Module/BaseProfile.php:117
+#: src/Module/BaseProfile.php:117 src/Module/Profile/Schedule.php:68
 msgid "Scheduled Posts"
 msgstr ""
 
@@ -8779,10 +8779,16 @@ msgstr ""
 msgid "%s's comments"
 msgstr ""
 
-#: src/Module/Profile/Schedule.php:40
-msgid ""
-"Currently here is no functionality here. Please use an app to have a look at "
-"your scheduled posts."
+#: src/Module/Profile/Schedule.php:70
+msgid "Scheduled"
+msgstr ""
+
+#: src/Module/Profile/Schedule.php:71
+msgid "Content"
+msgstr ""
+
+#: src/Module/Profile/Schedule.php:72
+msgid "Remove post"
 msgstr ""
 
 #: src/Module/Register.php:69
diff --git a/view/templates/profile/schedule.tpl b/view/templates/profile/schedule.tpl
new file mode 100644 (file)
index 0000000..ae7e085
--- /dev/null
@@ -0,0 +1,23 @@
+<div class="generic-page-wrapper">
+       <h1>{{$title}}</h1>
+       <form action="profile/{{$nickname}}/schedule" method="post" autocomplete="off">
+               <input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
+               <table id='application-block' class='table table-condensed table-striped'>
+                       <thead>
+                               <tr>
+                                       <th>{{$scheduled_at}}</th>
+                                       <th>{{$content}}</th>
+                               </tr>
+                       </thead>
+                       <tbody>
+                               {{foreach $schedule as $entry}}
+                               <tr>
+                                       <td>{{$entry.scheduled_at}}</td>
+                                       <td>{{$entry.content}}</td>
+                                       <td><a href="{{$baseurl}}/profile/{{$nickname}}/schedule/delete/{{$entry.id}}?t={{$form_security_token}}" class="icon s22 delete" title="{{$delete}}">&nbsp;</a></td>
+                               </tr>
+                               {{/foreach}}
+                       </tbody>
+               </table>
+       </form>
+</div>
diff --git a/view/theme/frio/templates/profile/schedule.tpl b/view/theme/frio/templates/profile/schedule.tpl
new file mode 100644 (file)
index 0000000..e481639
--- /dev/null
@@ -0,0 +1,24 @@
+<div class="generic-page-wrapper">
+       {{* include the title template for the settings title *}}
+       {{include file="section_title.tpl" title=$title}}
+       <form action="profile/{{$nickname}}/schedule" method="post" autocomplete="off">
+               <input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
+               <table id='application-block' class='table table-condensed table-striped'>
+                       <thead>
+                               <tr>
+                                       <th>{{$scheduled_at}}</th>
+                                       <th>{{$content}}</th>
+                               </tr>
+                       </thead>
+                       <tbody>
+                               {{foreach $schedule as $row}}
+                               <tr>
+                                       <td>{{$row.scheduled_at}}</td>
+                                       <td>{{$row.content}}</td>
+                                       <td><a href="{{$baseurl}}/profile/{{$nickname}}/schedule/delete/{{$row.id}}?t={{$form_security_token}}" class="btn" title="{{$delete}}"><i class="fa fa-trash" aria-hidden="true"></i></a></td>
+                               </tr>
+                               {{/foreach}}
+                       </tbody>
+               </table>
+       </form>
+</div>