Use new Model methods for groups
This commit is contained in:
parent
fe89e7760e
commit
abdecd2b2f
17 changed files with 65 additions and 63 deletions
|
|
@ -13,6 +13,7 @@ use Friendica\Core\NotificationsManager;
|
|||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\FKOAuth1;
|
||||
|
|
@ -4645,7 +4646,7 @@ function api_friendica_group_show($type)
|
|||
|
||||
// loop through all groups and retrieve all members for adding data in the user array
|
||||
foreach ($r as $rr) {
|
||||
$members = group_get_members($rr['id']);
|
||||
$members = Contact::getByGroupId($rr['id']);
|
||||
$users = array();
|
||||
|
||||
if ($type == "xml") {
|
||||
|
|
@ -4713,7 +4714,7 @@ function api_friendica_group_delete($type)
|
|||
}
|
||||
|
||||
// delete group
|
||||
$ret = group_rmv($uid, $name);
|
||||
$ret = Group::removeByName($uid, $name);
|
||||
if ($ret) {
|
||||
// return success
|
||||
$success = array('success' => $ret, 'gid' => $gid, 'name' => $name, 'status' => 'deleted', 'wrong users' => array());
|
||||
|
|
@ -4764,9 +4765,9 @@ function api_friendica_group_create($type)
|
|||
$reactivate_group = true;
|
||||
|
||||
// create group
|
||||
$ret = group_add($uid, $name);
|
||||
$ret = Group::create($uid, $name);
|
||||
if ($ret) {
|
||||
$gid = group_byname($uid, $name);
|
||||
$gid = Group::getIdByName($uid, $name);
|
||||
} else {
|
||||
throw new BadRequestException('other API error');
|
||||
}
|
||||
|
|
@ -4783,7 +4784,7 @@ function api_friendica_group_create($type)
|
|||
intval($uid)
|
||||
);
|
||||
if (count($contact))
|
||||
$result = group_add_member($uid, $name, $cid, $gid);
|
||||
$result = Group::create_member($uid, $name, $cid, $gid);
|
||||
else {
|
||||
$erroraddinguser = true;
|
||||
$errorusers[] = $cid;
|
||||
|
|
@ -4822,14 +4823,14 @@ function api_friendica_group_update($type)
|
|||
throw new BadRequestException('gid not specified');
|
||||
|
||||
// remove members
|
||||
$members = group_get_members($gid);
|
||||
$members = Contact::getByGroupId($gid);
|
||||
foreach ($members as $member) {
|
||||
$cid = $member['id'];
|
||||
foreach ($users as $user) {
|
||||
$found = ($user['cid'] == $cid ? true : false);
|
||||
}
|
||||
if (!$found) {
|
||||
$ret = group_rmv_member($uid, $name, $cid);
|
||||
$ret = Group::removeMemberByName($uid, $name, $cid);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4846,7 +4847,7 @@ function api_friendica_group_update($type)
|
|||
);
|
||||
|
||||
if (count($contact)) {
|
||||
$result = group_add_member($uid, $name, $cid, $gid);
|
||||
$result = Group::create_member($uid, $name, $cid, $gid);
|
||||
} else {
|
||||
$erroraddinguser = true;
|
||||
$errorusers[] = $cid;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ use Friendica\Core\System;
|
|||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\OStatus;
|
||||
|
|
@ -244,10 +246,7 @@ function new_contact($uid, $url, $interactive = false, $network = '') {
|
|||
$contact_id = $r[0]['id'];
|
||||
$result['cid'] = $contact_id;
|
||||
|
||||
$def_gid = get_default_group($uid, $contact["network"]);
|
||||
if (intval($def_gid)) {
|
||||
group_add_member($uid, '', $contact_id, $def_gid);
|
||||
}
|
||||
Group::addMember(User::getDefaultGroup($uid, $contact["network"]), $contact_id);
|
||||
|
||||
// Update the avatar
|
||||
Contact::updateAvatar($ret['photo'], $uid, $contact_id);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ use Friendica\Core\System;
|
|||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Protocol\DFRN;
|
||||
use Friendica\Protocol\OStatus;
|
||||
|
|
@ -1720,11 +1722,7 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
|
|||
'hash' => $hash, 'datetime' => datetime_convert()));
|
||||
}
|
||||
|
||||
$def_gid = get_default_group($importer['uid'], $contact_record["network"]);
|
||||
|
||||
if (intval($def_gid)) {
|
||||
group_add_member($importer['uid'], '', $contact_record['id'], $def_gid);
|
||||
}
|
||||
Group::addMember(User::getDefaultGroup($importer['uid'], $contact_record["network"]), $contact_record['id']);
|
||||
|
||||
if (($r[0]['notify-flags'] & NOTIFY_INTRO) &&
|
||||
in_array($r[0]['page-flags'], array(PAGE_NORMAL))) {
|
||||
|
|
@ -1958,9 +1956,9 @@ function compare_permissions($obj1, $obj2) {
|
|||
/// @TODO type-hint is array
|
||||
function enumerate_permissions($obj) {
|
||||
$allow_people = expand_acl($obj['allow_cid']);
|
||||
$allow_groups = expand_groups(expand_acl($obj['allow_gid']));
|
||||
$allow_groups = Group::expand(expand_acl($obj['allow_gid']));
|
||||
$deny_people = expand_acl($obj['deny_cid']);
|
||||
$deny_groups = expand_groups(expand_acl($obj['deny_gid']));
|
||||
$deny_groups = Group::expand(expand_acl($obj['deny_gid']));
|
||||
$recipients = array_unique(array_merge($allow_people, $allow_groups));
|
||||
$deny = array_unique(array_merge($deny_people, $deny_groups));
|
||||
$recipients = array_diff($recipients, $deny);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue