* @todo Automatically detect if incoming data is HTML or BBCode
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Core\System;
use Friendica\Core\Config;
require_once 'mod/share.php';
require_once 'mod/item.php';
require_once 'include/security.php';
-require_once 'include/contact_selectors.php';
require_once 'include/html2bbcode.php';
require_once 'mod/wall_upload.php';
require_once 'mod/proxy.php';
} else {
$user_id = User::authenticate(trim($user), trim($password));
if ($user_id) {
- $record = dba::select('user', [], ['uid' => $user_id], ['limit' => 1]);
+ $record = dba::selectOne('user', [], ['uid' => $user_id]);
}
}
logger('API parameters: ' . print_r($_REQUEST, true));
$stamp = microtime(true);
- $r = call_user_func($info['func'], $type);
+ $return = call_user_func($info['func'], $type);
$duration = (float) (microtime(true) - $stamp);
logger("API call duration: " . round($duration, 2) . "\t" . $a->query_string, LOGGER_DEBUG);
}
}
- if (false === $r) {
+ if (false === $return) {
/*
* api function returned false withour throw an
* exception. This should not happend, throw a 500
switch ($type) {
case "xml":
header("Content-Type: text/xml");
- return $r;
break;
case "json":
header("Content-Type: application/json");
- foreach ($r as $rr) {
+ foreach ($return as $rr) {
$json = json_encode($rr);
}
if (x($_GET, 'callback')) {
$json = $_GET['callback'] . "(" . $json . ")";
}
- return $json;
+ $return = $json;
break;
case "rss":
header("Content-Type: application/rss+xml");
- return '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . $r;
+ $return = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . $return;
break;
case "atom":
header("Content-Type: application/atom+xml");
- return '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . $r;
+ $return = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . $return;
break;
}
+ return $return;
}
}
"code" => $e->httpcode . " " . $e->httpdesc,
"request" => $a->query_string);
- $ret = api_format_data('status', $type, array('status' => $error));
+ $return = api_format_data('status', $type, array('status' => $error));
switch ($type) {
case "xml":
header("Content-Type: text/xml");
- return $ret;
break;
case "json":
header("Content-Type: application/json");
- return json_encode($ret);
+ $return = json_encode($return);
break;
case "rss":
header("Content-Type: application/rss+xml");
- return $ret;
break;
case "atom":
header("Content-Type: application/atom+xml");
- return $ret;
break;
}
+
+ return $return;
}
/**
*/
function api_unique_id_to_nurl($id)
{
- $r = dba::select('contact', array('nurl'), array('uid' => 0, 'id' => $id), array('limit' => 1));
+ $r = dba::selectOne('contact', array('nurl'), array('uid' => 0, 'id' => $id));
if (DBM::is_result($r)) {
return $r["nurl"];
$user = null;
$extra_query = "";
$url = "";
- $nick = "";
logger("api_get_user: Fetching user data for user ".$contact_id, LOGGER_DEBUG);
}
if (is_null($user) && x($_GET, 'screen_name')) {
$user = dbesc($_GET['screen_name']);
- $nick = $user;
$extra_query = "AND `contact`.`nick` = '%s' ";
if (api_user() !== false) {
$extra_query .= "AND `contact`.`uid`=".intval(api_user());
if (is_null($user) && x($_GET, 'profileurl')) {
$user = dbesc(normalise_link($_GET['profileurl']));
- $nick = $user;
$extra_query = "AND `contact`.`nurl` = '%s' ";
if (api_user() !== false) {
$extra_query .= "AND `contact`.`uid`=".intval(api_user());
}
} else {
$user = dbesc($user);
- $nick = $user;
$extra_query = "AND `contact`.`nick` = '%s' ";
if (api_user() !== false) {
$extra_query .= "AND `contact`.`uid`=" . intval(api_user());
}
if (DBM::is_result($r)) {
- $network_name = network_to_name($r[0]['network'], $r[0]['url']);
+ $network_name = ContactSelector::networkToName($r[0]['network'], $r[0]['url']);
// If no nick where given, extract it from the address
if (($r[0]['nick'] == "") || ($r[0]['name'] == $r[0]['nick'])) {
$uinfo[0]['nick'] = api_get_nick($uinfo[0]["url"]);
}
- $network_name = network_to_name($uinfo[0]['network'], $uinfo[0]['url']);
+ $network_name = ContactSelector::networkToName($uinfo[0]['network'], $uinfo[0]['url']);
$pcontact_id = Contact::getIdForURL($uinfo[0]['url'], 0, true);
// If this is a local user and it uses Frio, we can get its color preferences.
if ($ret['self']) {
- $theme_info = dba::select('user', ['theme'], ['uid' => $ret['uid']], ['limit' => 1]);
+ $theme_info = dba::selectOne('user', ['theme'], ['uid' => $ret['uid']]);
if ($theme_info['theme'] === 'frio') {
$schema = PConfig::get($ret['uid'], 'frio', 'schema');
if ($schema && ($schema != '---')) {
return api_format_data("user", $type, array('user' => $user_info));
}
-/// @TODO move to top of file or somwhere better
+/// @TODO move to top of file or somewhere better
api_register_func('api/account/verify_credentials', 'api_account_verify_credentials', true);
/**
throw new ForbiddenException();
}
- $user_info = api_get_user($a);
+ api_get_user($a);
// convert $_POST array items to the form we use for web posts.
-
- // logger('api_post: ' . print_r($_POST,true));
-
if (requestdata('htmlstatus')) {
$txt = requestdata('htmlstatus');
if ((strpos($txt, '<') !== false) || (strpos($txt, '>') !== false)) {
return api_status_show($type);
}
-/// @TODO move to top of file or somwhere better
+/// @TODO move to top of file or somewhere better
api_register_func('api/statuses/update', 'api_statuses_update', true, API_METHOD_POST);
api_register_func('api/statuses/update_with_media', 'api_statuses_update', true, API_METHOD_POST);
/**
* Uploads an image to Friendica.
*
- * @param string $type Return type (atom, rss, xml, json)
- *
* @return array
* @see https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload
*/
-function api_media_upload($type)
+function api_media_upload()
{
$a = get_app();
throw new ForbiddenException();
}
- $user_info = api_get_user($a);
+ api_get_user($a);
if (!x($_FILES, 'media')) {
// Output error
return array("media" => $returndata);
}
-/// @TODO move to top of file or somwhere better
+/// @TODO move to top of file or somewhere better
api_register_func('api/media/upload', 'api_media_upload', true, API_METHOD_POST);
/**
}
if (($lastwall['item_network'] != "") && ($status["source"] == 'web')) {
- $status_info["source"] = network_to_name($lastwall['item_network'], $user_info['url']);
- } elseif (($lastwall['item_network'] != "") && (network_to_name($lastwall['item_network'], $user_info['url']) != $status_info["source"])) {
- $status_info["source"] = trim($status_info["source"].' ('.network_to_name($lastwall['item_network'], $user_info['url']).')');
+ $status_info["source"] = ContactSelector::networkToName($lastwall['item_network'], $user_info['url']);
+ } elseif (($lastwall['item_network'] != "") && (ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) != $status_info["source"])) {
+ $status_info["source"] = trim($status_info["source"].' ('.ContactSelector::networkToName($lastwall['item_network'], $user_info['url']).')');
}
// "uid" and "self" are only needed for some internal stuff, so remove it from here
}
if (($lastwall['item_network'] != "") && ($user_info["status"]["source"] == 'web')) {
- $user_info["status"]["source"] = network_to_name($lastwall['item_network'], $user_info['url']);
+ $user_info["status"]["source"] = ContactSelector::networkToName($lastwall['item_network'], $user_info['url']);
}
- if (($lastwall['item_network'] != "") && (network_to_name($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) {
- $user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . network_to_name($lastwall['item_network'], $user_info['url']) . ')');
+ if (($lastwall['item_network'] != "") && (ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) {
+ $user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) . ')');
}
}
{
$a = get_app();
- $page = (x($_REQUEST, 'page') ? $_REQUEST['page'] - 1 : 0);
-
$userlist = array();
if (x($_GET, 'q')) {
} else {
throw new BadRequestException("User not found.");
}
+
return api_format_data("users", $type, $userlist);
}
$unseen = q("SELECT `id` FROM `item` WHERE `unseen` AND `id` IN (%s)", $idlist);
if ($unseen) {
- $r = q("UPDATE `item` SET `unseen` = 0 WHERE `unseen` AND `id` IN (%s)", $idlist);
+ q("UPDATE `item` SET `unseen` = 0 WHERE `unseen` AND `id` IN (%s)", $idlist);
}
}
throw new ForbiddenException();
}
- $user_info = api_get_user($a);
+ api_get_user($a);
// params
$id = intval($a->argv[3]);
throw new ForbiddenException();
}
- $user_info = api_get_user($a);
+ api_get_user($a);
// params
$id = intval($a->argv[3]);
// params
- $count = (x($_REQUEST, 'count') ? $_REQUEST['count'] : 20);
- $page = (x($_REQUEST, 'page') ? $_REQUEST['page'] -1 : 0);
- if ($page < 0) {
- $page = 0;
+ $since_id = defaults($_REQUEST, 'since_id', 0);
+ $max_id = defaults($_REQUEST, 'max_id' , 0);
+ $count = defaults($_REQUEST, 'count' , 20);
+ $page = defaults($_REQUEST, 'page' , 1);
+ if ($page < 1) {
+ $page = 1;
}
- $since_id = (x($_REQUEST, 'since_id') ? $_REQUEST['since_id'] : 0);
- $max_id = (x($_REQUEST, 'max_id') ? $_REQUEST['max_id'] : 0);
- //$since_id = 0;//$since_id = (x($_REQUEST, 'since_id')?$_REQUEST['since_id'] : 0);
- $start = $page * $count;
+ $start = ($page - 1) * $count;
// Ugly code - should be changed
$myurl = System::baseUrl() . '/profile/'. $a->user['nickname'];
$myurl = substr($myurl, strpos($myurl, '://') + 3);
- //$myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
$myurl = str_replace('www.', '', $myurl);
- $diasp_url = str_replace('/profile/', '/u/', $myurl);
if ($max_id > 0) {
$sql_extra = ' AND `item`.`id` <= ' . intval($max_id);
return api_format_data("statuses", $type, $data);
}
-/// @TODO move to top of file or somwhere better
+/// @TODO move to top of file or somewhere better
api_register_func('api/statuses/user_timeline', 'api_statuses_user_timeline', true);
/**
return api_format_data("status", $type, $data);
}
-/// @TODO move to top of file or somwhere better
+/// @TODO move to top of file or somewhere better
api_register_func('api/favorites/create', 'api_favorites_create_destroy', true, API_METHOD_POST);
api_register_func('api/favorites/destroy', 'api_favorites_create_destroy', true, API_METHOD_DELETE);
return api_format_data("statuses", $type, $data);
}
-/// @TODO move to top of file or somwhere better
+/// @TODO move to top of file or somewhere better
api_register_func('api/favorites', 'api_favorites', true);
/**
*
* @param string $body
*
- * @return array
+ * @return array|false
*/
function api_get_attachments(&$body)
{
*/
function api_get_entitities(&$text, $bbcode)
{
- $a = get_app();
-
$include_entities = strtolower(x($_REQUEST, 'include_entities') ? $_REQUEST['include_entities'] : "false");
if ($include_entities != "true") {
*
* @return string
*/
-function api_format_items_embeded_images(&$item, $text)
+function api_format_items_embeded_images($item, $text)
{
$text = preg_replace_callback(
- "|data:image/([^;]+)[^=]+=*|m",
- function ($match) use ($item) {
- return System::baseUrl()."/display/".$item['guid'];
+ '|data:image/([^;]+)[^=]+=*|m',
+ function () use ($item) {
+ return System::baseUrl() . '/display/' . $item['guid'];
},
$text
);
return $text;
}
-
/**
* @brief return <a href='url'>name</a> as array
*
/**
* @brief return data from profiles
*
- * @param array $profile array containing data from db table 'profile'
- * @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
+ * @param array $profile_row array containing data from db table 'profile'
* @return array
*/
-function api_format_items_profiles(&$profile = null, $type = "json")
+function api_format_items_profiles($profile_row)
{
- if ($profile != null) {
- $profile = array('profile_id' => $profile['id'],
- 'profile_name' => $profile['profile-name'],
- 'is_default' => $profile['is-default'] ? true : false,
- 'hide_friends'=> $profile['hide-friends'] ? true : false,
- 'profile_photo' => $profile['photo'],
- 'profile_thumb' => $profile['thumb'],
- 'publish' => $profile['publish'] ? true : false,
- 'net_publish' => $profile['net-publish'] ? true : false,
- 'description' => $profile['pdesc'],
- 'date_of_birth' => $profile['dob'],
- 'address' => $profile['address'],
- 'city' => $profile['locality'],
- 'region' => $profile['region'],
- 'postal_code' => $profile['postal-code'],
- 'country' => $profile['country-name'],
- 'hometown' => $profile['hometown'],
- 'gender' => $profile['gender'],
- 'marital' => $profile['marital'],
- 'marital_with' => $profile['with'],
- 'marital_since' => $profile['howlong'],
- 'sexual' => $profile['sexual'],
- 'politic' => $profile['politic'],
- 'religion' => $profile['religion'],
- 'public_keywords' => $profile['pub_keywords'],
- 'private_keywords' => $profile['prv_keywords'],
- 'likes' => bbcode(api_clean_plain_items($profile['likes']), false, false, 2, false),
- 'dislikes' => bbcode(api_clean_plain_items($profile['dislikes']), false, false, 2, false),
- 'about' => bbcode(api_clean_plain_items($profile['about']), false, false, 2, false),
- 'music' => bbcode(api_clean_plain_items($profile['music']), false, false, 2, false),
- 'book' => bbcode(api_clean_plain_items($profile['book']), false, false, 2, false),
- 'tv' => bbcode(api_clean_plain_items($profile['tv']), false, false, 2, false),
- 'film' => bbcode(api_clean_plain_items($profile['film']), false, false, 2, false),
- 'interest' => bbcode(api_clean_plain_items($profile['interest']), false, false, 2, false),
- 'romance' => bbcode(api_clean_plain_items($profile['romance']), false, false, 2, false),
- 'work' => bbcode(api_clean_plain_items($profile['work']), false, false, 2, false),
- 'education' => bbcode(api_clean_plain_items($profile['education']), false, false, 2, false),
- 'social_networks' => bbcode(api_clean_plain_items($profile['contact']), false, false, 2, false),
- 'homepage' => $profile['homepage'],
- 'users' => null);
- return $profile;
- }
+ $profile = array(
+ 'profile_id' => $profile_row['id'],
+ 'profile_name' => $profile_row['profile-name'],
+ 'is_default' => $profile_row['is-default'] ? true : false,
+ 'hide_friends' => $profile_row['hide-friends'] ? true : false,
+ 'profile_photo' => $profile_row['photo'],
+ 'profile_thumb' => $profile_row['thumb'],
+ 'publish' => $profile_row['publish'] ? true : false,
+ 'net_publish' => $profile_row['net-publish'] ? true : false,
+ 'description' => $profile_row['pdesc'],
+ 'date_of_birth' => $profile_row['dob'],
+ 'address' => $profile_row['address'],
+ 'city' => $profile_row['locality'],
+ 'region' => $profile_row['region'],
+ 'postal_code' => $profile_row['postal-code'],
+ 'country' => $profile_row['country-name'],
+ 'hometown' => $profile_row['hometown'],
+ 'gender' => $profile_row['gender'],
+ 'marital' => $profile_row['marital'],
+ 'marital_with' => $profile_row['with'],
+ 'marital_since' => $profile_row['howlong'],
+ 'sexual' => $profile_row['sexual'],
+ 'politic' => $profile_row['politic'],
+ 'religion' => $profile_row['religion'],
+ 'public_keywords' => $profile_row['pub_keywords'],
+ 'private_keywords' => $profile_row['prv_keywords'],
+ 'likes' => bbcode(api_clean_plain_items($profile_row['likes']) , false, false, 2, false),
+ 'dislikes' => bbcode(api_clean_plain_items($profile_row['dislikes']) , false, false, 2, false),
+ 'about' => bbcode(api_clean_plain_items($profile_row['about']) , false, false, 2, false),
+ 'music' => bbcode(api_clean_plain_items($profile_row['music']) , false, false, 2, false),
+ 'book' => bbcode(api_clean_plain_items($profile_row['book']) , false, false, 2, false),
+ 'tv' => bbcode(api_clean_plain_items($profile_row['tv']) , false, false, 2, false),
+ 'film' => bbcode(api_clean_plain_items($profile_row['film']) , false, false, 2, false),
+ 'interest' => bbcode(api_clean_plain_items($profile_row['interest']) , false, false, 2, false),
+ 'romance' => bbcode(api_clean_plain_items($profile_row['romance']) , false, false, 2, false),
+ 'work' => bbcode(api_clean_plain_items($profile_row['work']) , false, false, 2, false),
+ 'education' => bbcode(api_clean_plain_items($profile_row['education']), false, false, 2, false),
+ 'social_networks' => bbcode(api_clean_plain_items($profile_row['contact']) , false, false, 2, false),
+ 'homepage' => $profile_row['homepage'],
+ 'users' => null
+ );
+ return $profile;
}
/**
}
if (($item['item_network'] != "") && ($status["source"] == 'web')) {
- $status["source"] = network_to_name($item['item_network'], $user_info['url']);
- } elseif (($item['item_network'] != "") && (network_to_name($item['item_network'], $user_info['url']) != $status["source"])) {
- $status["source"] = trim($status["source"].' ('.network_to_name($item['item_network'], $user_info['url']).')');
+ $status["source"] = ContactSelector::networkToName($item['item_network'], $user_info['url']);
+ } elseif (($item['item_network'] != "") && (ContactSelector::networkToName($item['item_network'], $user_info['url']) != $status["source"])) {
+ $status["source"] = trim($status["source"].' ('.ContactSelector::networkToName($item['item_network'], $user_info['url']).')');
}
return api_format_data('hash', $type, array('hash' => $hash));
}
-/// @TODO move to top of file or somwhere better
+/// @TODO move to top of file or somewhere better
api_register_func('api/account/rate_limit_status', 'api_account_rate_limit_status', true);
/**
return api_format_data('ok', $type, array("ok" => $ok));
}
-/// @TODO move to top of file or somwhere better
+/// @TODO move to top of file or somewhere better
api_register_func('api/help/test', 'api_help_test', false);
/**
return api_format_data('lists', $type, array("lists_list" => $ret));
}
-/// @TODO move to top of file or somwhere better
+/// @TODO move to top of file or somewhere better
api_register_func('api/lists', 'api_lists', true);
/**
return api_format_data('lists', $type, array("lists_list" => $ret));
}
-/// @TODO move to top of file or somwhere better
+/// @TODO move to top of file or somewhere better
api_register_func('api/lists/list', 'api_lists_list', true);
/**
/**
*
* @param string $type Return type (atom, rss, xml, json)
- * @param string $qtype
*
* @todo use api_format_data() to return data
*/
-function api_ff_ids($type, $qtype)
+function api_ff_ids($type)
{
- $a = get_app();
-
if (! api_user()) {
throw new ForbiddenException();
}
- $user_info = api_get_user($a);
+ api_get_user($a);
- $stringify_ids = (x($_REQUEST, 'stringify_ids') ? $_REQUEST['stringify_ids'] : false);
+ $stringify_ids = defaults($_REQUEST, 'stringify_ids', false);
$r = q(
"SELECT `pcontact`.`id` FROM `contact`
WHERE `contact`.`uid` = %s AND NOT `contact`.`self`",
intval(api_user())
);
-
if (!DBM::is_result($r)) {
return;
}
*/
function api_friends_ids($type)
{
- return api_ff_ids($type, 'friends');
+ return api_ff_ids($type);
}
/**
*/
function api_followers_ids($type)
{
- return api_ff_ids($type, 'followers');
+ return api_ff_ids($type);
}
/// @TODO move to top of file or somewhere better
/**
* Returns an OAuth Request Token.
*
- * @param string $type Return type (atom, rss, xml, json)
* @see https://oauth.net/core/1.0/#auth_step1
*/
-function api_oauth_request_token($type)
+function api_oauth_request_token()
{
$oauth1 = new FKOAuth1();
try {
/**
* Returns an OAuth Access Token.
*
- * @param string $type Return type (atom, rss, xml, json)
- *
* @return array|string
* @see https://oauth.net/core/1.0/#auth_step3
*/
-function api_oauth_access_token($type)
+function api_oauth_access_token()
{
$oauth1 = new FKOAuth1();
try {
* @brief returns the details of a specified photo id, if scale is given, returns the photo data in base 64
*
* @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
- * @return string
+ * @return string|array
*/
function api_fr_photo_detail($type)
{
throw new ForbiddenException();
}
// input params
- $profileid = (x($_REQUEST, 'profile_id') ? $_REQUEST['profile_id'] : 0);
+ $profileid = defaults($_REQUEST, 'profile_id', 0);
// error if image data is missing
if (!x($_FILES, 'image')) {
}
// change specified profile or all profiles to the new resource-id
if ($is_default_profile) {
- $r = q(
+ q(
"UPDATE `photo` SET `profile` = 0 WHERE `profile` = 1 AND `resource-id` != '%s' AND `uid` = %d",
dbesc($data['photo']['id']),
intval(local_user())
);
- $r = q(
+ q(
"UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `self` AND `uid` = %d",
dbesc(System::baseUrl() . '/photo/' . $data['photo']['id'] . '-4.' . $fileext),
dbesc(System::baseUrl() . '/photo/' . $data['photo']['id'] . '-5.' . $fileext),
intval(local_user())
);
} else {
- $r = q(
+ q(
"UPDATE `profile` SET `photo` = '%s', `thumb` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc(System::baseUrl() . '/photo/' . $data['photo']['id'] . '-4.' . $filetype),
dbesc(System::baseUrl() . '/photo/' . $data['photo']['id'] . '-5.' . $filetype),
// we'll set the updated profile-photo timestamp even if it isn't the default profile,
// so that browsers will do a cache update unconditionally
- $r = q(
+ q(
"UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
dbesc(datetime_convert()),
intval(local_user())
api_register_func('api/friendica/photo', 'api_fr_photo_detail', true);
api_register_func('api/account/update_profile_image', 'api_account_update_profile_image', true, API_METHOD_POST);
+/**
+ * Update user profile
+ *
+ * @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
+ *
+ * @return array|string
+ */
+function api_account_update_profile($type)
+{
+ $local_user = api_user();
+ $api_user = api_get_user(get_app());
+
+ if (!empty($_POST['name'])) {
+ dba::update('profile', ['name' => $_POST['name']], ['uid' => $local_user]);
+ dba::update('user', ['username' => $_POST['name']], ['uid' => $local_user]);
+ dba::update('contact', ['name' => $_POST['name']], ['uid' => $local_user, 'self' => 1]);
+ dba::update('contact', ['name' => $_POST['name']], ['id' => $api_user['id']]);
+ }
+
+ if (isset($_POST['description'])) {
+ dba::update('profile', ['about' => $_POST['description']], ['uid' => $local_user]);
+ dba::update('contact', ['about' => $_POST['description']], ['uid' => $local_user, 'self' => 1]);
+ dba::update('contact', ['about' => $_POST['description']], ['id' => $api_user['id']]);
+ }
+
+ Worker::add(PRIORITY_LOW, 'ProfileUpdate', $local_user);
+ // Update global directory in background
+ if ($api_user['url'] && strlen(Config::get('system', 'directory'))) {
+ Worker::add(PRIORITY_LOW, "Directory", $api_user['url']);
+ }
+
+ return api_account_verify_credentials($type);
+}
+
+/// @TODO move to top of file or somewhere better
+api_register_func('api/account/update_profile', 'api_account_update_profile', true, API_METHOD_POST);
+
/**
*
* @param string $acl_string
// traditional DFRN
- $r = dba::select('contact', [], ['uid' => api_user(), 'nurl' => $c_url], ['limit' => 1]);
+ $r = dba::selectOne('contact', [], ['uid' => api_user(), 'nurl' => $c_url]);
if (!DBM::is_result($r) || ($r['network'] !== NETWORK_DFRN)) {
throw new BadRequestException("Unknown contact");
$cid = $r['id'];
- $dfrn_id = $orig_id = (($r['issued-id']) ? $r['issued-id'] : $r['dfrn-id']);
+ $dfrn_id = defaults($r, 'issued-id', $r['dfrn-id']);
if ($r['duplex'] && $r['issued-id']) {
$orig_id = $r['issued-id'];
intval($uid)
);
if (count($contact)) {
- $result = Group::addMember($gid, $cid);
+ Group::addMember($gid, $cid);
} else {
$erroraddinguser = true;
$errorusers[] = $cid;
$found = ($user['cid'] == $cid ? true : false);
}
if (!$found) {
- $ret = Group::removeMemberByName($uid, $name, $cid);
+ Group::removeMemberByName($uid, $name, $cid);
}
}
);
if (count($contact)) {
- $result = Group::addMember($gid, $cid);
+ Group::addMember($gid, $cid);
} else {
$erroraddinguser = true;
$errorusers[] = $cid;
}
}
-/// @TODO move to top of file or somwhere better
+/// @TODO move to top of file or somewhere better
api_register_func('api/friendica/activity/like', 'api_friendica_activity', true, API_METHOD_POST);
api_register_func('api/friendica/activity/dislike', 'api_friendica_activity', true, API_METHOD_POST);
api_register_func('api/friendica/activity/attendyes', 'api_friendica_activity', true, API_METHOD_POST);
return api_format_data('result', $type, array('result' => "success"));
}
-/// @TODO move to top of file or somwhere better
+/// @TODO move to top of file or somewhere better
api_register_func('api/friendica/notification/seen', 'api_friendica_notification_seen', true, API_METHOD_POST);
api_register_func('api/friendica/notification', 'api_friendica_notification', true, API_METHOD_GET);
}
}
-/// @TODO move to top of file or somwhere better
+/// @TODO move to top of file or somewhere better
api_register_func('api/friendica/direct_messages_setseen', 'api_friendica_direct_messages_setseen', true);
/**
return api_format_data("direct_message_search", $type, array('$result' => $success));
}
-/// @TODO move to top of file or somwhere better
+/// @TODO move to top of file or somewhere better
api_register_func('api/friendica/direct_messages_search', 'api_friendica_direct_messages_search', true);
/**
// loop through all returned profiles and retrieve data and users
$k = 0;
foreach ($r as $rr) {
- $profile = api_format_items_profiles($rr, $type);
+ $profile = api_format_items_profiles($rr);
// select all users from contact table, loop and prepare standard return for user data
$users = array();
return api_format_data("terms", $type, array('terms' => $result));
}
-/// @TODO move to top of file or somwhere better
+/// @TODO move to top of file or somewhere better
api_register_func('api/saved_searches/list', 'api_saved_searches_list', true);
/*