I've read a lot about this, but no solutions. I do not see anywhere to assign a tag to a new message. I do see a tag field once a message is created, within the message itself. I've added the tag there for several messages, and it still doesn't show under the tag field heading in the rows view of messages.

I'm somewhat confused. It seems backwards that I would insert a tag within a message itself rather than tag it during creation. Or am I missing something? At the least, I need to tag or have some way of adding taxonomy to a particular thread at creation. I read a post from 2009 which has 3 requests and adding the ability to add a tag on the fly of creation was the last step that needed to be done on the list. Is this done yet and I'm just missing something?

Thanks

Comments

berdir’s picture

No, this is not yet implemented.

IWasBornToWin’s picture

None of it? I assume you mean adding a tag to a newly created message? Ok. what about when I add a tag to the message after it is created? That tag still doesn't show up anywhere. I can't get a tag to show in the tags column nor can I filter by a tag.

berdir’s picture

Status: Active » Postponed (maintainer needs more info)

Tagging new messages when creating them is not implemented.

You can tag threads either through the tagging form on the bottom of the view thread page or use the textfield below the thread list. For both of them exist tests, so it's unlikely that it is broken. Please describe the exact steps of what you are doing, with screenshots.

IWasBornToWin’s picture

Status: Postponed (maintainer needs more info) » Active
StatusFileSize
new36.48 KB
new30.3 KB

1. Added a public tag "giver" in configuration
2. Create mail, open message, add tag in the tag field box, save (screenshot attached)
3. Rebuild tags from configuration
4. Go back and view inbox, not tags are showing under column heading "tags", (Screenshot attached)

