Changeset 1397

Show
Ignore:
Timestamp:
12/06/07 18:34:45 (1 year ago)
Author:
rho
Message:

improved "manage users" options to manage every user type registered.
Also fixes #173 allowing to access community profile as administrator
and delete them

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

Files:

Legend:

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

    r1344 r1397  
    131131                $url .= '?do=users'; 
    132132                break; 
     133            case 'admin::userdetails': 
     134                $url = $CFG->wwwroot . 'mod/users/?context=admin&profile_id='.$oid; 
     135                break; 
    133136            case 'admin::main': 
    134137            default: 
     
    139142    return $url; 
    140143} 
     144 
     145function get_url_query($object_id, $object_type, $query) { 
     146    $url = get_url($object_id, $object_type); 
     147 
     148    if (strpos($url, '?') === 'false') { 
     149        $sep = '?'; 
     150    } else { 
     151        $sep = '&amp;'; 
     152    } 
     153 
     154    return $url . $sep . $query; 
     155} 
     156 
     157/** 
     158 * Register user types 
     159 */ 
     160function register_user_type($type) { 
     161    global $CFG; 
     162    if (!isset($CFG->user_types)) { 
     163        $CFG->user_types = array(); 
     164    } 
     165 
     166    $CFG->user_types[] = $type; 
     167    return true; 
     168} 
     169 
     170function get_user_types() { 
     171    global $CFG; 
     172    if (!isset($CFG->user_types)) { 
     173        $CFG->user_types = array(); 
     174    } 
     175 
     176    return $CFG->user_types; 
     177} 
     178 
    141179?> 
  • devel/mod/admin/lib/admin_users.php

    r1248 r1397  
    1010    $run_result .= "<p>" . __gettext("The following is a list of all the users in the system, 50 users at a time. You can click each one to edit their user details as if you were logged in as them, as well as set user flags (including 'ban user' and 'set user as administrator').") . "</p>"; 
    1111    $run_result .= "<p>" . __gettext("If you know the username of the user you would like to edit, you can also enter it below.") . "</p>"; 
     12 
     13    $current_type = optional_param('user_type', 'person'); 
     14    $user_types = get_user_types(); 
     15    if (!empty($user_types)) { 
     16        $run_result .= '<p>' . __gettext('Filter user type'); 
     17        foreach ($user_types as $user_type) { 
     18            $run_result .= ' | '; 
     19            if ($user_type == $current_type) { 
     20                $run_result .= $user_type; 
     21            } else { 
     22                $run_result .= '<a href="'.get_url_query(1,'admin::users','user_type='.$user_type) . '">' . $user_type . '</a>'; 
     23            } 
     24        } 
     25    } 
    1226     
    1327    $run_result .= "<form action=\"". url . "_userdetails/\" method=\"get\">"; 
     
    2135    $run_result .= "</form>"; 
    2236     
    23     $maxusers = count_records('users','user_type','person'); 
     37    $maxusers = count_records('users','user_type',$current_type); 
    2438     
    25     if ($users = get_records('users','user_type','person','username ASC','*',$offset,50)) { 
    26         $run_result .= templates_draw(array( 
    27                                             'context' => 'adminTable', 
    28                                             'name' => "<h3>" . __gettext("Username") . "</h3>", 
    29                                             'column1' => "<h3>" . __gettext("Full name") . "</h3>", 
    30                                             'column2' => "<h3>" . __gettext("Email address") . "</h3>" 
    31                                             ) 
    32                                       ); 
    33         foreach($users as $user) { 
    34             $run_result .= run("admin:users:panel",$user); 
    35         } 
     39    if ($users = get_records('users','user_type',$current_type,'name ASC','*',$offset,50)) { 
    3640        if ($maxusers > ($offset + 50)) { 
    37             $next = "<a href=\"" . url . "mod/admin/users.php?offset=" . ($offset + 50) . "\">" . __gettext("Next") . "</a>"; 
     41            $next = "<a href=\"" . get_url_query(null, 'admin::users', "user_type=$current_type&offset=" . ($offset + 50)) . "\">" . __gettext("Next") . "</a>"; 
    3842        } else { 
    3943            $next = ""; 
     
    4448        } 
    4549        if ($prevoffset != $offset) { 
    46             $prev = "<a href=\"" . url . "mod/admin/users.php?offset=" . ($prevoffset) . "\">" . __gettext("Previous") . "</a>"; 
     50            $prev = "<a href=\"" . get_url(null, 'admin::users', "user_type=$current_type&offset=" . ($prevoffset)) . "\">" . __gettext("Previous") . "</a>"; 
    4751        } else { 
    4852            $prev = ""; 
    4953        } 
    5054         
    51         $run_result .= templates_draw(array( 
     55        $nav = templates_draw(array( 
    5256                                            'context' => 'adminTable', 
    53                                             'name' => "&nbsp;"
     57                                            'name' => __gettext('Total users') . ":&nbsp;" . $maxusers
    5458                                            'column1' => $prev . "&nbsp;" . $next, 
    5559                                            'column2' => "&nbsp;" 
    5660                                            ) 
    5761                                      ); 
     62 
     63        $run_result .= $nav; 
    5864         
     65        $run_result .= templates_draw(array( 
     66                                            'context' => 'adminTable', 
     67                                            'name' => "<h3>" . __gettext("Full name") . "</h3>", 
     68                                            'column1' => "<h3>" . __gettext("Username") . "</h3>", 
     69                                            'column2' => "<h3>" . __gettext("Extra info") . "</h3>" 
     70                                            ) 
     71                                      ); 
     72 
     73        foreach($users as $user) { 
     74            $run_result .= run("admin:users:panel",$user); 
     75        } 
     76 
     77        $run_result .= $nav; 
     78 
    5979    } 
    6080} 
  • devel/mod/admin/lib/admin_users_panel.php

    r1248 r1397  
    66     
    77    if (isset($parameter)) { 
    8          
     8        $profile_link = ' <a href="' . get_url($parameter->ident, 'admin::userdetails') . '"><small>| ' . __gettext('User details') . '</small></a>'; 
     9 
    910        $run_result .= templates_draw(array( 
    1011                        'context' => 'adminTable', 
    11                         'name' => "<p>" . $parameter->username . "</p>", 
    12                         'column1' => "<a href=\"" . url . "_userdetails/?profile_id=" .$parameter->ident . "&amp;context=admin\" >" . stripslashes($parameter->name) . "</a> [<a href=\"".url . $parameter->username ."/\">" . __gettext("Profile") . "</a>]", 
     12                        'name' => "<a href=\"" . url . "profile/index.php?profile_id=" .$parameter->ident . "\" >" . stripslashes($parameter->name) . "</a>", 
     13                        'column1' => "<p><strong>" . $parameter->username . '</strong>'. $profile_link . "</p>", 
    1314                        'column2' => "<a href=\"mailto:" . $parameter->email. "\" >" . $parameter->email . "</a>" 
    1415                    ) 
  • devel/mod/community/lib.php

    r1390 r1397  
    219219                river_register_friendlyname_hook('community::community', 'community_get_friendly_name'); 
    220220        } 
     221 
     222        register_user_type('community'); 
    221223} 
    222224 
  • devel/mod/community/lib/userdetails_edit.php

    r1080 r1397  
    103103END; 
    104104 
     105    if (context == "admin") { 
     106         
     107        $blurb = __gettext("Deleting this account is permanent and absolutely cannot be undone. Only click this button if you're really sure!"); 
     108        $deleteaccount = __gettext("Delete community account"); 
     109        $body .= templates_draw(array( 
     110            'context' => 'databox', 
     111            'name' => $blurb, 
     112            'column1' => "<a href=\"index.php?action=user:delete&profile_id=$page_owner\">{$deleteaccount}</a>", 
     113            )); 
     114 
     115    } 
     116 
     117 
     118 
    105119    $run_result .= $body; 
    106120    } 
  • devel/mod/users/lib.php

    r1301 r1397  
    6868        $function['users:flags:unset'][] = dirname(__FILE__) . "/lib/flag_unset.php"; // DEPRECATED - use user_flag_unset($flag_name, $user_id) 
    6969 
     70    register_user_type('person'); 
    7071} 
    7172?>