Posted by
jsmoraes on
Dec 15, 2013; 2:53am
URL: https://support.nabble.com/Option-to-solve-topics-Give-XP-tp7588730p7588762.html
Ok, I finished the code. With the following features:
1) Mark the message as question and present an icon to it.
2) Mark the message(s) as correct answer(s) and present an icon to it. More one message can be marked.
3) The author of question message can edit the subject (name or title of message, if you prefer), but can't change the status of be marked.
4) The author of answer message can edit the subject (name or title of message, if you prefer), but can't change the status of be marked.
5) Nobody see the flags that mark messages. Only Administrators can see.
6) Only Administrator can mark or unmark the message.
7) Any kind of character or sentence can be used to mark messages. (it needs changing in some lines of the code to reconize them).
8) Replies don't propagate the flags.
9) List and Thread modes don't show the flags.
10) Any image can be icons, respected the size. The files with image must be published. Inside the forum or out forum. (it needs changing in some lines of the code). If inside the forum, the gallery must has permission to be seen by anyone: registered or not.
Not developed:1) automation to insertion of flags. It must be inserted manually, by administrator.
2) automation to clear the flags. It must be deleted manually, by administrator.
3) any kind of contabilization of score, bonus or other ressources.
note:It's not the best code, and certainly it can be improved. Everyone are free to do it.
I reckon this code can be used in many others circustances than forum support.
A table with characteres, as flag, and images can mark many kind of message: important, new, admin, interrogation, attention ...
The first version, when the icon solved was at position of pinned icon, can be used to call attention to any message. Pinned or not the icon will be showed. The code to this was posted in NAML - free support section as append.
To this presentation I used as flags:
question: " ¢¬"
answer: " ¬"
call attention in pinned icon position: "New Year"




