Hi, your module not working for me. But I has found where is mistake and has repaired it. And now working for me fine with no warnings. Sorry for my English.

Fatal error is in function admin_notes_block_form_submit where is bad setting switch case. You must add translations case, because drupal translate this value and then not working for other languages only in English. Below is correct code.

switch($form_state['values']['op']) {
    case t('Delete'):
      db_delete('admin_notes')
        ->condition('path', $_GET['q'])
        ->execute();
        
      $message = 'Your admin note has been deleted.';
      break;
    
    case t('Save'):
      global $user;
      $note = $form_state['values']['admin_note'];
      
      // Was there already a note added for this path
      if (_admin_notes_note_exists()) {
        db_update('admin_notes')
          ->fields(array(
            'uid' => $user->uid,
            'note' => $note,
            'timestamp' => time(),
          ))
          ->condition('path', $_GET['q'])
          ->execute();
          
        $message = 'Your admin note has been updated.';
      }
      else {
        db_insert('admin_notes')
          ->fields(array(
            'uid' => $user->uid,
            'note' => $note,
            'path' => $_GET['q'],
            'timestamp' => time(),
          ))
          ->execute();
          
        $message = 'Your admin note has been saved.';
      }
      break;
  }
  
  drupal_set_message(t($message));

Other things what I have repaired is warnings.
First warning is

Notice: Undefined index: content in function admin_notes_block_view() (row: 82 in file sites/all/modules/admin_notes/admin_notes.module).

Mistake is in this $block['content'] .= drupal_render($form);
I dont know why you have dot there. According to me it is pointless and removes this warning.

Second warning is

Strict warning: Only variables should be passed by reference ve funkci admin_notes_block_view() (row: 82 in file sites/all/modules/admin_notes/admin_notes.module).

I found solution here
http://drupal.stackexchange.com/questions/6322/strict-warning-only-variables-should-be-passed-by-reference-in-include

Correct code is below.

function admin_notes_block_view($delta = '') {
  global $user;
  // Only show the block for users that have correct permission
  if (user_access('access admin notes')) {
    $block['subject'] = t('Admin Notes');
    
    $note = db_query("SELECT note FROM {admin_notes} WHERE path=:path", array(':path' =>$_GET['q']))->fetchField();
    $form = drupal_get_form('admin_notes_block_form', $note);

    
    $block['content'] = drupal_render($form);
  }
  return $block;
}

Please update it and add new version for other. Thanks you for your module.

CommentFileSizeAuthor
#2 admin_notes_2190261.patch881 byteshanskuiters

Comments

vojta0001’s picture

I find other error. You can't return variable if not exist for anonymous user. Correct code is below:

function admin_notes_block_view($delta = '') {
  global $user;
  $block = "";
  // Only show the block for users that have correct permission
  if (user_access('access admin notes')) {
    $block['subject'] = t('Admin Notes');
    
    $note = db_query("SELECT note FROM {admin_notes} WHERE path=:path", array(':path' =>$_GET['q']))->fetchField();
    $form = drupal_get_form('admin_notes_block_form', $note);

    
    $block['content'] = drupal_render($form);
  }
  return $block;
}

hanskuiters’s picture

StatusFileSize
new881 bytes

I created a patch for this one.

hanskuiters’s picture

Status: Active » Needs review