Changeset 3416
- Timestamp:
- 06/09/07 04:44:45 (18 months ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
components/Textcube.Core.php (modified) (4 diffs)
-
lib/auth.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/Textcube.Core.php
r3413 r3416 29 29 } 30 30 31 } 32 33 /* Access Control Object: i.e. uri, component, function */ 31 function adjust( $aco, $aco_action ) 32 { 33 global $owner; 34 if( !Acl::isAvailable() ) { 35 Acl::setCurrentAro( $owner ); 36 } 37 38 $aro = Acl::getCurrentAro(); 39 foreach( $aco as $obj ) { 40 if( $obj == "group.members" && !empty($_SESSION['userid']) && $_SESSION['userid'] != $owner ) { 41 $aro[] = "group.members"; 42 } 43 if( function_exists("fireEvent") ) { 44 $aro = call_user_func( "fireEvent", "AclAdjustAro", $aro, $obj ); 45 } 46 } 47 return $aro; 48 } 49 } 50 51 /* Access Control Object: i.e. uri, components, functions */ 34 52 class Aco { 35 function Aco() { 53 var $predefiend; 54 55 function Aco( $predefined = null ) { 56 $this->predefined = $predefined; 57 } 58 59 function adjust( $aco, $aco_action ) { 60 // $aco is an string array 61 if( function_exists("fireEvent") ) { 62 $aco = call_user_func("fireEvent", "AclAdjustAco", $aco ); 63 } 64 return $aco; 36 65 } 37 66 } … … 39 68 class Acl { 40 69 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 } 70 global $owner; /*blogid*/ 52 71 53 72 if( !is_array( $aco ) ) { … … 55 74 } 56 75 76 /* Adujsting access controll object from plugins */ 77 $aco = Aco::adjust($aco, $aco_action); 78 79 /* Adujsting required object from plugins by aco*/ 80 $aro = Aro::adjust($aco, $aco_action); 81 82 /* We need one of aco elements is in aro array */ 83 57 84 foreach( $aco as $obj ) { 58 /*owner = blogid*/ 59 if( in_array( $obj, $_SESSION['acl'][$owner] ) ) { 85 if(in_array($obj, $aro)) { 60 86 return true; 61 87 } 62 88 } 89 63 90 return false; 64 91 } 65 92 66 function setCurrentAro( $blogid, $group , $user, $add = false ) {93 function setCurrentAro( $blogid, $group = null, $user = null, $add = false ) { 67 94 if( !isset( $_SESSION['acl'] ) ) { 68 95 $_SESSION['acl'] = array(); 69 96 } 97 98 if( !isset( $_SESSION['acl'][$blogid] ) ) { 99 $_SESSION['acl'][$blogid] = array(); 100 } 101 102 if( $group === null ) { 103 return; 104 } 105 70 106 if( $add ) { 71 107 $_SESSION['acl'][$blogid] = array_merge( $_SESSION['acl'][$blogid], array( $group, $user ) ); … … 73 109 $_SESSION['acl'][$blogid] = array( $group, $user ); 74 110 } 111 } 112 113 function getCurrentAro() { 114 global $owner; /*blogid*/ 115 if( Acl::isAvailable() ) { 116 return $_SESSION['acl'][$owner]; 117 } 118 return array(); 75 119 } 76 120 -
trunk/lib/auth.php
r3414 r3416 68 68 69 69 function doesHaveMembership() { 70 return empty($_SESSION['userid']) ? false : true; 71 /* return Acl::check( "group.members" ); */ 70 return Acl::check( "group.members" ); 72 71 } 73 72
