mirror of
				https://github.com/sitelease/sugar-cube-client.git
				synced 2025-10-31 12:02:30 +01:00 
			
		
		
		
	Added the permission models
This commit is contained in:
		
							
								
								
									
										49
									
								
								lib/models/Permission.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								lib/models/Permission.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,49 @@ | ||||
| <?php | ||||
| declare(strict_types=1); | ||||
| namespace yii\gitea\models; | ||||
|  | ||||
| use yii\base\{Model}; | ||||
|  | ||||
| /** | ||||
|  * Represents a set of permissions. | ||||
|  */ | ||||
| class Permission extends Model { | ||||
|  | ||||
|   /** | ||||
|    * @var bool Value indicating whether administrator access is allowed. | ||||
|    */ | ||||
|   public $admin = false; | ||||
|  | ||||
|   /** | ||||
|    * @var bool Value indicating whether pull is allowed. | ||||
|    */ | ||||
|   public $pull = false; | ||||
|  | ||||
|   /** | ||||
|    * @var bool Value indicating whether push is allowed. | ||||
|    */ | ||||
|   public $push = false; | ||||
|  | ||||
|   /** | ||||
|    * Creates a new user from the specified JSON map. | ||||
|    * @param object $map A JSON map representing a user. | ||||
|    * @return static The instance corresponding to the specified JSON map. | ||||
|    */ | ||||
|   static function fromJson(object $map): self { | ||||
|     return new static([ | ||||
|       'admin' => isset($map->admin) && is_bool($map->admin) ? $map->admin : false, | ||||
|       'pull' => isset($map->pull) && is_bool($map->pull) ? $map->pull : false, | ||||
|       'push' => isset($map->push) && is_bool($map->push) ? $map->push : false | ||||
|     ]); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Returns the validation rules for attributes. | ||||
|    * @return array[] The validation rules. | ||||
|    */ | ||||
|   function rules(): array { | ||||
|     return [ | ||||
|       [['admin', 'pull', 'push'], 'boolean', 'falseValue' => false, 'trueValue' => true] | ||||
|     ]; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										37
									
								
								lib/models/TeamPermission.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								lib/models/TeamPermission.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | ||||
| <?php | ||||
| declare(strict_types=1); | ||||
| namespace yii\gitea\models; | ||||
|  | ||||
| use Enum\{EnumTrait}; | ||||
|  | ||||
| /** | ||||
|  * Defines the permission of a Gitea status. | ||||
|  */ | ||||
| final class TeamPermission { | ||||
|   use EnumTrait; | ||||
|  | ||||
|   /** | ||||
|    * @var string The team has the administrator permission. | ||||
|    */ | ||||
|   const ADMIN = 'admin'; | ||||
|  | ||||
|   /** | ||||
|    * @var string The team doesn't have any permission. | ||||
|    */ | ||||
|   const NONE = 'none'; | ||||
|  | ||||
|   /** | ||||
|    * @var string The team has the owner permission. | ||||
|    */ | ||||
|   const OWNER = 'owner'; | ||||
|  | ||||
|   /** | ||||
|    * @var string The team has the read permission. | ||||
|    */ | ||||
|   const READ = 'read'; | ||||
|  | ||||
|   /** | ||||
|    * @var string The team has the write permission. | ||||
|    */ | ||||
|   const WRITE = 'write'; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user