Replaced all api_user calls
This commit is contained in:
parent
ebdfe388de
commit
420f6c652f
1 changed files with 124 additions and 124 deletions
248
include/api.php
248
include/api.php
|
@ -228,7 +228,7 @@ function api_call(App $a, App\Arguments $args = null)
|
|||
|
||||
$called_api = explode("/", $p);
|
||||
|
||||
if (!empty($info['auth']) && api_user() === false) {
|
||||
if (!empty($info['auth']) && BaseApi::getCurrentUserID() === false) {
|
||||
BasicAuth::getCurrentUserID(true);
|
||||
Logger::info(API_LOG_PREFIX . 'nickname {nickname}', ['module' => 'api', 'action' => 'call', 'nickname' => $a->getLoggedInUserNickname()]);
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ function api_call(App $a, App\Arguments $args = null)
|
|||
function api_rss_extra($arr, $user_info)
|
||||
{
|
||||
if (is_null($user_info)) {
|
||||
$uid = api_user();
|
||||
$uid = BaseApi::getCurrentUserID();
|
||||
if (empty($uid)) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
|
@ -368,8 +368,8 @@ function api_get_user($contact_id = null)
|
|||
$user = Strings::normaliseLink($contact_id);
|
||||
$url = $user;
|
||||
$extra_query = "AND `contact`.`nurl` = ? ";
|
||||
if (api_user() !== false) {
|
||||
$extra_query .= "AND `contact`.`uid`=" . intval(api_user());
|
||||
if (BaseApi::getCurrentUserID() !== false) {
|
||||
$extra_query .= "AND `contact`.`uid`=" . intval(BaseApi::getCurrentUserID());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -383,8 +383,8 @@ function api_get_user($contact_id = null)
|
|||
|
||||
$url = $user;
|
||||
$extra_query = "AND `contact`.`nurl` = ? ";
|
||||
if (api_user() !== false) {
|
||||
$extra_query .= "AND `contact`.`uid`=" . intval(api_user());
|
||||
if (BaseApi::getCurrentUserID() !== false) {
|
||||
$extra_query .= "AND `contact`.`uid`=" . intval(BaseApi::getCurrentUserID());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -397,23 +397,23 @@ function api_get_user($contact_id = null)
|
|||
|
||||
$url = $user;
|
||||
$extra_query = "AND `contact`.`nurl` = ? ";
|
||||
if (api_user() !== false) {
|
||||
$extra_query .= "AND `contact`.`uid`=" . intval(api_user());
|
||||
if (BaseApi::getCurrentUserID() !== false) {
|
||||
$extra_query .= "AND `contact`.`uid`=" . intval(BaseApi::getCurrentUserID());
|
||||
}
|
||||
}
|
||||
if (is_null($user) && !empty($_GET['screen_name'])) {
|
||||
$user = $_GET['screen_name'];
|
||||
$extra_query = "AND `contact`.`nick` = ? ";
|
||||
if (api_user() !== false) {
|
||||
$extra_query .= "AND `contact`.`uid`=".intval(api_user());
|
||||
if (BaseApi::getCurrentUserID() !== false) {
|
||||
$extra_query .= "AND `contact`.`uid`=".intval(BaseApi::getCurrentUserID());
|
||||
}
|
||||
}
|
||||
|
||||
if (is_null($user) && !empty($_GET['profileurl'])) {
|
||||
$user = Strings::normaliseLink($_GET['profileurl']);
|
||||
$extra_query = "AND `contact`.`nurl` = ? ";
|
||||
if (api_user() !== false) {
|
||||
$extra_query .= "AND `contact`.`uid`=".intval(api_user());
|
||||
if (BaseApi::getCurrentUserID() !== false) {
|
||||
$extra_query .= "AND `contact`.`uid`=".intval(BaseApi::getCurrentUserID());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -432,14 +432,14 @@ function api_get_user($contact_id = null)
|
|||
if ($user != "") {
|
||||
$url = $user;
|
||||
$extra_query = "AND `contact`.`nurl` = ? ";
|
||||
if (api_user() !== false) {
|
||||
$extra_query .= "AND `contact`.`uid`=" . intval(api_user());
|
||||
if (BaseApi::getCurrentUserID() !== false) {
|
||||
$extra_query .= "AND `contact`.`uid`=" . intval(BaseApi::getCurrentUserID());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$extra_query = "AND `contact`.`nick` = ? ";
|
||||
if (api_user() !== false) {
|
||||
$extra_query .= "AND `contact`.`uid`=" . intval(api_user());
|
||||
if (BaseApi::getCurrentUserID() !== false) {
|
||||
$extra_query .= "AND `contact`.`uid`=" . intval(BaseApi::getCurrentUserID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -447,11 +447,11 @@ function api_get_user($contact_id = null)
|
|||
Logger::info(API_LOG_PREFIX . 'getting user {user}', ['module' => 'api', 'action' => 'get_user', 'user' => $user]);
|
||||
|
||||
if (!$user) {
|
||||
if (api_user() === false) {
|
||||
if (BaseApi::getCurrentUserID() === false) {
|
||||
BasicAuth::getCurrentUserID(true);
|
||||
return false;
|
||||
} else {
|
||||
$user = api_user();
|
||||
$user = BaseApi::getCurrentUserID();
|
||||
$extra_query = "AND `contact`.`uid` = ? AND `contact`.`self` ";
|
||||
}
|
||||
}
|
||||
|
@ -498,14 +498,14 @@ function api_get_user($contact_id = null)
|
|||
*/
|
||||
function api_item_get_user(App $a, $item)
|
||||
{
|
||||
$status_user = DI::twitterUser()->createFromContactId($item['author-id'] ?? 0, api_user())->toArray();
|
||||
$status_user = DI::twitterUser()->createFromContactId($item['author-id'] ?? 0, BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
$author_user = $status_user;
|
||||
|
||||
$status_user["protected"] = isset($item['private']) && ($item['private'] == Item::PRIVATE);
|
||||
|
||||
if (($item['thr-parent'] ?? '') == ($item['uri'] ?? '')) {
|
||||
$owner_user = DI::twitterUser()->createFromContactId($item['owner-id'] ?? 0, api_user())->toArray();
|
||||
$owner_user = DI::twitterUser()->createFromContactId($item['owner-id'] ?? 0, BaseApi::getCurrentUserID())->toArray();
|
||||
} else {
|
||||
$owner_user = $author_user;
|
||||
}
|
||||
|
@ -543,7 +543,7 @@ function api_account_verify_credentials($type)
|
|||
|
||||
$skip_status = $_REQUEST['skip_status'] ?? false;
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
// "verified" isn't used here in the standard
|
||||
unset($user_info["verified"]);
|
||||
|
@ -601,9 +601,9 @@ function api_statuses_mediap($type)
|
|||
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
$_REQUEST['profile_uid'] = api_user();
|
||||
$_REQUEST['profile_uid'] = BaseApi::getCurrentUserID();
|
||||
$_REQUEST['api_source'] = true;
|
||||
$txt = requestdata('status') ?? '';
|
||||
/// @TODO old-lost code?
|
||||
|
@ -689,7 +689,7 @@ function api_statuses_update($type)
|
|||
if (requestdata('lat') && requestdata('long')) {
|
||||
$_REQUEST['coord'] = sprintf("%s %s", requestdata('lat'), requestdata('long'));
|
||||
}
|
||||
$_REQUEST['profile_uid'] = api_user();
|
||||
$_REQUEST['profile_uid'] = BaseApi::getCurrentUserID();
|
||||
|
||||
if (!$parent) {
|
||||
// Check for throttling (maximum posts per day, week and month)
|
||||
|
@ -697,11 +697,11 @@ function api_statuses_update($type)
|
|||
if ($throttle_day > 0) {
|
||||
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60);
|
||||
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, api_user(), $datefrom];
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, BaseApi::getCurrentUserID(), $datefrom];
|
||||
$posts_day = Post::count($condition);
|
||||
|
||||
if ($posts_day > $throttle_day) {
|
||||
logger::info('Daily posting limit reached for user '.api_user());
|
||||
logger::info('Daily posting limit reached for user '.BaseApi::getCurrentUserID());
|
||||
// die(api_error($type, DI::l10n()->t("Daily posting limit of %d posts reached. The post was rejected.", $throttle_day));
|
||||
throw new TooManyRequestsException(DI::l10n()->tt("Daily posting limit of %d post reached. The post was rejected.", "Daily posting limit of %d posts reached. The post was rejected.", $throttle_day));
|
||||
}
|
||||
|
@ -711,11 +711,11 @@ function api_statuses_update($type)
|
|||
if ($throttle_week > 0) {
|
||||
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7);
|
||||
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, api_user(), $datefrom];
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, BaseApi::getCurrentUserID(), $datefrom];
|
||||
$posts_week = Post::count($condition);
|
||||
|
||||
if ($posts_week > $throttle_week) {
|
||||
logger::info('Weekly posting limit reached for user '.api_user());
|
||||
logger::info('Weekly posting limit reached for user '.BaseApi::getCurrentUserID());
|
||||
// die(api_error($type, DI::l10n()->t("Weekly posting limit of %d posts reached. The post was rejected.", $throttle_week)));
|
||||
throw new TooManyRequestsException(DI::l10n()->tt("Weekly posting limit of %d post reached. The post was rejected.", "Weekly posting limit of %d posts reached. The post was rejected.", $throttle_week));
|
||||
}
|
||||
|
@ -725,11 +725,11 @@ function api_statuses_update($type)
|
|||
if ($throttle_month > 0) {
|
||||
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30);
|
||||
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, api_user(), $datefrom];
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, BaseApi::getCurrentUserID(), $datefrom];
|
||||
$posts_month = Post::count($condition);
|
||||
|
||||
if ($posts_month > $throttle_month) {
|
||||
logger::info('Monthly posting limit reached for user '.api_user());
|
||||
logger::info('Monthly posting limit reached for user '.BaseApi::getCurrentUserID());
|
||||
// die(api_error($type, DI::l10n()->t("Monthly posting limit of %d posts reached. The post was rejected.", $throttle_month));
|
||||
throw new TooManyRequestsException(DI::l10n()->t("Monthly posting limit of %d post reached. The post was rejected.", "Monthly posting limit of %d posts reached. The post was rejected.", $throttle_month));
|
||||
}
|
||||
|
@ -754,7 +754,7 @@ function api_statuses_update($type)
|
|||
$media = DBA::toArray(DBA::p("SELECT `resource-id`, `scale`, `nickname`, `type`, `desc`, `filename`, `datasize`, `width`, `height` FROM `photo`
|
||||
INNER JOIN `user` ON `user`.`uid` = `photo`.`uid` WHERE `resource-id` IN
|
||||
(SELECT `resource-id` FROM `photo` WHERE `id` = ?) AND `photo`.`uid` = ?
|
||||
ORDER BY `photo`.`width` DESC LIMIT 2", $id, api_user()));
|
||||
ORDER BY `photo`.`width` DESC LIMIT 2", $id, BaseApi::getCurrentUserID()));
|
||||
|
||||
if (!empty($media)) {
|
||||
$ressources[] = $media[0]['resource-id'];
|
||||
|
@ -802,7 +802,7 @@ function api_statuses_update($type)
|
|||
if (!empty($ressources) && !empty($item_id)) {
|
||||
$item = Post::selectFirst(['uri-id', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'], ['id' => $item_id]);
|
||||
foreach ($ressources as $ressource) {
|
||||
Photo::setPermissionForRessource($ressource, api_user(), $item['allow_cid'], $item['allow_gid'], $item['deny_cid'], $item['deny_gid']);
|
||||
Photo::setPermissionForRessource($ressource, BaseApi::getCurrentUserID(), $item['allow_cid'], $item['allow_gid'], $item['deny_cid'], $item['deny_gid']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -900,7 +900,7 @@ function api_media_metadata_create($type)
|
|||
|
||||
Logger::info('Updating metadata', ['media_id' => $data['media_id']]);
|
||||
|
||||
$condition = ['id' => $data['media_id'], 'uid' => api_user()];
|
||||
$condition = ['id' => $data['media_id'], 'uid' => BaseApi::getCurrentUserID()];
|
||||
$photo = DBA::selectFirst('photo', ['resource-id'], $condition);
|
||||
if (!DBA::isResult($photo)) {
|
||||
throw new BadRequestException("Metadata not found.");
|
||||
|
@ -985,7 +985,7 @@ function api_users_show($type)
|
|||
{
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
$item = api_get_last_status($user_info['pid'], $user_info['uid']);
|
||||
if (!empty($item)) {
|
||||
|
@ -1034,7 +1034,7 @@ function api_users_search($type)
|
|||
if (DBA::isResult($contacts)) {
|
||||
$k = 0;
|
||||
foreach ($contacts as $contact) {
|
||||
$user_info = DI::twitterUser()->createFromContactId($contact['id'], api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromContactId($contact['id'], BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
if ($type == 'xml') {
|
||||
$userlist[$k++ . ':user'] = $user_info;
|
||||
|
@ -1110,7 +1110,7 @@ function api_search($type)
|
|||
{
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
if (empty($_REQUEST['q'])) {
|
||||
throw new BadRequestException('q parameter is required.');
|
||||
|
@ -1160,7 +1160,7 @@ function api_search($type)
|
|||
" . ($exclude_replies ? " AND `gravity` = " . GRAVITY_PARENT : ' ') . "
|
||||
AND (`uid` = 0 OR (`uid` = ? AND NOT `global`))
|
||||
AND `body` LIKE CONCAT('%',?,'%')",
|
||||
$since_id, api_user(), $_REQUEST['q']];
|
||||
$since_id, BaseApi::getCurrentUserID(), $_REQUEST['q']];
|
||||
if ($max_id > 0) {
|
||||
$condition[0] .= ' AND `id` <= ?';
|
||||
$condition[] = $max_id;
|
||||
|
@ -1170,7 +1170,7 @@ function api_search($type)
|
|||
$statuses = [];
|
||||
|
||||
if (parse_url($searchTerm, PHP_URL_SCHEME) != '') {
|
||||
$id = Item::fetchByLink($searchTerm, api_user());
|
||||
$id = Item::fetchByLink($searchTerm, BaseApi::getCurrentUserID());
|
||||
if (!$id) {
|
||||
// Public post
|
||||
$id = Item::fetchByLink($searchTerm);
|
||||
|
@ -1181,7 +1181,7 @@ function api_search($type)
|
|||
}
|
||||
}
|
||||
|
||||
$statuses = $statuses ?: Post::selectForUser(api_user(), [], $condition, $params);
|
||||
$statuses = $statuses ?: Post::selectForUser(BaseApi::getCurrentUserID(), [], $condition, $params);
|
||||
|
||||
$data['status'] = api_format_items(Post::toArray($statuses), $user_info);
|
||||
|
||||
|
@ -1214,7 +1214,7 @@ function api_statuses_home_timeline($type)
|
|||
{
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
unset($_REQUEST["user_id"]);
|
||||
unset($_GET["user_id"]);
|
||||
|
@ -1235,7 +1235,7 @@ function api_statuses_home_timeline($type)
|
|||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `id` > ?",
|
||||
api_user(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
|
||||
BaseApi::getCurrentUserID(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
|
||||
|
||||
if ($max_id > 0) {
|
||||
$condition[0] .= " AND `id` <= ?";
|
||||
|
@ -1251,7 +1251,7 @@ function api_statuses_home_timeline($type)
|
|||
}
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser(api_user(), [], $condition, $params);
|
||||
$statuses = Post::selectForUser(BaseApi::getCurrentUserID(), [], $condition, $params);
|
||||
|
||||
$items = Post::toArray($statuses);
|
||||
|
||||
|
@ -1305,7 +1305,7 @@ function api_statuses_public_timeline($type)
|
|||
{
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
// get last network messages
|
||||
|
||||
|
@ -1329,7 +1329,7 @@ function api_statuses_public_timeline($type)
|
|||
}
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser(api_user(), [], $condition, $params);
|
||||
$statuses = Post::selectForUser(BaseApi::getCurrentUserID(), [], $condition, $params);
|
||||
|
||||
$r = Post::toArray($statuses);
|
||||
} else {
|
||||
|
@ -1346,7 +1346,7 @@ function api_statuses_public_timeline($type)
|
|||
}
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser(api_user(), [], $condition, $params);
|
||||
$statuses = Post::selectForUser(BaseApi::getCurrentUserID(), [], $condition, $params);
|
||||
|
||||
$r = Post::toArray($statuses);
|
||||
}
|
||||
|
@ -1385,7 +1385,7 @@ function api_statuses_networkpublic_timeline($type)
|
|||
{
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
$since_id = $_REQUEST['since_id'] ?? 0;
|
||||
$max_id = $_REQUEST['max_id'] ?? 0;
|
||||
|
@ -1405,7 +1405,7 @@ function api_statuses_networkpublic_timeline($type)
|
|||
}
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::toArray(Post::selectForUser(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params));
|
||||
$statuses = Post::toArray(Post::selectForUser(BaseApi::getCurrentUserID(), Item::DISPLAY_FIELDLIST, $condition, $params));
|
||||
|
||||
$ret = api_format_items($statuses, $user_info, false, $type);
|
||||
|
||||
|
@ -1443,7 +1443,7 @@ function api_statuses_show($type)
|
|||
{
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
// params
|
||||
$id = intval(DI::args()->getArgv()[3] ?? 0);
|
||||
|
@ -1467,7 +1467,7 @@ function api_statuses_show($type)
|
|||
throw new BadRequestException(sprintf("There is no status with the id %d", $id));
|
||||
}
|
||||
|
||||
$item = Post::selectFirst(['id'], ['uri-id' => $uri_item['uri-id'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
|
||||
$item = Post::selectFirst(['id'], ['uri-id' => $uri_item['uri-id'], 'uid' => [0, BaseApi::getCurrentUserID()]], ['order' => ['uid' => true]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
throw new BadRequestException(sprintf("There is no status with the uri-id %d for the given user.", $uri_item['uri-id']));
|
||||
}
|
||||
|
@ -1482,7 +1482,7 @@ function api_statuses_show($type)
|
|||
$params = [];
|
||||
}
|
||||
|
||||
$statuses = Post::selectForUser(api_user(), [], $condition, $params);
|
||||
$statuses = Post::selectForUser(BaseApi::getCurrentUserID(), [], $condition, $params);
|
||||
|
||||
/// @TODO How about copying this to above methods which don't check $r ?
|
||||
if (!DBA::isResult($statuses)) {
|
||||
|
@ -1519,7 +1519,7 @@ function api_conversation_show($type)
|
|||
{
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
// params
|
||||
$id = intval(DI::args()->getArgv()[3] ?? 0);
|
||||
|
@ -1547,7 +1547,7 @@ function api_conversation_show($type)
|
|||
throw new BadRequestException("There is no status with the id $id.");
|
||||
}
|
||||
|
||||
$parent = Post::selectFirst(['id'], ['uri-id' => $item['parent-uri-id'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
|
||||
$parent = Post::selectFirst(['id'], ['uri-id' => $item['parent-uri-id'], 'uid' => [0, BaseApi::getCurrentUserID()]], ['order' => ['uid' => true]]);
|
||||
if (!DBA::isResult($parent)) {
|
||||
throw new BadRequestException("There is no status with this id.");
|
||||
}
|
||||
|
@ -1555,7 +1555,7 @@ function api_conversation_show($type)
|
|||
$id = $parent['id'];
|
||||
|
||||
$condition = ["`parent` = ? AND `uid` IN (0, ?) AND `gravity` IN (?, ?) AND `id` > ?",
|
||||
$id, api_user(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
|
||||
$id, BaseApi::getCurrentUserID(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
|
||||
|
||||
if ($max_id > 0) {
|
||||
$condition[0] .= " AND `id` <= ?";
|
||||
|
@ -1563,7 +1563,7 @@ function api_conversation_show($type)
|
|||
}
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser(api_user(), [], $condition, $params);
|
||||
$statuses = Post::selectForUser(BaseApi::getCurrentUserID(), [], $condition, $params);
|
||||
|
||||
if (!DBA::isResult($statuses)) {
|
||||
throw new BadRequestException("There is no status with id $id.");
|
||||
|
@ -1639,7 +1639,7 @@ function api_statuses_repeat($type)
|
|||
$post .= "[/share]";
|
||||
}
|
||||
$_REQUEST['body'] = $post;
|
||||
$_REQUEST['profile_uid'] = api_user();
|
||||
$_REQUEST['profile_uid'] = BaseApi::getCurrentUserID();
|
||||
$_REQUEST['api_source'] = true;
|
||||
|
||||
if (empty($_REQUEST['source'])) {
|
||||
|
@ -1693,7 +1693,7 @@ function api_statuses_destroy($type)
|
|||
|
||||
$ret = api_statuses_show($type);
|
||||
|
||||
Item::deleteForUser(['id' => $id], api_user());
|
||||
Item::deleteForUser(['id' => $id], BaseApi::getCurrentUserID());
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
@ -1718,7 +1718,7 @@ function api_statuses_mentions($type)
|
|||
{
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
unset($_REQUEST["user_id"]);
|
||||
unset($_GET["user_id"]);
|
||||
|
@ -1742,11 +1742,11 @@ function api_statuses_mentions($type)
|
|||
|
||||
$condition = [
|
||||
GRAVITY_PARENT, GRAVITY_COMMENT,
|
||||
api_user(),
|
||||
BaseApi::getCurrentUserID(),
|
||||
Post\UserNotification::TYPE_EXPLICIT_TAGGED | Post\UserNotification::TYPE_IMPLICIT_TAGGED |
|
||||
Post\UserNotification::TYPE_THREAD_COMMENT | Post\UserNotification::TYPE_DIRECT_COMMENT |
|
||||
Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT,
|
||||
api_user(), $since_id,
|
||||
BaseApi::getCurrentUserID(), $since_id,
|
||||
];
|
||||
|
||||
if ($max_id > 0) {
|
||||
|
@ -1757,7 +1757,7 @@ function api_statuses_mentions($type)
|
|||
array_unshift($condition, $query);
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser(api_user(), [], $condition, $params);
|
||||
$statuses = Post::selectForUser(BaseApi::getCurrentUserID(), [], $condition, $params);
|
||||
|
||||
$ret = api_format_items(Post::toArray($statuses), $user_info, false, $type);
|
||||
|
||||
|
@ -1793,9 +1793,9 @@ function api_statuses_user_timeline($type)
|
|||
{
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
Logger::info('api_statuses_user_timeline', ['api_user' => api_user(), 'user_info' => $user_info, '_REQUEST' => $_REQUEST]);
|
||||
Logger::info('api_statuses_user_timeline', ['api_user' => BaseApi::getCurrentUserID(), 'user_info' => $user_info, '_REQUEST' => $_REQUEST]);
|
||||
|
||||
$since_id = $_REQUEST['since_id'] ?? 0;
|
||||
$max_id = $_REQUEST['max_id'] ?? 0;
|
||||
|
@ -1809,7 +1809,7 @@ function api_statuses_user_timeline($type)
|
|||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `id` > ? AND `contact-id` = ?",
|
||||
api_user(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, $user_info['cid']];
|
||||
BaseApi::getCurrentUserID(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, $user_info['cid']];
|
||||
|
||||
if ($user_info['self'] == 1) {
|
||||
$condition[0] .= ' AND `wall` ';
|
||||
|
@ -1830,7 +1830,7 @@ function api_statuses_user_timeline($type)
|
|||
$condition[] = $max_id;
|
||||
}
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser(api_user(), [], $condition, $params);
|
||||
$statuses = Post::selectForUser(BaseApi::getCurrentUserID(), [], $condition, $params);
|
||||
|
||||
$ret = api_format_items(Post::toArray($statuses), $user_info, true, $type);
|
||||
|
||||
|
@ -1886,7 +1886,7 @@ function api_favorites_create_destroy($type)
|
|||
$itemid = intval($_REQUEST['id'] ?? 0);
|
||||
}
|
||||
|
||||
$item = Post::selectFirstForUser(api_user(), [], ['id' => $itemid, 'uid' => api_user()]);
|
||||
$item = Post::selectFirstForUser(BaseApi::getCurrentUserID(), [], ['id' => $itemid, 'uid' => BaseApi::getCurrentUserID()]);
|
||||
|
||||
if (!DBA::isResult($item)) {
|
||||
throw new BadRequestException("Invalid item.");
|
||||
|
@ -1909,7 +1909,7 @@ function api_favorites_create_destroy($type)
|
|||
throw new InternalServerErrorException("DB error");
|
||||
}
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
$rets = api_format_items([$item], $user_info, false, $type);
|
||||
$ret = $rets[0];
|
||||
|
||||
|
@ -1947,7 +1947,7 @@ function api_favorites($type)
|
|||
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
$called_api = [];
|
||||
|
||||
|
@ -1967,7 +1967,7 @@ function api_favorites($type)
|
|||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `id` > ? AND `starred`",
|
||||
api_user(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
|
||||
BaseApi::getCurrentUserID(), GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
|
||||
|
@ -1976,7 +1976,7 @@ function api_favorites($type)
|
|||
$condition[] = $max_id;
|
||||
}
|
||||
|
||||
$statuses = Post::selectForUser(api_user(), [], $condition, $params);
|
||||
$statuses = Post::selectForUser(BaseApi::getCurrentUserID(), [], $condition, $params);
|
||||
|
||||
$ret = api_format_items(Post::toArray($statuses), $user_info, false, $type);
|
||||
}
|
||||
|
@ -2431,7 +2431,7 @@ function api_format_items_activities($item, $type = "json")
|
|||
//builtin_activity_puller($i, $activities);
|
||||
|
||||
// get user data and add it to the array of the activity
|
||||
$user = DI::twitterUser()->createFromContactId($parent_item['author-id'], api_user())->toArray();
|
||||
$user = DI::twitterUser()->createFromContactId($parent_item['author-id'], BaseApi::getCurrentUserID())->toArray();
|
||||
switch ($parent_item['verb']) {
|
||||
case Activity::LIKE:
|
||||
$activities['like'][] = $user;
|
||||
|
@ -2595,7 +2595,7 @@ function api_format_item($item, $type = "json", $status_user = null, $author_use
|
|||
if (!empty($announce)) {
|
||||
$retweeted_item = $item;
|
||||
$item = $announce;
|
||||
$status['friendica_owner'] = DI::twitterUser()->createFromContactId($announce['author-id'], api_user())->toArray();
|
||||
$status['friendica_owner'] = DI::twitterUser()->createFromContactId($announce['author-id'], BaseApi::getCurrentUserID())->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2614,7 +2614,7 @@ function api_format_item($item, $type = "json", $status_user = null, $author_use
|
|||
$quoted_status['text'] = $conv_quoted['text'];
|
||||
$quoted_status['statusnet_html'] = $conv_quoted['html'];
|
||||
try {
|
||||
$quoted_status["user"] = DI::twitterUser()->createFromContactId($quoted_item['author-id'], api_user())->toArray();
|
||||
$quoted_status["user"] = DI::twitterUser()->createFromContactId($quoted_item['author-id'], BaseApi::getCurrentUserID())->toArray();
|
||||
} catch (BadRequestException $e) {
|
||||
// user not found. should be found?
|
||||
/// @todo check if the user should be always found
|
||||
|
@ -2636,7 +2636,7 @@ function api_format_item($item, $type = "json", $status_user = null, $author_use
|
|||
unset($retweeted_status['statusnet_conversation_id']);
|
||||
$status['user'] = $status['friendica_owner'];
|
||||
try {
|
||||
$retweeted_status["user"] = DI::twitterUser()->createFromContactId($retweeted_item['author-id'], api_user())->toArray();
|
||||
$retweeted_status["user"] = DI::twitterUser()->createFromContactId($retweeted_item['author-id'], BaseApi::getCurrentUserID())->toArray();
|
||||
} catch (BadRequestException $e) {
|
||||
// user not found. should be found?
|
||||
/// @todo check if the user should be always found
|
||||
|
@ -2721,7 +2721,7 @@ function api_lists_ownerships($type)
|
|||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
|
||||
// params
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
$uid = $user_info['uid'];
|
||||
|
||||
$groups = DBA::select('group', [], ['deleted' => 0, 'uid' => $uid]);
|
||||
|
@ -2765,7 +2765,7 @@ function api_lists_statuses($type)
|
|||
{
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
unset($_REQUEST["user_id"]);
|
||||
unset($_GET["user_id"]);
|
||||
|
@ -2789,7 +2789,7 @@ function api_lists_statuses($type)
|
|||
|
||||
$groups = DBA::selectToArray('group_member', ['contact-id'], ['gid' => 1]);
|
||||
$gids = array_column($groups, 'contact-id');
|
||||
$condition = ['uid' => api_user(), 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'group-id' => $gids];
|
||||
$condition = ['uid' => BaseApi::getCurrentUserID(), 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'group-id' => $gids];
|
||||
$condition = DBA::mergeConditions($condition, ["`id` > ?", $since_id]);
|
||||
|
||||
if ($max_id > 0) {
|
||||
|
@ -2806,7 +2806,7 @@ function api_lists_statuses($type)
|
|||
}
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser(api_user(), [], $condition, $params);
|
||||
$statuses = Post::selectForUser(BaseApi::getCurrentUserID(), [], $condition, $params);
|
||||
|
||||
$items = api_format_items(Post::toArray($statuses), $user_info, false, $type);
|
||||
|
||||
|
@ -2849,7 +2849,7 @@ function api_statuses_f($qtype)
|
|||
|
||||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
if (!empty($_GET['cursor']) && $_GET['cursor'] == 'undefined') {
|
||||
/* this is to stop Hotot to load friends multiple times
|
||||
|
@ -2892,14 +2892,14 @@ function api_statuses_f($qtype)
|
|||
$sql_extra
|
||||
ORDER BY `nick`
|
||||
LIMIT ?, ?",
|
||||
api_user(),
|
||||
BaseApi::getCurrentUserID(),
|
||||
$start,
|
||||
$count
|
||||
));
|
||||
|
||||
$ret = [];
|
||||
foreach ($r as $cid) {
|
||||
$user = DI::twitterUser()->createFromContactId($cid['id'], api_user())->toArray();
|
||||
$user = DI::twitterUser()->createFromContactId($cid['id'], BaseApi::getCurrentUserID())->toArray();
|
||||
// "uid" and "self" are only needed for some internal stuff, so remove it from here
|
||||
unset($user["uid"]);
|
||||
unset($user["self"]);
|
||||
|
@ -3025,7 +3025,7 @@ function api_direct_messages_new($type)
|
|||
{
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
|
||||
|
||||
$uid = api_user();
|
||||
$uid = BaseApi::getCurrentUserID();
|
||||
if (empty($uid)) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
|
@ -3038,7 +3038,7 @@ function api_direct_messages_new($type)
|
|||
|
||||
$recipient = null;
|
||||
if (!empty($_POST['screen_name'])) {
|
||||
$contacts = Contact::selectToArray(['id', 'nurl', 'network'], ['uid' => api_user(), 'nick' => $_POST['screen_name']]);
|
||||
$contacts = Contact::selectToArray(['id', 'nurl', 'network'], ['uid' => BaseApi::getCurrentUserID(), 'nick' => $_POST['screen_name']]);
|
||||
if (DBA::isResult($contacts)) {
|
||||
// Selecting the id by priority, friendica first
|
||||
api_best_nickname($contacts);
|
||||
|
@ -3055,7 +3055,7 @@ function api_direct_messages_new($type)
|
|||
|
||||
$replyto = '';
|
||||
if (!empty($_REQUEST['replyto'])) {
|
||||
$mail = DBA::selectFirst('mail', ['parent-uri', 'title'], ['uid' => api_user(), 'id' => $_REQUEST['replyto']]);
|
||||
$mail = DBA::selectFirst('mail', ['parent-uri', 'title'], ['uid' => BaseApi::getCurrentUserID(), 'id' => $_REQUEST['replyto']]);
|
||||
$replyto = $mail['parent-uri'];
|
||||
$sub = $mail['title'];
|
||||
} else {
|
||||
|
@ -3108,7 +3108,7 @@ function api_direct_messages_destroy($type)
|
|||
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
|
||||
|
||||
// params
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
//required
|
||||
$id = $_REQUEST['id'] ?? 0;
|
||||
// optional
|
||||
|
@ -3174,7 +3174,7 @@ api_register_func('api/direct_messages/destroy', 'api_direct_messages_destroy',
|
|||
*/
|
||||
function api_friendships_destroy($type)
|
||||
{
|
||||
$uid = api_user();
|
||||
$uid = BaseApi::getCurrentUserID();
|
||||
|
||||
if ($uid === false) {
|
||||
throw new HTTPException\ForbiddenException();
|
||||
|
@ -3275,7 +3275,7 @@ function api_direct_messages_box($type, $box, $verbose)
|
|||
unset($_REQUEST["screen_name"]);
|
||||
unset($_GET["screen_name"]);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
$profile_url = $user_info["url"];
|
||||
|
||||
|
@ -3307,7 +3307,7 @@ function api_direct_messages_box($type, $box, $verbose)
|
|||
|
||||
$r = DBA::toArray(DBA::p(
|
||||
"SELECT `mail`.*, `contact`.`nurl` AS `contact-url` FROM `mail`,`contact` WHERE `mail`.`contact-id` = `contact`.`id` AND `mail`.`uid` = ? AND $sql_extra AND `mail`.`id` > ? ORDER BY `mail`.`id` DESC LIMIT ?,?",
|
||||
api_user(),
|
||||
BaseApi::getCurrentUserID(),
|
||||
$since_id,
|
||||
$start,
|
||||
$count
|
||||
|
@ -3321,9 +3321,9 @@ function api_direct_messages_box($type, $box, $verbose)
|
|||
foreach ($r as $item) {
|
||||
if ($box == "inbox" || $item['from-url'] != $profile_url) {
|
||||
$recipient = $user_info;
|
||||
$sender = DI::twitterUser()->createFromContactId($item['contact-id'], api_user())->toArray();
|
||||
$sender = DI::twitterUser()->createFromContactId($item['contact-id'], BaseApi::getCurrentUserID())->toArray();
|
||||
} elseif ($box == "sentbox" || $item['from-url'] == $profile_url) {
|
||||
$recipient = DI::twitterUser()->createFromContactId($item['contact-id'], api_user())->toArray();
|
||||
$recipient = DI::twitterUser()->createFromContactId($item['contact-id'], BaseApi::getCurrentUserID())->toArray();
|
||||
$sender = $user_info;
|
||||
}
|
||||
|
||||
|
@ -3421,7 +3421,7 @@ api_register_func('api/direct_messages', 'api_direct_messages_inbox', true);
|
|||
*/
|
||||
function api_fr_photos_list($type)
|
||||
{
|
||||
if (api_user() === false) {
|
||||
if (BaseApi::getCurrentUserID() === false) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
$r = DBA::toArray(DBA::p(
|
||||
|
@ -3472,7 +3472,7 @@ function api_fr_photos_list($type)
|
|||
*/
|
||||
function api_fr_photo_create_update($type)
|
||||
{
|
||||
if (api_user() === false) {
|
||||
if (BaseApi::getCurrentUserID() === false) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
// input params
|
||||
|
@ -3507,7 +3507,7 @@ function api_fr_photo_create_update($type)
|
|||
$mode = "update";
|
||||
|
||||
// check if photo is existing in databasei
|
||||
if (!Photo::exists(['resource-id' => $photo_id, 'uid' => api_user(), 'album' => $album])) {
|
||||
if (!Photo::exists(['resource-id' => $photo_id, 'uid' => BaseApi::getCurrentUserID(), 'album' => $album])) {
|
||||
throw new BadRequestException("photo not available");
|
||||
}
|
||||
}
|
||||
|
@ -3569,7 +3569,7 @@ function api_fr_photo_create_update($type)
|
|||
$result = false;
|
||||
if (count($updated_fields) > 0) {
|
||||
$nothingtodo = false;
|
||||
$result = Photo::update($updated_fields, ['uid' => api_user(), 'resource-id' => $photo_id, 'album' => $album]);
|
||||
$result = Photo::update($updated_fields, ['uid' => BaseApi::getCurrentUserID(), 'resource-id' => $photo_id, 'album' => $album]);
|
||||
} else {
|
||||
$nothingtodo = true;
|
||||
}
|
||||
|
@ -3610,7 +3610,7 @@ function api_fr_photo_create_update($type)
|
|||
*/
|
||||
function api_fr_photo_detail($type)
|
||||
{
|
||||
if (api_user() === false) {
|
||||
if (BaseApi::getCurrentUserID() === false) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
if (empty($_REQUEST['photo_id'])) {
|
||||
|
@ -3642,7 +3642,7 @@ function api_fr_photo_detail($type)
|
|||
*/
|
||||
function api_account_update_profile_image($type)
|
||||
{
|
||||
if (api_user() === false) {
|
||||
if (BaseApi::getCurrentUserID() === false) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
// input params
|
||||
|
@ -3655,7 +3655,7 @@ function api_account_update_profile_image($type)
|
|||
|
||||
// check if specified profile id is valid
|
||||
if ($profile_id != 0) {
|
||||
$profile = DBA::selectFirst('profile', ['is-default'], ['uid' => api_user(), 'id' => $profile_id]);
|
||||
$profile = DBA::selectFirst('profile', ['is-default'], ['uid' => BaseApi::getCurrentUserID(), 'id' => $profile_id]);
|
||||
// error message if specified profile id is not in database
|
||||
if (!DBA::isResult($profile)) {
|
||||
throw new BadRequestException("profile_id not available");
|
||||
|
@ -3691,18 +3691,18 @@ function api_account_update_profile_image($type)
|
|||
|
||||
// change specified profile or all profiles to the new resource-id
|
||||
if ($is_default_profile) {
|
||||
$condition = ["`profile` AND `resource-id` != ? AND `uid` = ?", $data['photo']['id'], api_user()];
|
||||
$condition = ["`profile` AND `resource-id` != ? AND `uid` = ?", $data['photo']['id'], BaseApi::getCurrentUserID()];
|
||||
Photo::update(['profile' => false, 'photo-type' => Photo::DEFAULT], $condition);
|
||||
} else {
|
||||
$fields = ['photo' => DI::baseUrl() . '/photo/' . $data['photo']['id'] . '-4.' . $fileext,
|
||||
'thumb' => DI::baseUrl() . '/photo/' . $data['photo']['id'] . '-5.' . $fileext];
|
||||
DBA::update('profile', $fields, ['id' => $_REQUEST['profile'], 'uid' => api_user()]);
|
||||
DBA::update('profile', $fields, ['id' => $_REQUEST['profile'], 'uid' => BaseApi::getCurrentUserID()]);
|
||||
}
|
||||
|
||||
Contact::updateSelfFromUserID(api_user(), true);
|
||||
Contact::updateSelfFromUserID(BaseApi::getCurrentUserID(), true);
|
||||
|
||||
// Update global directory in background
|
||||
Profile::publishUpdate(api_user());
|
||||
Profile::publishUpdate(BaseApi::getCurrentUserID());
|
||||
|
||||
// output for client
|
||||
if ($data) {
|
||||
|
@ -3736,9 +3736,9 @@ function api_account_update_profile($type)
|
|||
{
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
|
||||
|
||||
$local_user = api_user();
|
||||
$local_user = BaseApi::getCurrentUserID();
|
||||
|
||||
$api_user = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$api_user = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
if (!empty($_POST['name'])) {
|
||||
DBA::update('profile', ['name' => $_POST['name']], ['uid' => $local_user]);
|
||||
|
@ -3783,7 +3783,7 @@ function check_acl_input($acl_string)
|
|||
foreach ($cid_array as $cid) {
|
||||
$cid = str_replace("<", "", $cid);
|
||||
$cid = str_replace(">", "", $cid);
|
||||
$condition = ['id' => $cid, 'uid' => api_user()];
|
||||
$condition = ['id' => $cid, 'uid' => BaseApi::getCurrentUserID()];
|
||||
$contact_not_found |= !DBA::exists('contact', $condition);
|
||||
}
|
||||
return $contact_not_found;
|
||||
|
@ -3962,12 +3962,12 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $
|
|||
function post_photo_item($hash, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $filetype, $visibility = false)
|
||||
{
|
||||
// get data about the api authenticated user
|
||||
$uri = Item::newURI(intval(api_user()));
|
||||
$owner_record = DBA::selectFirst('contact', [], ['uid' => api_user(), 'self' => true]);
|
||||
$uri = Item::newURI(intval(BaseApi::getCurrentUserID()));
|
||||
$owner_record = DBA::selectFirst('contact', [], ['uid' => BaseApi::getCurrentUserID(), 'self' => true]);
|
||||
|
||||
$arr = [];
|
||||
$arr['guid'] = System::createUUID();
|
||||
$arr['uid'] = intval(api_user());
|
||||
$arr['uid'] = intval(BaseApi::getCurrentUserID());
|
||||
$arr['uri'] = $uri;
|
||||
$arr['type'] = 'photo';
|
||||
$arr['wall'] = 1;
|
||||
|
@ -4020,7 +4020,7 @@ function prepare_photo_data($type, $scale, $photo_id)
|
|||
{
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
$scale_sql = ($scale === false ? "" : sprintf("AND scale=%d", intval($scale)));
|
||||
$data_sql = ($scale === false ? "" : "data, ");
|
||||
|
@ -4077,7 +4077,7 @@ function prepare_photo_data($type, $scale, $photo_id)
|
|||
}
|
||||
|
||||
// retrieve item element for getting activities (like, dislike etc.) related to photo
|
||||
$condition = ['uid' => api_user(), 'resource-id' => $photo_id];
|
||||
$condition = ['uid' => BaseApi::getCurrentUserID(), 'resource-id' => $photo_id];
|
||||
$item = Post::selectFirst(['id', 'uid', 'uri', 'parent', 'allow_cid', 'deny_cid', 'allow_gid', 'deny_gid'], $condition);
|
||||
if (!DBA::isResult($item)) {
|
||||
throw new NotFoundException('Photo-related item not found.');
|
||||
|
@ -4087,9 +4087,9 @@ function prepare_photo_data($type, $scale, $photo_id)
|
|||
|
||||
// retrieve comments on photo
|
||||
$condition = ["`parent` = ? AND `uid` = ? AND `gravity` IN (?, ?)",
|
||||
$item['parent'], api_user(), GRAVITY_PARENT, GRAVITY_COMMENT];
|
||||
$item['parent'], BaseApi::getCurrentUserID(), GRAVITY_PARENT, GRAVITY_COMMENT];
|
||||
|
||||
$statuses = Post::selectForUser(api_user(), [], $condition);
|
||||
$statuses = Post::selectForUser(BaseApi::getCurrentUserID(), [], $condition);
|
||||
|
||||
// prepare output of comments
|
||||
$commentData = api_format_items(Post::toArray($statuses), $user_info, false, $type);
|
||||
|
@ -4312,7 +4312,7 @@ function api_friendica_group_show($type)
|
|||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
|
||||
// params
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
$gid = $_REQUEST['gid'] ?? 0;
|
||||
$uid = $user_info['uid'];
|
||||
|
||||
|
@ -4338,13 +4338,13 @@ function api_friendica_group_show($type)
|
|||
$user_element = "users";
|
||||
$k = 0;
|
||||
foreach ($members as $member) {
|
||||
$user = DI::twitterUser()->createFromContactId($member['contact-id'], api_user())->toArray();
|
||||
$user = DI::twitterUser()->createFromContactId($member['contact-id'], BaseApi::getCurrentUserID())->toArray();
|
||||
$users[$k++.":user"] = $user;
|
||||
}
|
||||
} else {
|
||||
$user_element = "user";
|
||||
foreach ($members as $member) {
|
||||
$user = DI::twitterUser()->createFromContactId($member['contact-id'], api_user())->toArray();
|
||||
$user = DI::twitterUser()->createFromContactId($member['contact-id'], BaseApi::getCurrentUserID())->toArray();
|
||||
$users[] = $user;
|
||||
}
|
||||
}
|
||||
|
@ -4373,7 +4373,7 @@ function api_lists_destroy($type)
|
|||
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
|
||||
|
||||
// params
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
$gid = $_REQUEST['list_id'] ?? 0;
|
||||
$uid = $user_info['uid'];
|
||||
|
||||
|
@ -4474,7 +4474,7 @@ function api_friendica_group_create($type)
|
|||
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
|
||||
|
||||
// params
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
$name = $_REQUEST['name'] ?? '';
|
||||
$uid = $user_info['uid'];
|
||||
$json = json_decode($_POST['json'], true);
|
||||
|
@ -4505,7 +4505,7 @@ function api_lists_create($type)
|
|||
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
|
||||
|
||||
// params
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
$name = $_REQUEST['name'] ?? '';
|
||||
$uid = $user_info['uid'];
|
||||
|
||||
|
@ -4541,7 +4541,7 @@ function api_friendica_group_update($type)
|
|||
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
|
||||
|
||||
// params
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
$uid = $user_info['uid'];
|
||||
$gid = $_REQUEST['gid'] ?? 0;
|
||||
$name = $_REQUEST['name'] ?? '';
|
||||
|
@ -4611,7 +4611,7 @@ function api_lists_update($type)
|
|||
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
|
||||
|
||||
// params
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
$gid = $_REQUEST['list_id'] ?? 0;
|
||||
$name = $_REQUEST['name'] ?? '';
|
||||
$uid = $user_info['uid'];
|
||||
|
@ -4659,7 +4659,7 @@ function api_friendica_notification_seen($type)
|
|||
{
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
|
||||
if (DI::args()->getArgc() !== 4) {
|
||||
throw new BadRequestException('Invalid argument count');
|
||||
|
@ -4669,7 +4669,7 @@ function api_friendica_notification_seen($type)
|
|||
|
||||
try {
|
||||
$Notify = DI::notify()->selectOneById($id);
|
||||
if ($Notify->uid !== api_user()) {
|
||||
if ($Notify->uid !== BaseApi::getCurrentUserID()) {
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
|
@ -4681,7 +4681,7 @@ function api_friendica_notification_seen($type)
|
|||
DI::notify()->save($Notify);
|
||||
|
||||
if ($Notify->otype === Notification\ObjectType::ITEM) {
|
||||
$item = Post::selectFirstForUser(api_user(), [], ['id' => $Notify->iid, 'uid' => api_user()]);
|
||||
$item = Post::selectFirstForUser(BaseApi::getCurrentUserID(), [], ['id' => $Notify->iid, 'uid' => BaseApi::getCurrentUserID()]);
|
||||
if (DBA::isResult($item)) {
|
||||
// we found the item, return it to the user
|
||||
$ret = api_format_items([$item], $user_info, false, $type);
|
||||
|
@ -4721,7 +4721,7 @@ function api_friendica_direct_messages_search($type, $box = "")
|
|||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
|
||||
// params
|
||||
$user_info = DI::twitterUser()->createFromUserId(api_user())->toArray();
|
||||
$user_info = DI::twitterUser()->createFromUserId(BaseApi::getCurrentUserID())->toArray();
|
||||
$searchstring = $_REQUEST['searchstring'] ?? '';
|
||||
$uid = $user_info['uid'];
|
||||
|
||||
|
@ -4750,9 +4750,9 @@ function api_friendica_direct_messages_search($type, $box = "")
|
|||
foreach ($r as $item) {
|
||||
if ($box == "inbox" || $item['from-url'] != $profile_url) {
|
||||
$recipient = $user_info;
|
||||
$sender = DI::twitterUser()->createFromContactId($item['contact-id'], api_user())->toArray();
|
||||
$sender = DI::twitterUser()->createFromContactId($item['contact-id'], BaseApi::getCurrentUserID())->toArray();
|
||||
} elseif ($box == "sentbox" || $item['from-url'] == $profile_url) {
|
||||
$recipient = DI::twitterUser()->createFromContactId($item['contact-id'], api_user())->toArray();
|
||||
$recipient = DI::twitterUser()->createFromContactId($item['contact-id'], BaseApi::getCurrentUserID())->toArray();
|
||||
$sender = $user_info;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue