Replace "group" with "circle" in the rest of the code

- Remaining mentions already mean "forum"
This commit is contained in:
Hypolite Petovan 2023-05-13 19:54:35 -04:00
parent 4f6e02357a
commit 4f7740264e
120 changed files with 1308 additions and 1304 deletions

View file

@ -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];

View file

@ -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

View file

@ -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);

View file

@ -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;

View file

@ -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

View file

@ -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');
}

View file

@ -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');
}