Cool module! A good contribution to the community. Good work!

Here's a different use case, and some features that would be useful.

Use case: Bunch o' pages. Users add notes. Users can see notes that specific other users add. Users select the other users whose notes they want to see.

So user A might choose to see the notes of users B and C, as well as his/her own. User D might choose to see the notes of user B, as well as his/her own.

User A only sees notes that B and C have marked public. User B can make notes that only s/he can see.

Features that might help:

1. Admin can remove ability for users to say whether notes can appear on pages other than the current one. Check boxes in the admin interface, perhaps.

2. When notes are specific to a page, have the title of the page and a link to the page in the notes overview. Sortable.

3. Let admin remove note priority from user interface.

4. User can enter list of users to see notes from. Autocomplete field, users type user names.

Where should this field go? Maybe on the user's profile page, a tab. Not sure, though.

5. Use color of pin to indicate the user who added the note. Maybe admin selects what the color of the pin means: note priority, or note source.

No need to let user choose colors - module just allocates first color to the first user, etc.

6. Right now, notes can overlap and hide each other. When two notes are too close, move one some distance, so they are stacked, with all of the pin images visible.

7. When a user moves a note created by someone else, remember the new position of the note for that user.

8. Module doesn't seem to work with external links module.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MGN’s picture

Sounds very much like what I was thinking. I would be happy to contribute to this if there is interest!

MGN’s picture

I think #1 is a priority. Right now its possible for a user to post sticky notes on pages that they cannot view, and should not have access to, by setting the scope to 'all pages'.

#2 and #4 are already somewhat possible from the sticky_notes overview view. Users can search for notes from other people. And the default view can be customized however you like as with any other view. But I agree that a user config option to view/hide notes from other users would be useful.

I also think it would be helpful for the creator of the sticky notes to choose who is allowed to see the note. At first I tried to do this using a node access module (coherent access) which allows users to assign viewers and editors for their nodes, but that didn't work. Not sure why right now, but I'll look into it.

#5 might be difficult if the site has hundreds of users? This also relates to #742904: color for priority. What if there were many styles (background color, pin color, ... ) to choose from? I think there would be an advantage to letting the user choose the style, but it could also be sequentially assigned?

MGN’s picture

Status: Active » Needs review
FileSize
2.45 KB

This patch provides an additional permission 'post sticky notes to all pages' so the admin can control which users should be able to do this, by role. Note the patch is against head, but should be the same for 6.x-1.x-dev.

MGN’s picture

It would be great if additional use cases could be added by other modules rather than having to build them into the base sticky notes module. This is often done in Drupal by using hooks to allow modules to interact.

I've been able to modify sticky_notes to allow it work with coherent access (and other node access modules) to allow the creator of the sticky note to select who can view the sticky note. I think these modifications would make it easier to implement the use case suggested by mathieso.

