next up previous contents
Next: 用戶相片尺寸 Up: 用戶 Previous: editlib.php 程式修改   Contents

index.php 程式修改

  1. 用戶列表中「學號」與「姓名」改成兩個獨立欄位。
    [root@moodle html]# diff -urNwbBE moodle/user/index.php moodle23/user/index.php
    --- moodle/user/index.php	2012-08-10 08:06:08.000000000 +0800
    +++ moodle23/user/index.php	2014-03-27 16:15:56.886152535 +0800
    @@ -313,9 +312,9 @@
     
         /// Define a table showing a list of users in the current role selection
     
    -    $tablecolumns = array('userpic', 'fullname');
    +    $tablecolumns = array('userpic', 'firstname', 'lastname');
         $extrafields = get_extra_user_fields($context);
    -    $tableheaders = array(get_string('userpic'), get_string('fullnameuser'));
    +    $tableheaders = array(get_string('userpic'), get_string('firstname'), get_string('lastname'));
         if ($mode === MODE_BRIEF) {
             foreach ($extrafields as $field) {
                 $tablecolumns[] = $field;
    
  2. 用戶列表中增加「科系」departmant 欄位。
    @@ -378,12 +377,12 @@
         $wheres = array();
     
         $extrasql = get_extra_user_fields_sql($context, 'u', '', array(
    -            'id', 'username', 'firstname', 'lastname', 'email', 'city', 'country',
    +            'id', 'username', 'firstname', 'lastname', 'email', 'department', 'city' ,'country',
                 'picture', 'lang', 'timezone', 'maildisplay', 'imagealt', 'lastaccess'));
     
         if ($isfrontpage) {
    -        $select = "SELECT u.id, u.username, u.firstname, u.lastname,
    -                          u.email, u.city, u.country, u.picture,
    +        $select = "SELECT u.id, u.username, u.firstname, u.lastname, u.department, u.city, u.country,
    +                          u.email, u.picture,
                               u.lang, u.timezone, u.maildisplay, u.imagealt,
                               u.lastaccess$extrasql";
             $joins[] = "JOIN ($esql) e ON e.id = u.id"; // everybody on the frontpage usually
    @@ -392,8 +391,8 @@
             }
     
         } else {
    -        $select = "SELECT u.id, u.username, u.firstname, u.lastname,
    -                          u.email, u.city, u.country, u.picture,
    +        $select = "SELECT u.id, u.username, u.firstname, u.lastname, u.department, u.city, u.country,
    +                          u.email, u.picture, 
                               u.lang, u.timezone, u.maildisplay, u.imagealt,
                               COALESCE(ul.timeaccess, 0) AS lastaccess$extrasql";
             $joins[] = "JOIN ($esql) e ON e.id = u.id"; // course enrolled users only
    
  3. 因「學號」與「姓名」分開欄位顯示,所以連結也要增加。
    @@ -731,12 +730,14 @@
                     $usercontext = get_context_instance(CONTEXT_USER, $user->id);
     
                     if ($piclink = ($USER->id == $user->id || has_capability('moodle/user:viewdetails', $context) || has_capability('moodle/user:viewdetails', $usercontext))) {
    -                    $profilelink = '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$course->id.'">'.fullname($user).'</a></strong>';
    +                    $profilelinkf = '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$course->id.'">'.$user->firstname.'</a></strong>';
    +                    $profilelinkl = '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$course->id.'">'.$user->lastname.'</a></strong>';
                     } else {
    -                    $profilelink = '<strong>'.fullname($user).'</strong>';
    +                    $profilelinkf = '<strong>'.$user->firstname.'</strong>';
    +                    $profilelinkl = '<strong>'.$user->firstname.'</strong>';
                     }
    
  4. 用戶相片大小由 35 改成 25 ,以免佔用太大的版面。
    -                $data = array ($OUTPUT->user_picture($user, array('size' => 35, 'courseid'=>$course->id)), $profilelink);
    +                $data = array ($OUTPUT->user_picture($user, array('size' => 20, 'courseid'=>$course->id)), $profilelinkf, $profilelinkl); //dywang
     
                     if ($mode === MODE_BRIEF) {
                         foreach ($extrafields as $field) {
    



2017-08-04