Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: patch updates for appwrite 1.4.1 #22

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Appwrite/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class Client
*/
protected $headers = [
'content-type' => '',
'user-agent' => 'AppwritePHPSDK/9.0.0 ()',
'user-agent' => 'AppwritePHPSDK/9.0.1 ()',
'x-sdk-name'=> 'PHP',
'x-sdk-platform'=> 'server',
'x-sdk-language'=> 'php',
'x-sdk-version'=> '9.0.0',
'x-sdk-version'=> '9.0.1',
];

/**
Expand Down
71 changes: 71 additions & 0 deletions src/Appwrite/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,110 @@

namespace Appwrite;

/**
* Helper class to generate role strings for Permission.
*/
class Role
{
/**
* Grants access to anyone.
*
* This includes authenticated and unauthenticated users.
*
* @return string
*/
public static function any(): string
{
return 'any';
}

/**
* Grants access to a specific user by user ID.
*
* You can optionally pass verified or unverified for
* `status` to target specific types of users.
*
* @param string $id
* @param string $status
* @return string
*/
public static function user(string $id, string $status = ""): string
{
if(empty($status)) {
return "user:$id";
}
return "user:$id/$status";
}

/**
* Grants access to any authenticated or anonymous user.
*
* You can optionally pass verified or unverified for
* `status` to target specific types of users.
*
* @param string $status
* @return string
*/
public static function users(string $status = ""): string
{
if(empty($status)) {
return 'users';
}
return "users/$status";
}

/**
* Grants access to any guest user without a session.
*
* Authenticated users don't have access to this role.
*
* @return string
*/
public static function guests(): string
{
return 'guests';
}

/**
* Grants access to a team by team ID.
*
* You can optionally pass a role for `role` to target
* team members with the specified role.
*
* @param string $id
* @param string $role
* @return string
*/
public static function team(string $id, string $role = ""): string
{
if(empty($role)) {
return "team:$id";
}
return "team:$id/$role";
}

/**
* Grants access to a specific member of a team.
*
* When the member is removed from the team, they will
* no longer have access.
*
* @param string $id
* @return string
*/
public static function member(string $id): string
{
return "member:$id";
}

/**
* Grants access to a user with the specified label.
*
* @param string $name
* @return string
*/
public static function label(string $name): string
{
return "label:$name";
}
}
Loading