mirror of
https://github.com/friendica/friendica
synced 2025-04-22 11:10:11 +00:00
Merge remote-tracking branch 'upstream/develop' into parent-view
This commit is contained in:
commit
1129e8f17d
147 changed files with 1736 additions and 1725 deletions
|
@ -131,7 +131,7 @@ class Site extends BaseAdmin
|
|||
$temppath = (!empty($_POST['temppath']) ? trim($_POST['temppath']) : '');
|
||||
$singleuser = (!empty($_POST['singleuser']) ? trim($_POST['singleuser']) : '');
|
||||
$only_tag_search = !empty($_POST['only_tag_search']);
|
||||
$compute_group_counts = !empty($_POST['compute_group_counts']);
|
||||
$compute_circle_counts = !empty($_POST['compute_circle_counts']);
|
||||
$check_new_version_url = (!empty($_POST['check_new_version_url']) ? trim($_POST['check_new_version_url']) : 'none');
|
||||
|
||||
$worker_queues = (!empty($_POST['worker_queues']) ? intval($_POST['worker_queues']) : 10);
|
||||
|
@ -278,7 +278,7 @@ class Site extends BaseAdmin
|
|||
$transactionConfig->set('system', 'temppath', $temppath);
|
||||
|
||||
$transactionConfig->set('system', 'only_tag_search' , $only_tag_search);
|
||||
$transactionConfig->set('system', 'compute_group_counts', $compute_group_counts);
|
||||
$transactionConfig->set('system', 'compute_circle_counts', $compute_circle_counts);
|
||||
|
||||
$transactionConfig->set('system', 'worker_queues' , $worker_queues);
|
||||
$transactionConfig->set('system', 'worker_fastlane' , $worker_fastlane);
|
||||
|
@ -452,7 +452,7 @@ class Site extends BaseAdmin
|
|||
'$block_public' => ['block_public', DI::l10n()->t('Block public'), DI::config()->get('system', 'block_public'), DI::l10n()->t('Check to block public access to all otherwise public personal pages on this site unless you are currently logged in.')],
|
||||
'$force_publish' => ['publish_all', DI::l10n()->t('Force publish'), DI::config()->get('system', 'publish_all'), DI::l10n()->t('Check to force all profiles on this site to be listed in the site directory.') . '<strong>' . DI::l10n()->t('Enabling this may violate privacy laws like the GDPR') . '</strong>'],
|
||||
'$global_directory' => ['directory', DI::l10n()->t('Global directory URL'), DI::config()->get('system', 'directory'), DI::l10n()->t('URL to the global directory. If this is not set, the global directory is completely unavailable to the application.')],
|
||||
'$newuser_private' => ['newuser_private', DI::l10n()->t('Private posts by default for new users'), DI::config()->get('system', 'newuser_private'), DI::l10n()->t('Set default post permissions for all new members to the default privacy group rather than public.')],
|
||||
'$newuser_private' => ['newuser_private', DI::l10n()->t('Private posts by default for new users'), DI::config()->get('system', 'newuser_private'), DI::l10n()->t('Set default post permissions for all new members to the default privacy circle rather than public.')],
|
||||
'$enotify_no_content' => ['enotify_no_content', DI::l10n()->t('Don\'t include post content in email notifications'), DI::config()->get('system', 'enotify_no_content'), DI::l10n()->t('Don\'t include the content of a post/comment/private message/etc. in the email notifications that are sent out from this site, as a privacy measure.')],
|
||||
'$private_addons' => ['private_addons', DI::l10n()->t('Disallow public access to addons listed in the apps menu.'), DI::config()->get('config', 'private_addons'), DI::l10n()->t('Checking this box will restrict addons listed in the apps menu to members only.')],
|
||||
'$disable_embedded' => ['disable_embedded', DI::l10n()->t('Don\'t embed private images in posts'), DI::config()->get('system', 'disable_embedded'), DI::l10n()->t('Don\'t replace locally-hosted private photos in posts with an embedded copy of the image. This means that contacts who receive posts containing private photos will have to authenticate and load each image, which may take a while.')],
|
||||
|
@ -504,7 +504,7 @@ class Site extends BaseAdmin
|
|||
'$max_display_comments' => ['max_display_comments', DI::l10n()->t('Maximum numbers of comments per post on the display page'), DI::config()->get('system', 'max_display_comments'), DI::l10n()->t('How many comments should be shown on the single view for each post? Default value is 1000.')],
|
||||
'$temppath' => ['temppath', DI::l10n()->t('Temp path'), DI::config()->get('system', 'temppath'), DI::l10n()->t('If you have a restricted system where the webserver can\'t access the system temp path, enter another path here.')],
|
||||
'$only_tag_search' => ['only_tag_search', DI::l10n()->t('Only search in tags'), DI::config()->get('system', 'only_tag_search'), DI::l10n()->t('On large systems the text search can slow down the system extremely.')],
|
||||
'$compute_group_counts' => ['compute_group_counts', DI::l10n()->t('Generate counts per contact group when calculating network count'), DI::config()->get('system', 'compute_group_counts'), DI::l10n()->t('On systems with users that heavily use contact groups the query can be very expensive.')],
|
||||
'$compute_circle_counts' => ['compute_circle_counts', DI::l10n()->t('Generate counts per contact circle when calculating network count'), DI::config()->get('system', 'compute_group_counts') ?? DI::config()->get('system', 'compute_circle_counts'), DI::l10n()->t('On systems with users that heavily use contact circles the query can be very expensive.')],
|
||||
|
||||
'$worker_queues' => ['worker_queues', DI::l10n()->t('Maximum number of parallel workers'), DI::config()->get('system', 'worker_queues'), DI::l10n()->t('On shared hosters set this to %d. On larger systems, values of %d are great. Default value is %d.', 5, 20, 10)],
|
||||
'$worker_fastlane' => ['worker_fastlane', DI::l10n()->t('Enable fastlane'), DI::config()->get('system', 'worker_fastlane'), DI::l10n()->t('When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.')],
|
||||
|
|
|
@ -19,14 +19,15 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Api\Friendica\Group;
|
||||
namespace Friendica\Module\Api\Friendica\Circle;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
/**
|
||||
* API endpoint: /api/friendica/circle_create
|
||||
* API endpoint: /api/friendica/group_create
|
||||
*/
|
||||
class Create extends BaseApi
|
||||
|
@ -43,23 +44,22 @@ class Create extends BaseApi
|
|||
|
||||
// error if no name specified
|
||||
if ($name == '') {
|
||||
throw new HTTPException\BadRequestException('group name not specified');
|
||||
throw new HTTPException\BadRequestException('circle name not specified');
|
||||
}
|
||||
|
||||
// error message if specified group name already exists
|
||||
// error message if specified circle name already exists
|
||||
if (DBA::exists('group', ['uid' => $uid, 'name' => $name, 'deleted' => false])) {
|
||||
throw new HTTPException\BadRequestException('group name already exists');
|
||||
throw new HTTPException\BadRequestException('circle name already exists');
|
||||
}
|
||||
|
||||
// Check if the group needs to be reactivated
|
||||
// Check if the circle needs to be reactivated
|
||||
if (DBA::exists('group', ['uid' => $uid, 'name' => $name, 'deleted' => true])) {
|
||||
$reactivate_group = true;
|
||||
$reactivate_circle = true;
|
||||
}
|
||||
|
||||
// create group
|
||||
$ret = Group::create($uid, $name);
|
||||
$ret = Circle::create($uid, $name);
|
||||
if ($ret) {
|
||||
$gid = Group::getIdByName($uid, $name);
|
||||
$gid = Circle::getIdByName($uid, $name);
|
||||
} else {
|
||||
throw new HTTPException\BadRequestException('other API error');
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ class Create extends BaseApi
|
|||
foreach ($users as $user) {
|
||||
$cid = $user['cid'];
|
||||
if (DBA::exists('contact', ['id' => $cid, 'uid' => $uid])) {
|
||||
Group::addMember($gid, $cid);
|
||||
Circle::addMember($gid, $cid);
|
||||
} else {
|
||||
$erroraddinguser = true;
|
||||
$errorusers[] = $cid;
|
||||
|
@ -78,7 +78,7 @@ class Create extends BaseApi
|
|||
}
|
||||
|
||||
// return success message incl. missing users in array
|
||||
$status = ($erroraddinguser ? 'missing user' : ((isset($reactivate_group) && $reactivate_group) ? 'reactivated' : 'ok'));
|
||||
$status = ($erroraddinguser ? 'missing user' : (!empty($reactivate_circle) ? 'reactivated' : 'ok'));
|
||||
|
||||
$result = ['success' => true, 'gid' => $gid, 'name' => $name, 'status' => $status, 'wrong users' => $errorusers];
|
||||
|
|
@ -19,15 +19,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Api\Friendica\Group;
|
||||
namespace Friendica\Module\Api\Friendica\Circle;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
|
||||
/**
|
||||
* API endpoint: /api/friendica/group/delete
|
||||
* API endpoint: /api/friendica/circle/delete
|
||||
*/
|
||||
class Delete extends BaseApi
|
||||
{
|
||||
|
@ -55,16 +56,16 @@ class Delete extends BaseApi
|
|||
|
||||
// error message if specified gid is not in database
|
||||
if (!DBA::exists('group', ['uid' => $uid, 'id' => $request['gid'], 'name' => $request['name']])) {
|
||||
throw new BadRequestException('wrong group name');
|
||||
throw new BadRequestException('wrong circle name');
|
||||
}
|
||||
|
||||
// delete group
|
||||
$gid = Group::getIdByName($uid, $request['name']);
|
||||
// delete circle
|
||||
$gid = Circle::getIdByName($uid, $request['name']);
|
||||
if (empty($request['gid'])) {
|
||||
throw new BadRequestException('other API error');
|
||||
}
|
||||
|
||||
$ret = Group::remove($gid);
|
||||
$ret = Circle::remove($gid);
|
||||
|
||||
if ($ret) {
|
||||
// return success
|
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Api\Friendica\Group;
|
||||
namespace Friendica\Module\Api\Friendica\Circle;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -28,6 +28,7 @@ use Friendica\Module\BaseApi;
|
|||
use Friendica\Network\HTTPException;
|
||||
|
||||
/**
|
||||
* API endpoint: /api/friendica/circle_show
|
||||
* API endpoint: /api/friendica/group_show
|
||||
*/
|
||||
class Show extends BaseApi
|
||||
|
@ -41,22 +42,22 @@ class Show extends BaseApi
|
|||
// params
|
||||
$gid = $this->getRequestValue($request, 'gid', 0);
|
||||
|
||||
// get data of the specified group id or all groups if not specified
|
||||
// get data of the specified circle id or all circles if not specified
|
||||
if ($gid != 0) {
|
||||
$groups = DBA::selectToArray('group', [], ['deleted' => false, 'uid' => $uid, 'id' => $gid]);
|
||||
$circles = DBA::selectToArray('group', [], ['deleted' => false, 'uid' => $uid, 'id' => $gid]);
|
||||
|
||||
// error message if specified gid is not in database
|
||||
if (!DBA::isResult($groups)) {
|
||||
if (!DBA::isResult($circles)) {
|
||||
throw new HTTPException\BadRequestException('gid not available');
|
||||
}
|
||||
} else {
|
||||
$groups = DBA::selectToArray('group', [], ['deleted' => false, 'uid' => $uid]);
|
||||
$circles = DBA::selectToArray('group', [], ['deleted' => false, 'uid' => $uid]);
|
||||
}
|
||||
|
||||
// loop through all groups and retrieve all members for adding data in the user array
|
||||
// loop through all circles and retrieve all members for adding data in the user array
|
||||
$grps = [];
|
||||
foreach ($groups as $rr) {
|
||||
$members = Contact\Group::getById($rr['id']);
|
||||
foreach ($circles as $circle) {
|
||||
$members = Contact\Circle::getById($circle['id']);
|
||||
$users = [];
|
||||
|
||||
if ($type == 'xml') {
|
||||
|
@ -71,7 +72,7 @@ class Show extends BaseApi
|
|||
$users[] = DI::twitterUser()->createFromContactId($member['contact-id'], $uid, true)->toArray();
|
||||
}
|
||||
}
|
||||
$grps[] = ['name' => $rr['name'], 'gid' => $rr['id'], $user_element => $users];
|
||||
$grps[] = ['name' => $circle['name'], 'gid' => $circle['id'], $user_element => $users];
|
||||
}
|
||||
|
||||
$this->response->exit('group_update', ['group' => $grps], $this->parameters['extension'] ?? null);
|
|
@ -19,15 +19,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Api\Friendica\Group;
|
||||
namespace Friendica\Module\Api\Friendica\Circle;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
|
||||
/**
|
||||
* API endpoint: /api/friendica/circle_update
|
||||
* API endpoint: /api/friendica/group_update
|
||||
*/
|
||||
class Update extends BaseApi
|
||||
|
@ -45,7 +46,7 @@ class Update extends BaseApi
|
|||
|
||||
// error if no name specified
|
||||
if (!$name) {
|
||||
throw new BadRequestException('group name not specified');
|
||||
throw new BadRequestException('circle name not specified');
|
||||
}
|
||||
|
||||
// error if no gid specified
|
||||
|
@ -54,15 +55,15 @@ class Update extends BaseApi
|
|||
}
|
||||
|
||||
// remove members
|
||||
$members = Contact\Group::getById($gid);
|
||||
$members = Contact\Circle::getById($gid);
|
||||
foreach ($members as $member) {
|
||||
$cid = $member['id'];
|
||||
foreach ($users as $user) {
|
||||
$found = $user['cid'] == $cid;
|
||||
}
|
||||
if (!isset($found) || !$found) {
|
||||
$gid = Group::getIdByName($uid, $name);
|
||||
Group::removeMember($gid, $cid);
|
||||
$gid = Circle::getIdByName($uid, $name);
|
||||
Circle::removeMember($gid, $cid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,7 @@ class Update extends BaseApi
|
|||
$cid = $user['cid'];
|
||||
|
||||
if (DBA::exists('contact', ['id' => $cid, 'uid' => $uid])) {
|
||||
Group::addMember($gid, $cid);
|
||||
Circle::addMember($gid, $cid);
|
||||
} else {
|
||||
$erroraddinguser = true;
|
||||
$errorusers[] = $cid;
|
|
@ -53,9 +53,9 @@ class Create extends BaseApi
|
|||
'place' => '', //location of the event
|
||||
'publish' => 0, //publish message
|
||||
'allow_cid' => '', //array of allowed person, if access restricted
|
||||
'allow_gid' => '', //array of allowed groups, if access restricted
|
||||
'allow_gid' => '', //array of allowed circles, if access restricted
|
||||
'deny_cid' => '', //array of denied person, if access restricted
|
||||
'deny_gid' => '', //array of denied groups, if access restricted
|
||||
'deny_gid' => '', //array of denied circles, if access restricted
|
||||
], $request);
|
||||
|
||||
// error if no name specified
|
||||
|
|
|
@ -78,8 +78,8 @@ class Create extends BaseApi
|
|||
$acl_input_error = false;
|
||||
$acl_input_error |= !ACL::isValidContact($allow_cid, $uid);
|
||||
$acl_input_error |= !ACL::isValidContact($deny_cid, $uid);
|
||||
$acl_input_error |= !ACL::isValidGroup($allow_gid, $uid);
|
||||
$acl_input_error |= !ACL::isValidGroup($deny_gid, $uid);
|
||||
$acl_input_error |= !ACL::isValidCircle($allow_gid, $uid);
|
||||
$acl_input_error |= !ACL::isValidCircle($deny_gid, $uid);
|
||||
if ($acl_input_error) {
|
||||
throw new HTTPException\BadRequestException('acl data invalid');
|
||||
}
|
||||
|
|
|
@ -79,8 +79,8 @@ class Update extends BaseApi
|
|||
$acl_input_error = false;
|
||||
$acl_input_error |= !ACL::isValidContact($allow_cid, $uid);
|
||||
$acl_input_error |= !ACL::isValidContact($deny_cid, $uid);
|
||||
$acl_input_error |= !ACL::isValidGroup($allow_gid, $uid);
|
||||
$acl_input_error |= !ACL::isValidGroup($deny_gid, $uid);
|
||||
$acl_input_error |= !ACL::isValidCircle($allow_gid, $uid);
|
||||
$acl_input_error |= !ACL::isValidCircle($deny_gid, $uid);
|
||||
if ($acl_input_error) {
|
||||
throw new HTTPException\BadRequestException('acl data invalid');
|
||||
}
|
||||
|
|
|
@ -53,11 +53,11 @@ class Lists extends BaseApi
|
|||
|
||||
$cdata = Contact::getPublicAndUserContactID($id, $uid);
|
||||
if (!empty($cdata['user'])) {
|
||||
$groups = DBA::select('group_member', ['gid'], ['contact-id' => $cdata['user']]);
|
||||
while ($group = DBA::fetch($groups)) {
|
||||
$lists[] = DI::mstdnList()->createFromGroupId($group['gid']);
|
||||
$circles = DBA::select('group_member', ['gid'], ['contact-id' => $cdata['user']]);
|
||||
while ($circle = DBA::fetch($circles)) {
|
||||
$lists[] = DI::mstdnList()->createFromCircleId($circle['gid']);
|
||||
}
|
||||
DBA::close($groups);
|
||||
DBA::close($circles);
|
||||
}
|
||||
|
||||
System::jsonExit($lists);
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Friendica\Module\Api\Mastodon;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
|
||||
/**
|
||||
* @see https://docs.joinmastodon.org/methods/timelines/lists/
|
||||
|
@ -40,11 +40,11 @@ class Lists extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity();
|
||||
}
|
||||
|
||||
if (!Group::exists($this->parameters['id'], $uid)) {
|
||||
if (!Circle::exists($this->parameters['id'], $uid)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
||||
if (!Group::remove($this->parameters['id'])) {
|
||||
if (!Circle::remove($this->parameters['id'])) {
|
||||
DI::mstdnError()->InternalError();
|
||||
}
|
||||
|
||||
|
@ -64,14 +64,14 @@ class Lists extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity();
|
||||
}
|
||||
|
||||
Group::create($uid, $request['title']);
|
||||
Circle::create($uid, $request['title']);
|
||||
|
||||
$id = Group::getIdByName($uid, $request['title']);
|
||||
$id = Circle::getIdByName($uid, $request['title']);
|
||||
if (!$id) {
|
||||
DI::mstdnError()->InternalError();
|
||||
}
|
||||
|
||||
System::jsonExit(DI::mstdnList()->createFromGroupId($id));
|
||||
System::jsonExit(DI::mstdnList()->createFromCircleId($id));
|
||||
}
|
||||
|
||||
public function put(array $request = [])
|
||||
|
@ -85,7 +85,7 @@ class Lists extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity();
|
||||
}
|
||||
|
||||
Group::update($this->parameters['id'], $request['title']);
|
||||
Circle::update($this->parameters['id'], $request['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,18 +99,16 @@ class Lists extends BaseApi
|
|||
if (empty($this->parameters['id'])) {
|
||||
$lists = [];
|
||||
|
||||
$groups = Group::getByUserId($uid);
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$lists[] = DI::mstdnList()->createFromGroupId($group['id']);
|
||||
foreach (Circle::getByUserId($uid) as $circle) {
|
||||
$lists[] = DI::mstdnList()->createFromCircleId($circle['id']);
|
||||
}
|
||||
} else {
|
||||
$id = $this->parameters['id'];
|
||||
|
||||
if (!Group::exists($id, $uid)) {
|
||||
if (!Circle::exists($id, $uid)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
$lists = DI::mstdnList()->createFromGroupId($id);
|
||||
$lists = DI::mstdnList()->createFromCircleId($id);
|
||||
}
|
||||
|
||||
System::jsonExit($lists);
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Friendica\Module\Api\Mastodon\Lists;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Module\BaseApi;
|
||||
|
||||
/**
|
||||
|
@ -46,7 +46,7 @@ class Accounts extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity();
|
||||
}
|
||||
|
||||
return Group::removeMembers($this->parameters['id'], $request['account_ids']);
|
||||
return Circle::removeMembers($this->parameters['id'], $request['account_ids']);
|
||||
}
|
||||
|
||||
protected function post(array $request = [])
|
||||
|
@ -61,7 +61,7 @@ class Accounts extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity();
|
||||
}
|
||||
|
||||
Group::addMembers($this->parameters['id'], $request['account_ids']);
|
||||
Circle::addMembers($this->parameters['id'], $request['account_ids']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,7 @@ use Friendica\Core\Worker;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Model\Post;
|
||||
|
@ -230,7 +230,7 @@ class Statuses extends BaseApi
|
|||
$item['deny_gid'] = $owner['deny_gid'];
|
||||
} else {
|
||||
$item['allow_cid'] = '';
|
||||
$item['allow_gid'] = '<' . Group::FOLLOWERS . '>';
|
||||
$item['allow_gid'] = '<' . Circle::FOLLOWERS . '>';
|
||||
$item['deny_cid'] = '';
|
||||
$item['deny_gid'] = '';
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ class Statuses extends BaseApi
|
|||
// The permissions are assigned in "expandTags"
|
||||
break;
|
||||
default:
|
||||
if (is_numeric($request['visibility']) && Group::exists($request['visibility'], $uid)) {
|
||||
if (is_numeric($request['visibility']) && Circle::exists($request['visibility'], $uid)) {
|
||||
$item['allow_cid'] = '';
|
||||
$item['allow_gid'] = '<' . $request['visibility'] . '>';
|
||||
$item['deny_cid'] = '';
|
||||
|
|
|
@ -24,34 +24,34 @@ namespace Friendica\Module\Api\Twitter\Lists;
|
|||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Factory\Api\Friendica\Group as FriendicaGroup;
|
||||
use Friendica\Factory\Api\Friendica\Circle as FriendicaCircle;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Module\Api\ApiResponse;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Update information about a group.
|
||||
* Update information about a circle.
|
||||
*
|
||||
* @see https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-update
|
||||
*/
|
||||
class Create extends BaseApi
|
||||
{
|
||||
/** @var friendicaGroup */
|
||||
private $friendicaGroup;
|
||||
/** @var FriendicaCircle */
|
||||
private $friendicaCircle;
|
||||
|
||||
/** @var Database */
|
||||
private $dba;
|
||||
|
||||
public function __construct(Database $dba, FriendicaGroup $friendicaGroup, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
public function __construct(Database $dba, FriendicaCircle $friendicaCircle, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->dba = $dba;
|
||||
$this->friendicaGroup = $friendicaGroup;
|
||||
$this->dba = $dba;
|
||||
$this->friendicaCircle = $friendicaCircle;
|
||||
}
|
||||
|
||||
protected function rawContent(array $request = [])
|
||||
|
@ -63,22 +63,22 @@ class Create extends BaseApi
|
|||
$name = $this->getRequestValue($request, 'name', '');
|
||||
|
||||
if ($name == '') {
|
||||
throw new HTTPException\BadRequestException('group name not specified');
|
||||
throw new HTTPException\BadRequestException('circle name not specified');
|
||||
}
|
||||
|
||||
// error message if specified group name already exists
|
||||
// error message if specified circle name already exists
|
||||
if ($this->dba->exists('group', ['uid' => $uid, 'name' => $name, 'deleted' => false])) {
|
||||
throw new HTTPException\BadRequestException('group name already exists');
|
||||
throw new HTTPException\BadRequestException('circle name already exists');
|
||||
}
|
||||
|
||||
$ret = Group::create($uid, $name);
|
||||
$ret = Circle::create($uid, $name);
|
||||
if ($ret) {
|
||||
$gid = Group::getIdByName($uid, $name);
|
||||
$gid = Circle::getIdByName($uid, $name);
|
||||
} else {
|
||||
throw new HTTPException\BadRequestException('other API error');
|
||||
}
|
||||
|
||||
$grp = $this->friendicaGroup->createFromId($gid);
|
||||
$grp = $this->friendicaCircle->createFromId($gid);
|
||||
|
||||
$this->response->exit('statuses', ['lists' => ['lists' => $grp]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
|
|
|
@ -24,34 +24,34 @@ namespace Friendica\Module\Api\Twitter\Lists;
|
|||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Factory\Api\Friendica\Group as FriendicaGroup;
|
||||
use Friendica\Factory\Api\Friendica\Circle as FriendicaCirle;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Module\Api\ApiResponse;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Delete a group.
|
||||
* Delete a circle.
|
||||
*
|
||||
* @see https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-destroy
|
||||
*/
|
||||
class Destroy extends BaseApi
|
||||
{
|
||||
/** @var friendicaGroup */
|
||||
private $friendicaGroup;
|
||||
/** @var FriendicaCirle */
|
||||
private $friendicaCircle;
|
||||
|
||||
/** @var Database */
|
||||
private $dba;
|
||||
|
||||
public function __construct(Database $dba, FriendicaGroup $friendicaGroup, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
public function __construct(Database $dba, FriendicaCirle $friendicaCircle, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->dba = $dba;
|
||||
$this->friendicaGroup = $friendicaGroup;
|
||||
$this->dba = $dba;
|
||||
$this->friendicaCircle = $friendicaCircle;
|
||||
}
|
||||
|
||||
protected function rawContent(array $request = [])
|
||||
|
@ -67,16 +67,16 @@ class Destroy extends BaseApi
|
|||
throw new HTTPException\BadRequestException('gid not specified');
|
||||
}
|
||||
|
||||
// get data of the specified group id
|
||||
$group = $this->dba->selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
|
||||
// get data of the specified circle id
|
||||
$circle = $this->dba->selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
|
||||
// error message if specified gid is not in database
|
||||
if (!$group) {
|
||||
if (!$circle) {
|
||||
throw new HTTPException\BadRequestException('gid not available');
|
||||
}
|
||||
|
||||
$list = $this->friendicaGroup->createFromId($gid);
|
||||
$list = $this->friendicaCircle->createFromId($gid);
|
||||
|
||||
if (Group::remove($gid)) {
|
||||
if (Circle::remove($gid)) {
|
||||
$this->response->exit('statuses', ['lists' => ['lists' => $list]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Friendica\Module\Api\Twitter\Lists;
|
|||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Factory\Api\Friendica\Group as FriendicaGroup;
|
||||
use Friendica\Factory\Api\Friendica\Circle as FriendicaCircle;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Module\Api\ApiResponse;
|
||||
|
@ -32,36 +32,36 @@ use Friendica\Util\Profiler;
|
|||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Returns all groups the user owns.
|
||||
* Returns all circles the user owns.
|
||||
*
|
||||
* @see https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-ownerships
|
||||
*/
|
||||
class Ownership extends BaseApi
|
||||
{
|
||||
/** @var friendicaGroup */
|
||||
private $friendicaGroup;
|
||||
/** @var FriendicaCircle */
|
||||
private $friendicaCircle;
|
||||
|
||||
/** @var Database */
|
||||
private $dba;
|
||||
|
||||
public function __construct(Database $dba, FriendicaGroup $friendicaGroup, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
public function __construct(Database $dba, FriendicaCircle $friendicaCircle, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->dba = $dba;
|
||||
$this->friendicaGroup = $friendicaGroup;
|
||||
$this->dba = $dba;
|
||||
$this->friendicaCircle = $friendicaCircle;
|
||||
}
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
$uid = BaseApi::getCurrentUserID();
|
||||
|
||||
$groups = $this->dba->select('group', [], ['deleted' => false, 'uid' => $uid, 'cid' => null]);
|
||||
$circles = $this->dba->select('group', [], ['deleted' => false, 'uid' => $uid, 'cid' => null]);
|
||||
|
||||
// loop through all groups
|
||||
// loop through all circles
|
||||
$lists = [];
|
||||
foreach ($groups as $group) {
|
||||
$lists[] = $this->friendicaGroup->createFromId($group['id']);
|
||||
foreach ($circles as $circle) {
|
||||
$lists[] = $this->friendicaCircle->createFromId($circle['id']);
|
||||
}
|
||||
|
||||
$this->response->exit('statuses', ['lists' => ['lists' => $lists]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
|
|
|
@ -36,7 +36,7 @@ use Friendica\Util\Profiler;
|
|||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Returns recent statuses from users in the specified group.
|
||||
* Returns recent statuses from users in the specified circle.
|
||||
*
|
||||
* @see https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-ownerships
|
||||
*/
|
||||
|
@ -76,9 +76,9 @@ class Statuses extends BaseApi
|
|||
|
||||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
$groups = $this->dba->selectToArray('group_member', ['contact-id'], ['gid' => $request['list_id']]);
|
||||
$gids = array_column($groups, 'contact-id');
|
||||
$condition = ['uid' => $uid, 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT], 'contact-id' => $gids];
|
||||
$members = $this->dba->selectToArray('group_member', ['contact-id'], ['gid' => $request['list_id']]);
|
||||
$cids = array_column($members, 'contact-id');
|
||||
$condition = ['uid' => $uid, 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT], 'contact-id' => $cids];
|
||||
$condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $since_id]);
|
||||
|
||||
if ($max_id > 0) {
|
||||
|
|
|
@ -24,34 +24,34 @@ namespace Friendica\Module\Api\Twitter\Lists;
|
|||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Factory\Api\Friendica\Group as FriendicaGroup;
|
||||
use Friendica\Factory\Api\Friendica\Circle as FriendicaCircle;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Module\Api\ApiResponse;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Update information about a group.
|
||||
* Update information about a circle.
|
||||
*
|
||||
* @see https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-update
|
||||
*/
|
||||
class Update extends BaseApi
|
||||
{
|
||||
/** @var friendicaGroup */
|
||||
private $friendicaGroup;
|
||||
/** @var FriendicaCircle */
|
||||
private $friendicaCircle;
|
||||
|
||||
/** @var Database */
|
||||
private $dba;
|
||||
|
||||
public function __construct(Database $dba, FriendicaGroup $friendicaGroup, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
public function __construct(Database $dba, FriendicaCircle $friendicaCircle, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->dba = $dba;
|
||||
$this->friendicaGroup = $friendicaGroup;
|
||||
$this->dba = $dba;
|
||||
$this->friendicaCircle = $friendicaCircle;
|
||||
}
|
||||
|
||||
protected function rawContent(array $request = [])
|
||||
|
@ -68,15 +68,15 @@ class Update extends BaseApi
|
|||
throw new HTTPException\BadRequestException('gid not specified');
|
||||
}
|
||||
|
||||
// get data of the specified group id
|
||||
$group = $this->dba->selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
|
||||
// get data of the specified circle id
|
||||
$circle = $this->dba->selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
|
||||
// error message if specified gid is not in database
|
||||
if (!$group) {
|
||||
if (!$circle) {
|
||||
throw new HTTPException\BadRequestException('gid not available');
|
||||
}
|
||||
|
||||
if (Group::update($gid, $name)) {
|
||||
$list = $this->friendicaGroup->createFromId($gid);
|
||||
if (Circle::update($gid, $name)) {
|
||||
$list = $this->friendicaCircle->createFromId($gid);
|
||||
|
||||
$this->response->exit('statuses', ['lists' => ['lists' => $list]], $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
|
||||
}
|
||||
|
|
|
@ -62,9 +62,9 @@ class Update extends BaseApi
|
|||
'source' => '',
|
||||
'include_entities' => false,
|
||||
'contact_allow' => $owner['allow_cid'],
|
||||
'group_allow' => $owner['allow_gid'],
|
||||
'circle_allow' => $owner['allow_gid'],
|
||||
'contact_deny' => $owner['deny_cid'],
|
||||
'group_deny' => $owner['deny_gid'],
|
||||
'circle_deny' => $owner['deny_gid'],
|
||||
], $request);
|
||||
|
||||
if (!empty($request['htmlstatus'])) {
|
||||
|
@ -102,9 +102,9 @@ class Update extends BaseApi
|
|||
|
||||
$aclFormatter = DI::aclFormatter();
|
||||
$item['allow_cid'] = $aclFormatter->toString($request['contact_allow']);
|
||||
$item['allow_gid'] = $aclFormatter->toString($request['group_allow']);
|
||||
$item['allow_gid'] = $aclFormatter->toString($request['circle_allow']);
|
||||
$item['deny_cid'] = $aclFormatter->toString($request['contact_deny']);
|
||||
$item['deny_gid'] = $aclFormatter->toString($request['group_deny']);
|
||||
$item['deny_gid'] = $aclFormatter->toString($request['circle_deny']);
|
||||
|
||||
if (!empty($item['allow_cid'] . $item['allow_gid'] . $item['deny_cid'] . $item['deny_gid'])) {
|
||||
$item['private'] = Item::PRIVATE;
|
||||
|
|
|
@ -212,14 +212,14 @@ class API extends BaseModule
|
|||
}
|
||||
|
||||
$strAclContactAllow = isset($request['contact_allow']) ? $aclFormatter->toString($request['contact_allow']) : $user['allow_cid'] ?? '';
|
||||
$strAclGroupAllow = isset($request['group_allow']) ? $aclFormatter->toString($request['group_allow']) : $user['allow_gid'] ?? '';
|
||||
$strContactDeny = isset($request['contact_deny']) ? $aclFormatter->toString($request['contact_deny']) : $user['deny_cid'] ?? '';
|
||||
$strGroupDeny = isset($request['group_deny']) ? $aclFormatter->toString($request['group_deny']) : $user['deny_gid'] ?? '';
|
||||
$strAclCircleAllow = isset($request['circle_allow']) ? $aclFormatter->toString($request['circle_allow']) : $user['allow_gid'] ?? '';
|
||||
$strContactDeny = isset($request['contact_deny']) ? $aclFormatter->toString($request['contact_deny']) : $user['deny_cid'] ?? '';
|
||||
$strCircleDeny = isset($request['circle_deny']) ? $aclFormatter->toString($request['circle_deny']) : $user['deny_gid'] ?? '';
|
||||
|
||||
$visibility = $request['visibility'] ?? '';
|
||||
if ($visibility === 'public') {
|
||||
// The ACL selector introduced in version 2019.12 sends ACL input data even when the Public visibility is selected
|
||||
$strAclContactAllow = $strAclGroupAllow = $strContactDeny = $strGroupDeny = '';
|
||||
$strAclContactAllow = $strAclCircleAllow = $strContactDeny = $strCircleDeny = '';
|
||||
} elseif ($visibility === 'custom') {
|
||||
// Since we know from the visibility parameter the item should be private, we have to prevent the empty ACL
|
||||
// case that would make it public. So we always append the author's contact id to the allowed contacts.
|
||||
|
@ -228,9 +228,9 @@ class API extends BaseModule
|
|||
}
|
||||
} else {
|
||||
$strAclContactAllow = $aclFormatter->toString($self);
|
||||
$strAclGroupAllow = '';
|
||||
$strAclCircleAllow = '';
|
||||
$strContactDeny = '';
|
||||
$strGroupDeny = '';
|
||||
$strCircleDeny = '';
|
||||
}
|
||||
|
||||
$datarray = [
|
||||
|
@ -244,9 +244,9 @@ class API extends BaseModule
|
|||
'uid' => $uid,
|
||||
'cid' => $cid,
|
||||
'allow_cid' => $strAclContactAllow,
|
||||
'allow_gid' => $strAclGroupAllow,
|
||||
'allow_gid' => $strAclCircleAllow,
|
||||
'deny_cid' => $strContactDeny,
|
||||
'deny_gid' => $strGroupDeny,
|
||||
'deny_gid' => $strCircleDeny,
|
||||
'id' => $eventId,
|
||||
];
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ use Friendica\Database\DBA;
|
|||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
|
||||
class Group extends BaseModule
|
||||
class Circle extends BaseModule
|
||||
{
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
|
@ -43,34 +43,34 @@ class Group extends BaseModule
|
|||
|
||||
// @TODO: Replace with parameter from router
|
||||
if ((DI::args()->getArgc() == 2) && (DI::args()->getArgv()[1] === 'new')) {
|
||||
BaseModule::checkFormSecurityTokenRedirectOnError('/group/new', 'group_edit');
|
||||
BaseModule::checkFormSecurityTokenRedirectOnError('/circle/new', 'circle_edit');
|
||||
|
||||
$name = trim($request['groupname']);
|
||||
$r = Model\Group::create(DI::userSession()->getLocalUserId(), $name);
|
||||
$name = trim($request['circle_name']);
|
||||
$r = Model\Circle::create(DI::userSession()->getLocalUserId(), $name);
|
||||
if ($r) {
|
||||
$r = Model\Group::getIdByName(DI::userSession()->getLocalUserId(), $name);
|
||||
$r = Model\Circle::getIdByName(DI::userSession()->getLocalUserId(), $name);
|
||||
if ($r) {
|
||||
DI::baseUrl()->redirect('group/' . $r);
|
||||
DI::baseUrl()->redirect('circle/' . $r);
|
||||
}
|
||||
} else {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Could not create group.'));
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Could not create circle.'));
|
||||
}
|
||||
DI::baseUrl()->redirect('group');
|
||||
DI::baseUrl()->redirect('circle');
|
||||
}
|
||||
|
||||
// @TODO: Replace with parameter from router
|
||||
if ((DI::args()->getArgc() == 2) && intval(DI::args()->getArgv()[1])) {
|
||||
BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_edit');
|
||||
BaseModule::checkFormSecurityTokenRedirectOnError('/circle', 'circle_edit');
|
||||
|
||||
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
if (!DBA::isResult($group)) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
|
||||
$circle = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
if (!DBA::isResult($circle)) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Circle not found.'));
|
||||
DI::baseUrl()->redirect('contact');
|
||||
}
|
||||
$groupname = trim($_POST['groupname']);
|
||||
if (strlen($groupname) && ($groupname != $group['name'])) {
|
||||
if (!Model\Group::update($group['id'], $groupname)) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Group name was not changed.'));
|
||||
$circlename = trim($_POST['circle_name']);
|
||||
if (strlen($circlename) && ($circlename != $circle['name'])) {
|
||||
if (!Model\Circle::update($circle['id'], $circlename)) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Circle name was not changed.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,11 +84,11 @@ class Group extends BaseModule
|
|||
}
|
||||
|
||||
if (isset($this->parameters['command'])) {
|
||||
$group_id = $this->parameters['group'];
|
||||
$circle_id = $this->parameters['circle'];
|
||||
$contact_id = $this->parameters['contact'];
|
||||
|
||||
if (!Model\Group::exists($group_id, DI::userSession()->getLocalUserId())) {
|
||||
throw new \Exception(DI::l10n()->t('Unknown group.'), 404);
|
||||
if (!Model\Circle::exists($circle_id, DI::userSession()->getLocalUserId())) {
|
||||
throw new \Exception(DI::l10n()->t('Unknown circle.'), 404);
|
||||
}
|
||||
|
||||
// @TODO Backward compatibility with user contacts, remove by version 2022.03
|
||||
|
@ -112,18 +112,18 @@ class Group extends BaseModule
|
|||
|
||||
switch($this->parameters['command']) {
|
||||
case 'add':
|
||||
if (!Model\Group::addMember($group_id, $cdata['user'])) {
|
||||
throw new \Exception(DI::l10n()->t('Unable to add the contact to the group.'), 500);
|
||||
if (!Model\Circle::addMember($circle_id, $cdata['user'])) {
|
||||
throw new \Exception(DI::l10n()->t('Unable to add the contact to the circle.'), 500);
|
||||
}
|
||||
|
||||
$message = DI::l10n()->t('Contact successfully added to group.');
|
||||
$message = DI::l10n()->t('Contact successfully added to circle.');
|
||||
break;
|
||||
case 'remove':
|
||||
if (!Model\Group::removeMember($group_id, $cdata['user'])) {
|
||||
throw new \Exception(DI::l10n()->t('Unable to remove the contact from the group.'), 500);
|
||||
if (!Model\Circle::removeMember($circle_id, $cdata['user'])) {
|
||||
throw new \Exception(DI::l10n()->t('Unable to remove the contact from the circle.'), 500);
|
||||
}
|
||||
|
||||
$message = DI::l10n()->t('Contact successfully removed from group.');
|
||||
$message = DI::l10n()->t('Contact successfully removed from circle.');
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -148,56 +148,58 @@ class Group extends BaseModule
|
|||
|
||||
$a = DI::app();
|
||||
|
||||
DI::page()['aside'] = Model\Group::sidebarWidget('contact', 'group', 'extended', ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : 'everyone'));
|
||||
DI::page()['aside'] = Model\Circle::sidebarWidget('contact', 'circle', 'extended', ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : 'everyone'));
|
||||
|
||||
// With no group number provided we jump to the unassigned contacts as a starting point
|
||||
// With no circle number provided we jump to the unassigned contacts as a starting point
|
||||
// @TODO: Replace with parameter from router
|
||||
if (DI::args()->getArgc() == 1) {
|
||||
DI::baseUrl()->redirect('group/none');
|
||||
DI::baseUrl()->redirect('circle/none');
|
||||
}
|
||||
|
||||
// Switch to text mode interface if we have more than 'n' contacts or group members
|
||||
$switchtotext = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'groupedit_image_limit');
|
||||
// Switch to text mode interface if we have more than 'n' contacts or circle members
|
||||
$switchtotext = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'circle_edit_image_limit') ??
|
||||
DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'groupedit_image_limit');
|
||||
if (is_null($switchtotext)) {
|
||||
$switchtotext = DI::config()->get('system', 'groupedit_image_limit', 200);
|
||||
$switchtotext = DI::config()->get('system', 'groupedit_image_limit') ??
|
||||
DI::config()->get('system', 'circle_edit_image_limit');
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('group_edit.tpl');
|
||||
$tpl = Renderer::getMarkupTemplate('circle_edit.tpl');
|
||||
|
||||
|
||||
$context = [
|
||||
'$submit' => DI::l10n()->t('Save Group'),
|
||||
'$submit' => DI::l10n()->t('Save Circle'),
|
||||
'$submit_filter' => DI::l10n()->t('Filter'),
|
||||
];
|
||||
|
||||
// @TODO: Replace with parameter from router
|
||||
if ((DI::args()->getArgc() == 2) && (DI::args()->getArgv()[1] === 'new')) {
|
||||
return Renderer::replaceMacros($tpl, $context + [
|
||||
'$title' => DI::l10n()->t('Create a group of contacts/friends.'),
|
||||
'$gname' => ['groupname', DI::l10n()->t('Group Name: '), '', ''],
|
||||
'$title' => DI::l10n()->t('Create a circle of contacts/friends.'),
|
||||
'$gname' => ['circle_name', DI::l10n()->t('Circle Name: '), '', ''],
|
||||
'$gid' => 'new',
|
||||
'$form_security_token' => BaseModule::getFormSecurityToken("group_edit"),
|
||||
'$form_security_token' => BaseModule::getFormSecurityToken('circle_edit'),
|
||||
]);
|
||||
}
|
||||
|
||||
$nogroup = false;
|
||||
$nocircle = false;
|
||||
|
||||
// @TODO: Replace with parameter from router
|
||||
if ((DI::args()->getArgc() == 2) && (DI::args()->getArgv()[1] === 'none') ||
|
||||
(DI::args()->getArgc() == 1) && (DI::args()->getArgv()[0] === 'nogroup')) {
|
||||
(DI::args()->getArgc() == 1) && (DI::args()->getArgv()[0] === 'nocircle')) {
|
||||
$id = -1;
|
||||
$nogroup = true;
|
||||
$group = [
|
||||
$nocircle = true;
|
||||
$circle = [
|
||||
'id' => $id,
|
||||
'name' => DI::l10n()->t('Contacts not in any group'),
|
||||
'name' => DI::l10n()->t('Contacts not in any circle'),
|
||||
];
|
||||
|
||||
$members = [];
|
||||
$preselected = [];
|
||||
|
||||
$context = $context + [
|
||||
'$title' => $group['name'],
|
||||
'$gname' => ['groupname', DI::l10n()->t('Group Name: '), $group['name'], ''],
|
||||
'$title' => $circle['name'],
|
||||
'$gname' => ['circle_name', DI::l10n()->t('Circle Name: '), $circle['name'], ''],
|
||||
'$gid' => $id,
|
||||
'$editable' => 0,
|
||||
];
|
||||
|
@ -205,25 +207,25 @@ class Group extends BaseModule
|
|||
|
||||
// @TODO: Replace with parameter from router
|
||||
if ((DI::args()->getArgc() == 3) && (DI::args()->getArgv()[1] === 'drop')) {
|
||||
BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_drop', 't');
|
||||
BaseModule::checkFormSecurityTokenRedirectOnError('/circle', 'circle_drop', 't');
|
||||
|
||||
// @TODO: Replace with parameter from router
|
||||
if (intval(DI::args()->getArgv()[2])) {
|
||||
if (!Model\Group::exists(DI::args()->getArgv()[2], DI::userSession()->getLocalUserId())) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
|
||||
if (!Model\Circle::exists(DI::args()->getArgv()[2], DI::userSession()->getLocalUserId())) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Circle not found.'));
|
||||
DI::baseUrl()->redirect('contact');
|
||||
}
|
||||
|
||||
if (!Model\Group::remove(DI::args()->getArgv()[2])) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to remove group.'));
|
||||
if (!Model\Circle::remove(DI::args()->getArgv()[2])) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to remove circle.'));
|
||||
}
|
||||
}
|
||||
DI::baseUrl()->redirect('group');
|
||||
DI::baseUrl()->redirect('circle');
|
||||
}
|
||||
|
||||
// @TODO: Replace with parameter from router
|
||||
if ((DI::args()->getArgc() > 2) && intval(DI::args()->getArgv()[1]) && intval(DI::args()->getArgv()[2])) {
|
||||
BaseModule::checkFormSecurityTokenForbiddenOnError('group_member_change', 't');
|
||||
BaseModule::checkFormSecurityTokenForbiddenOnError('circle_member_change', 't');
|
||||
|
||||
if (DBA::exists('contact', ['id' => DI::args()->getArgv()[2], 'uid' => DI::userSession()->getLocalUserId(), 'self' => false, 'pending' => false, 'blocked' => false])) {
|
||||
$change = intval(DI::args()->getArgv()[2]);
|
||||
|
@ -232,13 +234,13 @@ class Group extends BaseModule
|
|||
|
||||
// @TODO: Replace with parameter from router
|
||||
if ((DI::args()->getArgc() > 1) && intval(DI::args()->getArgv()[1])) {
|
||||
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => DI::userSession()->getLocalUserId(), 'deleted' => false]);
|
||||
if (!DBA::isResult($group)) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
|
||||
$circle = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => DI::userSession()->getLocalUserId(), 'deleted' => false]);
|
||||
if (!DBA::isResult($circle)) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Circle not found.'));
|
||||
DI::baseUrl()->redirect('contact');
|
||||
}
|
||||
|
||||
$members = Model\Contact\Group::getById($group['id']);
|
||||
$members = Model\Contact\Circle::getById($circle['id']);
|
||||
$preselected = [];
|
||||
|
||||
if (count($members)) {
|
||||
|
@ -249,12 +251,12 @@ class Group extends BaseModule
|
|||
|
||||
if ($change) {
|
||||
if (in_array($change, $preselected)) {
|
||||
Model\Group::removeMember($group['id'], $change);
|
||||
Model\Circle::removeMember($circle['id'], $change);
|
||||
} else {
|
||||
Model\Group::addMember($group['id'], $change);
|
||||
Model\Circle::addMember($circle['id'], $change);
|
||||
}
|
||||
|
||||
$members = Model\Contact\Group::getById($group['id']);
|
||||
$members = Model\Contact\Circle::getById($circle['id']);
|
||||
$preselected = [];
|
||||
if (count($members)) {
|
||||
foreach ($members as $member) {
|
||||
|
@ -263,59 +265,59 @@ class Group extends BaseModule
|
|||
}
|
||||
}
|
||||
|
||||
$drop_tpl = Renderer::getMarkupTemplate('group_drop.tpl');
|
||||
$drop_tpl = Renderer::getMarkupTemplate('circle_drop.tpl');
|
||||
$drop_txt = Renderer::replaceMacros($drop_tpl, [
|
||||
'$id' => $group['id'],
|
||||
'$delete' => DI::l10n()->t('Delete Group'),
|
||||
'$form_security_token' => BaseModule::getFormSecurityToken("group_drop"),
|
||||
'$id' => $circle['id'],
|
||||
'$delete' => DI::l10n()->t('Delete Circle'),
|
||||
'$form_security_token' => BaseModule::getFormSecurityToken('circle_drop'),
|
||||
]);
|
||||
|
||||
$context = $context + [
|
||||
'$title' => $group['name'],
|
||||
'$gname' => ['groupname', DI::l10n()->t('Group Name: '), $group['name'], ''],
|
||||
'$gid' => $group['id'],
|
||||
'$title' => $circle['name'],
|
||||
'$gname' => ['circle_name', DI::l10n()->t('Circle Name: '), $circle['name'], ''],
|
||||
'$gid' => $circle['id'],
|
||||
'$drop' => $drop_txt,
|
||||
'$form_security_token' => BaseModule::getFormSecurityToken('group_edit'),
|
||||
'$edit_name' => DI::l10n()->t('Edit Group Name'),
|
||||
'$form_security_token' => BaseModule::getFormSecurityToken('circle_edit'),
|
||||
'$edit_name' => DI::l10n()->t('Edit Circle Name'),
|
||||
'$editable' => 1,
|
||||
];
|
||||
}
|
||||
|
||||
if (!isset($group)) {
|
||||
if (!isset($circle)) {
|
||||
throw new \Friendica\Network\HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
$groupeditor = [
|
||||
$circle_editor = [
|
||||
'label_members' => DI::l10n()->t('Members'),
|
||||
'members' => [],
|
||||
'label_contacts' => DI::l10n()->t('All Contacts'),
|
||||
'group_is_empty' => DI::l10n()->t('Group is empty'),
|
||||
'circle_is_empty' => DI::l10n()->t('Circle is empty'),
|
||||
'contacts' => [],
|
||||
];
|
||||
|
||||
$sec_token = addslashes(BaseModule::getFormSecurityToken('group_member_change'));
|
||||
$sec_token = addslashes(BaseModule::getFormSecurityToken('circle_member_change'));
|
||||
|
||||
// Format the data of the group members
|
||||
// Format the data of the circle members
|
||||
foreach ($members as $member) {
|
||||
if ($member['url']) {
|
||||
$entry = Contact::getContactTemplateVars($member);
|
||||
$entry['label'] = 'members';
|
||||
$entry['photo_menu'] = '';
|
||||
$entry['change_member'] = [
|
||||
'title' => DI::l10n()->t("Remove contact from group"),
|
||||
'gid' => $group['id'],
|
||||
'title' => DI::l10n()->t('Remove contact from circle'),
|
||||
'gid' => $circle['id'],
|
||||
'cid' => $member['id'],
|
||||
'sec_token' => $sec_token
|
||||
];
|
||||
|
||||
$groupeditor['members'][] = $entry;
|
||||
$circle_editor['members'][] = $entry;
|
||||
} else {
|
||||
Model\Group::removeMember($group['id'], $member['id']);
|
||||
Model\Circle::removeMember($circle['id'], $member['id']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($nogroup) {
|
||||
$contacts = Model\Contact\Group::listUngrouped(DI::userSession()->getLocalUserId());
|
||||
if ($nocircle) {
|
||||
$contacts = Model\Contact\Circle::listUncircled(DI::userSession()->getLocalUserId());
|
||||
} else {
|
||||
$contacts_stmt = DBA::select('contact', [],
|
||||
['rel' => [Model\Contact::FOLLOWER, Model\Contact::FRIEND, Model\Contact::SHARING],
|
||||
|
@ -327,40 +329,40 @@ class Group extends BaseModule
|
|||
}
|
||||
|
||||
if (DBA::isResult($contacts)) {
|
||||
// Format the data of the contacts who aren't in the contact group
|
||||
// Format the data of the contacts who aren't in the contact circle
|
||||
foreach ($contacts as $member) {
|
||||
if (!in_array($member['id'], $preselected)) {
|
||||
$entry = Contact::getContactTemplateVars($member);
|
||||
$entry['label'] = 'contacts';
|
||||
if (!$nogroup)
|
||||
if (!$nocircle)
|
||||
$entry['photo_menu'] = [];
|
||||
|
||||
if (!$nogroup) {
|
||||
if (!$nocircle) {
|
||||
$entry['change_member'] = [
|
||||
'title' => DI::l10n()->t("Add contact to group"),
|
||||
'gid' => $group['id'],
|
||||
'title' => DI::l10n()->t('Add contact to circle'),
|
||||
'gid' => $circle['id'],
|
||||
'cid' => $member['id'],
|
||||
'sec_token' => $sec_token
|
||||
];
|
||||
}
|
||||
|
||||
$groupeditor['contacts'][] = $entry;
|
||||
$circle_editor['contacts'][] = $entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$context['$groupeditor'] = $groupeditor;
|
||||
$context['$circle_editor'] = $circle_editor;
|
||||
|
||||
// If there are to many contacts we could provide an alternative view mode
|
||||
$total = count($groupeditor['members']) + count($groupeditor['contacts']);
|
||||
$total = count($circle_editor['members']) + count($circle_editor['contacts']);
|
||||
$context['$shortmode'] = (($switchtotext && ($total > $switchtotext)) ? true : false);
|
||||
|
||||
if ($change) {
|
||||
$tpl = Renderer::getMarkupTemplate('groupeditor.tpl');
|
||||
$tpl = Renderer::getMarkupTemplate('circle_editor.tpl');
|
||||
echo Renderer::replaceMacros($tpl, $context);
|
||||
System::exit();
|
||||
}
|
||||
|
||||
return Renderer::replaceMacros($tpl, $context);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -191,7 +191,7 @@ class Contact extends BaseModule
|
|||
$search = trim($_GET['search'] ?? '');
|
||||
$nets = trim($_GET['nets'] ?? '');
|
||||
$rel = trim($_GET['rel'] ?? '');
|
||||
$group = trim($_GET['group'] ?? '');
|
||||
$circle = trim($_GET['circle'] ?? '');
|
||||
|
||||
$accounttype = $_GET['accounttype'] ?? '';
|
||||
$accounttypeid = User::getAccountTypeByString($accounttype);
|
||||
|
@ -211,12 +211,12 @@ class Contact extends BaseModule
|
|||
$follow_widget = Widget::follow();
|
||||
}
|
||||
|
||||
$account_widget = Widget::accountTypes($_SERVER['REQUEST_URI'], $accounttype);
|
||||
$account_widget = Widget::accountTypes($_SERVER['REQUEST_URI'], $accounttype);
|
||||
$networks_widget = Widget::networks($_SERVER['REQUEST_URI'], $nets);
|
||||
$rel_widget = Widget::contactRels($_SERVER['REQUEST_URI'], $rel);
|
||||
$groups_widget = Widget::groups($_SERVER['REQUEST_URI'], $group);
|
||||
$rel_widget = Widget::contactRels($_SERVER['REQUEST_URI'], $rel);
|
||||
$circles_widget = Widget::circles($_SERVER['REQUEST_URI'], $circle);
|
||||
|
||||
DI::page()['aside'] .= $vcard_widget . $findpeople_widget . $follow_widget . $rel_widget . $groups_widget . $networks_widget . $account_widget;
|
||||
DI::page()['aside'] .= $vcard_widget . $findpeople_widget . $follow_widget . $rel_widget . $circles_widget . $networks_widget . $account_widget;
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('contacts-head.tpl');
|
||||
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
|
||||
|
@ -306,9 +306,9 @@ class Contact extends BaseModule
|
|||
break;
|
||||
}
|
||||
|
||||
if ($group) {
|
||||
if ($circle) {
|
||||
$sql_extra .= " AND `id` IN (SELECT `contact-id` FROM `group_member` WHERE `gid` = ?)";
|
||||
$sql_values[] = $group;
|
||||
$sql_values[] = $circle;
|
||||
}
|
||||
|
||||
$networks = Widget::unavailableNetworks();
|
||||
|
@ -391,11 +391,11 @@ class Contact extends BaseModule
|
|||
'accesskey' => 'h',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Groups'),
|
||||
'url' => 'group',
|
||||
'label' => DI::l10n()->t('Circles'),
|
||||
'url' => 'circle',
|
||||
'sel' => '',
|
||||
'title' => DI::l10n()->t('Organize your contact groups'),
|
||||
'id' => 'contactgroups-tab',
|
||||
'title' => DI::l10n()->t('Organize your contact circles'),
|
||||
'id' => 'contactcircles-tab',
|
||||
'accesskey' => 'e',
|
||||
],
|
||||
];
|
||||
|
|
|
@ -37,7 +37,7 @@ use Friendica\Core\Renderer;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Module;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
@ -222,13 +222,13 @@ class Profile extends BaseModule
|
|||
}
|
||||
|
||||
$vcard_widget = Widget\VCard::getHTML($contact);
|
||||
$groups_widget = '';
|
||||
$circles_widget = '';
|
||||
|
||||
if (!in_array($localRelationship->rel, [Contact::NOTHING, Contact::SELF])) {
|
||||
$groups_widget = Group::sidebarWidget('contact', 'group', 'full', 'everyone', $data['user']);
|
||||
$circles_widget = Circle::sidebarWidget('contact', 'circle', 'full', 'everyone', $data['user']);
|
||||
}
|
||||
|
||||
$this->page['aside'] .= $vcard_widget . $groups_widget;
|
||||
$this->page['aside'] .= $vcard_widget . $circles_widget;
|
||||
|
||||
$o = '';
|
||||
Nav::setSelected('contact');
|
||||
|
|
|
@ -36,7 +36,7 @@ use Friendica\Core\Session\Capability\IHandleUserSessions;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Profile;
|
||||
|
@ -50,7 +50,7 @@ use Friendica\Util\DateTimeFormat;
|
|||
class Network extends BaseModule
|
||||
{
|
||||
/** @var int */
|
||||
private static $groupId;
|
||||
private static $circleId;
|
||||
/** @var int */
|
||||
private static $forumContactId;
|
||||
/** @var string */
|
||||
|
@ -89,7 +89,7 @@ class Network extends BaseModule
|
|||
$module = 'network';
|
||||
|
||||
DI::page()['aside'] .= Widget::accountTypes($module, self::$accountTypeString);
|
||||
DI::page()['aside'] .= Group::sidebarWidget($module, $module . '/group', 'standard', self::$groupId);
|
||||
DI::page()['aside'] .= Circle::sidebarWidget($module, $module . '/circle', 'standard', self::$circleId);
|
||||
DI::page()['aside'] .= ForumManager::widget($module . '/forum', DI::userSession()->getLocalUserId(), self::$forumContactId);
|
||||
DI::page()['aside'] .= Widget::postedByYear($module . '/archive', DI::userSession()->getLocalUserId(), false);
|
||||
DI::page()['aside'] .= Widget::networks($module, !self::$forumContactId ? self::$network : '');
|
||||
|
@ -131,8 +131,8 @@ class Network extends BaseModule
|
|||
$a = DI::app();
|
||||
|
||||
$default_permissions = [];
|
||||
if (self::$groupId) {
|
||||
$default_permissions['allow_gid'] = [self::$groupId];
|
||||
if (self::$circleId) {
|
||||
$default_permissions['allow_gid'] = [self::$circleId];
|
||||
}
|
||||
|
||||
$allowedCids = [];
|
||||
|
@ -160,23 +160,23 @@ class Network extends BaseModule
|
|||
}
|
||||
|
||||
$x = [
|
||||
'lockstate' => self::$groupId || self::$forumContactId || self::$network || ACL::getLockstateForUserId($a->getLoggedInUserId()) ? 'lock' : 'unlock',
|
||||
'lockstate' => self::$circleId || self::$forumContactId || self::$network || ACL::getLockstateForUserId($a->getLoggedInUserId()) ? 'lock' : 'unlock',
|
||||
'acl' => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId(), true, $default_permissions),
|
||||
'bang' => ((self::$groupId || self::$forumContactId || self::$network) ? '!' : ''),
|
||||
'bang' => ((self::$circleId || self::$forumContactId || self::$network) ? '!' : ''),
|
||||
'content' => $content,
|
||||
];
|
||||
|
||||
$o .= DI::conversation()->statusEditor($x);
|
||||
}
|
||||
|
||||
if (self::$groupId) {
|
||||
$group = DBA::selectFirst('group', ['name'], ['id' => self::$groupId, 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
if (!DBA::isResult($group)) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('No such group'));
|
||||
if (self::$circleId) {
|
||||
$circle = DBA::selectFirst('group', ['name'], ['id' => self::$circleId, 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
if (!DBA::isResult($circle)) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('No such circle'));
|
||||
}
|
||||
|
||||
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'), [
|
||||
'$title' => DI::l10n()->t('Group: %s', $group['name'])
|
||||
'$title' => DI::l10n()->t('Circle: %s', $circle['name'])
|
||||
]) . $o;
|
||||
} elseif (self::$forumContactId) {
|
||||
$contact = Contact::getById(self::$forumContactId);
|
||||
|
@ -305,7 +305,7 @@ class Network extends BaseModule
|
|||
|
||||
protected function parseRequest(array $get)
|
||||
{
|
||||
self::$groupId = $this->parameters['group_id'] ?? 0;
|
||||
self::$circleId = $this->parameters['circle_id'] ?? 0;
|
||||
|
||||
self::$forumContactId = $this->parameters['contact_id'] ?? 0;
|
||||
|
||||
|
@ -411,8 +411,8 @@ class Network extends BaseModule
|
|||
$conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` >= ? ", DateTimeFormat::convert(self::$dateTo, 'UTC', DI::app()->getTimeZone())]);
|
||||
}
|
||||
|
||||
if (self::$groupId) {
|
||||
$conditionStrings = DBA::mergeConditions($conditionStrings, ["`contact-id` IN (SELECT `contact-id` FROM `group_member` WHERE `gid` = ?)", self::$groupId]);
|
||||
if (self::$circleId) {
|
||||
$conditionStrings = DBA::mergeConditions($conditionStrings, ["`contact-id` IN (SELECT `contact-id` FROM `group_member` WHERE `gid` = ?)", self::$circleId]);
|
||||
} elseif (self::$forumContactId) {
|
||||
$conditionStrings = DBA::mergeConditions($conditionStrings,
|
||||
["((`contact-id` = ?) OR `uri-id` IN (SELECT `parent-uri-id` FROM `post-user-view` WHERE (`contact-id` = ? AND `gravity` = ? AND `vid` = ? AND `uid` = ?)))",
|
||||
|
@ -476,10 +476,10 @@ class Network extends BaseModule
|
|||
$parents = [];
|
||||
}
|
||||
|
||||
// We aren't going to try and figure out at the item, group, and page
|
||||
// We aren't going to try and figure out at the item, circle, and page
|
||||
// level which items you've seen and which you haven't. If you're looking
|
||||
// at the top level network page just mark everything seen.
|
||||
if (!self::$groupId && !self::$forumContactId && !self::$star && !self::$mention) {
|
||||
if (!self::$circleId && !self::$forumContactId && !self::$star && !self::$mention) {
|
||||
$condition = ['unseen' => true, 'uid' => DI::userSession()->getLocalUserId()];
|
||||
self::setItemsSeenByCondition($condition);
|
||||
} elseif (!empty($parents)) {
|
||||
|
|
|
@ -113,9 +113,9 @@ class Compose extends BaseModule
|
|||
$user = User::getById(DI::userSession()->getLocalUserId(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'default-location']);
|
||||
|
||||
$contact_allow_list = $this->ACLFormatter->expand($user['allow_cid']);
|
||||
$group_allow_list = $this->ACLFormatter->expand($user['allow_gid']);
|
||||
$circle_allow_list = $this->ACLFormatter->expand($user['allow_gid']);
|
||||
$contact_deny_list = $this->ACLFormatter->expand($user['deny_cid']);
|
||||
$group_deny_list = $this->ACLFormatter->expand($user['deny_gid']);
|
||||
$circle_deny_list = $this->ACLFormatter->expand($user['deny_gid']);
|
||||
|
||||
switch ($posttype) {
|
||||
case Item::PT_PERSONAL_NOTE:
|
||||
|
@ -123,9 +123,9 @@ class Compose extends BaseModule
|
|||
$type = 'note';
|
||||
$doesFederate = false;
|
||||
$contact_allow_list = [$a->getContactId()];
|
||||
$group_allow_list = [];
|
||||
$circle_allow_list = [];
|
||||
$contact_deny_list = [];
|
||||
$group_deny_list = [];
|
||||
$circle_deny_list = [];
|
||||
break;
|
||||
default:
|
||||
$compose_title = $this->l10n->t('Compose new post');
|
||||
|
@ -133,19 +133,19 @@ class Compose extends BaseModule
|
|||
$doesFederate = true;
|
||||
|
||||
$contact_allow = $_REQUEST['contact_allow'] ?? '';
|
||||
$group_allow = $_REQUEST['group_allow'] ?? '';
|
||||
$circle_allow = $_REQUEST['circle_allow'] ?? '';
|
||||
$contact_deny = $_REQUEST['contact_deny'] ?? '';
|
||||
$group_deny = $_REQUEST['group_deny'] ?? '';
|
||||
$circle_deny = $_REQUEST['circle_deny'] ?? '';
|
||||
|
||||
if ($contact_allow
|
||||
. $group_allow
|
||||
. $circle_allow
|
||||
. $contact_deny
|
||||
. $group_deny)
|
||||
. $circle_deny)
|
||||
{
|
||||
$contact_allow_list = $contact_allow ? explode(',', $contact_allow) : [];
|
||||
$group_allow_list = $group_allow ? explode(',', $group_allow) : [];
|
||||
$circle_allow_list = $circle_allow ? explode(',', $circle_allow) : [];
|
||||
$contact_deny_list = $contact_deny ? explode(',', $contact_deny) : [];
|
||||
$group_deny_list = $group_deny ? explode(',', $group_deny) : [];
|
||||
$circle_deny_list = $circle_deny ? explode(',', $circle_deny) : [];
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -229,18 +229,18 @@ class Compose extends BaseModule
|
|||
'$body' => $body,
|
||||
'$location' => $location,
|
||||
|
||||
'$contact_allow'=> implode(',', $contact_allow_list),
|
||||
'$group_allow' => implode(',', $group_allow_list),
|
||||
'$contact_deny' => implode(',', $contact_deny_list),
|
||||
'$group_deny' => implode(',', $group_deny_list),
|
||||
'$contact_allow' => implode(',', $contact_allow_list),
|
||||
'$circle_allow' => implode(',', $circle_allow_list),
|
||||
'$contact_deny' => implode(',', $contact_deny_list),
|
||||
'$circle_deny' => implode(',', $circle_deny_list),
|
||||
|
||||
'$jotplugins' => $jotplugins,
|
||||
'$rand_num' => Crypto::randomDigits(12),
|
||||
'$acl_selector' => ACL::getFullSelectorHTML($this->page, $a->getLoggedInUserId(), $doesFederate, [
|
||||
'allow_cid' => $contact_allow_list,
|
||||
'allow_gid' => $group_allow_list,
|
||||
'allow_gid' => $circle_allow_list,
|
||||
'deny_cid' => $contact_deny_list,
|
||||
'deny_gid' => $group_deny_list,
|
||||
'deny_gid' => $circle_deny_list,
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ use Friendica\Core\Session\Capability\IHandleUserSessions;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Model\Verb;
|
||||
|
@ -108,7 +108,7 @@ class Ping extends BaseModule
|
|||
$network_count = 0;
|
||||
$register_count = 0;
|
||||
$sysnotify_count = 0;
|
||||
$groups_unseen = [];
|
||||
$circles_unseen = [];
|
||||
$forums_unseen = [];
|
||||
|
||||
$event_count = 0;
|
||||
|
@ -151,12 +151,12 @@ class Ping extends BaseModule
|
|||
}
|
||||
}
|
||||
|
||||
$compute_group_counts = $this->config->get('system','compute_group_counts');
|
||||
if ($network_count && $compute_group_counts) {
|
||||
// Find out how unseen network posts are spread across groups
|
||||
foreach (Group::countUnseen() as $group_count) {
|
||||
if ($group_count['count'] > 0) {
|
||||
$groups_unseen[] = $group_count;
|
||||
$compute_circle_counts = $this->config->get('system','compute_group_counts') ?? $this->config->get('system','compute_circle_counts');
|
||||
if ($network_count && $compute_circle_counts) {
|
||||
// Find out how unseen network posts are spread across circles
|
||||
foreach (Circle::countUnseen() as $circle_count) {
|
||||
if ($circle_count['count'] > 0) {
|
||||
$circles_unseen[] = $circle_count;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ class Ping extends BaseModule
|
|||
$data['events-today'] = $today_event_count;
|
||||
$data['birthdays'] = $birthday_count;
|
||||
$data['birthdays-today'] = $today_birthday_count;
|
||||
$data['groups'] = $groups_unseen;
|
||||
$data['circles'] = $circles_unseen;
|
||||
$data['forums'] = $forums_unseen;
|
||||
$data['notification'] = ($notification_count < 50) ? $notification_count : '49+';
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ use Friendica\Core\System;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\APContact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Tag;
|
||||
|
@ -113,29 +113,29 @@ class PermissionTooltip extends \Friendica\BaseModule
|
|||
exit;
|
||||
}
|
||||
|
||||
$allowed_users = $model['allow_cid'];
|
||||
$allowed_groups = $model['allow_gid'];
|
||||
$deny_users = $model['deny_cid'];
|
||||
$deny_groups = $model['deny_gid'];
|
||||
$allowed_users = $model['allow_cid'];
|
||||
$allowed_circles = $model['allow_gid'];
|
||||
$deny_users = $model['deny_cid'];
|
||||
$deny_circles = $model['deny_gid'];
|
||||
|
||||
$o = DI::l10n()->t('Visible to:') . '<br />';
|
||||
$l = [];
|
||||
|
||||
if (count($allowed_groups)) {
|
||||
$key = array_search(Group::FOLLOWERS, $allowed_groups);
|
||||
if (count($allowed_circles)) {
|
||||
$key = array_search(Circle::FOLLOWERS, $allowed_circles);
|
||||
if ($key !== false) {
|
||||
$l[] = '<b>' . DI::l10n()->t('Followers') . '</b>';
|
||||
unset($allowed_groups[$key]);
|
||||
unset($allowed_circles[$key]);
|
||||
}
|
||||
|
||||
$key = array_search(Group::MUTUALS, $allowed_groups);
|
||||
$key = array_search(Circle::MUTUALS, $allowed_circles);
|
||||
if ($key !== false) {
|
||||
$l[] = '<b>' . DI::l10n()->t('Mutuals') . '</b>';
|
||||
unset($allowed_groups[$key]);
|
||||
unset($allowed_circles[$key]);
|
||||
}
|
||||
|
||||
foreach (DI::dba()->selectToArray('group', ['name'], ['id' => $allowed_groups]) as $group) {
|
||||
$l[] = '<b>' . $group['name'] . '</b>';
|
||||
foreach (DI::dba()->selectToArray('group', ['name'], ['id' => $allowed_circles]) as $circle) {
|
||||
$l[] = '<b>' . $circle['name'] . '</b>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,21 +143,21 @@ class PermissionTooltip extends \Friendica\BaseModule
|
|||
$l[] = $contact['name'];
|
||||
}
|
||||
|
||||
if (count($deny_groups)) {
|
||||
$key = array_search(Group::FOLLOWERS, $deny_groups);
|
||||
if (count($deny_circles)) {
|
||||
$key = array_search(Circle::FOLLOWERS, $deny_circles);
|
||||
if ($key !== false) {
|
||||
$l[] = '<b><strike>' . DI::l10n()->t('Followers') . '</strike></b>';
|
||||
unset($deny_groups[$key]);
|
||||
unset($deny_circles[$key]);
|
||||
}
|
||||
|
||||
$key = array_search(Group::MUTUALS, $deny_groups);
|
||||
$key = array_search(Circle::MUTUALS, $deny_circles);
|
||||
if ($key !== false) {
|
||||
$l[] = '<b><strike>' . DI::l10n()->t('Mutuals') . '</strike></b>';
|
||||
unset($deny_groups[$key]);
|
||||
unset($deny_circles[$key]);
|
||||
}
|
||||
|
||||
foreach (DI::dba()->selectToArray('group', ['name'], ['id' => $allowed_groups]) as $group) {
|
||||
$l[] = '<b><strike>' . $group['name'] . '</strike></b>';
|
||||
foreach (DI::dba()->selectToArray('group', ['name'], ['id' => $allowed_circles]) as $circle) {
|
||||
$l[] = '<b><strike>' . $circle['name'] . '</strike></b>';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ class Conversations extends BaseProfile
|
|||
$o .= $this->conversation->statusEditor($x);
|
||||
}
|
||||
|
||||
// Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
|
||||
// Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched their circles
|
||||
$condition = Item::getPermissionsConditionArrayByUserId($profile['uid']);
|
||||
|
||||
$last_updated_array = $this->session->get('last_updated', []);
|
||||
|
|
|
@ -93,14 +93,14 @@ class Photos extends \Friendica\Module\BaseProfile
|
|||
}
|
||||
|
||||
$str_contact_allow = isset($request['contact_allow']) ? $this->aclFormatter->toString($request['contact_allow']) : $this->owner['allow_cid'] ?? '';
|
||||
$str_group_allow = isset($request['group_allow']) ? $this->aclFormatter->toString($request['group_allow']) : $this->owner['allow_gid'] ?? '';
|
||||
$str_circle_allow = isset($request['circle_allow']) ? $this->aclFormatter->toString($request['circle_allow']) : $this->owner['allow_gid'] ?? '';
|
||||
$str_contact_deny = isset($request['contact_deny']) ? $this->aclFormatter->toString($request['contact_deny']) : $this->owner['deny_cid'] ?? '';
|
||||
$str_group_deny = isset($request['group_deny']) ? $this->aclFormatter->toString($request['group_deny']) : $this->owner['deny_gid'] ?? '';
|
||||
$str_circle_deny = isset($request['circle_deny']) ? $this->aclFormatter->toString($request['circle_deny']) : $this->owner['deny_gid'] ?? '';
|
||||
|
||||
$visibility = $request['visibility'] ?? '';
|
||||
if ($visibility === 'public') {
|
||||
// The ACL selector introduced in version 2019.12 sends ACL input data even when the Public visibility is selected
|
||||
$str_contact_allow = $str_group_allow = $str_contact_deny = $str_group_deny = '';
|
||||
$str_contact_allow = $str_circle_allow = $str_contact_deny = $str_circle_deny = '';
|
||||
} else if ($visibility === 'custom') {
|
||||
// Since we know from the visibility parameter the item should be private, we have to prevent the empty ACL
|
||||
// case that would make it public. So we always append the author's contact id to the allowed contacts.
|
||||
|
@ -231,7 +231,7 @@ class Photos extends \Friendica\Module\BaseProfile
|
|||
|
||||
$resource_id = Photo::newResource();
|
||||
|
||||
$preview = Photo::storeWithPreview($image, $this->owner['uid'], $resource_id, $filename, $filesize, $album, '', $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
|
||||
$preview = Photo::storeWithPreview($image, $this->owner['uid'], $resource_id, $filename, $filesize, $album, '', $str_contact_allow, $str_circle_allow, $str_contact_deny, $str_circle_deny);
|
||||
if ($preview < 0) {
|
||||
$this->logger->warning('image store failed');
|
||||
$this->systemMessages->addNotice($this->t('Image upload failed.'));
|
||||
|
@ -267,9 +267,9 @@ class Photos extends \Friendica\Module\BaseProfile
|
|||
$arr['author-avatar'] = $this->owner['thumb'];
|
||||
$arr['title'] = '';
|
||||
$arr['allow_cid'] = $str_contact_allow;
|
||||
$arr['allow_gid'] = $str_group_allow;
|
||||
$arr['allow_gid'] = $str_circle_allow;
|
||||
$arr['deny_cid'] = $str_contact_deny;
|
||||
$arr['deny_gid'] = $str_group_deny;
|
||||
$arr['deny_gid'] = $str_circle_deny;
|
||||
$arr['visible'] = $visible;
|
||||
$arr['origin'] = 1;
|
||||
|
||||
|
|
|
@ -46,13 +46,13 @@ use Psr\Log\LoggerInterface;
|
|||
*/
|
||||
class Acl extends BaseModule
|
||||
{
|
||||
const TYPE_GLOBAL_CONTACT = 'x';
|
||||
const TYPE_MENTION_CONTACT = 'c';
|
||||
const TYPE_MENTION_GROUP = 'g';
|
||||
const TYPE_MENTION_CONTACT_GROUP = '';
|
||||
const TYPE_MENTION_FORUM = 'f';
|
||||
const TYPE_PRIVATE_MESSAGE = 'm';
|
||||
const TYPE_ANY_CONTACT = 'a';
|
||||
const TYPE_GLOBAL_CONTACT = 'x';
|
||||
const TYPE_MENTION_CONTACT = 'c';
|
||||
const TYPE_MENTION_CIRCLE = 'g';
|
||||
const TYPE_MENTION_CONTACT_CIRCLE = '';
|
||||
const TYPE_MENTION_FORUM = 'f';
|
||||
const TYPE_PRIVATE_MESSAGE = 'm';
|
||||
const TYPE_ANY_CONTACT = 'a';
|
||||
|
||||
/** @var IHandleUserSessions */
|
||||
private $session;
|
||||
|
@ -73,7 +73,7 @@ class Acl extends BaseModule
|
|||
throw new HTTPException\UnauthorizedException($this->t('You must be logged in to use this module.'));
|
||||
}
|
||||
|
||||
$type = $request['type'] ?? self::TYPE_MENTION_CONTACT_GROUP;
|
||||
$type = $request['type'] ?? self::TYPE_MENTION_CONTACT_CIRCLE;
|
||||
if ($type === self::TYPE_GLOBAL_CONTACT) {
|
||||
$o = $this->globalContactSearch($request);
|
||||
} else {
|
||||
|
@ -128,28 +128,28 @@ class Acl extends BaseModule
|
|||
|
||||
$this->logger->info('ACL {action} - {subaction} - start', ['module' => 'acl', 'action' => 'content', 'subaction' => 'search', 'search' => $search, 'type' => $type, 'conversation' => $conv_id]);
|
||||
|
||||
$sql_extra = '';
|
||||
$condition = ["`uid` = ? AND NOT `deleted` AND NOT `pending` AND NOT `archive`", $this->session->getLocalUserId()];
|
||||
$condition_group = ["`uid` = ? AND NOT `deleted`", $this->session->getLocalUserId()];
|
||||
$sql_extra = '';
|
||||
$condition = ["`uid` = ? AND NOT `deleted` AND NOT `pending` AND NOT `archive`", $this->session->getLocalUserId()];
|
||||
$condition_circle = ["`uid` = ? AND NOT `deleted`", $this->session->getLocalUserId()];
|
||||
|
||||
if ($search != '') {
|
||||
$sql_extra = "AND `name` LIKE '%%" . $this->database->escape($search) . "%%'";
|
||||
$condition = DBA::mergeConditions($condition, ["(`attag` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?)",
|
||||
$sql_extra = "AND `name` LIKE '%%" . $this->database->escape($search) . "%%'";
|
||||
$condition = DBA::mergeConditions($condition, ["(`attag` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?)",
|
||||
'%' . $search . '%', '%' . $search . '%', '%' . $search . '%']);
|
||||
$condition_group = DBA::mergeConditions($condition_group, ["`name` LIKE ?", '%' . $search . '%']);
|
||||
$condition_circle = DBA::mergeConditions($condition_circle, ["`name` LIKE ?", '%' . $search . '%']);
|
||||
}
|
||||
|
||||
// count groups and contacts
|
||||
$group_count = 0;
|
||||
if ($type == self::TYPE_MENTION_CONTACT_GROUP || $type == self::TYPE_MENTION_GROUP) {
|
||||
$group_count = $this->database->count('group', $condition_group);
|
||||
// count circles and contacts
|
||||
$circle_count = 0;
|
||||
if ($type == self::TYPE_MENTION_CONTACT_CIRCLE || $type == self::TYPE_MENTION_CIRCLE) {
|
||||
$circle_count = $this->database->count('group', $condition_circle);
|
||||
}
|
||||
|
||||
$networks = Widget::unavailableNetworks();
|
||||
$condition = DBA::mergeConditions($condition, array_merge(["NOT `network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")"], $networks));
|
||||
|
||||
switch ($type) {
|
||||
case self::TYPE_MENTION_CONTACT_GROUP:
|
||||
case self::TYPE_MENTION_CONTACT_CIRCLE:
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
["NOT `self` AND NOT `blocked` AND `notify` != ? AND `network` != ?", '', Protocol::OSTATUS
|
||||
]);
|
||||
|
@ -176,52 +176,52 @@ class Acl extends BaseModule
|
|||
|
||||
$contact_count = $this->database->count('contact', $condition);
|
||||
|
||||
$resultTotal = $group_count + $contact_count;
|
||||
$resultTotal = $circle_count + $contact_count;
|
||||
|
||||
$resultGroups = [];
|
||||
$resultCircles = [];
|
||||
$resultContacts = [];
|
||||
|
||||
if ($type == self::TYPE_MENTION_CONTACT_GROUP || $type == self::TYPE_MENTION_GROUP) {
|
||||
if ($type == self::TYPE_MENTION_CONTACT_CIRCLE || $type == self::TYPE_MENTION_CIRCLE) {
|
||||
/// @todo We should cache this query.
|
||||
// This can be done when we can delete cache entries via wildcard
|
||||
$groups = $this->database->toArray($this->database->p("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') AS uids
|
||||
FROM `group`
|
||||
INNER JOIN `group_member` ON `group_member`.`gid`=`group`.`id`
|
||||
WHERE NOT `group`.`deleted` AND `group`.`uid` = ?
|
||||
$circles = $this->database->toArray($this->database->p("SELECT `circle`.`id`, `circle`.`name`, GROUP_CONCAT(DISTINCT `circle_member`.`contact-id` SEPARATOR ',') AS uids
|
||||
FROM `group` AS `circle`
|
||||
INNER JOIN `group_member` AS `circle_member` ON `circle_member`.`gid` = `circle`.`id`
|
||||
WHERE NOT `circle`.`deleted` AND `circle`.`uid` = ?
|
||||
$sql_extra
|
||||
GROUP BY `group`.`name`, `group`.`id`
|
||||
ORDER BY `group`.`name`
|
||||
GROUP BY `circle`.`name`, `circle`.`id`
|
||||
ORDER BY `circle`.`name`
|
||||
LIMIT ?, ?",
|
||||
$this->session->getLocalUserId(),
|
||||
$start,
|
||||
$count
|
||||
));
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$resultGroups[] = [
|
||||
'type' => 'g',
|
||||
foreach ($circles as $circle) {
|
||||
$resultCircles[] = [
|
||||
'type' => self::TYPE_MENTION_CIRCLE,
|
||||
'photo' => 'images/twopeople.png',
|
||||
'name' => htmlspecialchars($group['name']),
|
||||
'id' => intval($group['id']),
|
||||
'uids' => array_map('intval', explode(',', $group['uids'])),
|
||||
'name' => htmlspecialchars($circle['name']),
|
||||
'id' => intval($circle['id']),
|
||||
'uids' => array_map('intval', explode(',', $circle['uids'])),
|
||||
'link' => '',
|
||||
'forum' => '0'
|
||||
];
|
||||
}
|
||||
if ((count($resultGroups) > 0) && ($search == '')) {
|
||||
$resultGroups[] = ['separator' => true];
|
||||
if ((count($resultCircles) > 0) && ($search == '')) {
|
||||
$resultCircles[] = ['separator' => true];
|
||||
}
|
||||
}
|
||||
|
||||
$contacts = [];
|
||||
if ($type != self::TYPE_MENTION_GROUP) {
|
||||
if ($type != self::TYPE_MENTION_CIRCLE) {
|
||||
$contacts = Contact::selectToArray([], $condition, ['order' => ['name']]);
|
||||
}
|
||||
|
||||
$forums = [];
|
||||
foreach ($contacts as $contact) {
|
||||
$entry = [
|
||||
'type' => 'c',
|
||||
'type' => self::TYPE_MENTION_CONTACT,
|
||||
'photo' => Contact::getMicro($contact, true),
|
||||
'name' => htmlspecialchars($contact['name']),
|
||||
'id' => intval($contact['id']),
|
||||
|
@ -246,7 +246,7 @@ class Acl extends BaseModule
|
|||
$resultContacts = array_merge($forums, $resultContacts);
|
||||
}
|
||||
|
||||
$resultItems = array_merge($resultGroups, $resultContacts);
|
||||
$resultItems = array_merge($resultCircles, $resultContacts);
|
||||
|
||||
if ($conv_id) {
|
||||
// In multithreaded posts the conv_id is not the parent of the whole thread
|
||||
|
@ -277,7 +277,7 @@ class Acl extends BaseModule
|
|||
$contact = Contact::getByURL($author, false, ['micro', 'name', 'id', 'network', 'nick', 'addr', 'url', 'forum', 'avatar']);
|
||||
if ($contact) {
|
||||
$unknown_contacts[] = [
|
||||
'type' => 'c',
|
||||
'type' => self::TYPE_MENTION_CONTACT,
|
||||
'photo' => Contact::getMicro($contact, true),
|
||||
'name' => htmlspecialchars($contact['name']),
|
||||
'id' => intval($contact['id']),
|
||||
|
@ -298,7 +298,7 @@ class Acl extends BaseModule
|
|||
'tot' => $resultTotal,
|
||||
'start' => $start,
|
||||
'count' => $count,
|
||||
'groups' => $resultGroups,
|
||||
'circles' => $resultCircles,
|
||||
'contacts' => $resultContacts,
|
||||
'items' => $resultItems,
|
||||
'type' => $type,
|
||||
|
|
|
@ -29,7 +29,7 @@ use Friendica\Core\Search;
|
|||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Model\Notification;
|
||||
use Friendica\Model\Post\UserNotification;
|
||||
use Friendica\Model\Profile;
|
||||
|
@ -162,23 +162,23 @@ class Account extends BaseSettings
|
|||
$blocktags = empty($request['blocktags']); // this setting is inverted!
|
||||
$unkmail = !empty($request['unkmail']);
|
||||
$cntunkmail = intval($request['cntunkmail'] ?? 0);
|
||||
$def_gid = intval($request['group-selection'] ?? 0);
|
||||
$def_gid = intval($request['circle-selection'] ?? 0);
|
||||
|
||||
$aclFormatter = DI::aclFormatter();
|
||||
|
||||
$str_group_allow = !empty($request['group_allow']) ? $aclFormatter->toString($request['group_allow']) : '';
|
||||
$str_contact_allow = !empty($request['contact_allow']) ? $aclFormatter->toString($request['contact_allow']) : '';
|
||||
$str_group_deny = !empty($request['group_deny']) ? $aclFormatter->toString($request['group_deny']) : '';
|
||||
$str_contact_deny = !empty($request['contact_deny']) ? $aclFormatter->toString($request['contact_deny']) : '';
|
||||
$str_circle_allow = !empty($request['circle_allow']) ? $aclFormatter->toString($request['circle_allow']) : '';
|
||||
$str_contact_deny = !empty($request['contact_deny']) ? $aclFormatter->toString($request['contact_deny']) : '';
|
||||
$str_circle_deny = !empty($request['circle_deny']) ? $aclFormatter->toString($request['circle_deny']) : '';
|
||||
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'unlisted', !empty($request['unlisted']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'accessible-photos', !empty($request['accessible-photos']));
|
||||
|
||||
$fields = [
|
||||
'allow_cid' => $str_contact_allow,
|
||||
'allow_gid' => $str_group_allow,
|
||||
'allow_gid' => $str_circle_allow,
|
||||
'deny_cid' => $str_contact_deny,
|
||||
'deny_gid' => $str_group_deny,
|
||||
'deny_gid' => $str_circle_deny,
|
||||
'maxreq' => $maxreq,
|
||||
'def_gid' => $def_gid,
|
||||
'blockwall' => $blockwall,
|
||||
|
@ -329,7 +329,7 @@ class Account extends BaseSettings
|
|||
$fields = [
|
||||
'allow_cid' => '',
|
||||
'allow_gid' => $page_flags == User::PAGE_FLAGS_PRVGROUP ?
|
||||
'<' . Group::FOLLOWERS . '>'
|
||||
'<' . Circle::FOLLOWERS . '>'
|
||||
: '',
|
||||
'deny_cid' => '',
|
||||
'deny_gid' => '',
|
||||
|
@ -592,7 +592,7 @@ class Account extends BaseSettings
|
|||
'$blocktags' => ['blocktags', DI::l10n()->t('Allow friends to tag your posts?'), (intval($user['blocktags']) ? '0' : '1'), DI::l10n()->t('Your contacts can add additional tags to your posts.')],
|
||||
'$unkmail' => ['unkmail', DI::l10n()->t('Permit unknown people to send you private mail?'), $unkmail, DI::l10n()->t('Friendica network users may send you private messages even if they are not in your contact list.')],
|
||||
'$cntunkmail' => ['cntunkmail', DI::l10n()->t('Maximum private messages per day from unknown people:'), $cntunkmail, DI::l10n()->t("(to prevent spam abuse)")],
|
||||
'$group_select' => Group::displayGroupSelection(DI::userSession()->getLocalUserId(), $user['def_gid']),
|
||||
'$circle_select' => Circle::getSelectorHTML(DI::userSession()->getLocalUserId(), $user['def_gid']),
|
||||
'$permissions' => DI::l10n()->t('Default Post Permissions'),
|
||||
'$aclselect' => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId()),
|
||||
|
||||
|
|
|
@ -260,7 +260,7 @@ class Index extends BaseSettings
|
|||
<p>You can use BBCodes in the field values.</p>
|
||||
<p>Reorder by dragging the field title.</p>
|
||||
<p>Empty the label field to remove a custom field.</p>
|
||||
<p>Non-public fields can only be seen by the selected Friendica contacts or the Friendica contacts in the selected groups.</p>",
|
||||
<p>Non-public fields can only be seen by the selected Friendica contacts or the Friendica contacts in the selected circles.</p>",
|
||||
'profile/' . $profile['nickname'] . '/profile'
|
||||
),
|
||||
'$custom_fields' => $custom_fields,
|
||||
|
@ -284,9 +284,9 @@ class Index extends BaseSettings
|
|||
$permissionSet = DI::permissionSet()->selectOrCreate(DI::permissionSetFactory()->createFromString(
|
||||
$uid,
|
||||
DI::aclFormatter()->toString($profileFieldInputs['new']['contact_allow'] ?? ''),
|
||||
DI::aclFormatter()->toString($profileFieldInputs['new']['group_allow'] ?? ''),
|
||||
DI::aclFormatter()->toString($profileFieldInputs['new']['circle_allow'] ?? ''),
|
||||
DI::aclFormatter()->toString($profileFieldInputs['new']['contact_deny'] ?? ''),
|
||||
DI::aclFormatter()->toString($profileFieldInputs['new']['group_deny'] ?? '')
|
||||
DI::aclFormatter()->toString($profileFieldInputs['new']['circle_deny'] ?? '')
|
||||
));
|
||||
|
||||
$profileFields->append(DI::profileFieldFactory()->createFromValues(
|
||||
|
@ -305,9 +305,9 @@ class Index extends BaseSettings
|
|||
$permissionSet = DI::permissionSet()->selectOrCreate(DI::permissionSetFactory()->createFromString(
|
||||
$uid,
|
||||
DI::aclFormatter()->toString($profileFieldInput['contact_allow'] ?? ''),
|
||||
DI::aclFormatter()->toString($profileFieldInput['group_allow'] ?? ''),
|
||||
DI::aclFormatter()->toString($profileFieldInput['circle_allow'] ?? ''),
|
||||
DI::aclFormatter()->toString($profileFieldInput['contact_deny'] ?? ''),
|
||||
DI::aclFormatter()->toString($profileFieldInput['group_deny'] ?? '')
|
||||
DI::aclFormatter()->toString($profileFieldInput['circle_deny'] ?? '')
|
||||
));
|
||||
|
||||
$profileFields->append(DI::profileFieldFactory()->createFromValues(
|
||||
|
|
|
@ -263,12 +263,12 @@ class UserExport extends BaseSettings
|
|||
sprintf("SELECT * FROM `pconfig` WHERE uid = %d", $user_id)
|
||||
);
|
||||
|
||||
$group = $this->exportMultiRow(
|
||||
$circle = $this->exportMultiRow(
|
||||
sprintf("SELECT * FROM `group` WHERE uid = %d", $user_id)
|
||||
);
|
||||
|
||||
$group_member = $this->exportMultiRow(
|
||||
sprintf("SELECT `group_member`.`gid`, `group_member`.`contact-id` FROM `group_member` INNER JOIN `group` ON `group`.`id` = `group_member`.`gid` WHERE `group`.`uid` = %d", $user_id)
|
||||
$circle_member = $this->exportMultiRow(
|
||||
sprintf("SELECT `circle_member`.`gid`, `circle_member`.`contact-id` FROM `group_member` AS `circle_member` INNER JOIN `group` AS `circle` ON `circle`.`id` = `circle_member`.`gid` WHERE `circle`.`uid` = %d", $user_id)
|
||||
);
|
||||
|
||||
$output = [
|
||||
|
@ -281,8 +281,8 @@ class UserExport extends BaseSettings
|
|||
'profile_fields' => $profile_fields,
|
||||
'photo' => $photo,
|
||||
'pconfig' => $pconfig,
|
||||
'group' => $group,
|
||||
'group_member' => $group_member,
|
||||
'circle' => $circle,
|
||||
'circle_member' => $circle_member,
|
||||
];
|
||||
|
||||
echo json_encode($output, JSON_PARTIAL_OUTPUT_ON_ERROR);
|
||||
|
|
|
@ -63,7 +63,7 @@ class Profile extends BaseModule
|
|||
System::htmlUpdateExit($o);
|
||||
}
|
||||
|
||||
// Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
|
||||
// Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched their circles
|
||||
$sql_extra = Item::getPermissionsSQLByUserId($a->getProfileOwner());
|
||||
|
||||
$last_updated_array = DI::session()->get('last_updated', []);
|
||||
|
|
|
@ -231,6 +231,10 @@ class Import extends \Friendica\BaseModule
|
|||
return;
|
||||
}
|
||||
|
||||
// Backward compatibility
|
||||
$account['circle'] = $account['circle'] ?? $account['group'];
|
||||
$account['circle_member'] = $account['circle_member'] ?? $account['group_member'];
|
||||
|
||||
$oldBaseUrl = $account['baseurl'];
|
||||
$newBaseUrl = (string)$this->baseUrl;
|
||||
|
||||
|
@ -312,35 +316,35 @@ class Import extends \Friendica\BaseModule
|
|||
$this->systemMessages->addNotice($this->tt('%d contact not imported', '%d contacts not imported', $errorCount));
|
||||
}
|
||||
|
||||
array_walk($account['group'], function (&$group) use ($newUid) {
|
||||
$group['uid'] = $newUid;
|
||||
if ($this->dbImportAssoc('group', $group) === false) {
|
||||
$this->logger->warning('Error inserting group', ['name' => $group['name'], 'error' => $this->database->errorMessage()]);
|
||||
array_walk($account['circle'], function (&$circle) use ($newUid) {
|
||||
$circle['uid'] = $newUid;
|
||||
if ($this->dbImportAssoc('group', $circle) === false) {
|
||||
$this->logger->warning('Error inserting circle', ['name' => $circle['name'], 'error' => $this->database->errorMessage()]);
|
||||
} else {
|
||||
$group['newid'] = $this->lastInsertId();
|
||||
$circle['newid'] = $this->lastInsertId();
|
||||
}
|
||||
});
|
||||
|
||||
foreach ($account['group_member'] as $group_member) {
|
||||
foreach ($account['circle_member'] as $circle_member) {
|
||||
$import = 0;
|
||||
foreach ($account['group'] as $group) {
|
||||
if ($group['id'] == $group_member['gid'] && isset($group['newid'])) {
|
||||
$group_member['gid'] = $group['newid'];
|
||||
foreach ($account['circle'] as $circle) {
|
||||
if ($circle['id'] == $circle_member['gid'] && isset($circle['newid'])) {
|
||||
$circle_member['gid'] = $circle['newid'];
|
||||
$import++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($account['contact'] as $contact) {
|
||||
if ($contact['id'] == $group_member['contact-id'] && isset($contact['newid'])) {
|
||||
$group_member['contact-id'] = $contact['newid'];
|
||||
if ($contact['id'] == $circle_member['contact-id'] && isset($contact['newid'])) {
|
||||
$circle_member['contact-id'] = $contact['newid'];
|
||||
$import++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($import == 2 && $this->dbImportAssoc('group_member', $group_member) === false) {
|
||||
$this->logger->warning('Error inserting group member', ['gid' => $group_member['id'], 'error' => $this->database->errorMessage()]);
|
||||
if ($import == 2 && $this->dbImportAssoc('group_member', $circle_member) === false) {
|
||||
$this->logger->warning('Error inserting circle member', ['gid' => $circle_member['id'], 'error' => $this->database->errorMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,9 +73,9 @@ class Welcome extends BaseModule
|
|||
'$finding_link' => DI::l10n()->t('Finding New People'),
|
||||
'$finding_txt' => DI::l10n()->t('On the side panel of the Contacts page are several tools to find new friends. We can match people by interest, look up people by name or interest, and provide suggestions based on network relationships. On a brand new site, friend suggestions will usually begin to be populated within 24 hours.'),
|
||||
|
||||
'$groups' => DI::l10n()->t('Groups'),
|
||||
'$group_contact_link' => DI::l10n()->t('Group Your Contacts'),
|
||||
'$group_contact_txt' => DI::l10n()->t('Once you have made some friends, organize them into private conversation groups from the sidebar of your Contacts page and then you can interact with each group privately on your Network page.'),
|
||||
'$circles' => DI::l10n()->t('Circles'),
|
||||
'$circle_contact_link' => DI::l10n()->t('Add Your Contacts To Circle'),
|
||||
'$circle_contact_txt' => DI::l10n()->t('Once you have made some friends, organize them into private conversation circles from the sidebar of your Contacts page and then you can interact with each circle privately on your Network page.'),
|
||||
'$newuser_private' => $newuser_private,
|
||||
'$private_link' => DI::l10n()->t('Why Aren\'t My Posts Public?'),
|
||||
'$private_txt' => DI::l10n()->t('Friendica respects your privacy. By default, your posts will only show up to people you\'ve added as friends. For more information, see the help section from the link above.'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue