Posted by OFF on February 28, 2008 at 8:25pm
| Project: | Smileys |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | reviewed & tested by the community |
Issue Summary
I cannot add smileys in private messages (http://drupal.org/project/privatemsg)
I think it is necessary to add support of the privatemsg module in function "smileys_form_alter"
Comments
#1
nobody help me?
#2
Does the privatemsg module support input format filters in it's message body? If so, it should be easy task. If not, then it should be a feature request for privatemsg module.
#3
yes, the privatemsg module support input format filters in it's message body!
#4
It's two ways - hard change of smileys module or easy append 3 lines to privatemsg module. (Рома еби мозг чувакам из privatemsg)
#5
@stokito - Ok, moved this issue. What are the three lines? The filter already works. What's needed is to show the smilies box.
Michelle
#6
No, it would actually be a change in smileys_form_alter() to insert the box at the right place. And support for clicking and inserting the acronym would be a change in smileys.js. DRUPAL-6--1's smileys.js has an array of textarea IDs to insert an acronym into. It can be used with DRUPAL-5 as well (Don't think it'll break anything).
#7
Has passed almost year, but my visitors on the former wish to use smileys at sending of personal messages through the privatemsg module (буду так же ебать мозг чувакам из privatemsg)
#8
Yep, my users are also requesting Smiley's in the PM module. It works if you know the code, but most of my users aren't "Geek" ;-)
Would love to see Smiley support in the PM module.
#9
Me too!
Is there no other way to add smilies to the privatemsg module?
#10
smileys like in nodes! das ist fantastisch
#11
yes, but how?
#12
This would be a really nice feature for every site that uses Smileys and PM I would think. I came here looking for this and was bummed to not find a solution.
#13
Ok,
I did change the Smileys module before, to take Privatemsg into account, it worked but it was lame and broke the permissions.
For those who want Smileys to appear in virtually any form, go to smileys.module, and change the form_alter function with this :
/**
* Implementation of hook_form_alter().
*/
function smileys_form_alter(&$form, $form_state, $form_id) {
// Create a list of extra accepted form keys besides the comment and node forms
// This does take only 'use smiley select box' permission into account
$valid_ids = array ('privatemsg');
// Check if one of the keys exists in the form first children level
$form_ok = FALSE;
foreach ($valid_ids as $valid_id) { if (isset($form[$valid_id])) { $form_ok = TRUE; break; } }
// Dont check anything if form is not node/comment/ok
if ($form_id != 'comment_form' && !isset($form['#node']) && !form_ok) {
return;
}
if ($form_id == 'comment_form') {
$node_type = db_result(db_query('SELECT type FROM {node} WHERE nid=%d', $form['nid']['#value']));
}
else if (!empty($form['type']['#value'])) {
$node_type = $form['type']['#value'];
}
if (in_array($node_type, variable_get('smileys_node_types_content', array()), TRUE) || $form_ok) {
if ((user_access('use smiley select box') && $form_ok) || user_access('use smiley select box') &&
((isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) &&
variable_get('smileys_enable_for_nodes', 0) &&
isset($form['body_field']) ||
('comment_form' == $form_id && variable_get('smileys_enable_for_comments', 0)))) {
$output = '';
// Once again, list all the form keys valid for adding the smileys box in it. The key=>value is used so you can add the smileys box in $form['A'] instead of in $form['B'] if $form['B'] is found.
$valid_fields = array ('body_field'=>'body_field', 'comment_filter'=>'comment_filter', 'privatemsg'=>'privatemsg');
$key = '';
// If one of the above keys is found, set $key
foreach ($valid_fields as $field_key => $field) {
if (array_key_exists($field_key, $form)) {
$key = $field;
break;
}
}
// If none of the field keys have been found in the form, add a smileys_wrapper key (usually at the bottom of the form)
if ($key == '') $key = 'smileys_wrapper';
$collapsed = variable_get('smileys_select_box_expanded', TRUE) ? FALSE : TRUE;
$form[$key]['smileys'] = array(
'#type' => 'fieldset',
'#title' => t('Smileys'),
'#collapsible' => TRUE,
'#collapsed' => $collapsed,
'#weight' => -1,
'#prefix' => '<div class="smileys-box">',
'#suffix' => '</div>',
);
$form[$key]['smileys']['smileys_box'] = array(
'#type' => 'markup',
'#value' => theme('smileys_select_table', TRUE),
);
_smileys_add_files();
}
}
return $form;
}
(I'm not at ease with diffs and patches)
It extends Smileys so that it can now take into account any form other than node_body and comment_form.
Later, I might add a textarea in the smileys settings to let the admin enter his own form keys.
#14
#15
how is the review going?
#16
can't believe since 2 years ago, this function still not being added into the module
#17
@freelylw: Well, in all this time there isn't any code here that's ready to be added so I don't know why you're surprised.
Updating title... The old title makes no sense in this queue.
Michelle
#18
Are new infos available for Smileys use in Privatemasg?
#19
I changed the code from #13 to make it more clear, added the privatemsg option to the settings form an added the hook hook_smileys_get_additional_forms(). This hook could be implemented by other modules to provide the form_id and the field where to add the smileys box.
Please review my changes.
#20
New patch removes some not used code from #13 and fixes a typo in the node case.
#21
Hi i tried to insert your code but i keep getting errors, can you give me the text for the complete module ? i think i dont insert the text as you do..
#22
I just tested the patch with the current dev release and it works fine.
To test/apply the patch use the following commands (--dry-run: Do not actually change any files; just print what would happen.) inside the modules directory:
patch -p1 --dry-run < path-to-patch/smileys-228113-20.patchpatch -p1 < path-to-patch/smileys-228113-20.patch
#23
Appears to work. But what was that about breaking permissions? Is there a security flaw in this patch?
As far as I can tell, it works though. Thanks!