Changeset 1471

Show
Ignore:
Timestamp:
12/17/07 03:55:33 (8 months ago)
Author:
rho
Message:
  • Fixed #201
  • Pages/content disabled for users by default
  • Fixed issue with sidebar

Signed-off: Rolando Espinoza La fuente <rho@prosoftpeople.com>

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/mod/pages/index.php

    r1466 r1471  
    2626if (page_owner() < 1) { 
    2727    // remove all but pages block 
    28     sidebar_remove(array('pages_sidebar', 'sidebar-profile'), true); 
     28    sidebar_remove(array('pages_sidebar'), true); 
    2929} 
    3030 
     
    3232$do_action = optional_param('do'); 
    3333 
    34 if ($do_action == 'edit') { 
    35     $page = pages_edit_page($page_id, page_owner()); 
     34if (!pages_enabled()) { 
     35    $page = new StdClass; 
     36    $page->title = __gettext('Plugin disabled for users'); 
     37    $page->content = __gettext('This plugin is currently disabled by site administrator'); 
    3638} else { 
    37     $page = pages_get_page($page_id, page_owner()); 
     39    if ($do_action == 'edit') { 
     40        $page = pages_edit_page($page_id, page_owner()); 
     41    } else { 
     42        $page = pages_get_page($page_id, page_owner()); 
     43    }    
    3844} 
     45 
    3946 
    4047if (!empty($page->ident)) { 
  • devel/mod/pages/lib.php

    r1468 r1471  
    1111 
    1212function pages_init() { 
    13     global $CFG, $function, $PAGE; 
    14  
    15     define('pages_allow_php_admin', true); 
    16     define('pages_allow_php_user', false); 
    17     define('pages_parse_keywords', true); 
    18     define('pages_blog_textproc', false); // breaks content with br's 
     13    global $CFG; 
     14 
     15    require_once($CFG->dirroot . 'mod/pages/lib/pages.config.php'); 
    1916 
    2017    pages_dbsetup(); 
    21  
    22     //DEPRECATED: legacy pages 
    23     /* 
    24     $PAGE->pages->old_compat = array( 
    25         'about.php' => array( 
    26             'title' => sprintf(__gettext('About %s'), $CFG->sitename), 
    27             'function' => 'content:about', 
    28             ), 
    29         'faq.php' => array( 
    30             'title' => sprintf(__gettext('%s FAQ'), $CFG->sitename), 
    31             'function' => 'content:faq', 
    32             ), 
    33         'privacy.php' => array( 
    34             'title' => sprintf(__gettext('%s Privacy Police'), $CFG->sitename), 
    35             'function' => 'content:privacy', 
    36             ), 
    37         'terms.php' => array( 
    38             'title' => sprintf(__gettext('%s Terms & Conditions'), $CFG->sitename), 
    39             'function' => 'content:terms', 
    40             ), 
    41         'run_your_own.php' => array( 
    42             'title' => sprintf(__gettext('Running your own %s'), $CFG->sitename), 
    43             'function' => 'content:run_your_own', 
    44             ), 
    45         ); 
    46  
    47     $function["pages:frontpage_loggedin"][] = dirname(__FILE__) . "/lib/function_frontpage_loggedin.php"; 
    48     $function["pages:frontpage_loggedout"][] = dirname(__FILE__) . "/lib/function_frontpage_loggedout.php"; 
    49  
    50     $PAGE->pages->old_compat['frontpage_loggedin'] = array( 
    51         'title' => sprintf(__gettext('Welcome {{username}}')), 
    52         'function' => 'pages:frontpage_loggedin', 
    53         ); 
    54     $PAGE->pages->old_compat['frontpage_loggedout'] = array( 
    55         'title' => sprintf(__gettext('Welcome Guest')), 
    56         'function' => 'pages:frontpage_loggedout', 
    57         ); 
    58      */ 
    5918} 
    6019 
     
    6928 
    7029    if (defined('context') && context == 'pages' || defined('pages_external')) { 
    71         if (permissions_check('pages::edit', page_owner())) { 
     30        if (pages_enabled() && permissions_check('pages::edit', page_owner())) { 
    7231            $page_name = optional_param('page'); 
    7332            $do_action = optional_param('do'); 
    7433 
    7534            if ($do_action != 'edit') { 
    76                 pages_submenu_add('pages:edit', __gettext('Edit this page'), pages_url($page_name, 'pages::edit', page_owner()), 0); 
    77             } 
    78         } 
    79     } 
    80  
    81     if (isloggedin()) { 
    82         pages_menu_add('pages', __gettext('Your Pages'), get_url($_SESSION['userid'], 'pages::')); 
    83     } 
    84  
    85     // not show main site pages on sidebar 
    86     sidebar_add(25, 'pages_sidebar', null, true, __gettext('Your pages')); 
     35                // new page link 
     36                pages_submenu_add('pages:edit', __gettext('New page'), pages_url('New_page', 'pages::edit', page_owner()), 0); 
     37                // edit this page link 
     38                pages_submenu_add('pages:edit', __gettext('Edit this page'), pages_url($page_name, 'pages::edit', page_owner()), 1); 
     39            } 
     40        } 
     41    } 
     42 
     43    if (!PAGES_DISABLE_USERS && isloggedin()) { 
     44        pages_menu_add('pages', __gettext('Your Content'), get_url($_SESSION['userid'], 'pages::')); 
     45    } 
     46 
     47    if (pages_enabled()) { 
     48        // not show main site pages on sidebar 
     49        sidebar_add(25, 'pages_sidebar', null, true, __gettext('Your Content')); 
     50    } 
    8751} 
    8852 
    8953function pages_php_allowed() { 
    9054    if (page_owner() == -1 
    91         || pages_allow_php_user 
    92         || (pages_allow_php_admin && user_flag_get('admin', page_owner()))) 
     55        || PAGES_ALLOW_PHP_USER  
     56        || (PAGES_ALLOW_PHP_ADMIN && user_flag_get('admin', page_owner()))) 
    9357    { 
    9458        return true; 
     
    10771    switch ($type) { 
    10872        case 'pages::edit': 
    109             if ($ident > 0) { 
     73            if (pages_enabled() && $ident > 0) { 
    11074                $result = run('permissions:check', 'profile'); 
    11175            } else { 
     
    147111                $_page = new StdClass; 
    148112                $_page->uri = 'privacy.php'; //backward compatibility 
     113                $_page->name = 'privacy.php'; //backward compatibility 
    149114                $_page->title = __gettext('Privacy Policy'); 
    150115                $_page->content = @file_get_contents(dirname(__FILE__).'/legacy/content_privacy.html'); 
     
    154119                $_page = new StdClass; 
    155120                $_page->uri = 'terms.php'; //backward compatibility 
     121                $_page->name = 'terms.php'; //backward compatibility 
    156122                $_page->title = __gettext('Terms and Conditions'); 
    157123                $_page->content = @file_get_contents(dirname(__FILE__).'/legacy/content_terms.html'); 
     
    202168            if ($id > 0) { 
    203169                $url = get_url($id, 'profile::'); 
    204                 if (!empty($url)) $url .= 'pages/'; // url for user's pages 
     170                if (!empty($url)) $url .= 'content/'; // url for user's pages 
    205171            } else { 
    206                 $url = $CFG->wwwroot . 'pages/'; // url for site pages 
     172                $url = $CFG->wwwroot . 'content/'; // url for site pages 
    207173            } 
    208174            break; 
     
    321287    if ($owner > 0) { 
    322288        if ($_SESSION['userid'] == $owner) { 
    323             $title = __gettext('Your pages'); 
     289            $title = __gettext('Your Content'); 
    324290        }else { 
    325291            //$title = sprintf(__gettext("%s's pages"), htmlspecialchars(user_name($owner), ENT_COMPAT, 'utf-8')); 
    326             $title = __gettext("Pages"); 
     292            $title = __gettext("Content"); 
    327293        } 
    328294    } else { 
     
    337303 
    338304    return $body; 
     305} 
     306 
     307function pages_enabled() { 
     308    if (page_owner() == -1 || 
     309       (page_owner() > 0 && !PAGES_DISABLE_USERS) ) { 
     310        return true; 
     311    } else { 
     312        return false; 
     313    } 
    339314} 
    340315 
     
    415390        $main_link = pages_html_a(pages_url(__gettext('Main'), 'pages::page', $owner), __gettext('Main')); 
    416391        $menu .= pages_html_wrap('li', $main_link, array('class' => 'menu-item')); 
    417     } 
    418  
    419     // "add new" page link 
    420     if (permissions_check('pages::edit',$owner)) { 
    421         $new_page_link = pages_html_wrap('small', __gettext('New page')); 
    422         $menu .= pages_html_wrap('li', pages_html_wrap('a', $new_page_link, array('href'=>pages_url('New_page', 'pages::edit', $owner), 'title'=>__gettext('New page')), array('class' => 'menu-item'))); 
    423392    } 
    424393 
     
    721690    } 
    722691} 
     692 
     693if (!function_exists('html_entity_decode')) { 
     694    function html_entity_decode($string) { 
     695        // replace numeric entities 
     696        $string = preg_replace('/&#x([0-9a-f]+);/ei', 'chr(hexdec("\\1"))', $string); 
     697        $string = preg_replace('/&#([0-9]+);/e', 'char("\\1")', $string); 
     698        // replace literal entities 
     699        $trans_tbl = get_html_translation_table(HTML_ENTITIES); 
     700        $trans_tbl = array_flip($trans_tbl); 
     701        return strtr($string, $trans_tbl); 
     702 
     703    } 
     704} 
    723705?> 
  • devel/mod/pages/lib/pages.inc.php

    r1456 r1471  
    3030    $owner = ($owner > 0) ? $owner : -1; 
    3131 
    32     if (defined('context') && context == 'pages' && $action == 'pages:edit' && $do_action == 'edit' && permissions_check('pages::edit', $owner)) { 
     32    if ((defined('context') && context == 'pages' || defined('pages_external')) && $action == 'pages:edit' && $do_action == 'edit' && permissions_check('pages::edit', $owner)) { 
    3333        $submit = optional_param('submit'); 
    3434        // get page id 
     
    157157            $content = trim(optional_param('page-content')); 
    158158        } 
     159        $content = html_entity_decode($content); 
    159160        $name = trim(optional_param('page-name')); 
    160161        $parent = optional_param('menu-parent', 0, PARAM_INT); 
     
    338339 
    339340    // parse elgg template keywords 
    340     if (pages_parse_keywords) { 
     341    if (PAGES_PARSE_KEYWORDS) { 
    341342        // wrap into templates_draw 
    342343        global $template; 
     
    352353 
    353354    // process with blog filters 
    354     if (pages_blog_textproc) { 
     355    if (PAGES_BLOG_TEXTPROC) { 
    355356        $content = run('weblogs:text:process', $content); 
    356357    } 
     
    378379    $PAGE->pages->editing = true; 
    379380 
    380     if (!empty($page_name) && permissions_check('pages::edit', $owner)) { 
     381    if (pages_enabled() && !empty($page_name) && permissions_check('pages::edit', $owner)) { 
    381382        if ($owner == -1 && pages_is_frontpage($page_name)) { 
    382383            $is_frontpage = true; 
     
    409410        $title_enc = htmlspecialchars($page->title, ENT_QUOTES, 'utf-8'); 
    410411        //$page->content = htmlspecialchars(stripslashes($page->content), ENT_COMPAT, 'utf-8'); 
    411         $page->content = $page->content
     412        $page->content = trim($page->content)
    412413        $page->name = htmlspecialchars($page->name, ENT_QUOTES, 'utf-8'); 
    413414 
     
    426427        $input_content = pages_html_wrap('label', __gettext('Content:'), array('for' => 'page-content')); 
    427428        $input_content .= pages_html_wrap( 
    428                         'textarea', $page->content
     429                        'textarea', htmlentities($page->content)
    429430                        array( 
    430431                            'id' => 'page-content',