----------------------------------------------------------------------------------
Full code:
Two new macros used to clear flags:
<macro name="jsm_limpastr" dot_parameter="texto">
<n.regex_replace_all. pattern=" ¢¬" replacement="">
<n.texto/>
</n.regex_replace_all.>
</macro>
<macro name="jsm_limpastr1" dot_parameter="texto">
<n.regex_replace_all. pattern=" ¬" replacement="">
<n.texto/>
</n.regex_replace_all.>
</macro>
Icon in main page:
<override_macro name="smart_post_link" requires="node" dot_parameter="href" parameters="text, title, class">
<n.if.is_post>
<then>
<n.if.contains_substring string="[n.node_text.text/]" substring=" ¢¬">
<then>
<n.set_var. name="value"><n.node_text.text/></n.set_var.>
<img src="http://jsmtstnaml.23557.n7.nabble.com/file/n83/checkmark.png" /> <a href="[n.node_href.href/]" title="[n.title/]" class="[n.hide_null.class/] post-link[n.topic_node.id/]" node-id="[n.id/]"><n.jsm_limpastr texto="[n.var name='value'/]" /></a>
<n.call_later value="[n.topic_node.id/]" param="markUnreadTopics"/>
</then>
<else>
<a href="[n.node_href.href/]" title="[n.title/]" class="[n.hide_null.class/] post-link[n.topic_node.id/]" node-id="[n.id/]"><n.node_text.text/></a>
<n.call_later value="[n.topic_node.id/]" param="markUnreadTopics"/>
</else>
</n.if.contains_substring>
</then>
<else.node_link text="[n.text/]"/>
</n.if.is_post>
</override_macro>
Icon in title of topic page:
<override_macro name="topic_header">
<div id="topic-search-box" class="search-box float-right" style="padding:.5em 0">
<n.page_node.search_box/>
</div>
<n.if.contains_substring string="[n.break_up.page_node.subject/]" substring=" ¢¬">
<then>
<n.set_var. name="value"><n.break_up.page_node.subject/></n.set_var.>
<h1 id="post-title" class="adbayes-content" style="margin:0.25em 0 .8em"><img src="http://jsmtstnaml.23557.n7.nabble.com/file/n83/checkmark.png" /> <n.jsm_limpastr texto="[n.var name='value'/]" /></h1>
</then>
<else>
<h1 id="post-title" class="adbayes-content" style="margin:0.25em 0 .8em">
<n.break_up.page_node.subject/>
</h1>
</else>
</n.if.contains_substring>
</override_macro>
Icons of messages in topic page:
<override_macro name="classic_subject_line" requires="node">
<n.if.contains_substring string="[n.break_up.subject/]" substring="¬">
<then>
<n.if.contains_substring string="[n.break_up.subject/]" substring=" ¬">
<then>
<n.set_var. name="value"><n.break_up.subject/></n.set_var.>
<h2 class="post-subject float-left adbayes-content" style="width:30%;overflow:visible;font-family:inherit">
<img src="http://jsmtstnaml.23557.n7.nabble.com/file/n81/iconsolucionado.png" /> <n.jsm_limpastr1 texto="[n.var name='value'/]" />
</h2>
</then>
<else>
<n.set_var. name="value"><n.break_up.subject/></n.set_var.>
<h2 class="post-subject float-left adbayes-content" style="width:30%;overflow:visible;font-family:inherit">
<img src="http://jsmtstnaml.23557.n7.nabble.com/file/n80/iconsolucionado2.png" /> <n.jsm_limpastr texto="[n.var name='value'/]" />
</h2>
</else>
</n.if.contains_substring>
</then>
<else>
<h2 class="post-subject float-left adbayes-content" style="width:30%;overflow:visible;font-family:inherit">
<n.break_up.subject/>
</h2>
</else>
</n.if.contains_substring>
</override_macro>
Trap in reply:
<override_macro name="new_post" parameters="page_name,mailing_list_etiquette,bottom,focus" requires="servlet">
<n.node_page.>
<n.handle_new_node_permission_error/>
<n.if.not.is_submitted_form>
<then>
<n.set_var. name="value"><n.page_node.default_reply_subject/></n.set_var.>
<n.if.not.is_empty.var name="value">
<then>
<n.if.contains_substring string="[n.page_node.default_reply_subject/]" substring="¬">
<then>
<n.if.contains_substring string="[n.page_node.default_reply_subject/]" substring=" ¬">
<then>
<n.set_var. name="value"><n.page_node.default_reply_subject/></n.set_var.>
<n.set_var. name="value1"><n.jsm_limpastr1 texto="[n.var name='value'/]" /></n.set_var.>
<n.subject_field.set_value value="[n.var name='value1'/]" />
</then>
<else>
<n.set_var. name="value"><n.page_node.default_reply_subject/></n.set_var.>
<n.set_var. name="value1"><n.jsm_limpastr texto="[n.var name='value'/]" /></n.set_var.>
<n.subject_field.set_value value="[n.var name='value1'/]" />
</else>
</n.if.contains_substring>
</then>
<else>
<n.subject_field.set_value value="[n.page_node.default_reply_subject/]" />
</else>
</n.if.contains_substring>
</then>
<else>
<n.subject_field.set_value value="[n.page_node.default_reply_subject/]" />
</else>
</n.if.not.is_empty.var>
<n.alert_field.set_value value="[n.page_node.alert_default_value/]" />
<n.init_new_post_custom_fields/>
</then>
<else>
<n.catch_exception. id="save-block">
<n.handle_anonymous_submit/>
<n.check_antispam_submit bypass="preview"/>
<n.check_recent_post_limit/>
<n.create_child_of_page_node commit="[n.not.is_preview/]">
<subject><n.subject_field.value/></subject>
<message><n.message_field.value/></message>
<is_html><n.html_format_field.value/></is_html>
<type><n.type_field.value/></type>
<kind>post</kind>
<do>
<n.remember_new_node/>
<n.if.not.is_preview>
<then>
<n.save_post/>
<n.save_new_post_custom_fields/>
<n.new_node.send_node_as_email/>
</then>
</n.if.not.is_preview>
</do>
</n.create_child_of_page_node>
<n.if.not.is_preview>
<then>
<n.new_node.save_alert_field/>
<n.redirect_to.new_node.url/>
</then>
</n.if.not.is_preview>
</n.catch_exception.>
</else>
</n.if.not.is_submitted_form>
<n.html>
<head>
<META NAME="robots" CONTENT="noindex,nofollow"/>
<n.title.><n.page_name/></n.title.>
<n.focus/>
<style type="text/css">
.title-row {
padding:.6em .8em;
font-weight:bold;
}
div.field-title {
margin-top: 0;
}
</style>
</head>
<body>
<n.if.contains_substring string="[n.page_node.subject/]" substring="¬">
<then>
<n.if.contains_substring string="[n.page_node.subject/]" substring=" ¬">
<then>
<n.set_var. name="value"><n.page_node.subject/></n.set_var.>
<n.set_var. name="value1"><n.jsm_limpastr1 texto="[n.var name='value'/]" /></n.set_var.>
<n.edit_header first_text="[n.page_name/]" second_text="[n.truncate. size='80'][n.var name='value1'/][/n.truncate.]" />
</then>
<else>
<n.set_var. name="value"><n.page_node.subject/></n.set_var.>
<n.set_var. name="value1"><n.jsm_limpastr texto="[n.var name='value'/]" /></n.set_var.>
<n.edit_header first_text="[n.page_name/]" second_text="[n.truncate. size='80'][n.var name='value1'/][/n.truncate.]" />
</else>
</n.if.contains_substring>
</then>
<else>
<n.edit_header first_text="[n.page_name/]" second_text="[n.truncate. size='80'][n.page_node.subject/][/n.truncate.]" />
</else>
</n.if.contains_substring>
<n.if.is_submitted_form>
<then>
<n.if.has_exception for="save-block">
<then.show_new_node_error/>
<else>
<n.if.is_preview>
<then.new_node.preview/>
</n.if.is_preview>
</else>
</n.if.has_exception>
</then>
</n.if.is_submitted_form>
<n.subscription_reminder/>
<n.form. onsubmit="return singleSubmit(this)">
<n.type_field.hidden/>
<n.mailing_list_notice.mailing_list_etiquette/>
<n.reply_form />
<div style="margin-top:1em">
<n.antispam_submit_button class="toolbar action-button" value="[t]Post Message[/t]"/>
<input type="submit" class="toolbar action-button" name="preview" value="[t]Preview Message[/t]"/>
<t>or</t>
<a href="[n.page_node.url /]"><t>Cancel</t></a>
</div>
</n.form.>
<n.hide_null.bottom/>
</body>
</n.html>
</n.node_page.>
</override_macro>
<override_macro name="in_reply_to">
<div class="title-row light-border-color shaded-bg-color" style="margin-top:2.5em"><t>In Reply To</t></div>
<div style="margin-left:1.2em;padding-top:1em">
<n.page_node.>
<n.put_in_head.>
<style type="text/css">
div.in-reply-to {
margin-bottom:1em;
padding-bottom:.4em;
border-bottom-width:1px;
border-bottom-style:dotted;
}
</style>
</n.put_in_head.>
<div class="medium-border-color in-reply-to">
<n.if.contains_substring string="[n.break_up.subject/]" substring="¬">
<then>
<n.if.contains_substring string="[n.break_up.subject/]" substring=" ¬">
<then>
<n.set_var. name="value"><n.break_up.subject/></n.set_var.>
<n.set_var. name="value1"><n.jsm_limpastr1 texto="[n.var name='value'/]" /></n.set_var.>
<b><n.var name='value1'/></b>
</then>
<else>
<n.set_var. name="value"><n.break_up.subject/></n.set_var.>
<n.set_var. name="value1"><n.jsm_limpastr texto="[n.var name='value'/]" /></n.set_var.>
<b><n.var name='value1'/></b>
</else>
</n.if.contains_substring>
</then>
<else>
<b><n.break_up.subject/></b>
</else>
</n.if.contains_substring>
<div class="weak-color" style="padding:.2em 0">
<span class="weak-color"><n.when_created.long_format/></span>
—
<t>by
<t.author>
<n.owner.avatar/>
<span class="nowrap"><n.owner.user_link/></span>
</t.author>
</t>
</div>
</div>
<n.message_with_signature/>
</n.page_node.>
</div>
</override_macro>
Trap in Edition
<override_macro name="edit_post" requires="servlet">
<n.node_page.>
<n.if.not.visitor.can_edit.page_node>
<then>
<n.login.><t>Only authorized users can proceed in this area.</t></n.login.>
</then>
</n.if.not.visitor.can_edit.page_node>
<n.set_var. name="value1"><n.page_node.raw_subject/></n.set_var.>
<n.if.not.is_submitted_form>
<then>
<n.if.visitor.is_site_admin>
<then>
<n.subject_field.set_value value="[n.page_node.raw_subject/]" />
</then>
<else>
<n.set_var. name="value"><n.jsm_limpastr texto="[n.var name='value1'/]" /></n.set_var.>
<n.set_var. name="value"><n.jsm_limpastr1 texto="[n.var name='value'/]" /></n.set_var.>
<n.subject_field.set_value value="[n.var name='value'/]" />
</else>
</n.if.visitor.is_site_admin>
<n.html_format_field.set_value value="[n.page_node.message.is_html_format/]" />
<n.message_field.set_value value="[n.page_node.message.as_editable/]" />
<n.alert_field.set_value value="[n.page_node.visitor_is_subscribed_to_topic/]" />
<n.page_node.init_edit_post_custom_fields/>
</then>
<else>
<n.catch_exception. id="save-block">
<n.edit_page_node. commit="[n.not.is_preview/]">
<n.set_subject subject="[n.subject_field.value/]" />
<n.if.not.visitor.is_site_admin>
<then>
<n.if.contains_substring string="[n.var name='value1'/]" substring=" ¬">
<then>
<n.set_subject subject="[n.subject_field.value/] ¬" />
</then>
</n.if.contains_substring>
<n.if.contains_substring string="[n.var name='value1'/]" substring=" ¢¬">
<then>
<n.set_subject subject="[n.subject_field.value/] ¢¬" />
</then>
</n.if.contains_substring>
</then>
</n.if.not.visitor.is_site_admin>
<n.set_message message="[n.message_field.value/]" is_html="[n.not.is_null.html_format_field.value/]" />
<n.if.not.is_preview>
<then.save_post />
</n.if.not.is_preview>
</n.edit_page_node.>
<n.if.not.is_preview>
<then>
<n.page_node.save_alert_field/>
<n.page_node.save_edit_post_custom_fields/>
<n.redirect_to.page_node.url/>
</then>
</n.if.not.is_preview>
</n.catch_exception.>
</else>
</n.if.not.is_submitted_form>
<n.html>
<head>
<META NAME="robots" CONTENT="noindex,nofollow"/>
<n.title.><t>Edit Post</t></n.title.>
<style type="text/css">
.title-row {
padding:.2em;
border-width:2px;
border-style:solid;
font-weight:bold;
}
div.field-title {
margin-top: 0;
}
</style>
</head>
<body>
<n.edit_header first_text="[t]Edit Post[/t]" second_text="[n.page_node.get_app_node.subject/]" />
<n.if.is_submitted_form>
<then>
<n.if.is_preview>
<then>
<n.page_node.preview/>
</then>
</n.if.is_preview>
<n.show_edit_post_error/>
</then>
</n.if.is_submitted_form>
<n.form.>
<n.edit_post_form />
<div style="margin-top:1em">
<input type="submit" class="toolbar action-button" value="[t]Post Message[/t]" />
<input type="submit" class="toolbar action-button" name="preview" value="[t]Preview Message[/t]" />
<t>or</t> <a href="[n.page_node.url/]"><t>Cancel</t></a>
</div>
</n.form.>
</body>
</n.html>
</n.node_page.>
</override_macro>
Cleanning Flags in List and Thread mode (re-edited in 13/12/15 - 11:59 UT)
<override_macro name="post_subject" parameters="separator" requires="node">
<n.set_var. name='parent_subject'>
<n.if.has_parent>
<then.parent_node.subject/>
</n.if.has_parent>
</n.set_var.>
<n.if.not.ends_with text="[n.subject/]" suffix="[n.var name='parent_subject'/]">
<then>
<n.set_var. name="value"><n.subject/></n.set_var.>
<n.if.contains_substring string="[n.var name='value'/]" substring="¬">
<then>
<n.if.contains_substring string="[n.var name='value'/]" substring=" ¬">
<then>
<n.set_var. name="value1"><n.jsm_limpastr1 texto="[n.var name='value'/]" /></n.set_var.>
<span class="post-subject adbayes-content"><img src="http://jsmtstnaml.23557.n7.nabble.com/file/n81/iconsolucionado.png" /> <n.var name='value1'/><n.hide_null.separator/></span>
</then>
<else>
<n.set_var. name="value1"><n.jsm_limpastr texto="[n.var name='value'/]" /></n.set_var.>
<span class="post-subject adbayes-content"><img src="http://jsmtstnaml.23557.n7.nabble.com/file/n80/iconsolucionado2.png" /> <n.var name='value1'/><n.hide_null.separator/></span>
</else>
</n.if.contains_substring>
</then>
<else>
<span class="post-subject adbayes-content"><n.var name='value'/><n.hide_null.separator/></span>
</else>
</n.if.contains_substring>
</then>
</n.if.not.ends_with>
</override_macro>
Append
To show some icon at pinned área:
<override_macro name="pin_column">
<n.table_column>
<head>
<td class="[n.column_default_border/] pin-column nowrap" style="width:24px"></td>
</head>
<body>
<n.current_node.>
<td class="[n.column_default_border/]" style="padding-left:.2em">
<n.if.is_app>
<then>
<n.if.is_pinned_in_loop>
<then><img src="/images/forum_pin.png" width="29" height="23" title="[t]Pinned sub-forum[/t]" alt="[t]Pinned sub-forum[/t]"/></then>
<else><img src="/images/forum.png" width="25" height="23" title="[t]Floating sub-forum[/t]" alt="[t]Floating sub-forum[/t]"/></else>
</n.if.is_pinned_in_loop>
</then>
<else>
<n.if.contains_substring string="[n.break_up.subject/]" substring="New Year">
<then>
<img src="http://jsmtstnaml.23557.n7.nabble.com/file/n93/thumbsup.gif" width="25" height="20" alt="GoodNews"/>
</then>
<else>
<n.if.is_pinned_in_loop>
<then><img src="/images/pin.png" width="20" height="21" alt="pin"/></then>
</n.if.is_pinned_in_loop>
</else>
</n.if.contains_substring>
</else>
</n.if.is_app>
</td>
</n.current_node.>
</body>
</n.table_column>
</override_macro>