コード例 #1
0
ファイル: lib.php プロジェクト: njorth/marginalia
 function show_user_dropdown($refurl)
 {
     global $USER;
     $summary = annotation_summary_query::from_url($refurl);
     $userlist = get_records_sql($summary->list_users_sql());
     $annotationuserid = moodle_marginalia::get_userid();
     $showannotationspref = moodle_marginalia::get_show_annotations_pref() == 'true';
     echo "<select name='anuser' id='anuser' onchange='window.moodleMarginalia.changeAnnotationUser(this,\"{$refurl}\");'>\n";
     $selected = $showannotationspref ? '' : " selected='selected' ";
     echo " <option {$selected} value=''>" . get_string('hide_annotations', ANNOTATION_STRINGS) . "</option>\n";
     if (!isguest()) {
         $selected = $showannotationspref && ($USER->username == $annotationuserid ? "selected='selected' " : '') ? " selected='selected' " : '';
         echo " <option {$selected}" . "value='" . s($USER->username) . "'>" . get_string('my_annotations', ANNOTATION_STRINGS) . "</option>\n";
     }
     if ($userlist) {
         foreach ($userlist as $user) {
             if ($user->username != $USER->username) {
                 $selected = $showannotationspref && ($user->id == $annotationuserid ? "selected='selected' " : '') ? " selected='selected' " : '';
                 echo " <option {$selected}" . "value='" . s($user->username) . "'>" . s($user->firstname . ' ' . $user->lastname) . "</option>\n";
             }
         }
     }
     // Show item for all users
     if (true) {
         $selected = $showannotationspref && ('*' == $annotationuserid ? "selected='selected' " : '') ? " selected='selected' " : '';
         echo " <option {$selected} value='*'>" . get_string('all_annotations', ANNOTATION_STRINGS) . "</option>\n";
     }
     echo "</select>\n";
 }