Commit 5202d8d1 authored by Jake Bell's avatar Jake Bell Committed by Marco Villegas
Browse files

Several API changes for 7.x compatibility.

- Updated all occurrances of hook_perm to hook_permission, and changed to return associative array.
- Updated all hook_nodeapi calls.
- A couple of occurrances of node_get_types() changed to node_type_get_names().
parent 13e69c82
Loading
Loading
Loading
Loading
+0 −15
Changes for vud.install: 0 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -5,25 +5,10 @@
 * Install, update and uninstall functions for the Vote Up/Down core module.
 */

/**
 * Implementation of hook_install().
 */
function vud_install() {
  drupal_install_schema('vud');
}

/**
 * Implementation of hook_schema().
 */
function vud_schema() {
  return array();
}

/**
 * Implementation of hook_uninstall().
 */
function vud_uninstall() {
  drupal_uninstall_schema('vud');
  variable_del('vud_tag');
  variable_del('vud_reset_vote');
}
+67 −50
Changes for vud.module: 67 added lines, 50 removed lines.
Original line number Diff line number Diff line
@@ -7,58 +7,13 @@

module_load_include('inc', 'vud', 'vud.theme');  // Include the theme.inc file.

/**
 * Implementation of hook_init().
 */
function vud_init() {
  // Remove anonymous sessions which were previously set to prevent pressflow
  // page caching. This will eventually clean up those sessions over time.
  // @todo: remove in a future release when it can be reasonably expected that
  // no more sessions with this variable exist in the wild.
  $now = time();
  if (!empty($_SESSION['vud_timestamp'])) {
    unset($_SESSION['vud_timestamp']);
  }
}

/**
 * Implementation of hook_help().
 */
function vud_help($path, $arg) {
  switch ($path) {
    case 'admin/help#vud':
      $output = '<p>'. t('Provides a configurable up/down voting widget for other modules to use.') .'</p>';
      return $output;
  }
}

/**
 * Advanced menu settings callback.
 */
function vud_admin_advanced_settings() {
  $form['vud_tag'] = array(
    '#type'          => 'textfield',
    '#title'         => t('Voting API tag'),
    '#default_value' => variable_get('vud_tag', 'vote'),
    '#description'   => t('Since Vote Up/Down uses Voting API, all votes will be tagged with this term. (default: vote)<br />This tag is useful is you have deployed various modules that use Voting API. It should always be a unique value. Usually, there is NO need to change this.'),
  );
  $form['vud_message_on_deny'] = array(
    '#type'          => 'checkbox',
    '#title'         => t('Message on denied permission'),
    '#default_value' => variable_get('vud_message_on_deny', FALSE),
    '#description'   => t('When this flag is active, a modal window will be shown to the end user instead of avoid showing the voting links'),
  );

  return system_settings_form($form);
}

/**
 * Implementation of hook_menu().
 */
