123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- abstract class AuthorizationPlugin extends Plugin
- {
-
- public $authoritative = false;
-
-
- function loginAllowed($user) {
- return null;
- }
-
- function hasRole($profile, $name) {
- return false;
- }
-
- function onStartSetUser($user) {
- $loginAllowed = $this->loginAllowed($user);
- if($loginAllowed === true){
- return;
- }else if($loginAllowed === false){
- $user = null;
- return false;
- }else{
- if($this->authoritative) {
- $user = null;
- return false;
- }else{
- return;
- }
- }
- }
- function onStartSetApiUser($user) {
- return $this->onStartSetUser($user);
- }
- function onStartHasRole($profile, $name, &$has_role) {
- if($this->hasRole($profile, $name)){
- $has_role = true;
- return false;
- }else{
- if($this->authoritative) {
- $has_role = false;
- return false;
- }else{
- return;
- }
- }
- }
- }
|