Files nmoderation-4.7.x-1.x-dev/.nmoderation.module.swp and nmoderation/.nmoderation.module.swp differ
diff -uriN nmoderation-4.7.x-1.x-dev/nmoderation.info nmoderation/nmoderation.info
--- nmoderation-4.7.x-1.x-dev/nmoderation.info 1969-12-31 18:00:00.000000000 -0600
+++ nmoderation/nmoderation.info 2008-03-07 21:14:56.000000000 -0600
@@ -0,0 +1,5 @@
+; $Id$
+name = Node Moderation
+description = "Enables users to vote nodes onto the home page."
+dependencies = votingapi
+package = "Voting"
diff -uriN nmoderation-4.7.x-1.x-dev/nmoderation.module nmoderation/nmoderation.module
--- nmoderation-4.7.x-1.x-dev/nmoderation.module 2006-06-20 15:40:30.000000000 -0500
+++ nmoderation/nmoderation.module 2008-03-08 04:03:16.000000000 -0600
@@ -10,30 +10,20 @@
define('NMODERATION_CACHE_TYPE', 'points');
define('NMODERATION_TAG', 'vote');
-/**
- * Implementation of hook_help().
- */
-function nmoderation_help($section = "admin/help#nmoderation") {
- switch ($section) {
- case 'admin/modules#description':
- return t('Enables users to vote nodes onto the home page.');
- }
-}
-
function nmoderation_menu($may_cache) {
if ($may_cache) {
$access = user_access('administer node moderation votes');
- $items[] = array('path' => 'admin/nmoderation', 'title' => t('node moderation'),
+ $items[] = array('path' => 'admin/content/nmoderation', 'title' => t('node moderation'),
'callback' => 'nmoderation_list_all', 'access' => $access);
- $items[] = array('path' => 'admin/nmoderation/list', 'title' => t('list'),
+ $items[] = array('path' => 'admin/content/nmoderation/list', 'title' => t('list'),
'access' => $access, 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
$access = user_access('administer node moderation configuration');
- $items[] = array('path' => 'admin/nmoderation/matrix', 'title' => t('moderation matrix'),
+ $items[] = array('path' => 'admin/settings/nmoderation/matrix', 'title' => t('moderation matrix'),
'callback' => 'nmoderation_matrix_settings', 'access' => $access, 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'admin/nmoderation/roles', 'title' => t('moderation roles'),
+ $items[] = array('path' => 'admin/settings/nmoderation/roles', 'title' => t('moderation roles'),
'callback' => 'nmoderation_role_settings', 'access' => $access, 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'admin/nmoderation/votes', 'title' => t('moderation votes'),
+ $items[] = array('path' => 'admin/settings/nmoderation/votes', 'title' => t('moderation votes'),
'callback' => 'nmoderation_vote_settings', 'access' => $access,'type' => MENU_LOCAL_TASK);
$access = user_access('moderate nodes');
@@ -49,6 +39,11 @@
$items[] = array('path' => 'nmoderation/all', 'title' => t('all node moderation votes'),
'callback' => 'nmoderation_list_all', 'weight' => 5, 'access' => user_access('administer node moderation votes'));
+
+ $access = user_access('administer site configuration');
+ $items[] = array( 'path' => 'admin/settings/nmoderation', 'title' => t('Node Moderation'),
+ 'callback' => 'drupal_get_form', 'callback arguments' => array('nmoderation_admin_settings'),
+ 'access' => $access, 'type' => MENU_NORMAL_ITEM);
}
else {
if (arg(0) == 'node' && is_numeric(arg(1))) {
@@ -56,11 +51,13 @@
$items[] = array('path' => 'node/'. arg(1). '/nmoderation', 'title' => t('votes'),
'type' => MENU_LOCAL_TASK, 'callback' => 'nmoderation_list_node', 'weight' => 5, 'access' => $access, 'callback arguments' => array(arg(1)));
}
- theme('add_style', drupal_get_path('module','nmoderation') . '/nmoderation.css');
+ //theme('add_style', drupal_get_path('module','nmoderation') . '/nmoderation.css');
}
return $items;
}
+drupal_add_css(drupal_get_path('module', 'nmoderation') .'/nmoderation.css');
+
/**
* Implementation of hook_perm().
*/
@@ -112,7 +109,13 @@
}
function nmoderation_matrix_settings() {
- $output .= '
Node Moderation vote/value matrix
';
+ $output = 'Node Moderation vote/value matrix
';
+
+ $output .= drupal_get_form('nmoderation_matrix_form');
+ return $output;
+}
+
+function nmoderation_matrix_form() {
$result = db_query("SELECT r.rid, r.name FROM {role} r, {permission} p WHERE r.rid = p.rid AND p.perm LIKE '%moderate nodes%'");
$role_names = array();
while ($role = db_fetch_object($result)) {
@@ -151,9 +154,7 @@
'#type' => 'value',
'#value' => $role_names,
);
-
- $output .= drupal_get_form('nmoderation_matrix_form', $form);
- return $output;
+ return $form;
}
function nmoderation_matrix_form_submit($form_id, $form_values) {
@@ -176,7 +177,7 @@
foreach (element_children($form['votes']) as $mid) {
$row = array();
foreach (element_children($form['votes'][$mid]) as $rid) {
- $row[] = form_render($form['votes'][$mid][$rid]);
+ $row[] = drupal_render($form['votes'][$mid][$rid]);
}
$rows[] = $row;
}
@@ -187,7 +188,7 @@
}
$output = theme('table', $header, $rows);
- $output .= form_render($form);
+ $output .= drupal_render($form);
return $output;
}
@@ -197,6 +198,11 @@
function nmoderation_role_settings() {
$output .= 'Initial node scores
';
+ $output .= drupal_get_form('nmoderation_role_form');
+ return $output;
+}
+
+function nmoderation_role_form() {
$start_values = variable_get('nmoderation_roles', array());
$result = db_query("SELECT r.rid, r.name FROM {role} r, {permission} p WHERE r.rid = p.rid AND p.perm LIKE '%moderate nodes%' ORDER BY r.rid");
@@ -216,8 +222,7 @@
'#value' => t('Save scores')
);
- $output .= drupal_get_form('nmoderation_role_form', $form);
- return $output;
+ return $form;
}
function nmoderation_role_form_validate($form_id, $form_values) {
@@ -241,12 +246,12 @@
$row = array();
$row[] = $form['role'][$rid]['#title'];
unset($form['role'][$rid]['#title']);
- $row[] = form_render($form['role'][$rid]);
+ $row[] = drupal_render($form['role'][$rid]);
$rows[] = $row;
}
$output = theme('table', $header, $rows);
- $output .= form_render($form);
+ $output .= drupal_render($form);
return $output;
}
@@ -256,7 +261,13 @@
function nmoderation_vote_settings() {
$output .= ''. t('Node moderation votes overview') .'
';
- // load up and show any vote types previously defined.
+
+ $output = drupal_get_form('nmoderation_vote_form');
+ return $output;
+}
+
+function nmoderation_vote_form() {
+ // load up and show any vote types previously defined.
$result = db_query('SELECT mid, vote, weight FROM {nmoderation_votes} ORDER BY weight');
while ($vote = db_fetch_object($result)) {
$form['old'][$vote->mid]['vote'] = array(
@@ -300,9 +311,7 @@
'#type' => 'submit',
'#value' => t('Save changes'),
);
-
- $output = drupal_get_form('nmoderation_vote_form', $form);
- return $output;
+ return $form;
}
function nmoderation_vote_form_validate($form_id, $form_values) {
@@ -336,21 +345,21 @@
// render the existing-vote fields.
foreach (element_children($form['old']) as $mid) {
$row = array();
- $row[] = form_render($form['old'][$mid]['vote']);
- $row[] = form_render($form['old'][$mid]['weight']);
- $row[] = form_render($form['old'][$mid]['delete']);
+ $row[] = drupal_render($form['old'][$mid]['vote']);
+ $row[] = drupal_render($form['old'][$mid]['weight']);
+ $row[] = drupal_render($form['old'][$mid]['delete']);
$rows[] = $row;
}
// render the add-a-vote fields.
$row = array();
- $row[] = form_render($form['new']['vote']);
- $row[] = form_render($form['new']['weight']);
+ $row[] = drupal_render($form['new']['vote']);
+ $row[] = drupal_render($form['new']['weight']);
$row[] = '';
$rows[] = $row;
$output .= theme('table', $header, $rows);
- $output .= form_render($form);
+ $output .= drupal_render($form);
return $output;
}
@@ -441,7 +450,7 @@
function theme_nmoderation_moderation_form($form) {
// We aren't actually going to do anything fancy, but it's here
// in case folks want to override it for a given theme.
- $output = form_render($form);
+ $output = drupal_render($form);
return $output;
}
@@ -457,16 +466,27 @@
}
function nmoderation_uservote_edit($vote_id) {
+
global $user;
$sql = 'SELECT vote_id, uid, content_id, value FROM {votingapi_vote} WHERE vote_id = %d';
$vote = db_fetch_object(db_query($sql, $vote_id));
+ if ($vote->uid != $user->uid) {
+ $output .= drupal_get_form('nmoderation_moderation_form', $vote);
+ return $output;
+ }
+ else {
+ drupal_access_denied();
+ }
+}
+
+function nmoderation_moderation_form($vote) {
+ global $user;
// may only edit own vote if you are not an admin
if ($user->uid == $vote->uid || user_access('administer node moderation votes')) {
$node = node_load($vote->content_id);
$form = nmoderation_get_moderation_form('node', $node->nid, $vote, t('Edit vote'));
- if ($vote->uid != $user->uid) {
$form['username'] = array(
'#type' => 'markup',
'#title' => t('Voter'),
@@ -481,19 +501,18 @@
'#value' => $node->title,
'#weight' => -1,
);
-
- $output .= drupal_get_form('nmoderation_moderation_form', $form);
- return $output;
- }
- else {
- drupal_access_denied();
- }
+ return $form;
}
function nmoderation_uservote_delete($vote_id) {
+ $output = drupal_get_form( 'nmoderation_delete_confirm',$vote_id);
+ return $output;
+}
+
+function nmoderation_delete_confirm($vote_id) {
+
$form['vote_id'] = array('#type' => 'value', '#value' => $vote_id);
- $output = confirm_form(
- 'nmoderation_delete_confirm',
+ return confirm_form(
$form,
t('Are you sure you want to delete this vote?'),
$_GET['destination'] ? $_GET['destination'] : 'nmoderation/voted',
@@ -501,7 +520,6 @@
t('Delete Vote'),
t('Cancel')
);
- return $output;
}
function nmoderation_delete_confirm_submit($form_id, $form_values) {
@@ -541,6 +559,25 @@
}
}
+/**
+ * Implementation of hook_link().
+ */
+function nmoderation_link($type, $node = 0, $main = 0) {
+ global $id;
+ $links = array();
+
+ if ($type == 'node' && $node->type == 'blog' && user_access('view post access counter')) {
+ $result=votingapi_get_voting_result($type, $node->nid, NMODERATION_CACHE_TYPE, NMODERATION_TAG, 'sum');
+ if(!empty($result->value))
+ $links['node_moderation_votes']= array (
+ 'title' => format_plural($result->value, '1 vote', '@count votes')
+ );
+ }
+
+ return $links;
+}
+
+
function nmoderation_list_unvoted($content_type = 'node') {
global $user;
@@ -677,10 +714,10 @@
return $output;
}
-function nmoderation_settings() {
+function nmoderation_admin_settings() {
$promote = drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100));
- $unpublish = drupal_map_assoc(array(-1, -2, -3, -4, -5, -6, -7, -8, -8, -10, -11, -12, -13, -14, -15, -20, -25, -30));
- $interval = drupal_map_assoc(range(1,60));
+ $unpublish = drupal_map_assoc(array(-1, -2, -3, -4, -5, -6, -7, -8, -8, -10, -11, -12, -13, -14, -15, -20, -25, -30, -35, -40, -45, -50, -60, -70, -80, -90, -100));
+ $interval = drupal_map_assoc(range(1,365));
$form['nmoderation_node_types'] = array(
'#type' => 'select',
@@ -713,7 +750,7 @@
'#description' => t('The number of days since the creation of a node when we allow voting.'),
);
- return $form;
+ return system_settings_form($form);
}
@@ -742,9 +779,13 @@
else {
$title = t('Add vote');
}
- if ($frm = nmoderation_get_moderation_form('node', $node->nid, $vote, $title)) {
- $node->body .= drupal_get_form('nmoderation_moderation_form', $frm);
- }
+ //if ($frm = nmoderation_get_moderation_form('node', $node->nid, $vote, $title)) {
+ $additional_field = drupal_get_form('nmoderation_get_moderation_form','node', $node->nid, $vote, $title );
+ $node->content['moderation_form'] = array(
+ '#value' => $additional_field,
+ '#weight' => 10
+ );
+ //}
}
break;
}
diff -uriN nmoderation-4.7.x-1.x-dev/nmoderation.mysql nmoderation/nmoderation.mysql
--- nmoderation-4.7.x-1.x-dev/nmoderation.mysql 1969-12-31 18:00:00.000000000 -0600
+++ nmoderation/nmoderation.mysql 2008-03-07 12:38:57.000000000 -0600
@@ -0,0 +1,32 @@
+CREATE TABLE nmoderation_filters (
+ fid int(10) unsigned NOT NULL auto_increment,
+ filter varchar(255) NOT NULL default '',
+ minimum smallint(6) NOT NULL default '0',
+ PRIMARY KEY (fid)
+);
+
+CREATE TABLE nmoderation_roles (
+ rid int(10) unsigned NOT NULL default '0',
+ mid int(10) unsigned NOT NULL default '0',
+ value tinyint(4) NOT NULL default '0',
+ KEY idx_rid (rid),
+ KEY idx_mid (mid)
+);
+
+CREATE TABLE nmoderation_uservotes (
+ uvid int(11) NOT NULL auto_increment,
+ uid int(10) NOT NULL default '0',
+ mid int(11) NOT NULL default '0',
+ gid int(10) unsigned NOT NULL default '0',
+ value int(11) NOT NULL default '0',
+ realm varchar(255) NOT NULL default '',
+ PRIMARY KEY (uvid),
+ UNIQUE KEY uid (uid,gid,realm)
+);
+
+CREATE TABLE nmoderation_votes (
+ mid int(10) unsigned NOT NULL auto_increment,
+ vote varchar(255) default NULL,
+ weight tinyint(4) NOT NULL default '0',
+ PRIMARY KEY (mid)
+);