I finally noticed the action box at the bottom of the message list, i inserted the tag there and clicked "apply". It now works. I'm not certain why you're not allowing to tag message at creation. (although, i'm not a programmer and do not know what is involved). What I am certain of is....this feature takes a whole lot more work and confusion for the pay off, unless I am missing something?

This may be an obvious "no" but is there any way to automatically assign a tag value to the field on creation...like through the url, prepopulate, default value, etc?

Thanks for your quick responses, I appreciate it.

berdir’s picture

Can't reproduce..

I see that you changed the URL prefix. Just to make sure, can you revert that back to the default (messages) and try again? That's quite a new feature...

Note that Steps 1 is optional (you can use whatever tag you want, without having to create them as public tags before that) and 3 has nothing to do with this. It just tags messages automatically with a hidden tag which are supposed to be displayed in the inbox.

IWasBornToWin’s picture

Ok, I changed the path to "messages" for all mail instead of individual users. The tagging works ok now.(would be interested in knowing the applicable way to use this since cant assign at creation. Also wonder why tabs column isn't sortable?)

After changing to messages as url path, the inbox is not working. Then I ran update, still not working. Now when a message is sent, there's no indicator in messages that a new message has arrived. Also when I click on the message tab from user account page, no sub tabs (inbox, all messages, sent, new, etc) are showing. just a list of all messages from url /messages/list. Once I open the message, then the sub tabs show but when I click on inbox I get a white screen which says access forbidden.

I went to backend to look at the folder "messages", it has the following permissions

drwxr-xr-x

berdir’s picture

Well..

- By default, the local task in the profile is *only* for reading messages of other users and needs the read all permission.

- No idea what your messages folder exactly contains but try renaming it (at least temporarly). Because this overrides the default /messages link, tries to show the content of the messages folder but that is not allowed (has nothing to do with file permissions but apache configuration). That's totally outside of Drupal.

- Tags column is not sortable because it's technically impossible. You can filter by tags, that's it..

- Tagging is only for yourself, other users don't see your tags. That's why tagging on creating was considered as not important feature because you are the only one who will see these tags. To tag the message for recipients, you can use Rules for example, or write custom code.

berdir’s picture

Title: unable to tag new messages » Tagging messages on view thread page doesn't work with a %user url prefix
Category: task » bug

Hint: That tagging doesn't work with a different url prefix is a bug, and I will look into fixing that.

IWasBornToWin’s picture

Title: Tagging messages on view thread page doesn't work with a %user url prefix » unable to tag new messages
Category: bug » task

I meant *tags column

IWasBornToWin’s picture

Ok, the message folder on backend (which I had created when initially installing this module because I couldn't get it to work (running update solved)) is now gone and everything works fine.

So with tags, when I tag an email it's simply for my personal viewing, just as if I were to receive an email and stick it in some other folder on my computer? Got it. which certainly explains not doing it at creation.

But you're saying with rules I can tag the message as it is sent? Basically here's what I'm trying to do. When a user sends a message to another user, from a node, I want it to be tagged, labeled, taxonomy vocabulary, etc. with a specific admin defined label. The user won't have an option here. It will just show up in their sort list, labeled. These messages will be specific messages identifiable to be separate from others. The reasoning is, these messages will be more urgent and we need to identify them as such. I thought you said I wasn't able to populate any other fields except recipient and subject, but you're saying through rules (which I understand is different than populating) that I can assign some type of label, tag, etc.?

Thanks again for your promptness.

berdir’s picture

Title: unable to tag new messages » Tagging messages on view thread page doesn't work with a %user url prefix
Category: task » bug

Exactly, tags are basically the same thing as labels in Gmail (Except that our UI isn't so cool, but we're working on that... ;))

Yes, Rules has a tag private message action. That means you can react on the event "message is sent" and then tag the message for the recipient. The tricky part is the condition, checking which messages to tag. A simple solution would be to rely on the subject pattern. You could do a string matching to see if it contains some given words. This is all possible from within Rules.

It would break when a user manually changes the default subject, but you could prevent that with a simple hook_form_alter and disable it if it has a default value. There is documentation on how to do that with the recipient field, see http://drupal.org/node/790414. (Remember that you need to remove the ['privatemsg'] part)

Or, you could go the other way round and create a custom form for this kind of "special messages", and then use our api functions to send the message and after that, tag it. There documentation of that too, except of the tag it part: http://drupal.org/node/624528.

Remember, privatemsg is a generic private message framework, we are trying hard to provide a useful default and provide ways to integrate it and change how it works through api functions and hooks but that results in custom code. You can only do so much without coding.

IWasBornToWin’s picture

This should work fine. I think I can assign a certain value to the subject field(via url or prepopulate mod) and then fire a rule when that condition is met....kind of what you just said :) And I believe I can hide the subject field through url fill module or autonode title module. This would prevent the user from changing it upon creation. I will look at your documentation from the references above. Alot of this will also be simpler in version 7. Which I plan to upgrade to very soon. I appreciate your quick help.

IWasBornToWin’s picture

From comment #6 this is still an issue...no sub tabs and no new message indicator. the path is different now because I fixed the path.

"Now when a message is sent, there's no indicator in messages that a new message has arrived. Also when I click on the message tab from user account page, no sub tabs (inbox, all messages, sent, new, etc) are showing. just a list of all messages from url /messages/list. Once I open the message, then the sub tabs show "

berdir’s picture

No, this is working as expected. The messages local task is only for administrative users and only lists the inbox. It is not a duplicate of /messages.

IWasBornToWin’s picture

Status: Active » Needs work

Go ya...so, if I do not hear back from you, I will assume the following. You're saying, there is not a tab on the account page of regular role users. There is simply a menu link showing messages and once the user clicks on that link, then they see the different boxes - inbox, sent messages, etc.

I'm moving this to "needs work" for the initial url issue. Thanks

berdir’s picture

Status: Needs work » Active

needs work means that there is a patch but needs (more) work. Setting back to active. Will try to look into this soon. No idea why it's happening right now.

IWasBornToWin’s picture

Since I am only using tagging to apply tags to certain messages which meet certain conditons via rules, I went to permissions and disabled "tag private messages" for all users except admin. This way, the tags would only be applied via rules. And no user would be bale to apply any tag via thread or message...cool. Except, now that I have disabled tagging ability for these users, the tag field no longer appears on their column headings. This is tw completely different options in my opinion. Viewing tags is not creating or assigning tags. Two options, two different uses. How would I allow them to view, but not create tags?

Thanks

berdir’s picture

Open a feature request for a "view tags on private messages" permission.

IWasBornToWin’s picture

I will open the feature request now, but shouldn't this be considered a bug at the moment because it is disabling the ability to "view" tags when I disable their ability to "create" them? Or, is this the typical process? I'm not up to the standard "flow" procedures of updating these status levels on the tickets here....but I'm learning :)

berdir’s picture

Status: Active » Needs review
StatusFileSize
new3.73 KB

No, it's not a bug because the tagging exist long before rules integration was added and that is the only way to add tags for a specific user. Before that, it made no sense to give someone a view only permission.

The attached patch fixes the tagging bug, also updated the test to verify that it works correctly now.

IWasBornToWin’s picture

I tested this patch (by the way...putty works excellent and very simple for patching...it makes it very obvious as to how to connect with your website from your computer). The patch works. However, since I switched the messages folder from "messages" to the user's folders my custom link I made for certain node types is not working. (cant use yours because I have panels and I need to autopopulate the subject field. I've been using this url in order to open new window for a new message

../messages/new/1/

that url no longer works after changing the folder name. This makes sense considering I changed the path...but now I do not know which url to use in order to populate a new messages window?

Also...I didn't understand the "test" part of the patch? Where/What do I test?

IWasBornToWin’s picture

Per your reference in comment #11 regarding disabling recipient field if it contains default info - instead of creating a module, can I simply use the php code in the same custom block I created, with the link i'm using to insert default values? My concern is, If I create a custom module...it's only good until I upgrade and forget it's in the old module folder.

IWasBornToWin’s picture

Disregard question on #22...I now see I can put custom module in folder of its own. Although, when I upgrade to version 7 in core I expect I will need to alter the module file to indicate such.

IWasBornToWin’s picture

I can't get your code to work for hiding the recipient field....here's what I am using;

function customsite_form_privatemsg_new_alter(&$form, &$form_state) {
  // Check if a default value is configured for the to field.
  if (!empty($form['recipient']['#default_value'])) {
 
    // Display a visible markup element.
    $form['recipient_display'] = array(
      '#value' => t('To: @recipients', array('@recipients' => $form['recipient']['#default_value'])),
      '#weight' => -10,
    );

    // Convert the recipient field to a value type and force the default value.
    $form['recipient']['#type'] = 'value';
    $form['recipient']['#value'] = $form['recipient']['#default_value'];
  }
}

I removed all the ['privatemsg'] fields like you suggest. I've also played around with the first line and changed it to;

function_customsite
function_customsite()
function(), etc.

Any advice?

IWasBornToWin’s picture

I forgot to add....as soon as I add your code to the .module file I get the white screen of death on my site

berdir’s picture

Some responses ;)

#22 We have an PHP function that will return the path to the new message form:
Function : http://blog.worldempire.ch/de/api/function/privatemsg_get_link/6-2
Usage example: http://blog.worldempire.ch/de/api/function/privatemsg_preprocess_author_...

Not sure if you can use PHP where you enter that link. You could also look at me.module, which allows you do create a link like user/me/something, where me will be replaced with the user id.

#22: You don't need to do anything with the test changes, this is automatically done (green = tests passed, red = not)

#23: Yes, you might need to update custom code for Drupal 7, but for this case, the changes should be small.

#24/25: white screen usually means that there is PHP error in your code. See http://drupal.org/node/158043, you might not be able to alter these settings if you are on a webhost (You shouldn't develop there anyway, that's why it's recommended to do that in a local test environment :)). Code looks good visually, did you include the <? php and ? >? You only need <? php (without space) once, on the first line in the file and ? > is not necessary, you can simply leave that away.

Tracking down PHP errors without actual errors is however really hard. Maybe you at least have access to the apache error log, PHP errors are often reported there.

IWasBornToWin’s picture

I will work on these...thank you.

Per #21...why isn't mysite.com/messages/new opening a default new message window? I've seen a lot of documentation that makes me believe that is a standard url for doing so? It worked for me until I changed the url path for default messages to user/%user

IWasBornToWin’s picture

I was finally able to get the code above to work. I was inserting the first <? php tag thinking it had to be on the first line of new code...but then figured out you mean first line of entire file....only.

I'm unable to get the code above to work for the subject field because I'm not sure how to change this part

