original_string: public static function update_notes($notes = array()) {
          global $CFG, $DB;
  
          $params = self::validate_parameters(self::update_notes_parameters(), array('notes' => $notes));
  
          // Check if note system is enabled.
          if (!$CFG->enablenotes) {
              throw new moodle_exception('notesdisabled', 'notes');
          }
  
          $warnings = array();
          foreach ($params['notes'] as $note) {
              $notedetails = note_load($note['id']);
              if (isset($notedetails->id)) {
                  // Ensure the current user is allowed to run this function.
                  $context = context_course::instance($notedetails->courseid);
                  self::validate_context($context);
                  require_capability('moodle/notes:manage', $context);
  
                  $dbnote = new stdClass;
                  $dbnote->id = $note['id'];
                  $dbnote->content = $note['text'];
                  $dbnote->format = external_validate_format($note['format']);
                  // Get the state ('personal', 'course', 'site').
                  switch ($note['publishstate']) {
                      case 'personal':
                          $dbnote->publishstate = NOTES_STATE_DRAFT;
                          break;
                      case 'course':
                          $dbnote->publishstate = NOTES_STATE_PUBLIC;
                          break;
                      case 'site':
                          $dbnote->publishstate = NOTES_STATE_SITE;
                          $dbnote->courseid = SITEID;
                          break;
                      default:
                          $warnings[] = array('item' => 'note',
                                              'itemid' => $note["id"],
                                              'warningcode' => 'badparam',
                                              'message' => 'Provided publishstate incorrect');
                          break;
                  }
                  if (!note_save($dbnote)) {
                      $warnings[] = array('item' => 'note',
                                          'itemid' => $note["id"],
                                          'warningcode' => 'savedfailed',
                                          'message' => 'Note could not be modified');
                  }
              } else {
                  $warnings[] = array('item' => 'note',
                                      'itemid' => $note["id"],
                                      'warningcode' => 'badid',
                                      'message' => 'Note does not exist');
              }
          }
          return $warnings;
      }
code: public static function update_notes($notes = array()) {
          global $CFG, $DB;
  
          $params = self::validate_parameters(self::update_notes_parameters(), array('notes' => $notes));
  
          // Check if note system is enabled.
          if (!$CFG->enablenotes) {
              throw new moodle_exception('notesdisabled', 'notes');
          }
  
          $warnings = array();
          foreach ($params['notes'] as $note) {
              $notedetails = note_load($note['id']);
              if (isset($notedetails->id)) {
                  // Ensure the current user is allowed to run this function.
                  $context = context_course::instance($notedetails->courseid);
                  self::validate_context($context);
                  require_capability('moodle/notes:manage', $context);
  
                  $dbnote = new stdClass;
                  $dbnote->id = $note['id'];
                  $dbnote->content = $note['text'];
                  $dbnote->format = external_validate_format($note['format']);
                  // Get the state ('personal', 'course', 'site').
                  switch ($note['publishstate']) {
                      case 'personal':
                          $dbnote->publishstate = NOTES_STATE_DRAFT;
                          break;
                      case 'course':
                          $dbnote->publishstate = NOTES_STATE_PUBLIC;
                          break;
                      case 'site':
                          $dbnote->publishstate = NOTES_STATE_SITE;
                          $dbnote->courseid = SITEID;
                          break;
                      default:
                          $warnings[] = array('item' => 'note',
                                              'itemid' => $note["id"],
                                              'warningcode' => 'badparam',
                                              'message' => 'Provided publishstate incorrect');
                          break;
                  }
                  if (!note_save($dbnote)) {
                      $warnings[] = array('item' => 'note',
                                          'itemid' => $note["id"],
                                          'warningcode' => 'savedfailed',
                                          'message' => 'Note could not be modified');
                  }
              } else {
                  $warnings[] = array('item' => 'note',
                                      'itemid' => $note["id"],
                                      'warningcode' => 'badid',
                                      'message' => 'Note does not exist');
              }
          }
          return $warnings;
      }
code_tokens: public static function update_notes ( $ notes = array ( ) ) { global $ CFG , $ DB ; $ params = self :: validate_parameters ( self :: update_notes_parameters ( ) , array ( 'notes' => $ notes ) ) ; // Check if note system is enabled. if ( ! $ CFG -> enablenotes ) { throw new moodle_exception ( 'notesdisabled' , 'notes' ) ; } $ warnings = array ( ) ; foreach ( $ params [ 'notes' ] as $ note ) { $ notedetails = note_load ( $ note [ 'id' ] ) ; if ( isset ( $ notedetails -> id ) ) { // Ensure the current user is allowed to run this function. $ context = context_course :: instance ( $ notedetails -> courseid ) ; self :: validate_context ( $ context ) ; require_capability ( 'moodle/notes:manage' , $ context ) ; $ dbnote = new stdClass ; $ dbnote -> id = $ note [ 'id' ] ; $ dbnote -> content = $ note [ 'text' ] ; $ dbnote -> format = external_validate_format ( $ note [ 'format' ] ) ; // Get the state ('personal', 'course', 'site'). switch ( $ note [ 'publishstate' ] ) { case 'personal' : $ dbnote -> publishstate = NOTES_STATE_DRAFT ; break ; case 'course' : $ dbnote -> publishstate = NOTES_STATE_PUBLIC ; break ; case 'site' : $ dbnote -> publishstate = NOTES_STATE_SITE ; $ dbnote -> courseid = SITEID ; break ; default : $ warnings [ ] = array ( 'item' => 'note' , 'itemid' => $ note [ "id" ] , 'warningcode' => 'badparam' , 'message' => 'Provided publishstate incorrect' ) ; break ; } if ( ! note_save ( $ dbnote ) ) { $ warnings [ ] = array ( 'item' => 'note' , 'itemid' => $ note [ "id" ] , 'warningcode' => 'savedfailed' , 'message' => 'Note could not be modified' ) ; } } else { $ warnings [ ] = array ( 'item' => 'note' , 'itemid' => $ note [ "id" ] , 'warningcode' => 'badid' , 'message' => 'Note does not exist' ) ; } } return $ warnings ; }
docstring: Update notes about users.
  
  @param array $notes An array of ids for the notes to update.
  @return array fail infos.
  @since Moodle 2.2
docstring_tokens: Update notes about users .