2705 */ |
2705 */ |
2706 |
2706 |
2707 var $acl_defaults_used = Array(); |
2707 var $acl_defaults_used = Array(); |
2708 |
2708 |
2709 /** |
2709 /** |
|
2710 * Tracks whether Wiki Mode is on for the page we're operating on. |
|
2711 * @var bool |
|
2712 */ |
|
2713 |
|
2714 var $wiki_mode = false; |
|
2715 |
|
2716 /** |
2710 * Constructor. |
2717 * Constructor. |
2711 * @param string $page_id The ID of the page to check |
2718 * @param string $page_id The ID of the page to check |
2712 * @param string $namespace The namespace of the page to check. |
2719 * @param string $namespace The namespace of the page to check. |
2713 * @param array $acl_types List of ACL types |
2720 * @param array $acl_types List of ACL types |
2714 * @param array $acl_descs List of human-readable descriptions for permissions (associative) |
2721 * @param array $acl_descs List of human-readable descriptions for permissions (associative) |
2761 } while ( $row = $db->fetchrow() ); |
2768 } while ( $row = $db->fetchrow() ); |
2762 } |
2769 } |
2763 |
2770 |
2764 $this->page_id = $page_id; |
2771 $this->page_id = $page_id; |
2765 $this->namespace = $namespace; |
2772 $this->namespace = $namespace; |
|
2773 |
|
2774 $pathskey = $paths->nslist[$this->namespace].$this->page_id; |
|
2775 $ppwm = 2; |
|
2776 if ( isset($paths->pages[$pathskey]) ) |
|
2777 { |
|
2778 if ( isset($paths->pages[$pathskey]['wiki_mode']) ) |
|
2779 $ppwm = $paths->pages[$pathskey]['wiki_mode']; |
|
2780 } |
|
2781 if ( $ppwm == 1 && ( $session->user_logged_in || getConfig('wiki_mode_require_login') != '1' ) ) |
|
2782 $this->wiki_mode = true; |
|
2783 else if ( $ppwm == 1 && !$session->user_logged_in && getConfig('wiki_mode_require_login') == '1' ) |
|
2784 $this->wiki_mode = true; |
|
2785 else if ( $ppwm == 0 ) |
|
2786 $this->wiki_mode = false; |
|
2787 else if ( $ppwm == 2 ) |
|
2788 { |
|
2789 if ( $session->user_logged_in ) |
|
2790 { |
|
2791 $this->wiki_mode = ( getConfig('wiki_mode') == '1' ); |
|
2792 } |
|
2793 else |
|
2794 { |
|
2795 $this->wiki_mode = ( getConfig('wiki_mode') == '1' && getConfig('wiki_mode_require_login') != '1' ); |
|
2796 } |
|
2797 } |
|
2798 else |
|
2799 { |
|
2800 // Ech. Internal logic failure, this should never happen. |
|
2801 return false; |
|
2802 } |
2766 } |
2803 } |
2767 |
2804 |
2768 /** |
2805 /** |
2769 * Tells us whether permission $type is allowed or not based on the current rules. |
2806 * Tells us whether permission $type is allowed or not based on the current rules. |
2770 * @param string $type The permission identifier ($acl_type passed to sessionManager::register_acl_type()) |
2807 * @param string $type The permission identifier ($acl_type passed to sessionManager::register_acl_type()) |
2774 |
2811 |
2775 function get_permissions($type, $no_deps = false) |
2812 function get_permissions($type, $no_deps = false) |
2776 { |
2813 { |
2777 // echo '<pre>' . print_r($this->perms, true) . '</pre>'; |
2814 // echo '<pre>' . print_r($this->perms, true) . '</pre>'; |
2778 global $db, $session, $paths, $template, $plugins; // Common objects |
2815 global $db, $session, $paths, $template, $plugins; // Common objects |
|
2816 |
2779 if ( isset( $this->perms[$type] ) ) |
2817 if ( isset( $this->perms[$type] ) ) |
2780 { |
2818 { |
2781 if ( $this->perms[$type] == AUTH_DENY ) |
2819 if ( $this->perms[$type] == AUTH_DENY ) |
|
2820 { |
2782 $ret = false; |
2821 $ret = false; |
2783 else if ( $this->perms[$type] == AUTH_WIKIMODE && |
2822 } |
2784 ( isset($paths->pages[$paths->nslist[$this->namespace].$this->page_id]) && |
2823 else if ( $this->perms[$type] == AUTH_WIKIMODE && $this->wiki_mode ) |
2785 ( $paths->pages[$paths->nslist[$this->namespace].$this->page_id]['wiki_mode'] == '1' || |
2824 { |
2786 ( $paths->pages[$paths->nslist[$this->namespace].$this->page_id]['wiki_mode'] == '2' |
|
2787 && getConfig('wiki_mode') == '1' |
|
2788 ) ) ) ) |
|
2789 $ret = true; |
2825 $ret = true; |
2790 else if ( $this->perms[$type] == AUTH_WIKIMODE && ( |
2826 } |
2791 !isset($paths->pages[$paths->nslist[$this->namespace].$this->page_id]) |
2827 else if ( $this->perms[$type] == AUTH_WIKIMODE && !$this->wiki_mode ) |
2792 || ( |
2828 { |
2793 isset($paths->pages[$paths->nslist[$this->namespace].$this->page_id]) && ( |
|
2794 $paths->pages[$paths->nslist[$this->namespace].$this->page_id]['wiki_mode'] == '0' |
|
2795 || ( |
|
2796 $paths->pages[$paths->nslist[$this->namespace].$this->page_id]['wiki_mode'] == '2' && getConfig('wiki_mode') != '1' |
|
2797 ) ) ) ) ) |
|
2798 $ret = false; |
2829 $ret = false; |
|
2830 } |
2799 else if ( $this->perms[$type] == AUTH_ALLOW ) |
2831 else if ( $this->perms[$type] == AUTH_ALLOW ) |
|
2832 { |
2800 $ret = true; |
2833 $ret = true; |
|
2834 } |
2801 else if ( $this->perms[$type] == AUTH_DISALLOW ) |
2835 else if ( $this->perms[$type] == AUTH_DISALLOW ) |
|
2836 { |
2802 $ret = false; |
2837 $ret = false; |
|
2838 } |
2803 } |
2839 } |
2804 else if(isset($this->acl_types[$type])) |
2840 else if(isset($this->acl_types[$type])) |
2805 { |
2841 { |
2806 if ( $this->acl_types[$type] == AUTH_DENY ) |
2842 if ( $this->acl_types[$type] == AUTH_DENY ) |
2807 $ret = false; |
2843 $ret = false; |