# This patch was generated against watcher.module 6.x-1.4 # It uses platform neutral UTF-8 encoding and \n newlines. --- Base (BASE) +++ Locally Modified (Based On LOCAL) @@ -162,6 +162,45 @@ } /** + * Return a toggle watching post link array to be displayed in the node links section + * + * Please note that the JavaScript that handles the AJAX request looks for the class + * attribute so do not change it, rather override it with your own CSS rules if you + * want to change the appearance of this element. + * + * @param $uid + * The user we'd like to toggle watching for + * @param $nid + * The node id we're toggling watching for for this user + * @param $query + * Query portion of the link + * @param $user_is_watching + * A boolean denoting whether uid is watching nid + * @param $t + * An associative array of localized strings + * + * @return + * An array defining the link properties + * + */ +function theme_watcher_node_links_toggle_watching_link($uid, $nid, $query, $user_is_watching, $t = array()) { + + // Set up classes + $class_watch_status_link = ( $user_is_watching ? ' watcher_node_toggle_watching_link_watched' : ''); + + return array( + 'href' => "user/$uid/watcher/toggle/$nid", + 'title' => ( $user_is_watching ? $t['watch_toggle_enabled'] : $t['watch_toggle_disabled'] ), + 'attributes' => array( + 'class' => "watcher_node_toggle_watching_link$class_watch_status_link", + 'title' => ( $user_is_watching ? $t['watch_toggle_enabled_title'] : $t['watch_toggle_disabled_title'] ), + ), + 'query' => $query, + ); + +} + +/** * Return the help page * * @param $content @@ -222,6 +261,9 @@ 'watcher_node_toggle_watching_link' => array( 'arguments' => array('uid' => null, 'nid' => null, 'query' => null, 'user_is_watching' => null, 't' => array()), ), + 'watcher_node_links_toggle_watching_link' => array( + 'arguments' => array('uid' => null, 'nid' => null, 'query' => null, 'user_is_watching' => null, 't' => array()), + ), 'watcher_help_page' => array( 'arguments' => array('content' => null), ), @@ -264,6 +306,16 @@ } /** + * Implementation of hook_link(). + */ +function watcher_link($type, $object, $teaser = FALSE) { + global $user; + if ($type == 'node' && _watcher_menu_access_toggle_watching_post($user) && _watcher_node_type_enabled($object)) { + return _watcher_node_watch_link($object, $teaser, null); + } +} + +/** * Implementation of hook_menu(). */ function watcher_menu() { @@ -576,7 +628,7 @@ if ($comment['status'] == COMMENT_PUBLISHED) { // If the comment author is anonymous, the uid field is null - $comment_author = user_load(array('uid' => (is_null($commment['uid']) ? 0 : $commment['uid']))); + $comment_author = user_load(array('uid' => (is_null($comment['uid']) ? 0 : $comment['uid']))); // If this comment was unpublished as a result of it requiring approval // notify the users watching the node now that it's deemed worthy to publish @@ -725,6 +777,34 @@ '#collapsed' => true, ); + $form['togglelink']['watcher_toggle_link_disabled_text'] = array( + '#type' => 'textfield', + '#title' => t('Link text when node is not being watched'), + '#default_value' => variable_get('watcher_toggle_link_disabled_text', t('You are not watching this post, click to start watching')), + '#size' => 50, + '#maxlength' => 100, + ); + + $form['togglelink']['watcher_toggle_link_enabled_text'] = array( + '#type' => 'textfield', + '#title' => t('Link text when node is being watched'), + '#description' => t('If your site uses many languages, both these strings can be translated to languages other than the default by using the locale module.'), + '#default_value' => variable_get('watcher_toggle_link_enabled_text', t('You are watching this post, click to stop watching')), + '#size' => 50, + '#maxlength' => 100, + ); + + $form['togglelink']['watcher_toggle_link_position'] = array( + '#type' => 'radios', + '#title' => t('Where should "watch this post" toggle links be inserted on each node?'), + '#description' => t('This setting applies for both full page view and teasers (if the "display in teasers" option is checked).'), + '#options' => array( + 'body' => t('At the bottom of the node body'), + 'links' => t('In the node links section'), + ), + '#default_value' => variable_get('watcher_toggle_link_position', 'body'), + ); + $form['togglelink']['watcher_toggle_link_in_teaser'] = array( '#type' => 'checkbox', '#title' => t('Display "watch this post" toggle link in teasers.'), @@ -2194,9 +2274,9 @@ // Make localized strings $tstrings = array(); - $tstrings['watch_toggle_enabled'] = t('You are watching this post, click to stop watching'); + $tstrings['watch_toggle_enabled'] = variable_get('watcher_toggle_link_enabled_text', t('You are watching this post, click to stop watching')); $tstrings['watch_toggle_enabled_title'] = t('This post is being watched. You can track and change email notification setting for this post in your watched posts list (see your user profile)'); - $tstrings['watch_toggle_disabled'] = t('You are not watching this post, click to start watching'); + $tstrings['watch_toggle_disabled'] = variable_get('watcher_toggle_link_disabled_text', t('You are not watching this post, click to start watching')); $tstrings['watch_toggle_disabled_title'] = t('Watch posts to be notified when other users comment on them or the posts are changed'); // Build link to the user's list of watched posts @@ -2220,12 +2300,19 @@ // Add CSS drupal_add_css(drupal_get_path('module', 'watcher') .'/css/watcher.css'); + $position = variable_get('watcher_toggle_link_position', 'body'); + if ($position == 'links') { + // Add toggle element to links array + return array( 'watcher' => theme('watcher_node_links_toggle_watching_link', $user->uid, $node->nid, $link_query, $watching, $tstrings) ); + } + else { //Add element to node $node->content['watcher'] = array( '#value' => theme('watcher_node_toggle_watching_link', $user->uid, $node->nid, $link_query, $watching, $tstrings), '#weight' => 30, ); } +} /** * Save user settings for Watcher