2906 */ |
2906 */ |
2907 |
2907 |
2908 var $acl_defaults_used = Array(); |
2908 var $acl_defaults_used = Array(); |
2909 |
2909 |
2910 /** |
2910 /** |
|
2911 * Tracks whether Wiki Mode is on for the page we're operating on. |
|
2912 * @var bool |
|
2913 */ |
|
2914 |
|
2915 var $wiki_mode = false; |
|
2916 |
|
2917 /** |
2911 * Constructor. |
2918 * Constructor. |
2912 * @param string $page_id The ID of the page to check |
2919 * @param string $page_id The ID of the page to check |
2913 * @param string $namespace The namespace of the page to check. |
2920 * @param string $namespace The namespace of the page to check. |
2914 * @param array $acl_types List of ACL types |
2921 * @param array $acl_types List of ACL types |
2915 * @param array $acl_descs List of human-readable descriptions for permissions (associative) |
2922 * @param array $acl_descs List of human-readable descriptions for permissions (associative) |
2962 } while ( $row = $db->fetchrow() ); |
2969 } while ( $row = $db->fetchrow() ); |
2963 } |
2970 } |
2964 |
2971 |
2965 $this->page_id = $page_id; |
2972 $this->page_id = $page_id; |
2966 $this->namespace = $namespace; |
2973 $this->namespace = $namespace; |
|
2974 |
|
2975 $pathskey = $paths->nslist[$this->namespace].$this->page_id; |
|
2976 $ppwm = 2; |
|
2977 if ( isset($paths->pages[$pathskey]) ) |
|
2978 { |
|
2979 if ( isset($paths->pages[$pathskey]['wiki_mode']) ) |
|
2980 $ppwm = $paths->pages[$pathskey]['wiki_mode']; |
|
2981 } |
|
2982 if ( $ppwm == 1 && ( $session->user_logged_in || getConfig('wiki_mode_require_login') != '1' ) ) |
|
2983 $this->wiki_mode = true; |
|
2984 else if ( $ppwm == 1 && !$session->user_logged_in && getConfig('wiki_mode_require_login') == '1' ) |
|
2985 $this->wiki_mode = true; |
|
2986 else if ( $ppwm == 0 ) |
|
2987 $this->wiki_mode = false; |
|
2988 else if ( $ppwm == 2 ) |
|
2989 { |
|
2990 if ( $session->user_logged_in ) |
|
2991 { |
|
2992 $this->wiki_mode = ( getConfig('wiki_mode') == '1' ); |
|
2993 } |
|
2994 else |
|
2995 { |
|
2996 $this->wiki_mode = ( getConfig('wiki_mode') == '1' && getConfig('wiki_mode_require_login') != '1' ); |
|
2997 } |
|
2998 } |
|
2999 else |
|
3000 { |
|
3001 // Ech. Internal logic failure, this should never happen. |
|
3002 return false; |
|
3003 } |
2967 } |
3004 } |
2968 |
3005 |
2969 /** |
3006 /** |
2970 * Tells us whether permission $type is allowed or not based on the current rules. |
3007 * Tells us whether permission $type is allowed or not based on the current rules. |
2971 * @param string $type The permission identifier ($acl_type passed to sessionManager::register_acl_type()) |
3008 * @param string $type The permission identifier ($acl_type passed to sessionManager::register_acl_type()) |
2975 |
3012 |
2976 function get_permissions($type, $no_deps = false) |
3013 function get_permissions($type, $no_deps = false) |
2977 { |
3014 { |
2978 // echo '<pre>' . print_r($this->perms, true) . '</pre>'; |
3015 // echo '<pre>' . print_r($this->perms, true) . '</pre>'; |
2979 global $db, $session, $paths, $template, $plugins; // Common objects |
3016 global $db, $session, $paths, $template, $plugins; // Common objects |
|
3017 |
2980 if ( isset( $this->perms[$type] ) ) |
3018 if ( isset( $this->perms[$type] ) ) |
2981 { |
3019 { |
2982 if ( $this->perms[$type] == AUTH_DENY ) |
3020 if ( $this->perms[$type] == AUTH_DENY ) |
|
3021 { |
2983 $ret = false; |
3022 $ret = false; |
2984 else if ( $this->perms[$type] == AUTH_WIKIMODE && |
3023 } |
2985 ( isset($paths->pages[$paths->nslist[$this->namespace].$this->page_id]) && |
3024 else if ( $this->perms[$type] == AUTH_WIKIMODE && $this->wiki_mode ) |
2986 ( $paths->pages[$paths->nslist[$this->namespace].$this->page_id]['wiki_mode'] == '1' || |
3025 { |
2987 ( $paths->pages[$paths->nslist[$this->namespace].$this->page_id]['wiki_mode'] == '2' |
|
2988 && getConfig('wiki_mode') == '1' |
|
2989 ) ) ) ) |
|
2990 $ret = true; |
3026 $ret = true; |
2991 else if ( $this->perms[$type] == AUTH_WIKIMODE && ( |
3027 } |
2992 !isset($paths->pages[$paths->nslist[$this->namespace].$this->page_id]) |
3028 else if ( $this->perms[$type] == AUTH_WIKIMODE && !$this->wiki_mode ) |
2993 || ( |
3029 { |
2994 isset($paths->pages[$paths->nslist[$this->namespace].$this->page_id]) && ( |
|
2995 $paths->pages[$paths->nslist[$this->namespace].$this->page_id]['wiki_mode'] == '0' |
|
2996 || ( |
|
2997 $paths->pages[$paths->nslist[$this->namespace].$this->page_id]['wiki_mode'] == '2' && getConfig('wiki_mode') != '1' |
|
2998 ) ) ) ) ) |
|
2999 $ret = false; |
3030 $ret = false; |
|
3031 } |
3000 else if ( $this->perms[$type] == AUTH_ALLOW ) |
3032 else if ( $this->perms[$type] == AUTH_ALLOW ) |
|
3033 { |
3001 $ret = true; |
3034 $ret = true; |
|
3035 } |
3002 else if ( $this->perms[$type] == AUTH_DISALLOW ) |
3036 else if ( $this->perms[$type] == AUTH_DISALLOW ) |
|
3037 { |
3003 $ret = false; |
3038 $ret = false; |
|
3039 } |
3004 } |
3040 } |
3005 else if(isset($this->acl_types[$type])) |
3041 else if(isset($this->acl_types[$type])) |
3006 { |
3042 { |
3007 if ( $this->acl_types[$type] == AUTH_DENY ) |
3043 if ( $this->acl_types[$type] == AUTH_DENY ) |
3008 $ret = false; |
3044 $ret = false; |