Changeset 329

Show
Ignore:
Timestamp:
05/09/06 06:41:36 (3 years ago)
Author:
carmartin
Message:

profile: fixed profile and homepage breakage when not logged in

The changes in commit r325 "Fix to prevent 'edit profile' links from
erroneously appearing" caused breakage in the homepage and profile pages.

This is because the function uses $page_owner but it is not actually the
global $page_owner. Clobbering the global breaks all sorts of things, so
I've renamed the var.

The fix that seemed to be the most correct was to wrap that code within the
if (isloggedin()) block. Edit links are keeping to themselves when they should
so I think we are ok on that front.

Also reverted the switch to old style privilege checks, which I suspect
happened during debugging. profile_permission_check() is right there and
is literally the same code. It was not the source of the problem.

Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/mod/profile/lib.php

    r325 r329  
    66    global $PAGE; 
    77    global $CFG; 
    8     global $page_owner; 
    98 
    10     $page_owner = $profile_id; 
     9    // don't clobber $page_owner, use a  
     10    // local $pgowner instead for clarity 
     11    $pgowner = $profile_id; 
    1112 
    1213    if (isloggedin()) { 
    13         if (context === "profile" && $page_owner == $_SESSION['userid']) {                 
     14        if (context === "profile" && $pgowner == $_SESSION['userid']) {                 
    1415            $PAGE->menu[] = array( 'name' => 'profile:me',  
    1516                                   'html' => '<li><a href="'.$CFG->wwwroot.$_SESSION['username'].'" class="selected">'.gettext("Your Profile").'</a></li>'); 
     
    1819                                   'html' => '<li><a href="'.$CFG->wwwroot.$_SESSION['username'].'">'.gettext("Your Profile").'</a></li>'); 
    1920        } 
     21 
     22        if (profile_permissions_check("profile") && context === "profile") { 
     23 
     24            $PAGE->menu_sub[] = array( 'name' => 'profile:edit',  
     25                                       'html' => '<a href="'.$CFG->wwwroot.'profile/edit.php?profile_id='.$pgowner.'">' 
     26                                       . gettext("Edit this profile") . '</a>'); 
     27 
     28            if (run("users:type:get", $pgowner) == "person") { 
     29                $PAGE->menu_sub[] = array( 'name' => 'profile:picedit',  
     30                                           'html' => '<a href="'.$CFG->wwwroot.'_icons/?context=profile&profile_id='.$pgowner.'">' 
     31                                           . gettext("Change site picture") . '</a>'); 
     32            } 
     33            $PAGE->menu_sub[] = array( 'name' => 'profile:help', 
     34                                       'html' => '<a href="'.$CFG->wwwroot.'help/profile_help.php">' 
     35                                       . gettext("Page help") . '</a>'); 
     36        } 
    2037    } 
    21  
    22     // if (profile_permissions_check("profile") && context === "profile") { 
    23     if (run("permissions:check", "profile") && context === "profile") { 
    24              
    25         $PAGE->menu_sub[] = array( 'name' => 'profile:edit',  
    26                                    'html' => '<a href="'.$CFG->wwwroot.'profile/edit.php?profile_id='.$page_owner.'">' 
    27                                    . gettext("Edit this profile") . '</a>'); 
    28          
    29         if (run("users:type:get", $page_owner) == "person") { 
    30             $PAGE->menu_sub[] = array( 'name' => 'profile:picedit',  
    31                                        'html' => '<a href="'.$CFG->wwwroot.'_icons/?context=profile&profile_id='.$page_owner.'">' 
    32                                        . gettext("Change site picture") . '</a>'); 
    33         } 
    34         $PAGE->menu_sub[] = array( 'name' => 'profile:help', 
    35                                    'html' => '<a href="'.$CFG->wwwroot.'help/profile_help.php">' 
    36                                    . gettext("Page help") . '</a>'); 
    37          
    38     } 
    39  
    4038} 
    4139