$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;
- }
+ $account = User::getAccountTypeByString($a->argv[1] ?? '');
if (!empty($_GET['file'])) {
$o .= networkFlatView($a, $update, $account);
use Friendica\Core\Addon;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\FileTag;
-use Friendica\Model\GContact;
use Friendica\Model\Group;
use Friendica\Model\Item;
-use Friendica\Model\Profile;
use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Strings;
use Friendica\Util\Temporal;
class Widget
return $o;
}
+ /**
+ * Display the account types sidebar
+ * The account type value is added as a parameter to the url
+ *
+ * @param string $base Basepath
+ * @param int $accounttype Acount type
+ * @return string
+ */
+ public static function accounttypes(string $base, $accounttype)
+ {
+ $accounts = [
+ ['ref' => 'person', 'name' => DI::l10n()->t('Persons')],
+ ['ref' => 'organisation', 'name' => DI::l10n()->t('Organisations')],
+ ['ref' => 'news', 'name' => DI::l10n()->t('News')],
+ ['ref' => 'community', 'name' => DI::l10n()->t('Forums')],
+ ];
+
+ return self::filter('accounttype', DI::l10n()->t('Accounts'), '',
+ DI::l10n()->t('All'), $base, $accounts, $accounttype);
+ }
+
/**
* Display the accounts sidebar
+ * The account type is added to the path
*
* @param string $base Basepath
* @param string $accounttype Acount type (person, organisation, news, community)
);
return DI::dba()->selectToArray('contact', [], $condition,
- ['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
+ ['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
);
}
public static function countAll(int $cid, array $condition = [])
{
$condition = DBA::mergeConditions($condition,
- ['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
- OR `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)',
+ ['(`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
+ OR `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`))',
$cid, $cid]
);
public static function listAll(int $cid, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
{
$condition = DBA::mergeConditions($condition,
- ['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
- OR `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)',
+ ['(`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
+ OR `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`))',
$cid, $cid]
);
return DI::dba()->selectToArray('contact', [], $condition,
- ['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
+ ['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
);
}
);
return DI::dba()->selectToArray('contact', [], $condition,
- ['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
+ ['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
);
}
);
return DI::dba()->selectToArray('contact', [], $condition,
- ['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
+ ['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
);
}
);
return DI::dba()->selectToArray('contact', [], $condition,
- ['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
+ ['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
);
}
}
private static $owner;
+ /**
+ * Returns the numeric account type by their string
+ *
+ * @param string $accounttype as string constant
+ * @return void
+ */
+ public static function getAccountTypeByString(string $accounttype)
+ {
+ switch ($accounttype) {
+ case 'person':
+ return User::ACCOUNT_TYPE_PERSON;
+ case 'organisation':
+ return User::ACCOUNT_TYPE_ORGANISATION;
+ case 'news':
+ return User::ACCOUNT_TYPE_NEWS;
+ case 'community':
+ return User::ACCOUNT_TYPE_COMMUNITY;
+ default:
+ return null;
+ break;
+ }
+ }
+
/**
* Fetch the system account
*
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model;
+use Friendica\Model\User;
use Friendica\Module\Security\Login;
use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Network\HTTPException\NotFoundException;
$rel = Strings::escapeTags(trim($_GET['rel'] ?? ''));
$group = Strings::escapeTags(trim($_GET['group'] ?? ''));
+ $accounttype = $_GET['accounttype'] ?? '';
+ $accounttypeid = User::getAccountTypeByString($accounttype);
+
$page = DI::page();
$page->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js'));
$findpeople_widget = '';
$follow_widget = '';
+ $account_widget = '';
$networks_widget = '';
$rel_widget = '';
$follow_widget = Widget::follow();
}
+ $account_widget = Widget::accounttypes($_SERVER['REQUEST_URI'], $accounttype);
$networks_widget = Widget::networks($_SERVER['REQUEST_URI'], $nets);
$rel_widget = Widget::contactRels($_SERVER['REQUEST_URI'], $rel);
$groups_widget = Widget::groups($_SERVER['REQUEST_URI'], $group);
}
- DI::page()['aside'] .= $vcard_widget . $findpeople_widget . $follow_widget . $groups_widget . $networks_widget . $rel_widget;
+ DI::page()['aside'] .= $vcard_widget . $findpeople_widget . $follow_widget . $account_widget . $groups_widget . $networks_widget . $rel_widget;
$tpl = Renderer::getMarkupTemplate('contacts-head.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
break;
}
+ if (isset($accounttypeid)) {
+ $sql_extra .= " AND `contact-type` = ?";
+ $sql_values[] = $accounttypeid;
+ }
+
$searching = false;
$search_hdr = null;
if ($search) {
use Friendica\BaseModule;
use Friendica\Content\Pager;
+use Friendica\Content\Widget;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model;
+use Friendica\Model\User;
use Friendica\Module;
use Friendica\Network\HTTPException;
$cid = $parameters['id'];
$type = $parameters['type'] ?? 'all';
+ $accounttype = $_GET['accounttype'] ?? '';
+ $accounttypeid = User::getAccountTypeByString($accounttype);
if (!$cid) {
throw new HTTPException\BadRequestException(DI::l10n()->t('Invalid contact.'));
'failed' => false,
];
+ if (isset($accounttypeid)) {
+ $condition['contact-type'] = $accounttypeid;
+ }
+
$noresult_label = DI::l10n()->t('No known contacts.');
switch ($type) {
$total = Model\Contact\Relation::countMutuals($cid, $condition);
break;
case 'common':
- $condition = [
- 'NOT `self` AND NOT `blocked` AND NOT `hidden` AND `id` != ?',
- $localContactId,
- ];
$total = Model\Contact\Relation::countCommon($localContactId, $cid, $condition);
$noresult_label = DI::l10n()->t('No common contacts.');
break;
'$paginate' => $pager->renderFull($total),
]);
+ DI::page()['aside'] .= Widget::accounttypes($_SERVER['REQUEST_URI'], $accounttype);
+
return $o;
}
}
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
}
- switch ($parameters['accounttype'] ?? '') {
- case 'person':
- self::$accounttype = User::ACCOUNT_TYPE_PERSON;
- break;
- case 'organisation':
- self::$accounttype = User::ACCOUNT_TYPE_ORGANISATION;
- break;
- case 'news':
- self::$accounttype = User::ACCOUNT_TYPE_NEWS;
- break;
- case 'community':
- self::$accounttype = User::ACCOUNT_TYPE_COMMUNITY;
- break;
- default:
- self::$accounttype = null;
- break;
- }
+ self::$accounttype = User::getAccountTypeByString($parameters['accounttype'] ?? '');
self::$content = $parameters['content'] ?? '';
if (!self::$content) {