use Friendica\Model\Item;
use Friendica\Model\Post\Category;
use Friendica\Model\Profile;
+use Friendica\Model\User;
use Friendica\Module\Contact as ModuleContact;
use Friendica\Module\Security\Login;
use Friendica\Util\DateTimeFormat;
DI::page()['aside'] = '';
}
+ if (in_array($a->argv[1], ['person', 'organisation', 'news', 'community'])) {
+ $accounttype = $a->argv[1];
+ } else {
+ $accounttype = '';
+ }
+
+ DI::page()['aside'] .= Widget::accounts('network', $accounttype);
DI::page()['aside'] .= Group::sidebarWidget('network/0', 'network', 'standard', $group_id);
DI::page()['aside'] .= ForumManager::widget(local_user(), $cid);
DI::page()['aside'] .= Widget::postedByYear('network', local_user(), false);
$o = '';
}
+ switch ($a->argv[1] ?? '') {
+ case 'person':
+ $account = User::ACCOUNT_TYPE_PERSON;
+ break;
+ case 'organisation':
+ $account = User::ACCOUNT_TYPE_ORGANISATION;
+ break;
+ case 'news':
+ $account = User::ACCOUNT_TYPE_NEWS;
+ break;
+ case 'community':
+ $account = User::ACCOUNT_TYPE_COMMUNITY;
+ break;
+ default:
+ $account = null;
+ break;
+ }
+
if (!empty($_GET['file'])) {
- $o .= networkFlatView($a, $update);
+ $o .= networkFlatView($a, $update, $account);
} else {
- $o .= networkThreadedView($a, $update, $parent);
+ $o .= networkThreadedView($a, $update, $parent, $account);
}
if (!$update && ($o === '')) {
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @global Pager $pager
*/
-function networkFlatView(App $a, $update = 0)
+function networkFlatView(App $a, $update, $account)
{
global $pager;
// Rawmode is used for fetching new content at the end of the page
networkSetSeen(['unseen' => true, 'uid' => local_user()]);
}
+ if (!empty($account)) {
+ $item_condition['contact-type'] = $account;
+ }
+
$result = Item::selectForUser(local_user(), [], $item_condition, $item_params);
$items = Item::inArray($result);
$o .= networkConversation($a, $items, $pager, 'network-new', $update);
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @global Pager $pager
*/
-function networkThreadedView(App $a, $update, $parent)
+function networkThreadedView(App $a, $update, $parent, $account)
{
/// @TODO this will have to be converted to a static property of the converted Module\Network class
global $pager;
$conditionFields = ['uid' => local_user()];
$conditionStrings = [];
+ if (!empty($account)) {
+ $conditionFields['contact-type'] = $account;
+ }
+
if ($star) {
$conditionFields['starred'] = true;
}
return $o;
}
+
+ /**
+ * Display the accounts sidebar
+ *
+ * @param string $base Basepath
+ * @param string $accounttype Acount type (person, organisation, news, community)
+ * @return string
+ */
+ public static function accounts(string $base, string $accounttype)
+ {
+ return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/accounts.tpl'), [
+ '$title' => DI::l10n()->t('Accounts'),
+ '$content' => $base,
+ '$accounttype' => ($accounttype ?? ''),
+ '$all' => DI::l10n()->t('All'),
+ '$person' => DI::l10n()->t('Persons'),
+ '$organisation' => DI::l10n()->t('Organisations'),
+ '$news' => DI::l10n()->t('News'),
+ '$community' => DI::l10n()->t('Forums'),
+ ]);
+ }
}
use Friendica\Content\Feature;
use Friendica\Content\Nav;
use Friendica\Content\Text\HTML;
+use Friendica\Content\Widget;
use Friendica\Content\Widget\TrendingTags;
use Friendica\Core\ACL;
use Friendica\Core\Renderer;
Nav::setSelected('community');
- DI::page()['aside'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/community_accounts.tpl'), [
- '$title' => DI::l10n()->t('Accounts'),
- '$content' => self::$content,
- '$accounttype' => ($parameters['accounttype'] ?? ''),
- '$all' => DI::l10n()->t('All'),
- '$person' => DI::l10n()->t('Persons'),
- '$organisation' => DI::l10n()->t('Organisations'),
- '$news' => DI::l10n()->t('News'),
- '$community' => DI::l10n()->t('Forums'),
- ]);
+ DI::page()['aside'] .= Widget::accounts('community/' . self::$content, $parameters['accounttype'] ?? '');
if (local_user() && DI::config()->get('system', 'community_no_sharer')) {
$path = self::$content;
use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) {
- define('DB_UPDATE_VERSION', 1369);
+ define('DB_UPDATE_VERSION', 1370);
}
return [
"unseen" => ["item", "unseen"],
"gravity" => ["item", "gravity"],
"contact-id" => ["item", "contact-id"],
+ "contact-type" => ["ownercontact", "contact-type"],
],
"query" => "FROM `item`
INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
+ LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
"mention" => ["thread", "mention"],
"network" => ["thread", "network"],
"contact-id" => ["thread", "contact-id"],
+ "contact-type" => ["ownercontact", "contact-type"],
],
"query" => "FROM `thread`
STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
+ LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
--- /dev/null
+<span id="sidebar-accounts-inflated" class="widget fakelink" onclick="openCloseWidget('sidebar-accounts', 'sidebar-accounts-inflated');">
+ <h3>{{$title}}</h3>
+</span>
+<div id="sidebar-accounts" class="widget">
+ <span class="fakelink" onclick="openCloseWidget('sidebar-accounts', 'sidebar-accounts-inflated');">
+ <h3>{{$title}}</h3>
+ </span>
+ <ul class="sidebar-accounts-ul">
+ <li role="menuitem" class="sidebar-accounts-li{{if !$accounttype}} selected{{/if}}"><a href="{{$content}}">{{$all}}</a></li>
+ <li role="menuitem" class="sidebar-accounts-li{{if $accounttype == 'person'}} selected{{/if}}"><a href="{{$content}}/person">{{$person}}</a></li>
+ <li role="menuitem" class="sidebar-accounts-li{{if $accounttype == 'organisation'}} selected{{/if}}"><a href="{{$content}}/organisation">{{$organisation}}</a></li>
+ <li role="menuitem" class="sidebar-accounts-li{{if $accounttype == 'news'}} selected{{/if}}"><a href="{{$content}}/news">{{$news}}</a></li>
+ <li role="menuitem" class="sidebar-accounts-li{{if $accounttype == 'community'}} selected{{/if}}"><a href="{{$content}}/community">{{$community}}</a></li>
+ </ul>
+</div>
+<script>
+initWidget('sidebar-accounts', 'sidebar-accounts-inflated');
+</script>
+++ /dev/null
-<span id="sidebar-community-accounts-inflated" class="widget fakelink" onclick="openCloseWidget('sidebar-community-accounts', 'sidebar-community-accounts-inflated');">
- <h3>{{$title}}</h3>
-</span>
-<div id="sidebar-community-accounts" class="widget">
- <span class="fakelink" onclick="openCloseWidget('sidebar-community-accounts', 'sidebar-community-accounts-inflated');">
- <h3>{{$title}}</h3>
- </span>
- <ul class="sidebar-community-accounts-ul">
- <li role="menuitem" class="sidebar-community-accounts-li{{if !$accounttype}} selected{{/if}}"><a href="community/{{$content}}">{{$all}}</a></li>
- <li role="menuitem" class="sidebar-community-accounts-li{{if $accounttype == 'person'}} selected{{/if}}"><a href="community/{{$content}}/person">{{$person}}</a></li>
- <li role="menuitem" class="sidebar-community-accounts-li{{if $accounttype == 'organisation'}} selected{{/if}}"><a href="community/{{$content}}/organisation">{{$organisation}}</a></li>
- <li role="menuitem" class="sidebar-community-accounts-li{{if $accounttype == 'news'}} selected{{/if}}"><a href="community/{{$content}}/news">{{$news}}</a></li>
- <li role="menuitem" class="sidebar-community-accounts-li{{if $accounttype == 'community'}} selected{{/if}}"><a href="community/{{$content}}/community">{{$community}}</a></li>
- </ul>
-</div>
-<script>
-initWidget('sidebar-community-accounts', 'sidebar-community-accounts-inflated');
-</script>