2018-07-19 09:52:05 -04:00
|
|
|
<?php
|
|
|
|
/**
|
2021-03-29 02:40:20 -04:00
|
|
|
* @copyright Copyright (C) 2010-2021, the Friendica project
|
2020-02-09 09:45:36 -05:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
2018-07-19 09:52:05 -04:00
|
|
|
*/
|
2019-11-05 08:27:22 -05:00
|
|
|
|
2018-07-19 09:52:05 -04:00
|
|
|
namespace Friendica\Model;
|
|
|
|
|
2020-01-13 22:20:18 -05:00
|
|
|
use Friendica\BaseModel;
|
2019-11-05 08:27:22 -05:00
|
|
|
use Friendica\DI;
|
2018-07-19 09:52:05 -04:00
|
|
|
|
|
|
|
/**
|
2020-01-19 01:05:23 -05:00
|
|
|
* functions for interacting with the permission set of an object (item, photo, event, ...)
|
2020-01-21 18:22:01 -05:00
|
|
|
*
|
|
|
|
* @property int uid
|
|
|
|
* @property string allow_cid
|
|
|
|
* @property string allow_gid
|
|
|
|
* @property string deny_cid
|
|
|
|
* @property string deny_gid
|
2018-07-19 09:52:05 -04:00
|
|
|
*/
|
2020-01-13 22:20:18 -05:00
|
|
|
class PermissionSet extends BaseModel
|
2018-07-19 09:52:05 -04:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Fetch the id of a given permission set. Generate a new one when needed
|
|
|
|
*
|
2019-11-05 08:27:22 -05:00
|
|
|
* @param int $uid
|
|
|
|
* @param string|null $allow_cid Allowed contact IDs - empty = everyone
|
|
|
|
* @param string|null $allow_gid Allowed group IDs - empty = everyone
|
|
|
|
* @param string|null $deny_cid Disallowed contact IDs - empty = no one
|
|
|
|
* @param string|null $deny_gid Disallowed group IDs - empty = no one
|
2019-01-06 16:06:53 -05:00
|
|
|
* @return int id
|
2020-01-13 22:20:18 -05:00
|
|
|
* @throws \Exception
|
|
|
|
* @deprecated since 2020.03, use Repository\PermissionSet instead
|
|
|
|
* @see \Friendica\Repository\PermissionSet->getIdFromACL
|
2018-07-19 09:52:05 -04:00
|
|
|
*/
|
2019-11-05 08:27:22 -05:00
|
|
|
public static function getIdFromACL(
|
|
|
|
int $uid,
|
|
|
|
string $allow_cid = null,
|
|
|
|
string $allow_gid = null,
|
|
|
|
string $deny_cid = null,
|
|
|
|
string $deny_gid = null
|
|
|
|
) {
|
2020-01-13 22:20:18 -05:00
|
|
|
return DI::permissionSet()->getIdFromACL($uid, $allow_cid, $allow_gid, $deny_cid, $deny_gid);
|
2018-07-19 09:52:05 -04:00
|
|
|
}
|
2018-07-25 19:14:55 -04:00
|
|
|
|
|
|
|
/**
|
2020-01-19 01:05:23 -05:00
|
|
|
* Returns a permission set for a given contact
|
2018-07-25 19:14:55 -04:00
|
|
|
*
|
|
|
|
* @param integer $uid User id whom the items belong
|
|
|
|
* @param integer $contact_id Contact id of the visitor
|
|
|
|
*
|
|
|
|
* @return array of permission set ids.
|
2019-01-06 16:06:53 -05:00
|
|
|
* @throws \Exception
|
2020-01-13 22:20:18 -05:00
|
|
|
* @deprecated since 2020.03, use Repository\PermissionSet instead
|
|
|
|
* @see \Friendica\Repository\PermissionSet->selectByContactId
|
2018-07-25 19:14:55 -04:00
|
|
|
*/
|
2020-01-13 22:20:18 -05:00
|
|
|
public static function get($uid, $contact_id)
|
2018-07-25 19:14:55 -04:00
|
|
|
{
|
2020-01-13 22:20:18 -05:00
|
|
|
$permissionSets = DI::permissionSet()->selectByContactId($contact_id, $uid);
|
2018-07-25 19:14:55 -04:00
|
|
|
|
2020-01-13 22:20:18 -05:00
|
|
|
return $permissionSets->column('id');
|
2018-07-25 19:14:55 -04:00
|
|
|
}
|
2018-07-19 09:52:05 -04:00
|
|
|
}
|