$selects[] = 'usermodified=' . $author;
}
if($state) {
- $selects[] = 'publishstate="' . $state . '"';
+ $selects[] = "publishstate='$state'";
}
- $selects[] = 'module="notes"';
+ $selects[] = "module='notes'";
$select = implode(' AND ', $selects);
$fields = 'id,courseid,userid,content,format,created,lastmodified,usermodified,publishstate';
// retrieve data
*/
function note_load($note_id) {
$fields = 'id,courseid,userid,content,format,created,lastmodified,usermodified,publishstate';
- return get_record_select('post', 'id=' . $note_id . ' AND module="notes"', $fields);
+ return get_record_select('post', "id=$note_id AND module='notes'", $fields);
}
/**
- * Saves a note object. The note object is passed by reference and its fields (i.e. id)
+ * Saves a note object. The note object is passed by reference and its fields (i.e. id)
* might change during the save.
*
* @param note $note object to save
* @return boolean true if the object was deleted; false otherwise
*/
function note_delete($noteid) {
- return delete_records_select('post', 'id=' . $noteid . ' AND module="notes"');
+ return delete_records_select('post', "id=$noteid AND module='notes'");
}
/**
$authoring->name = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$author->id.'&course='.$note->courseid.'">'.fullname($author).'</a>';
$authoring->date = userdate($note->lastmodified);
- echo '<div class="notepost '. $note->publishstate . 'notepost' .
+ echo '<div class="notepost '. $note->publishstate . 'notepost' .
($note->usermodified == $USER->id ? ' ownnotepost' : '') .
'" id="note-'. $note->id .'">';
echo '<div class="user">';
print_user_picture($user->id, $note->courseid, $user->picture);
echo fullname($user) . '</div>';
- echo '<div class="info">' .
- get_string('bynameondate', 'notes', $authoring) .
+ echo '<div class="info">' .
+ get_string('bynameondate', 'notes', $authoring) .
' (' . get_string('created', 'notes') . ': ' . userdate($note->created) . ')</div>';
echo '</div>';
}
-
+
// print note content
if($detail & NOTES_SHOW_BODY) {
echo '<div class="content">';
echo format_text($note->content, $note->format);
echo '</div>';
}
-
+
// print note options (e.g. delete, edit)
if($detail & NOTES_SHOW_FOOT) {
- if (has_capability('moodle/notes:manage', $sitecontext) && $note->publishstate == NOTES_STATE_SITE ||
+ if (has_capability('moodle/notes:manage', $sitecontext) && $note->publishstate == NOTES_STATE_SITE ||
has_capability('moodle/notes:manage', $context) && ($note->publishstate == NOTES_STATE_PUBLIC || $note->usermodified == $USER->id)) {
echo '<div class="footer"><p>';
echo '<a href="'.$CFG->wwwroot.'/notes/edit.php?note='.$note->id. '">'. get_string('edit') .'</a> | ';