function vud_menu() {
  $items = array();

  $items['admin/settings/voteupdown'] = array(
  $items['admin/config/search/voteupdown'] = array(
    'title'            => 'Vote Up/Down',
    'description'      => 'Control the functioning of Vote Up/Down.',
    'page callback'    => 'drupal_get_form',
@@ -67,7 +22,7 @@ function vud_menu() {
    'type'             => MENU_NORMAL_ITEM,
  );

  $items['admin/settings/voteupdown/advanced'] = array(
  $items['admin/config/search/voteupdown/advanced'] = array(
    'title'  => 'General',
    'type'   => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
@@ -110,10 +65,72 @@ function vud_menu() {
}

/**
 * Implementation of hook_perm().
 * Implementation of hook_init().
 */
function vud_perm() {
  return array('use vote up/down', 'administer vote up/down', 'access vote up/down statistics', 'reset vote up/down votes');
function vud_init() {
  // Remove anonymous sessions which were previously set to prevent pressflow
  // page caching. This will eventually clean up those sessions over time.
  // @todo: remove in a future release when it can be reasonably expected that
  // no more sessions with this variable exist in the wild.
  $now = time();
  if (!empty($_SESSION['vud_timestamp'])) {
    unset($_SESSION['vud_timestamp']);
  }
}

/**
 * Implementation of hook_help().
 */
function vud_help($path, $arg) {
  switch ($path) {
    case 'admin/help#vud':
      $output = '<p>'. t('Provides a configurable up/down voting widget for other modules to use.') .'</p>';
      return $output;
  }
}

/**
 * Advanced menu settings callback.
 */
function vud_admin_advanced_settings() {
  $form['vud_tag'] = array(
    '#type'          => 'textfield',
    '#title'         => t('Voting API tag'),
    '#default_value' => variable_get('vud_tag', 'vote'),
    '#description'   => t('Since Vote Up/Down uses Voting API, all votes will be tagged with this term. (default: vote)<br />This tag is useful is you have deployed various modules that use Voting API. It should always be a unique value. Usually, there is NO need to change this.'),
  );
  $form['vud_message_on_deny'] = array(
    '#type'          => 'checkbox',
    '#title'         => t('Message on denied permission'),
    '#default_value' => variable_get('vud_message_on_deny', FALSE),
    '#description'   => t('When this flag is active, a modal window will be shown to the end user instead of avoid showing the voting links'),
  );

  return system_settings_form($form);
}

/**
 * Implementation of hook_permission().
 */
function vud_permission() {
  return array(
    'use vote up/down' => array(
      'title' => t('Use Vote Up/Down'),
      'description' => t('Grant users the ability to cast votes'),
    ),
    'administer vote up/down' => array(
      'title' => t('Administer Vote Up/Down'),
      'description' => t('Adjust the settings of the Vote Up/Down module'),
    ), 
    'access vote up/down statistics' => array(
      'title' => t('Access Vote Up/Down Statistics'),
      'description' => t('Permission to see who is voting on what'),
    ), 
    'reset vote up/down votes' => array(
      'title' => t('Reset Votes'),
      'description' => t('Reset all of the Up/Down votes on the site'),
    ),
  );
}

/**
+1 −1
Changes for vud_comment/vud_comment.info: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -3,4 +3,4 @@ description = "Allows adding an up/down voting widget to comments."
dependencies[] = comment
dependencies[] = vud
package = Voting
core = 6.x
core = 7.x
+0 −15
Changes for vud_comment/vud_comment.install: 0 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -5,25 +5,10 @@
 * Install, update and uninstall functions for the Vote Up/Down Comment module.
 */

/**
 * Implementation of hook_install().
 */
function vud_comment_install() {
  drupal_install_schema('vud_comment');
}

/**
 * Implementation of hook_schema().
 */
function vud_comment_schema() {
  return array();
}

/**
 * Implementation of hook_uninstall().
 */
function vud_comment_uninstall() {
  drupal_uninstall_schema('vud_comment');
  variable_del('vud_comment_node_types');
  variable_del('vud_comment_widget');
  variable_del('vud_comment_widget_display');
+18 −16
Changes for vud_comment/vud_comment.module: 18 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -8,22 +8,14 @@
define('VUD_COMMENT_DISPLAY_HIDDEN', 0);
define('VUD_COMMENT_DISPLAY_NORMAL', 1);

/**
 * Implementation of hook_perm().
 */
function vud_comment_perm() {
  return array('administer vote up/down on comments', 'use vote up/down on comments');
}

/**
 * Implementation of hook_menu().
 */
function vud_comment_menu() {
  $items = array();
  $items['admin/settings/voteupdown/comment'] = array(
  $items['admin/config/search/voteupdown/comment'] = array(
    'title'            => 'Comments',
    'description'      => 'Vote Up/Down Comment settings',
    'page callback'    => 'drupal_get_form',
    'page arguments'   => array('vud_comment_admin_settings'),
    'access arguments' => array('administer vote up/down on comments'),
    'type'             => MENU_LOCAL_TASK,
@@ -32,6 +24,20 @@ function vud_comment_menu() {
  return $items;
}

/**
 * Implementation of hook_permission().
 */
function vud_comment_permission() {
  return array(
    'administer vote up/down on comments' => array(
      'title' => t('Administer Vote Up/Down on Comments'),
    ),
    'use vote up/down on comments' => array(
      'title' => t('Vote on Comments'),
    ),
  );
}

/**
 * Menu callback for administration settings.
 */
@@ -41,7 +47,7 @@ function vud_comment_admin_settings() {
    '#title'       => t('Node types'),
    '#description' => t('Select the node types for which voting on comments will be activated.'),
    '#default_value' => variable_get('vud_comment_node_types', array()),
    '#options'       => node_get_types('names'),
    '#options'       => node_type_get_names(),
  );
  $form['vud_comment_widget'] = array(
    '#type'          => 'radios',
@@ -101,11 +107,9 @@ function vud_comment_admin_settings_validate($form, &$form_state) {
}

/**
 * Implementation of hook_comment().
 * Implementation of hook_comment_view().
 */
function vud_comment_comment(&$comment, $op) {
  switch ($op) {
    case 'view':
function vud_comment_comment_view($comment, $view_mode, $langcode) {
  if (!isset($comment->cid)) {
    return;
  }
@@ -119,8 +123,6 @@ function vud_comment_comment(&$comment, $op) {
      $comment->comment = $comment->vud_comment_widget . $comment->comment;
    }
  }
      break;
  }
}

/**
Loading