3 * @copyright Copyright (C) 2010-2022, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Module\Profile;
24 use Friendica\BaseModule;
25 use Friendica\Content\Text\BBCode;
26 use Friendica\Core\Renderer;
27 use Friendica\Database\DBA;
29 use Friendica\Model\Post;
30 use Friendica\Module\BaseProfile;
31 use Friendica\Network\HTTPException;
32 use Friendica\Util\DateTimeFormat;
34 class Schedule extends BaseProfile
36 protected function post(array $request = [])
38 if (!DI::userSession()->getLocalUserId()) {
39 throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
42 if (empty($_REQUEST['delete'])) {
43 throw new HTTPException\BadRequestException();
46 if (!DBA::exists('delayed-post', ['id' => $_REQUEST['delete'], 'uid' => DI::userSession()->getLocalUserId()])) {
47 throw new HTTPException\NotFoundException();
50 Post\Delayed::deleteById($_REQUEST['delete']);
53 protected function content(array $request = []): string
55 if (!DI::userSession()->getLocalUserId()) {
56 throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
61 $o = self::getTabsHTML($a, 'schedule', true, $a->getLoggedInUserNickname(), false);
64 $delayed = DBA::select('delayed-post', [], ['uid' => DI::userSession()->getLocalUserId()]);
65 while ($row = DBA::fetch($delayed)) {
66 $parameter = Post\Delayed::getParametersForid($row['id']);
67 if (empty($parameter)) {
72 'scheduled_at' => DateTimeFormat::local($row['delayed']),
73 'content' => BBCode::toPlaintext($parameter['item']['body'], false)
78 $tpl = Renderer::getMarkupTemplate('profile/schedule.tpl');
79 $o .= Renderer::replaceMacros($tpl, [
80 '$form_security_token' => BaseModule::getFormSecurityToken("profile_schedule"),
81 '$baseurl' => DI::baseUrl()->get(true),
82 '$title' => DI::l10n()->t('Scheduled Posts'),
83 '$nickname' => $this->parameters['nickname'] ?? '',
84 '$scheduled_at' => DI::l10n()->t('Scheduled'),
85 '$content' => DI::l10n()->t('Content'),
86 '$delete' => DI::l10n()->t('Remove post'),
87 '$schedule' => $schedule,