From 48adbcdc150d7872d350ff5641a4942a0cdcd8c0 Mon Sep 17 00:00:00 2001 From: Jeremy Trojan Date: Wed, 16 Mar 2011 22:44:29 -0700 Subject: Initial commit. --- fblikebutton.admin.inc | 29 +++++++++++++++++++++ fblikebutton.install | 16 ++++++++++++ fblikebutton.module | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 fblikebutton.admin.inc create mode 100644 fblikebutton.install create mode 100644 fblikebutton.module diff --git a/fblikebutton.admin.inc b/fblikebutton.admin.inc new file mode 100644 index 0000000..a11e682 --- /dev/null +++ b/fblikebutton.admin.inc @@ -0,0 +1,29 @@ + 'checkboxes', + '#title' => t('Display the Like button on these content types'), + '#options' => $fblikebutton_node_options, + '#default_value' => variable_get('fblikebutton_node_types', array('page')), + '#description' => t('Each of these content types will have the "like" button automatically added to them.'), + );/** + $form['fblikebutton_show_faces'] = array( + '#type' => 'radios', + '#title' => t('Display faces in the Like box'), + '#options' => array('true' => t('Show faces'), 'false' => t('Do not show faces')) + '#default_value' => variable_get('fblikebutton_show_faces', array('true')), + '#description' => t('Should users see the faces of other people who have "liked" the same content?'), + ); */ + return system_settings_form($form); +} diff --git a/fblikebutton.install b/fblikebutton.install new file mode 100644 index 0000000..b6d4a63 --- /dev/null +++ b/fblikebutton.install @@ -0,0 +1,16 @@ + 'FB Like settings', + 'description' => 'Control which content types the "like" button should appear on.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('fblikebutton_admin_settings'), + 'access arguments' => array('administer site configuration'), + 'type' => MENU_NORMAL_ITEM, + 'file' => 'fblikebutton.admin.inc', + ); + return $items; +} + +/** + * Implementation of hook_nodeapi(). + * @todo + * Add more config options for like button (size, etc). + * Should $likebutton be wrapped in t()? + */ +function fblikebutton_nodeapi(&$node, $op, $teaser, $page) { + global $user; + switch ($op) { + case 'view': + // Set which node types users can "like". + $types_to_like = variable_get('fblikebutton_node_types', array('page')); + // Replace with drupal_get_path_alias() or something? + $likepath = $_SERVER['SCRIPT_URI']; + $likepath = urlencode($likepath); + // Facebook is doing away with FBML, so we use the iframe plugin option instead. + $likebutton = ''; + // Keep the fblikebutton button out of search results, etc. + if (!$page) { + break; + } + // Do not add the like button to any of the unchecked node types. + if (!in_array($node->type, $types_to_like, TRUE)) { + break; + } + // Set permissions, and keep the button out of teasers. Otherwise, there + // would be 50 "like" buttons on the front page of some sites... Not good. + if (!$teaser && user_access('users may access Like button')) { + $node->content['fblikebutton_button'] = array( + '#value' => $likebutton, + '#weight' => 100, + ); + } + break; + } +} + +/** + * Implementation of hook_perm(). + */ +function fblikebutton_perm() { + return array('users may access Like button'); +} -- cgit v1.2.3