mirror of
https://github.com/friendica/friendica
synced 2025-04-23 23:50:12 +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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue