Пример #1
0
/**
 * Retrieves and prints a list of note objects with specific atributes.
 *
 * @param string  $header HTML to print above the list
 * @param int     $addcourseid id of the course for the add notes link (0 hide link)
 * @param boolean $viewnotes true if the notes should be printed; false otherwise (print notesnotvisible string)
 * @param int     $courseid id of the course in which the notes were posted (0 means any)
 * @param int     $userid id of the user to which the notes refer (0 means any)
 * @param string  $state state of the notes (i.e. draft, public, site) ('' means any)
 * @param int     $author id of the user who modified the note last time (0 means any)
 */
function note_print_notes($header, $addcourseid = 0, $viewnotes = true, $courseid = 0, $userid = 0, $state = '', $author = 0)
{
    global $CFG;
    if ($header) {
        echo '<h3 class="notestitle">' . $header . '</h3>';
        echo '<div class="notesgroup">';
    }
    if ($addcourseid) {
        if ($userid) {
            echo '<p><a href="' . $CFG->wwwroot . '/notes/edit.php?courseid=' . $addcourseid . '&amp;userid=' . $userid . '&amp;publishstate=' . $state . '">' . get_string('addnewnote', 'notes') . '</a></p>';
        } else {
            echo '<p><a href="' . $CFG->wwwroot . '/user/index.php?id=' . $addcourseid . '">' . get_string('addnewnoteselect', 'notes') . '</a></p>';
        }
    }
    if ($viewnotes) {
        $notes = note_list($courseid, $userid, $state, $author);
        if ($notes) {
            note_print_list($notes);
        }
    } else {
        echo '<p>' . get_string('notesnotvisible', 'notes') . '</p>';
    }
    if ($header) {
        echo '</div>';
        // notesgroup
    }
}
Пример #2
0
 /**
  * Create a notes list
  *
  * @param int $courseid ID of the Course
  * @param stdClass $context context object
  * @param int $userid ID of the User
  * @param int $state
  * @param int $author
  * @return array of notes
  * @since Moodle 2.9
  */
 protected static function create_note_list($courseid, $context, $userid, $state, $author = 0)
 {
     $results = array();
     $notes = note_list($courseid, $userid, $state, $author);
     foreach ($notes as $key => $note) {
         $note = (array) $note;
         list($note['content'], $note['format']) = external_format_text($note['content'], $note['format'], $context->id, '', '', 0);
         $results[$key] = $note;
     }
     return $results;
 }