]> git.mxchange.org Git - friendica.git/blob - src/Model/PermissionSet.php
Merge pull request #8147 from annando/fetch-post
[friendica.git] / src / Model / PermissionSet.php
1 <?php
2 /**
3  * @file src/Model/PermissionSet.php
4  */
5
6 namespace Friendica\Model;
7
8 use Friendica\BaseModel;
9 use Friendica\DI;
10
11 /**
12  * functions for interacting with the permission set of an object (item, photo, event, ...)
13  */
14 class PermissionSet extends BaseModel
15 {
16         /**
17          * Fetch the id of a given permission set. Generate a new one when needed
18          *
19          * @param int         $uid
20          * @param string|null $allow_cid Allowed contact IDs    - empty = everyone
21          * @param string|null $allow_gid Allowed group IDs      - empty = everyone
22          * @param string|null $deny_cid  Disallowed contact IDs - empty = no one
23          * @param string|null $deny_gid  Disallowed group IDs   - empty = no one
24          * @return int id
25          * @throws \Exception
26          * @deprecated since 2020.03, use Repository\PermissionSet instead
27          * @see \Friendica\Repository\PermissionSet->getIdFromACL
28          */
29         public static function getIdFromACL(
30                 int $uid,
31                 string $allow_cid = null,
32                 string $allow_gid = null,
33                 string $deny_cid = null,
34                 string $deny_gid = null
35         ) {
36                 return DI::permissionSet()->getIdFromACL($uid, $allow_cid, $allow_gid, $deny_cid, $deny_gid);
37         }
38
39         /**
40          * Returns a permission set for a given contact
41          *
42          * @param integer $uid        User id whom the items belong
43          * @param integer $contact_id Contact id of the visitor
44          *
45          * @return array of permission set ids.
46          * @throws \Exception
47          * @deprecated since 2020.03, use Repository\PermissionSet instead
48          * @see \Friendica\Repository\PermissionSet->selectByContactId
49          */
50         public static function get($uid, $contact_id)
51         {
52                 $permissionSets = DI::permissionSet()->selectByContactId($contact_id, $uid);
53
54                 return $permissionSets->column('id');
55         }
56 }