mirror of
https://github.com/friendica/friendica
synced 2024-11-09 16:22:56 +00:00
Owner-view added
This commit is contained in:
parent
afa712b811
commit
02aed490e2
4 changed files with 138 additions and 73 deletions
|
@ -231,13 +231,18 @@ class Tag
|
|||
*/
|
||||
public static function remove(int $uriid, int $type, string $name, string $url = '')
|
||||
{
|
||||
$tag = DBA::fetchFirst("SELECT `id` FROM `tag` INNER JOIN `post-tag` ON `post-tag`.`tid` = `tag`.`id`
|
||||
WHERE `uri-id` = ? AND `type` = ? AND `name` = ? AND `url` = ?", $uriid, $type, $name, $url);
|
||||
$condition = ['uri-id' => $uriid, 'type' => $type, 'url' => $url];
|
||||
if ($type == self::HASHTAG) {
|
||||
$condition['name'] = $name;
|
||||
}
|
||||
|
||||
$tag = DBA::selectFirst('tag-view', ['tid', 'cid'], $condition);
|
||||
if (!DBA::isResult($tag)) {
|
||||
return;
|
||||
}
|
||||
Logger::info('Removing tag/mention', ['uri-id' => $uriid, 'tid' => $tag['id'], 'name' => $name, 'url' => $url, 'callstack' => System::callstack(8)]);
|
||||
DBA::delete('post-tag', ['uri-id' => $uriid, 'tid' => $tag['id']]);
|
||||
|
||||
Logger::info('Removing tag/mention', ['uri-id' => $uriid, 'tid' => $tag['tid'], 'name' => $name, 'url' => $url, 'callstack' => System::callstack(8)]);
|
||||
DBA::delete('post-tag', ['uri-id' => $uriid, 'type' => $type, 'tid' => $tag['tid'], 'cid' => $tag['cid']]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -195,66 +195,46 @@ class User
|
|||
*/
|
||||
public static function getOwnerDataById($uid, $check_valid = true)
|
||||
{
|
||||
$r = DBA::fetchFirst(
|
||||
"SELECT
|
||||
`contact`.*,
|
||||
`user`.`prvkey` AS `uprvkey`,
|
||||
`user`.`timezone`,
|
||||
`user`.`nickname`,
|
||||
`user`.`sprvkey`,
|
||||
`user`.`spubkey`,
|
||||
`user`.`page-flags`,
|
||||
`user`.`account-type`,
|
||||
`user`.`prvnets`,
|
||||
`user`.`account_removed`,
|
||||
`user`.`hidewall`
|
||||
FROM `contact`
|
||||
INNER JOIN `user`
|
||||
ON `user`.`uid` = `contact`.`uid`
|
||||
WHERE `contact`.`uid` = ?
|
||||
AND `contact`.`self`
|
||||
LIMIT 1",
|
||||
$uid
|
||||
);
|
||||
if (!DBA::isResult($r)) {
|
||||
$owner = DBA::selectFirst('owner-view', [], ['uid' => $uid]);
|
||||
if (!DBA::isResult($owner)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($r['nickname'])) {
|
||||
if (empty($owner['nickname'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$check_valid) {
|
||||
return $r;
|
||||
return $owner;
|
||||
}
|
||||
|
||||
// Check if the returned data is valid, otherwise fix it. See issue #6122
|
||||
|
||||
// Check for correct url and normalised nurl
|
||||
$url = DI::baseUrl() . '/profile/' . $r['nickname'];
|
||||
$repair = ($r['url'] != $url) || ($r['nurl'] != Strings::normaliseLink($r['url']));
|
||||
$url = DI::baseUrl() . '/profile/' . $owner['nickname'];
|
||||
$repair = ($owner['url'] != $url) || ($owner['nurl'] != Strings::normaliseLink($owner['url']));
|
||||
|
||||
if (!$repair) {
|
||||
// Check if "addr" is present and correct
|
||||
$addr = $r['nickname'] . '@' . substr(DI::baseUrl(), strpos(DI::baseUrl(), '://') + 3);
|
||||
$repair = ($addr != $r['addr']);
|
||||
$addr = $owner['nickname'] . '@' . substr(DI::baseUrl(), strpos(DI::baseUrl(), '://') + 3);
|
||||
$repair = ($addr != $owner['addr']);
|
||||
}
|
||||
|
||||
if (!$repair) {
|
||||
// Check if the avatar field is filled and the photo directs to the correct path
|
||||
$avatar = Photo::selectFirst(['resource-id'], ['uid' => $uid, 'profile' => true]);
|
||||
if (DBA::isResult($avatar)) {
|
||||
$repair = empty($r['avatar']) || !strpos($r['photo'], $avatar['resource-id']);
|
||||
$repair = empty($owner['avatar']) || !strpos($owner['photo'], $avatar['resource-id']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($repair) {
|
||||
Contact::updateSelfFromUserID($uid);
|
||||
// Return the corrected data and avoid a loop
|
||||
$r = self::getOwnerDataById($uid, false);
|
||||
$owner = self::getOwnerDataById($uid, false);
|
||||
}
|
||||
|
||||
return $r;
|
||||
return $owner;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1290,17 +1270,10 @@ class User
|
|||
'active_users_monthly' => 0,
|
||||
];
|
||||
|
||||
$userStmt = DBA::p("SELECT `user`.`uid`, `user`.`login_date`, `contact`.`last-item`
|
||||
FROM `user`
|
||||
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
|
||||
WHERE `user`.`verified`
|
||||
AND `user`.`login_date` > ?
|
||||
AND NOT `user`.`blocked`
|
||||
AND NOT `user`.`account_removed`
|
||||
AND NOT `user`.`account_expired`",
|
||||
DBA::NULL_DATETIME
|
||||
);
|
||||
|
||||
$userStmt = DBA::select('owner-view', ['uid', 'login_date', 'last-item'],
|
||||
["`verified` AND `login_date` > ? AND NOT `blocked`
|
||||
AND NOT `account_removed` AND NOT `account_expired`",
|
||||
DBA::NULL_DATETIME]);
|
||||
if (!DBA::isResult($userStmt)) {
|
||||
return $statistics;
|
||||
}
|
||||
|
@ -1332,39 +1305,27 @@ class User
|
|||
* @param int $count Count of the items per page (Default is @see Pager::ITEMS_PER_PAGE)
|
||||
* @param string $type The type of users, which should get (all, bocked, removed)
|
||||
* @param string $order Order of the user list (Default is 'contact.name')
|
||||
* @param string $order_direction Order direction (Default is ASC)
|
||||
* @param bool $descending Order direction (Default is ascending)
|
||||
*
|
||||
* @return array The list of the users
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getList($start = 0, $count = Pager::ITEMS_PER_PAGE, $type = 'all', $order = 'contact.name', $order_direction = '+')
|
||||
public static function getList($start = 0, $count = Pager::ITEMS_PER_PAGE, $type = 'all', $order = 'name', bool $descending = false)
|
||||
{
|
||||
$sql_order = '`' . str_replace('.', '`.`', $order) . '`';
|
||||
$sql_order_direction = ($order_direction === '+') ? 'ASC' : 'DESC';
|
||||
|
||||
$param = ['limit' => [$start, $count], 'order' => [$order => $descending]];
|
||||
$condition = [];
|
||||
switch ($type) {
|
||||
case 'active':
|
||||
$sql_extra = 'AND `user`.`blocked` = 0';
|
||||
$condition['blocked'] = false;
|
||||
break;
|
||||
case 'blocked':
|
||||
$sql_extra = 'AND `user`.`blocked` = 1';
|
||||
$condition['blocked'] = true;
|
||||
break;
|
||||
case 'removed':
|
||||
$sql_extra = 'AND `user`.`account_removed` = 1';
|
||||
break;
|
||||
case 'all':
|
||||
default:
|
||||
$sql_extra = '';
|
||||
$condition['account_removed'] = true;
|
||||
break;
|
||||
}
|
||||
|
||||
$usersStmt = DBA::p("SELECT `user`.*, `contact`.`name`, `contact`.`url`, `contact`.`micro`, `user`.`account_expired`, `contact`.`last-item` AS `lastitem_date`, `contact`.`nick`, `contact`.`created`
|
||||
FROM `user`
|
||||
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
|
||||
WHERE `user`.`verified` $sql_extra
|
||||
ORDER BY $sql_order $sql_order_direction LIMIT ?, ?", $start, $count
|
||||
);
|
||||
|
||||
return DBA::toArray($usersStmt);
|
||||
return DBA::selectToArray('owner-view', [], $condition, $param);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,15 +157,15 @@ class Users extends BaseAdmin
|
|||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 100);
|
||||
|
||||
$valid_orders = [
|
||||
'contact.name',
|
||||
'user.email',
|
||||
'user.register_date',
|
||||
'user.login_date',
|
||||
'name',
|
||||
'email',
|
||||
'register_date',
|
||||
'login_date',
|
||||
'lastitem_date',
|
||||
'user.page-flags'
|
||||
'page-flags'
|
||||
];
|
||||
|
||||
$order = 'contact.name';
|
||||
$order = 'name';
|
||||
$order_direction = '+';
|
||||
if (!empty($_GET['o'])) {
|
||||
$new_order = $_GET['o'];
|
||||
|
@ -179,7 +179,7 @@ class Users extends BaseAdmin
|
|||
}
|
||||
}
|
||||
|
||||
$users = User::getList($pager->getStart(), $pager->getItemsPerPage(), 'all', $order, $order_direction);
|
||||
$users = User::getList($pager->getStart(), $pager->getItemsPerPage(), 'all', $order, ($order_direction == '-'));
|
||||
|
||||
$adminlist = explode(',', str_replace(' ', '', DI::config()->get('config', 'admin_email')));
|
||||
$_setup_users = function ($e) use ($adminlist) {
|
||||
|
|
|
@ -53,5 +53,104 @@ return [
|
|||
LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
|
||||
LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`"
|
||||
],
|
||||
"owner-view" => [
|
||||
"fields" => [
|
||||
"id" => ["contact", "id"],
|
||||
"uid" => ["contact", "uid"],
|
||||
"created" => ["contact", "created"],
|
||||
"updated" => ["contact", "updated"],
|
||||
"self" => ["contact", "self"],
|
||||
"remote_self" => ["contact", "remote_self"],
|
||||
"rel" => ["contact", "rel"],
|
||||
"duplex" => ["contact", "duplex"],
|
||||
"network" => ["contact", "network"],
|
||||
"protocol" => ["contact", "protocol"],
|
||||
"name" => ["contact", "name"],
|
||||
"nick" => ["contact", "nick"],
|
||||
"location" => ["contact", "location"],
|
||||
"about" => ["contact", "about"],
|
||||
"keywords" => ["contact", "keywords"],
|
||||
"gender" => ["contact", "gender"],
|
||||
"xmpp" => ["contact", "xmpp"],
|
||||
"attag" => ["contact", "attag"],
|
||||
"avatar" => ["contact", "avatar"],
|
||||
"photo" => ["contact", "photo"],
|
||||
"thumb" => ["contact", "thumb"],
|
||||
"micro" => ["contact", "micro"],
|
||||
"site-pubkey" => ["contact", "site-pubkey"],
|
||||
"issued-id" => ["contact", "issued-id"],
|
||||
"dfrn-id" => ["contact", "dfrn-id"],
|
||||
"url" => ["contact", "url"],
|
||||
"nurl" => ["contact", "nurl"],
|
||||
"addr" => ["contact", "addr"],
|
||||
"alias" => ["contact", "alias"],
|
||||
"pubkey" => ["contact", "pubkey"],
|
||||
"prvkey" => ["contact", "prvkey"],
|
||||
"batch" => ["contact", "batch"],
|
||||
"request" => ["contact", "request"],
|
||||
"notify" => ["contact", "notify"],
|
||||
"poll" => ["contact", "poll"],
|
||||
"confirm" => ["contact", "confirm"],
|
||||
"poco" => ["contact", "poco"],
|
||||
"aes_allow" => ["contact", "aes_allow"],
|
||||
"ret-aes" => ["contact", "ret-aes"],
|
||||
"usehub" => ["contact", "usehub"],
|
||||
"subhub" => ["contact", "subhub"],
|
||||
"hub-verify" => ["contact", "hub-verify"],
|
||||
"last-update" => ["contact", "last-update"],
|
||||
"success_update" => ["contact", "success_update"],
|
||||
"failure_update" => ["contact", "failure_update"],
|
||||
"name-date" => ["contact", "name-date"],
|
||||
"uri-date" => ["contact", "uri-date"],
|
||||
"avatar-date" => ["contact", "avatar-date"],
|
||||
"term-date" => ["contact", "term-date"],
|
||||
"last-item" => ["contact", "last-item"],
|
||||
"lastitem_date" => ["contact", "last-item"],
|
||||
"priority" => ["contact", "priority"],
|
||||
"blocked" => ["contact", "blocked"],
|
||||
"block_reason" => ["contact", "block_reason"],
|
||||
"readonly" => ["contact", "readonly"],
|
||||
"writable" => ["contact", "writable"],
|
||||
"forum" => ["contact", "forum"],
|
||||
"prv" => ["contact", "prv"],
|
||||
"contact-type" => ["contact", "contact-type"],
|
||||
"hidden" => ["contact", "hidden"],
|
||||
"archive" => ["contact", "archive"],
|
||||
"pending" => ["contact", "pending"],
|
||||
"deleted" => ["contact", "deleted"],
|
||||
"rating" => ["contact", "rating"],
|
||||
"unsearchable" => ["contact", "unsearchable"],
|
||||
"sensitive" => ["contact", "sensitive"],
|
||||
"baseurl" => ["contact", "baseurl"],
|
||||
"reason" => ["contact", "reason"],
|
||||
"closeness" => ["contact", "closeness"],
|
||||
"info" => ["contact", "info"],
|
||||
"profile-id" => ["contact", "profile-id"],
|
||||
"bdyear" => ["contact", "bdyear"],
|
||||
"bd" => ["contact", "bd"],
|
||||
"notify_new_posts" => ["notify_new_posts"],
|
||||
"fetch_further_information" => ["fetch_further_information"],
|
||||
"ffi_keyword_blacklist" => ["ffi_keyword_blacklist"],
|
||||
"email" => ["user", "email"],
|
||||
"uprvkey" => ["user", "prvkey"],
|
||||
"timezone" => ["user", "timezone"],
|
||||
"nickname" => ["user", "nickname"],
|
||||
"sprvkey" => ["user", "sprvkey"],
|
||||
"spubkey" => ["user", "spubkey"],
|
||||
"page-flags" => ["user", "page-flags"],
|
||||
"account-type" => ["user", "account-type"],
|
||||
"prvnets" => ["user", "prvnets"],
|
||||
"account_removed" => ["user", "account_removed"],
|
||||
"hidewall" => ["user", "hidewall"],
|
||||
"login_date" => ["user", "login_date"],
|
||||
"register_date" => ["user", "register_date"],
|
||||
"verified" => ["user", "verified"],
|
||||
"account_removed" => ["user", "account_removed"],
|
||||
"account_expired" => ["user", "account_expired"],
|
||||
"account_expires_on" => ["user", "account_expires_on"],
|
||||
],
|
||||
"query" => "FROM `user`
|
||||
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`"
|
||||
]
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in a new issue