// Display a visible markup element.
$form['recipient_display'] = array(
'#value' => t('To: @recipients', array('@recipients' => $form['recipient']['#default_value'])),
'#weight' => -10,

It's like you have some @ email stuff going on that would not apply to the subject filed? I've gotta think it can't be as simple as replacing the word(s) recipient(s) with subject(s) for this particular area?

I tried removing this section and simply doing an "if there's no default subject, then block it out" but it wouldn't work. I was able to remove the "if" conditoner and block out the subject simply by using the bottom part of the code....but that won't help me when someone tries to write a message where there is no default subject....because it hides the field at creation.

berdir’s picture

@ has nothing to do with mails, it is a placeholder for dynamic content in translated strings, see http://api.drupal.org/api/drupal/includes--common.inc/function/t/6.

So you be able to copy the whole if block and replace it with subject and use something else than To:.

Also, please update the documentation page once you have it working (mention that ['privatemsg'] is obsolete in 6.x-2.x and add the code for the subject).

IWasBornToWin’s picture

Ok...I will work on this.

Still having an issue with #21 and 27....My url of ../messages/new doesn't work anymore. While i'm at it. What is the real advantage of having it in a user's folder anyway? Will it help on sorting or load speed? If there are millions of private messages being sent back and fourth will it help? If not I will just switch it back and let all of the PM's go to path

berdir’s picture

As I said above, you need some PHP code there.

No, there are absolutely zero technical benefits of having the link in the user profile. This is only a visual/logical difference, depending on your site layout you might want this or now.

IWasBornToWin’s picture

I can't get the subject code to work(recipient works fine)....I tried adding the function line in again, above the subject code. Wasn't sure if that particular line needed to be there....still didn't work. I also tried to remove the upper code pertaining to recipient and only leave in subject field code...still didn't work. Here is what I have. I will copy this over to your documentation page when I get it corrected.

<?php
// $Id: customsite.module

/**
* @file
* Custom functions for this site.
*/
function customsite_form_privatemsg_new_alter(&$form, &$form_state) {

// Check if a default value is configured for the to field.
if (!empty($form['recipient']['#default_value'])) {

// Display a visible markup element.
$form['recipient_display'] = array(
'#value' => t('To: @recipients', array('@recipients' => $form['recipient']['#default_value'])),
'#weight' => -10,
);

// Convert the recipient field to a value type and force the default value.
$form['recipient']['#type'] = 'value';
$form['recipient']['#value'] = $form['recipient']['#default_value'];

}

// Check if a default value is configured for the subject field.
if (!empty($form['subject']['#default_value'])) {

// Display a visible markup element.
$form['subject_display'] = array(
'#value' => t('Sub: @subject', array('@subject' => $form['subject']['#default_value'])),
'#weight' => -10,
);

// Convert the subject field to a value type and force the default value.
$form['subject']['#type'] = 'value';
$form['subject']['#value'] = $form['subject']['#default_value'];

}
}

berdir’s picture

Your code snippet works fine for me. Note that it places the Sub: sentence directly after the To: sentence on the same line because there are no HTML tags anywhere. You can use #prefix/#suffix properties to add

or whatever you want around it or also add it directly to the string in #value.
IWasBornToWin’s picture

Didn't really understand your htlm comments...I dont mind it being on same line at creation, or even if it shows at all, for that matter.

Evidently, when I attempt to prepopulate your form using prepopulate module's url code;.../?edit[recipient]=user1, it gets in the way of this code....i know this because;
1. it doesn't populate the node author instead it defaults to user1. It does, however, make the to: field uneditable.
2. It does nothing with the subject field

To test, I inserted this url ../messages/new/1/testsubject

the code did work this time, but it gave me this

To:user[user] Sub:testsubject

I went ahead and sent the email....and while it wasn't pretty at creation, it was fine afterwards. Here are a few questions
1. Will this code work with prepopulate? I have php code running to figure out what the title field of the current node is...remember yours doesn't work because im coming from a node panel.
2. If your code wont work with prepopulate...do I need to care about the [user] appended at the end of recipient field? It's ugly but is it effecting me?

berdir’s picture

I can't really follow you, so I guess we're even ;)

- The code only hides the subject if there is a default value provided. Your first URL doesn't do that, so the subject isn't touched. If you want to hide it all the time, you just need a single line: "$form['subject']['#access'] = FALSE". Privatemsg will then automatically use the first few characters of the body as subject.

- Yes, the not pretty on creation is exactly what it meant. If you don't want to show anything, you can remove the _display part althogether, that is optional, privatemsg does not care about that. It just needs 'subject'/'recipient'.

1. You should really use our API function I linked you to in #26. Not only will this check permissions and if the user is allowed to write the recipient (it could be that he is blocked), it will also always return the correct URL which you can then use together with l()/url() (look these up on api.d.o if you don't know them). Your hardcoded, relativ link will stop working when you have an alias like "mycontent/2010/something" instead of "node/123".

2. If you only want to put something in recipient and/or subject, there is no reason to use prepopulate.module at all for this. You can pass privatemsg_get_link one or multiple recipient user objects and optionally a subject and it will build the link for you.

- Regarding [user], that was added very recently to make the names unique. Not really necessary with username, but for example combined with realname.module, there could be multiple "John Wayne"'s and Privatemsg needs to know which one you want to address. We are still working on improving that part and only display that when necessary, it's still a -dev release...

berdir’s picture

Status: Needs review » Fixed

Commited.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.