Merge pull request #10565 from annando/schedule2
Scheduled posts are now listed and can be deleted
This commit is contained in:
commit
9b746e65da
|
@ -44,7 +44,7 @@ class Delayed
|
||||||
* @param array $taglist
|
* @param array $taglist
|
||||||
* @param array $attachments
|
* @param array $attachments
|
||||||
* @return int ID of the created delayed post entry
|
* @return int ID of the created delayed post entry
|
||||||
*/
|
*/
|
||||||
public static function add(string $uri, array $item, int $notify = 0, bool $unprepared = false, string $delayed = '', array $taglist = [], array $attachments = [])
|
public static function add(string $uri, array $item, int $notify = 0, bool $unprepared = false, string $delayed = '', array $taglist = [], array $attachments = [])
|
||||||
{
|
{
|
||||||
if (empty($item['uid']) || self::exists($uri, $item['uid'])) {
|
if (empty($item['uid']) || self::exists($uri, $item['uid'])) {
|
||||||
|
@ -98,6 +98,23 @@ class Delayed
|
||||||
return DBA::delete('delayed-post', ['uri' => $uri, 'uid' => $uid]);
|
return DBA::delete('delayed-post', ['uri' => $uri, 'uid' => $uid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete scheduled posts and the associated workerqueue entry
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function deleteById(int $id)
|
||||||
|
{
|
||||||
|
$post = DBA::selectFirst('delayed-post', ['wid'], ['id' => $id]);
|
||||||
|
if (empty($post['wid'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBA::delete('delayed-post', ['id' => $id]);
|
||||||
|
DBA::delete('workerqueue', ['id' => $post['wid']]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if an entry exists
|
* Check if an entry exists
|
||||||
*
|
*
|
||||||
|
@ -192,7 +209,7 @@ class Delayed
|
||||||
if (self::exists($uri, $item['uid'])) {
|
if (self::exists($uri, $item['uid'])) {
|
||||||
self::delete($uri, $item['uid']);
|
self::delete($uri, $item['uid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
$id = Item::insert($item, $notify);
|
$id = Item::insert($item, $notify);
|
||||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\App\Router;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Model\Post;
|
||||||
use Friendica\Module\BaseApi;
|
use Friendica\Module\BaseApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,15 +50,11 @@ class ScheduledStatuses extends BaseApi
|
||||||
DI::mstdnError()->UnprocessableEntity();
|
DI::mstdnError()->UnprocessableEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
$condtion = ['id' => $parameters['id'], 'uid' => $uid];
|
if (!DBA::exists('delayed-post', ['id' => $parameters['id'], 'uid' => $uid])) {
|
||||||
$post = DBA::selectFirst('delayed-post', ['id'], $condtion);
|
|
||||||
if (empty($post['id'])) {
|
|
||||||
DI::mstdnError()->RecordNotFound();
|
DI::mstdnError()->RecordNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DBA::delete('delayed-post', $condtion)) {
|
Post\Delayed::deleteById($parameters['id']);
|
||||||
DI::mstdnError()->RecordNotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
System::jsonExit([]);
|
System::jsonExit([]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,12 +21,34 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Profile;
|
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\DI;
|
||||||
|
use Friendica\Model\Post;
|
||||||
use Friendica\Module\BaseProfile;
|
use Friendica\Module\BaseProfile;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
|
|
||||||
class Schedule extends BaseProfile
|
class Schedule extends BaseProfile
|
||||||
{
|
{
|
||||||
|
public static function post(array $parameters = [])
|
||||||
|
{
|
||||||
|
if (!local_user()) {
|
||||||
|
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($_REQUEST['delete'])) {
|
||||||
|
throw new HTTPException\BadRequestException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!DBA::exists('delayed-post', ['id' => $_REQUEST['delete'], 'uid' => local_user()])) {
|
||||||
|
throw new HTTPException\NotFoundException();
|
||||||
|
}
|
||||||
|
|
||||||
|
Post\Delayed::deleteById($_REQUEST['delete']);
|
||||||
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public static function content(array $parameters = [])
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
|
@ -37,7 +59,33 @@ class Schedule extends BaseProfile
|
||||||
|
|
||||||
$o = self::getTabsHTML($a, 'schedule', true, $a->user);
|
$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;
|
return $o;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ use Friendica\Module;
|
||||||
$profileRoutes = [
|
$profileRoutes = [
|
||||||
'' => [Module\Profile\Index::class, [R::GET]],
|
'' => [Module\Profile\Index::class, [R::GET]],
|
||||||
'/profile' => [Module\Profile\Profile::class, [R::GET]],
|
'/profile' => [Module\Profile\Profile::class, [R::GET]],
|
||||||
'/schedule' => [Module\Profile\Schedule::class, [R::GET]],
|
'/schedule' => [Module\Profile\Schedule::class, [R::GET, R::POST]],
|
||||||
'/contacts/common' => [Module\Profile\Common::class, [R::GET]],
|
'/contacts/common' => [Module\Profile\Common::class, [R::GET]],
|
||||||
'/contacts[/{type}]' => [Module\Profile\Contacts::class, [R::GET]],
|
'/contacts[/{type}]' => [Module\Profile\Contacts::class, [R::GET]],
|
||||||
'/status[/{category}[/{date1}[/{date2}]]]' => [Module\Profile\Status::class, [R::GET]],
|
'/status[/{category}[/{date1}[/{date2}]]]' => [Module\Profile\Status::class, [R::GET]],
|
||||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: 2021.09-dev\n"
|
"Project-Id-Version: 2021.09-dev\n"
|
||||||
"Report-Msgid-Bugs-To: \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"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\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/Invite.php:127 src/Module/Notifications/Notification.php:47
|
||||||
#: src/Module/Notifications/Notification.php:76
|
#: src/Module/Notifications/Notification.php:76
|
||||||
#: src/Module/Profile/Common.php:56 src/Module/Profile/Contacts.php:57
|
#: 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:75 src/Module/Register.php:193
|
||||||
#: src/Module/Register.php:232 src/Module/Search/Directory.php:38
|
#: src/Module/Register.php:232 src/Module/Search/Directory.php:38
|
||||||
#: src/Module/Settings/Delegation.php:42 src/Module/Settings/Delegation.php:70
|
#: src/Module/Settings/Delegation.php:42 src/Module/Settings/Delegation.php:70
|
||||||
|
@ -7096,7 +7096,7 @@ msgstr ""
|
||||||
msgid "Only You Can See This"
|
msgid "Only You Can See This"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/Module/BaseProfile.php:117
|
#: src/Module/BaseProfile.php:117 src/Module/Profile/Schedule.php:68
|
||||||
msgid "Scheduled Posts"
|
msgid "Scheduled Posts"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -8779,10 +8779,16 @@ msgstr ""
|
||||||
msgid "%s's comments"
|
msgid "%s's comments"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/Module/Profile/Schedule.php:40
|
#: src/Module/Profile/Schedule.php:70
|
||||||
msgid ""
|
msgid "Scheduled"
|
||||||
"Currently here is no functionality here. Please use an app to have a look at "
|
msgstr ""
|
||||||
"your scheduled posts."
|
|
||||||
|
#: src/Module/Profile/Schedule.php:71
|
||||||
|
msgid "Content"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/Module/Profile/Schedule.php:72
|
||||||
|
msgid "Remove post"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/Module/Register.php:69
|
#: src/Module/Register.php:69
|
||||||
|
|
25
view/templates/profile/schedule.tpl
Normal file
25
view/templates/profile/schedule.tpl
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<div class="generic-page-wrapper">
|
||||||
|
<h1>{{$title}}</h1>
|
||||||
|
<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>
|
||||||
|
<form action="{{$baseurl}}/profile/{{$nickname}}/schedule" method="post">
|
||||||
|
<input type="hidden" name="form_security_token" value="{{$form_security_token}}">
|
||||||
|
<button type="submit" name="delete" value="{{$row.id}}" title="{{$delete}}" class="icon s22 delete"></button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{/foreach}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
28
view/theme/frio/templates/profile/schedule.tpl
Normal file
28
view/theme/frio/templates/profile/schedule.tpl
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<div class="generic-page-wrapper">
|
||||||
|
{{* include the title template for the settings title *}}
|
||||||
|
{{include file="section_title.tpl" title=$title}}
|
||||||
|
<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>
|
||||||
|
<form action="{{$baseurl}}/profile/{{$nickname}}/schedule" method="post">
|
||||||
|
<input type="hidden" name="form_security_token" value="{{$form_security_token}}">
|
||||||
|
<button class="btn btn-default" type="submit" name="delete" value="{{$row.id}}" title="{{$delete}}">
|
||||||
|
<i class="fa fa-trash" aria-hidden="true"></i>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{/foreach}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
Loading…
Reference in a new issue