/**
* @file src/Model/Group.php
*/
+
namespace Friendica\Model;
use Friendica\BaseModule;
-use Friendica\BaseObject;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
/**
* @brief functions for interacting with the group database table
*/
-class Group extends BaseObject
+class Group
{
const FOLLOWERS = '~';
const MUTUALS = '&';
public static function getByUserId($uid, $includesDeleted = false)
{
- $DB = self::getApp()->getDatabase();
-
$conditions = ['uid' => $uid];
if (!$includesDeleted) {
$conditions['deleted'] = false;
}
- $groupsStmt = $DB->select('group', [], $conditions);
-
- return $DB->toArray($groupsStmt);
+ return DBA::selectToArray('group', [], $conditions);
}
/**
/**
* Update group information.
*
- * @param int $id Group ID
- * @param string $name Group name
+ * @param int $id Group ID
+ * @param string $name Group name
*
* @return bool Was the update successful?
* @throws \Exception
* @return boolean
* @throws \Exception
*/
- public static function remove($gid) {
- if (! $gid) {
+ public static function remove($gid)
+ {
+ if (!$gid) {
return false;
}
/**
* @brief Mark a group as deleted based on its name
*
- * @deprecated Use Group::remove instead
- *
* @param int $uid
* @param string $name
* @return bool
* @throws \Exception
+ * @deprecated Use Group::remove instead
+ *
*/
- public static function removeByName($uid, $name) {
+ public static function removeByName($uid, $name)
+ {
$return = false;
if (!empty($uid) && !empty($name)) {
$gid = self::getIdByName($uid, $name);
/**
* @brief Removes a contact from a group based on its name
*
- * @deprecated Use Group::removeMember instead
- *
* @param int $uid
* @param string $name
* @param int $cid
* @return boolean
* @throws \Exception
+ * @deprecated Use Group::removeMember instead
+ *
*/
public static function removeMemberByName($uid, $name, $cid)
{
}
$return = [];
+ $pubmail = false;
+ $networks = Protocol::SUPPORT_PRIVATE;
+
+ $mailacct = DBA::selectFirst('mailacct', ['pubmail'], ['`uid` = ? AND `server` != ""', $uid]);
+ if (DBA::isResult($mailacct)) {
+ $pubmail = $mailacct['pubmail'];
+ }
+
+ if (!$pubmail) {
+ $networks = array_diff($networks, [Protocol::MAIL]);
+ }
$key = array_search(self::FOLLOWERS, $group_ids);
if ($key !== false) {
$followers = Contact::selectToArray(['id'], [
'uid' => $uid,
'rel' => [Contact::FOLLOWER, Contact::FRIEND],
- 'protocol' => Protocol::SUPPORT_PRIVATE,
+ 'network' => $networks,
+ 'contact-type' => [Contact::TYPE_UNKNOWN, Contact::TYPE_PERSON],
+ 'archive' => false,
+ 'pending' => false,
+ 'blocked' => false,
]);
foreach ($followers as $follower) {
$mutuals = Contact::selectToArray(['id'], [
'uid' => $uid,
'rel' => [Contact::FRIEND],
- 'protocol' => Protocol::SUPPORT_PRIVATE,
+ 'network' => $networks,
+ 'contact-type' => [Contact::TYPE_UNKNOWN, Contact::TYPE_PERSON],
+ 'archive' => false,
+ 'pending' => false,
+ 'blocked' => false,
]);
foreach ($mutuals as $mutual) {
}
$stmt = DBA::select('group_member', ['contact-id'], ['gid' => $group_ids]);
- while($group_member = DBA::fetch($stmt)) {
+ while ($group_member = DBA::fetch($stmt)) {
$return[] = $group_member['contact-id'];
}
DBA::close($stmt);
}
DBA::close($stmt);
- Logger::info('groups: ' . print_r($display_groups, true));
+ Logger::info('Got groups', $display_groups);
if ($label == '') {
$label = L10n::t('Default privacy group for new contacts');