mirror of
https://github.com/friendica/friendica
synced 2025-05-10 05:04:13 +02:00
Add new method from include/group in relevant Model classes
This commit is contained in:
parent
e44abb6c2a
commit
669c7dea59
3 changed files with 522 additions and 0 deletions
|
@ -8,10 +8,12 @@
|
|||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Object\Image;
|
||||
use dba;
|
||||
|
@ -30,6 +32,36 @@ require_once 'include/text.php';
|
|||
*/
|
||||
class User
|
||||
{
|
||||
/**
|
||||
* @brief Returns the default group for a given user and network
|
||||
*
|
||||
* @param int $uid User id
|
||||
* @param string $network network name
|
||||
*
|
||||
* @return int group id
|
||||
*/
|
||||
public static function getDefaultGroup($uid, $network = '')
|
||||
{
|
||||
$default_group = 0;
|
||||
|
||||
if ($network == NETWORK_OSTATUS) {
|
||||
$default_group = PConfig::get($uid, "ostatus", "default_group");
|
||||
}
|
||||
|
||||
if ($default_group != 0) {
|
||||
return $default_group;
|
||||
}
|
||||
|
||||
$user = dba::select('user', ['def_gid'], ['uid' => $uid], ['limit' => 1]);
|
||||
|
||||
if (DBM::is_result($user)) {
|
||||
$default_group = $user["def_gid"];
|
||||
}
|
||||
|
||||
return $default_group;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Authenticate a user with a clear text password
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue