Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/modr8/README.txt,v retrieving revision 1.5 diff -u -r1.5 README.txt --- README.txt 16 Aug 2007 02:54:53 -0000 1.5 +++ README.txt 9 Dec 2007 19:35:02 -0000 @@ -1,6 +1,6 @@ -$Id: README.txt,v 1.5 2007/08/16 02:54:53 pwolanin Exp $ +$Id: README.txt,v 1.3.2.2 2007/08/16 02:58:04 pwolanin Exp $ -Modr8 module for Drupal 5.x. +Modr8 module for Drupal 6.x. The moderation of content was removed from core in 5.x. This module adds back that capability and also prevents posts that are in moderation from showing @@ -46,4 +46,4 @@ This module was originally written for Drupal 4.7.x by Jeff Robbins (jjeff@drupal). Upgrade to 5.x and 5.x maintenance by Peter Wolanin (pwolanin@drupal) with help from Angela Byron (webchick@drupal). - +Upgrade to 6.x by Croitor Alexander (Placinta@drupal) Index: modr8.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/modr8/modr8.info,v retrieving revision 1.1 diff -u -r1.1 modr8.info --- modr8.info 31 Oct 2006 03:31:14 -0000 1.1 +++ modr8.info 8 Dec 2007 17:58:35 -0000 @@ -1,3 +1,4 @@ ; $Id: modr8.info,v 1.1 2006/10/31 03:31:14 pwolanin Exp $ name = Modr8 description = Easy, dedicated moderation of content +core = 6.x \ No newline at end of file Index: modr8.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/modr8/modr8.install,v retrieving revision 1.2 diff -u -r1.2 modr8.install --- modr8.install 20 Jan 2007 15:26:38 -0000 1.2 +++ modr8.install 11 Dec 2007 15:36:04 -0000 @@ -1,95 +1,72 @@ array( + 'modid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), + 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), + 'uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), + 'author_uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), + 'action' => array('type' => 'varchar', 'length' => 16, 'not null' => TRUE, 'default' => ''), + 'title' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), + 'message' => array('type' => 'text', 'size' => 'big', 'not null' => TRUE), + 'teaser' => array('type' => 'text', 'size' => 'big', 'not null' => TRUE), + 'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0) + ), + 'indexes' => array( + 'nid_time' => array('nid', 'modid'), + 'action' => array('action') + ), + 'primary key' => array('modid'), + ); + + return $schema; +} /** * Implementation of hook_install(). */ function modr8_install() { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - db_query("CREATE TABLE {modr8_log} ( - modid int NOT NULL auto_increment, - nid int unsigned NOT NULL default '0', - uid int NOT NULL default '0', - author_uid int NOT NULL default '0', - action varchar(16) NOT NULL default '', - title varchar(128) NOT NULL default '', - message longtext NOT NULL, - teaser longtext NOT NULL, - timestamp int NOT NULL default '0', - PRIMARY KEY (modid), - KEY nid_time (nid, modid), - KEY action (action) - ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); - break; - case 'pgsql': - db_query("CREATE TABLE {modr8_log} ( - modid serial, - nid int_unsigned NOT NULL default '0', - uid int NOT NULL default '0', - author_uid int NOT NULL default '0', - action varchar(16) NOT NULL default '', - title varchar(128) NOT NULL default '', - message text NOT NULL, - teaser text NOT NULL, - timestamp int NOT NULL default '0', - PRIMARY KEY (modid) - )"); - db_query("CREATE INDEX {modr8_log}_nid_time ON {modr8_log} (nid, modid)"); - db_query("CREATE INDEX {modr8_log}_act_idx ON {modr8_log} (action)"); - break; - } + // Create tables. + drupal_install_schema('modr8'); } /** * Implementation of hook_uninstall(). */ function modr8_uninstall() { - db_query('DROP TABLE {modr8_log}'); + // Remove tables. + drupal_uninstall_schema('modr8'); } - /** * Update table definitions. */ function modr8_update_1000() { $ret = array(); - - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - $ret[] = update_sql("CREATE TABLE {modr8_log} ( - modid int NOT NULL auto_increment, - nid int unsigned NOT NULL default '0', - uid int NOT NULL default '0', - author_uid int NOT NULL default '0', - action varchar(16) NOT NULL default '', - title varchar(128) NOT NULL default '', - message longtext NOT NULL, - teaser longtext NOT NULL, - timestamp int NOT NULL default '0', - PRIMARY KEY (modid), - KEY nid_time (nid, modid), - KEY action (action) - ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); - break; - case 'pgsql': - $ret[] = update_sql("CREATE TABLE {modr8_log} ( - modid serial, - nid int_unsigned NOT NULL default '0', - uid int NOT NULL default '0', - author_uid int NOT NULL default '0', - action varchar(16) NOT NULL default '', - title varchar(128) NOT NULL default '', - message text NOT NULL, - teaser text NOT NULL, - timestamp int NOT NULL default '0', - PRIMARY KEY (modid) - )"); - $ret[] = update_sql("CREATE INDEX {modr8_log}_nid_time ON {modr8_log} (nid, modid)"); - $ret[] = update_sql("CREATE INDEX {modr8_log}_act_idx ON {modr8_log} (action)"); - break; - } + $name = 'modr8_log'; + $table = array( + 'fields' => array( + 'modid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), + 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), + 'uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), + 'author_uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), + 'action' => array('type' => 'varchar', 'length' => 16, 'not null' => TRUE, 'default' => ''), + 'title' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), + 'message' => array('type' => 'text', 'size' => 'big', 'not null' => TRUE), + 'teaser' => array('type' => 'text', 'size' => 'big', 'not null' => TRUE), + 'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0) + ), + 'indexes' => array( + 'nid_time' => array('nid', 'modid'), + 'action' => array('action') + ), + 'primary key' => array('modid'), + ); + db_create_table(&$ret, $name, $table); return $ret; } Index: modr8.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/modr8/modr8.module,v retrieving revision 1.17 diff -u -r1.17 modr8.module --- modr8.module 16 Aug 2007 02:54:53 -0000 1.17 +++ modr8.module 13 Dec 2007 14:52:45 -0000 @@ -1,5 +1,5 @@ '. t("Easy, dedicated moderation of content. Assign the 'moderate content' permission to one or mode user roles. Set up the default moderation option for each node type."). '
'; + return ''. t("Easy, dedicated moderation of content. Assign the 'moderate content' permission to one or mode user roles. Set up the default moderation option for each node type.") .'
'; // OPTIONAL: Add additional cases for other paths that should display help text. } } +/** + * An access function for Moderation Menu Tab + */ +function modr8_moderation_access($nid) { + return user_access('moderate content') && db_result(db_query("SELECT COUNT(*) FROM {modr8_log} ml WHERE ml.nid = %d", $nid)); +} /** * Implementation of hook_menu(). */ -function modr8_menu($may_cache) { +function modr8_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'admin/content/modr8', - 'title' => t('Moderated content'), - 'description' => t('Approve or delete moderated content.'), - 'access' => user_access('moderate content'), - 'callback' => 'modr8_page', + $items['admin/content/modr8'] = array( + 'title' => 'Moderated content', + 'description' => 'Approve or delete moderated content.', + 'access callback' => 'user_access', + 'access arguments' => array('moderate content'), + 'page callback' => 'modr8_page', + 'file' => 'modr8_admin.inc', + 'file path' => drupal_get_path('module', 'modr8') , ); - $items[] = array( - 'path' => 'admin/logs/modr8', - 'title' => t('Content moderation log'), - 'description' => t('Show log of all actions on moderated content.'), - 'access' => user_access('moderate content'), - 'callback' => 'modr8_log_view', + $items['admin/reports/modr8'] = array( + 'title' => 'Content moderation log', + 'description' => 'Show log of all actions on moderated content.', + 'access callback' => 'user_access', + 'access arguments' => array('moderate content'), + 'page callback' => 'modr8_log_view', + 'file' => 'modr8_admin.inc', + 'file path' => drupal_get_path('module', 'modr8') , ); - $items[] = array( - 'path' => 'admin/settings/modr8', - 'title' => t('Modr8 settings'), - 'description' => t('Configure content moderation.'), - 'callback' => 'modr8_settings', - 'access' => user_access('administer site configuration'), + $items['admin/settings/modr8'] = array( + 'title' => 'Modr8 settings', + 'description' => 'Configure content moderation.', + 'page callback' => 'modr8_settings', + 'access callback' => 'user_access', + 'access arguments' => array('administer site configuration'), + 'file' => 'modr8_admin.inc', + 'file path' => drupal_get_path('module', 'modr8') , ); - } - elseif (arg(0) == 'node' && is_numeric($nid = arg(1))) { - $items[] = array( - 'path' => 'node/'. $nid .'/modr8', - 'title' => t('Moderation'), - 'callback' => 'modr8_log_view', - 'callback arguments' => array('node', $nid), - 'access' => user_access('moderate content') && db_result(db_query("SELECT COUNT(*) FROM {modr8_log} ml WHERE ml.nid = %d", $nid)), + + $items['node/%/modr8'] = array( + 'title' => 'Moderation', + 'page callback' => 'modr8_log_view', + 'page arguments' => array('node', 1), + 'access callback' => 'modr8_moderation_access', + 'access arguments' => array(1), + 'file' => 'modr8_admin.inc', + 'file path' => drupal_get_path('module', 'modr8') , 'weight' => 10, 'type' => MENU_LOCAL_TASK ); - } return $items; } @@ -74,8 +85,6 @@ */ function modr8_log_view($op = '', $id = 0) { - require_once drupal_get_path('module', 'modr8'). '/modr8_admin.inc'; - switch ($op) { case '': return modr8_log_overview(); @@ -83,15 +92,16 @@ if (is_numeric($id)) { drupal_set_title(t('Moderation log event')); return modr8_log_event($id); + } break; case 'node': if (is_numeric($id)) { $node = node_load($id); - if ($node->nid) { - drupal_set_title(check_plain($node->title)); - } - return modr8_log_overview($id); + if ($node->nid) { + drupal_set_title(check_plain($node->title)); + } + return modr8_log_overview($id); } break; } @@ -104,8 +114,6 @@ */ function modr8_settings() { - require_once drupal_get_path('module', 'modr8'). '/modr8_admin.inc'; - return drupal_get_form('modr8_settings_form'); } @@ -149,7 +157,7 @@ } } -function modr8_form_alter($form_id, &$form){ +function modr8_form_alter(&$form, $form_state, $form_id) { if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) { @@ -188,7 +196,6 @@ * Menu callback; displays the content moderation form. */ function modr8_page() { - require_once drupal_get_path('module', 'modr8'). '/modr8_admin.inc'; $is_published = ''; if (!user_access('administer nodes')) { @@ -197,15 +204,18 @@ } $count_sql = db_rewrite_sql('SELECT COUNT(*) FROM {node} n WHERE '. $is_published .' n.moderate = 1'); $page_sql = db_rewrite_sql('SELECT n.nid FROM {node} n WHERE '. $is_published .' n.moderate = 1 ORDER BY n.changed DESC'); - $result = pager_query($page_sql, variable_get('modr8_nodes_per_page', 10), 0, $count_sql); - - $output = ''. l(t('Show log of all actions on moderated content.'), 'admin/logs/modr8') .'
'; - if (db_num_rows($result)) { + $result = pager_query($page_sql, 10, 0, $count_sql); + $result_count = pager_query($page_sql, 10, 0, $count_sql); + $output = ''. l(t('Show log of all actions on moderated content.'), 'admin/reports/modr8') .'
'; + + + if (db_fetch_object($result_count)) { $output .= drupal_get_form('modr8_form', $result); $output .= theme('pager'); + } else { - $output .= ''. t('@items in moderation', array('@items' => format_plural(0, '1 post', '@count posts'))). '
'; + $output .= ''. t('@items in moderation', array('@items' => format_plural(0, '1 post', '@count posts'))) .'
'; } return $output; } @@ -240,7 +250,7 @@ /** * Implementation of hook_cron() * - *.Remove expired moderation log events. + * Remove expired moderation log events. */ function modr8_cron() { if ($log_clear = variable_get('modr8_log_clear', 0)) { @@ -257,7 +267,7 @@ return $blocks; } elseif ($op == 'view') { - if (user_access('moderate content')){ + if (user_access('moderate content')) { $block['subject'] = t('Moderation queue'); $is_published = ''; if (!user_access('administer nodes')) { @@ -265,10 +275,10 @@ $is_published = 'n.status = 1 AND '; } $count = db_result(db_query(db_rewrite_sql('SELECT COUNT(*) FROM {node} n WHERE '. $is_published .' n.moderate = 1'))); - $content = ''. l(t('@items in moderation',array('@items' => format_plural($count, '1 post', '@count posts'))),'admin/content/modr8'). '
'; + $content = ''. l(t('@items in moderation', array('@items' => format_plural($count, '1 post', '@count posts'))), 'admin/content/modr8') .'
'; if ($count) { $sql = db_rewrite_sql('SELECT n.nid, n.title FROM {node} n WHERE '. $is_published .' n.moderate = 1 ORDER BY n.changed DESC'); - $result = db_query_range($sql,0,6); + $result = db_query_range($sql, 0, 6); $content .= node_title_list($result, t('Recent additions:')); } $block['content'] = $content; @@ -276,7 +286,21 @@ } } } - +/** + * Implementation of hook_theme(). + */ +function modr8_theme() { + return array( + 'modr8_message' => array('arguments' => array('teaser', 'nodetype', 'op')), + 'modr8_form' => array('arguments' => array('form')), + 'moderation_event' => array('arguments' => array('event')), + 'modr8_note' => array('arguments' => array('note')), + + ); +} +/** + * Theming function for messages. + */ function theme_modr8_message($teaser = FALSE, $nodetype = 'page', $op = 'view') { if ($teaser) { return '