Add new method from include/group in relevant Model classes

This commit is contained in:
Hypolite Petovan 2017-12-09 13:31:00 -05:00
parent e44abb6c2a
commit 669c7dea59
3 changed files with 522 additions and 0 deletions

View file

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