1. Adjust hook_access so it works with node access modules. Right now sticky_notes_access has the final say in determining whether a user can or cannot view a sticky note. Other node access modules can't interact because sticky_notes_access returns FALSE, denying access, if it doesn't grant access (see http://api.drupal.org/api/function/node_access/6). To get around this problem, I modified sticky_notes_access to return NULL if not granting access.

2. Store the "public" checkbox value in a database field and use $node->public in place of $node->status. I had to do this because the node access tables are queried only if the node is published.

3. Allow node_access to grant access to sticky notes when loaded in sticky_notes_load_by_path() and also check the value of $node->public instead of $node->status.

4. Let modules theme the sticky_notes_node_form so they can control what fieldsets are present. This really amounts to moving the code in sticky_notes_form_alter_after_build to theme_sticky_notes_node_form (to provide default behavior) and registering this new theme function in sticky_notes_theme.

To my knowledge, these changes do not affect the default behavior of sticky notes. They just let other modules and themes interact with sticky_notes and allow extension to other use cases.

Attached are my patches (against HEAD) to implement these changes. Unfortunately, it looks like I also fixed some whitespace issues in the current code. Hopefully this doesn't make it difficult to review. The patch in #3 is also present in this patch. If you test these modifications, be sure to run update.php after patching.

berliner’s picture

Nice work. I didn't test it yet, but from what I see in the diffs I have some remarks.

1. The new permission "Post to all pages" controls the right to post to all pages and to all pages of the current type. This doesn't seem very intuitive. If needed I would split this into two permissions, but I wouldn't mix them.

2. The automatically created title as a truncated version of the body text: I did this to make it easier to identify a sticky note in some of the default pages, like /admin/content or the search. I find it practical, but indeed it is a bit messy to save it like this. It would be sufficient to put it into the node object every time the note is displayed somewhere.

I will test this the next days.

berliner’s picture

Concerning the permissions I would propose:
"Create sticky notes with scope all pages"
"Create sticky notes with scope all pages of a type"

That would group the permissions alongside with the general sticky notes create permission, making it easier to keep an overview, and it would separate the two distinct actions.

Maybe someone has a better idea for the wording.

MGN’s picture

Yes additional permissions make sense here because there are three options under the visibility settings. I briefly thought about that when I created the first patch, but needed a quick fix so I just made a blanket permission.

I don't think the word 'scope' is needed. I would suggest replacing 'with scope' with 'on' .

The length of the node title can already be truncated in views. Elsewhere, it can be truncated through appropriate theming. So I would opt for not truncating the node title, but perhaps provide some default templates if there is really a strong need for it.

As for searching, I think sticky_notes should implement hook_search so it can provide a link to the sticky note from the search results page (right now, the title is just printed without a link). In the implementation of this hook, the title could be truncated for display.

berliner’s picture

I don't think the word 'scope' is needed. I would suggest replacing 'with scope' with 'on' .

It might create confusion. "Create sticky notes on all pages" might be misinterpreted as the right to create a note from every page. But the permission does really mean, that a note can be made visible on all pages.

The use of hook_search would indeed be very useful.

berliner’s picture

Status: Needs review » Active

I included the patches from MGN as proposed in #4 and implemented hook_search.

There are three new permissions:
"create sticky notes with scope all pages"
"create sticky notes with scope all pages of a type"
"search sticky notes"

Anyone who is interested, please test the last modifications. I am a little bit worried about the access controls. Since I do not use any additional node access modules (and never have, so I don't have experience with that) it is a bit difficult for me to test it. I recognized though that returning NULL from hook_access doesn't prevent users without permissions to view a sticky note node page directly using node/[nid].

I implemented hook_db_rewrite_sql() to exclude sticky notes from normal search and implemented a custom search in hook_search that is more or less a 1:1 copy from the example found on http://api.drupal.org/api/function/hook_search. I modified it slightly to include sticky notes specific access control conditions in the queries and to change the output of the search results to include a link to the page that a note has been attached to as well as the notes body.

The changes have been commited to the dev branch. The release should be updated in the next 12 hours, but you can already checkout the last version directly from CVS.

AntiNSA’s picture

How can you set which pages each user role has an option to post sticky notes on exactly?

berliner’s picture

Right now this is not possible. I am thinking about how to do this (this also relates to http://drupal.org/node/774476).

I am just playing with role specific visibility settings that can override default settings (as those that can already be configured).

berliner’s picture

I included default and role based visibility settings for sticky notes in the latest cvs update of the dev branch. Though this concerns primarily the visibility of the notes and the info box you can exclude that way also where each user role can post notes to. It is not possible though to see notes on pages where the user has no role to see notes.

bomarmonk’s picture

Another feature request:

I would love to see this module module include functionality for highlighting text and previewing the notes as smaller icons that are associated with highlighted text or specific sections of page. In this way, this module might be used as an effective text annotation or feedback tool for papers (think of written assignments in e-learning-- this could be a great tool for that kind of environment or website).

I also posted this under the protonotes feature request.

Juan C’s picture

Subscribe + Feature request.

I am thinking to use these sticky notes as community bulletin board.
Where the community can post 'For Sale', 'Announcement', 'Garage Sale', 'Lost n Found', etc.

Cheers.

franzkewd’s picture

+1 for Bulletin board and/or Classified section idea.

berliner’s picture

Can you please open a new issue and elaborate on your ideas?