| 10 | 10 | else |
| 11 | 11 | return str_replace(array('%', ' ', '"', '#', '&', '\'', '<', '>', '?'), array('%25', '%20', '%22', '%23', '%26', '%27', '%3C', '%3E', '%3F'), $url); |
| | 12 | } |
| | 13 | |
| | 14 | /* Access Request Object: i.e. user */ |
| | 15 | class Aro { |
| | 16 | var $_aro = array( |
| | 17 | /* role => array( <available actions>, [<reference group>...] ) */ |
| | 18 | 'group.administrators' => array( 'blog-read', 'blog-write', 'blog-manage', 'comment-manage' ), |
| | 19 | 'group.blogwriters' => array( 'blog-read', 'blog-write' ), |
| | 20 | 'group.members' => array( 'comment-read', 'comment-writer' ), |
| | 21 | 'group.guests' => array( 'comment-read', 'comment-write' ) |
| | 22 | ); |
| | 23 | |
| | 24 | function Aro() { |
| | 25 | } |
| | 26 | |
| | 27 | function getCanonicalName( $userid ) { |
| | 28 | return "textcube:$userid"; |
| | 29 | } |
| | 30 | |
| | 31 | } |
| | 32 | |
| | 33 | /* Access Control Object: i.e. uri, component, function */ |
| | 34 | class Aco { |
| | 35 | function Aco() { |
| | 36 | } |
| | 37 | } |
| | 38 | |
| | 39 | class Acl { |
| | 40 | function check($aco = null, $aco_action = '*') { |
| | 41 | global $owner; |
| | 42 | |
| | 43 | if( $aco == null ) { |
| | 44 | if (empty($_SESSION['userid']) || ($_SESSION['userid'] != $owner)) |
| | 45 | return false; |
| | 46 | return true; |
| | 47 | } |
| | 48 | |
| | 49 | if( !Acl::isAvailable() ) { |
| | 50 | return false; |
| | 51 | } |
| | 52 | |
| | 53 | if( !is_array( $aco ) ) { |
| | 54 | $aco = array( $aco ); |
| | 55 | } |
| | 56 | |
| | 57 | foreach( $aco as $obj ) { |
| | 58 | /*owner = blogid*/ |
| | 59 | if( in_array( $obj, $_SESSION['acl'][$owner] ) ) { |
| | 60 | return true; |
| | 61 | } |
| | 62 | } |
| | 63 | return false; |
| | 64 | } |
| | 65 | |
| | 66 | function setCurrentAro( $blogid, $group, $user, $add = false ) { |
| | 67 | if( !isset( $_SESSION['acl'] ) ) { |
| | 68 | $_SESSION['acl'] = array(); |
| | 69 | } |
| | 70 | if( $add ) { |
| | 71 | $_SESSION['acl'][$blogid] = array_merge( $_SESSION['acl'][$blogid], array( $group, $user ) ); |
| | 72 | } else { |
| | 73 | $_SESSION['acl'][$blogid] = array( $group, $user ); |
| | 74 | } |
| | 75 | } |
| | 76 | |
| | 77 | function isAvailable() { |
| | 78 | global $owner; /*blogid*/ |
| | 79 | |
| | 80 | if( !isset( $_SESSION['acl'] ) || |
| | 81 | !is_array( $_SESSION['acl'] ) || |
| | 82 | !isset( $_SESSION['acl'][$owner] ) ) { |
| | 83 | return false; |
| | 84 | } |
| | 85 | |
| | 86 | return true; |
| | 87 | } |