Start free trial

Home > News, Articles & Multimedia > Blog Entry > WP Question Module: 2 in 1 module…or more

WP Question Module: 2 in 1 module…or more

by acenh (06/20/08).

WP Question module is more than 1 module. Currently, it caters 2 important administrative function regarding WP Questions — ask a question: The Unanswered Questions and Email Staff. It is up to 2 release respectively.

WP Question module contains all administrative task on WP Questions. It includes operations and functions only intended for admins and WP Staffs. The first version of this module is Unanswered Questions.

Unanswered Questions will give an ease for WP Staffs to track down questions yet unanswered. With a huge number of questions passed each day, there would be a big possibility for some questions to be left unanswered, which is not helpful on the customers end.

This module designed a table to file up all unanswered questions sorted in descending date. It displays the node title with link to the question, the post author and the date posted. Each table will handle 15 items at most in pager.

QUERIES AND SIGNIFICANT LINE OF CODES

1. “SELECT n.nid AS nid, n.title AS title, n.uid AS uid, n.created AS created
FROM {node} n
WHERE n.type = ‘question’
AND n.nid NOT IN (SELECT c.nid FROM {comments} c)
ORDER BY n.created DESC”

=>This query will select the nid of nodes with type question which is not in comments table. Since commented nids are placed automatically on comments table, that is equivalent on saying uncommented nodes are not placed on comments table. Thereby, we can fetch the nodes we need alongwith its respective title, uid and date created.

2. $output .= theme(‘table’, $header, $rows);
$output .= theme(‘pager’, NULL, 10, 0);

=>These are to create a table with pager function. Previous codes will show how data are inputted in a row.

3. Other codes are self-explanatory.

————————————————————

The second release of WP Question module contains the feature that will enable all WP staff to receive email notification about the question they responded with. The mail contains the title of the question, the author and the link of the question.

This feature would be helpful for Wp Staff to keep track of the questions they responded with and write follow-up comment on these.

HOW DOES IT WORK

1.hook_comment case ‘insert’ – this body is run everytime a new comment is inserted. If the role of the user who inserted the comment is WP Staff, he is sent with an email defined in the next function. The mail contains the title of the question responded, the author of that question and the link to worthpoint of the question.

IMPORTANT CODES:

1.$res = db_query(“SELECT r.name AS name FROM {role} r
LEFT JOIN {users_roles} u ON (r.rid=u.rid)
WHERE u.uid = %d”, $comment['uid']);
=> finds the role of the user who commented the question.

2.The rest are email configuration.

Since I’m out to Worthpoint Web Team, more release for this module is no longer probable. Performance team, which I’m now in, is entirely different thing, yet, I missed the excitement and satisfaction of creating your own module.

Want a picture icon with your comment? Sign up with Gravatar to get one.

Leave a Reply