<?php
+/**
+ * @copyright Copyright (C) 2010-2022, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
namespace Friendica\Module\Conversation;
/** @var string */
protected static $order;
- public static function content(array $parameters = [])
+ protected function content(array $request = []): string
{
if (!local_user()) {
return Login::form();
}
- self::parseRequest($parameters, $_GET);
+ $this->parseRequest($_GET);
$module = 'network';
if (self::$forumContactId) {
// If self::$forumContactId belongs to a communitity forum or a privat goup,.add a mention to the status editor
- $condition = ["`id` = ? AND (`forum` OR `prv`)", self::$forumContactId];
+ $condition = ["`id` = ? AND `contact-type` = ?", self::$forumContactId, Contact::TYPE_COMMUNITY];
$contact = DBA::selectFirst('contact', ['addr'], $condition);
if (!empty($contact['addr'])) {
$content = '!' . $contact['addr'];
}
$x = [
- 'lockstate' => self::$groupId || self::$forumContactId || self::$network || ACL::getLockstateForUserId($a->getUserId()) ? 'lock' : 'unlock',
- 'acl' => ACL::getFullSelectorHTML(DI::page(), $a->getUserId(), true, $default_permissions),
+ 'lockstate' => self::$groupId || self::$forumContactId || self::$network || ACL::getLockstateForUserId($a->getLoggedInUserId()) ? 'lock' : 'unlock',
+ 'acl' => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId(), true, $default_permissions),
'bang' => ((self::$groupId || self::$forumContactId || self::$network) ? '!' : ''),
'content' => $content,
];
- $o .= status_editor($a, $x);
+ $o .= DI::conversation()->statusEditor($x);
}
if (self::$groupId) {
$ordering = '`commented`';
}
- $o .= conversation(DI::app(), $items, 'network', false, false, $ordering, local_user());
+ $o .= DI::conversation()->create($items, 'network', false, false, $ordering, local_user());
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader();
return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs']]);
}
- protected static function parseRequest(array $parameters, array $get)
+ protected function parseRequest(array $get)
{
- self::$groupId = $parameters['group_id'] ?? 0;
+ self::$groupId = $this->parameters['group_id'] ?? 0;
- self::$forumContactId = $parameters['contact_id'] ?? 0;
+ self::$forumContactId = $this->parameters['contact_id'] ?? 0;
self::$selectedTab = Session::get('network-tab', DI::pConfig()->get(local_user(), 'network.view', 'selected_tab', ''));
Session::set('network-tab', self::$selectedTab);
DI::pConfig()->set(local_user(), 'network.view', 'selected_tab', self::$selectedTab);
- self::$accountTypeString = $get['accounttype'] ?? $parameters['accounttype'] ?? '';
+ self::$accountTypeString = $get['accounttype'] ?? $this->parameters['accounttype'] ?? '';
self::$accountType = User::getAccountTypeByString(self::$accountTypeString);
self::$network = $get['nets'] ?? '';
- self::$dateFrom = $parameters['from'] ?? '';
- self::$dateTo = $parameters['to'] ?? '';
+ self::$dateFrom = $this->parameters['from'] ?? '';
+ self::$dateTo = $this->parameters['to'] ?? '';
if (DI::mode()->isMobile()) {
self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
}
if (self::$dateFrom) {
- $conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` <= ? ", DateTimeFormat::convert(self::$dateFrom, 'UTC', date_default_timezone_get())]);
+ $conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` <= ? ", DateTimeFormat::convert(self::$dateFrom, 'UTC', DI::app()->getTimeZone())]);
}
if (self::$dateTo) {
- $conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` >= ? ", DateTimeFormat::convert(self::$dateTo, 'UTC', date_default_timezone_get())]);
+ $conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` >= ? ", DateTimeFormat::convert(self::$dateTo, 'UTC', DI::app()->getTimeZone())]);
}
if (self::$groupId) {
$conditionStrings = DBA::mergeConditions($conditionStrings, ["`contact-id` IN (SELECT `contact-id` FROM `group_member` WHERE `gid` = ?)", self::$groupId]);
} elseif (self::$forumContactId) {
$conditionStrings = DBA::mergeConditions($conditionStrings,
- ["((`contact-id` = ?) OR EXISTS(SELECT `uri-id` FROM `post-user-view` WHERE `post-user-view`.`parent-uri-id` = `network-thread-view`.`uri-id` AND (`contact-id` = ? AND `gravity` = ? AND `vid` = ? AND `uid` = ?)))",
+ ["((`contact-id` = ?) OR EXISTS(SELECT `uri-id` FROM `post-user-view` WHERE `post-user-view`.`parent-uri-id` = " . DBA::quoteIdentifier($table) . ".`uri-id` AND (`contact-id` = ? AND `gravity` = ? AND `vid` = ? AND `uid` = ?)))",
self::$forumContactId, self::$forumContactId, GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), local_user()]);
}