diff --git a/commons_follow.info b/commons_follow.info index 5327ae4..b543983 100644 --- a/commons_follow.info +++ b/commons_follow.info @@ -9,9 +9,5 @@ features[features_api][] = api:1 features[field_base][] = field_target_comments features[field_base][] = field_target_nodes features[field_base][] = field_target_users - -; Views handlers files[] = includes/views/commons_follow.views.inc files[] = includes/views/handlers/commons_follow_handler_filter_follow.inc -files[] = includes/views/handlers/commons_follow_plugin_argument_default_node.inc -files[] = includes/views/handlers/commons_follow_user_follow_filter.inc diff --git a/commons_follow.module b/commons_follow.module index 8843def..444f3bf 100644 --- a/commons_follow.module +++ b/commons_follow.module @@ -1,74 +1,6 @@ fid; - } - - return $flag_ids; -} - -/////////////////// - -/** * Implementation of hook_views_api(). */ function commons_follow_views_api() { @@ -146,8 +78,8 @@ function commons_follow_get_followed_message_ids($account = NULL) { foreach ($followed_content as $key => $content) { $function = $key . '_commons_follow_get_message_ids'; if (function_exists($function)) { - $function($followed_mids, $followed_content); - } + $function($followed_mids, $followed_content); + } } return $followed_mids; } diff --git a/commons_follow_node/commons_follow_node.module b/commons_follow_node/commons_follow_node.module index 32b28ce..f0967fe 100644 --- a/commons_follow_node/commons_follow_node.module +++ b/commons_follow_node/commons_follow_node.module @@ -6,50 +6,6 @@ include_once 'commons_follow_node.features.inc'; - - -/** - * Implements hook_commons_follow_get_nids(). - */ -function commons_follow_node_commons_follow_get_nids($account, $options) { - // Get all flaggings from flags that belong to Message-subscribe, that - // reference the node entity-type. - - // Get subscribe flag IDs. - $flag_ids = common_follow_get_subscription_flags_ids('node'); - - if (empty($flag_ids)) { - return array(); - } - - $query = db_select('flag_content', 'f'); - - if (!empty($options['range'])) { - $query->range(0, $options['range']); - } - - $result = $query - ->addTag('node_access') - ->condition('fid', $flag_ids, 'IN') - ->condition('uid', $account->uid, '=') - ->condition('content_type', 'node', '=') - ->fields('f',array('content_id')) - ->execute() - ->fetchAll(); - - $nids = array(); - foreach($result as $row) { - $nids[] = (integer) $row->content_id; - } - - return $nids; -} - - -/////////////// - - - /** * Implements hook_commons_follow_get_message_ids(). */ @@ -85,4 +41,4 @@ function commons_follow_node_commons_follow_get_following_uids(&$following_uids, foreach ($result as $this_result) { $following_uids[$this_result->uid] = $this_result->uid; } -} +} \ No newline at end of file diff --git a/commons_follow_term/commons_follow_term.module b/commons_follow_term/commons_follow_term.module index 67a4047..38ded16 100644 --- a/commons_follow_term/commons_follow_term.module +++ b/commons_follow_term/commons_follow_term.module @@ -6,73 +6,12 @@ include_once 'commons_follow_term.features.inc'; - - -/** - * Implements hook_commons_follow_get_nids(). - */ -function commons_follow_term_commons_follow_get_nids($account, $options) { - // Get all flaggings from flags that belong to Message-subscribe, that - // reference the taxonomy-term entity-type. - $flag_ids = common_follow_get_subscription_flags_ids('taxonomy_term'); - - if (empty($flag_ids)) { - return array(); - } - - // Get user's flagged terms. - $query = db_select('flag_content', 'f'); - $result = $query - ->condition('fid', $flag_ids, 'IN') - ->condition('uid', $account->uid, '=') - ->condition('content_type', 'taxonomy_term', '=') - ->fields('f',array('content_id')) - ->execute() - ->fetchAll(); - - if (empty($result)) { - // No term flags. - return array(); - } - - $tids = array(); - foreach($result as $row) { - $tids[] = (integer) $row->content_id; - } - - // Get IDs of nodes tagged by the specified terms. - $query = db_select('taxonomy_index', 't'); - - if (!empty($options['range'])) { - $query->range(0, $options['range']); - } - - $result = $query - ->addTag('node_access') - ->condition('tid', $tids, 'IN') - ->fields('t',array('nid')) - ->groupBy('nid') - ->execute() - ->fetchAll(); - - // Return the node IDs. - $nids = array(); - foreach($result as $row) { - $nids[] = (integer) $row->nid; - } - - return $nids; -} - - -////////// - /** * Implements hook_node_view_alter(). */ function commons_follow_term_node_view_alter(&$build) { - // TODO: - // If the user is already subscribed to terms covering this node, + // TODO: + // If the user is already subscribed to terms covering this node, // deny her the ability to subscribe to the individual node. } diff --git a/commons_follow_user/commons_follow_user.module b/commons_follow_user/commons_follow_user.module index e9d8e76..59b2d79 100644 --- a/commons_follow_user/commons_follow_user.module +++ b/commons_follow_user/commons_follow_user.module @@ -6,66 +6,6 @@ include_once 'commons_follow_user.features.inc'; - - -/** - * Implements hook_commons_follow_get_nids(). - */ -function commons_follow_user_commons_follow_get_nids($account, $options) { - // Get all flaggings from flags that belong to Message-subscribe, that - // reference the node entity-type. - - // Get subscribe flag IDs. - $flag_ids = common_follow_get_subscription_flags_ids('user'); - - if (empty($flag_ids)) { - return array(); - } - - // Get flagged user IDs. - $query = db_select('flag_content', 'f'); - $result = $query - ->condition('fid', $flag_ids, 'IN') - ->condition('uid', $account->uid, '=') - ->condition('content_type', 'user', '=') - ->fields('f',array('content_id')) - ->execute() - ->fetchAll(); - - if (empty($result)) { - // No user flags. - return array(); - } - - $uids = array(); - foreach($result as $row) { - $uids[] = (integer) $row->content_id; - } - - // Get the user's node IDs. - $query = new EntityFieldQuery(); - - if (!empty($options['range'])) { - $query->range(0, $options['range']); - } - - $result = $query - ->entityCondition('entity_type', 'node') - ->propertyCondition('uid', $uids, 'IN') - ->execute(); - - $nids = array(); - foreach ($result['node'] as $nid => $row) { - $nids[] = $nid; - } - - return $nids; -} - - -/////////////// - - /** * Implements hook_system_info_alter(). */ @@ -127,9 +67,9 @@ function commons_follow_user_commons_follow_get_message_ids(&$followed_mids, $fo } // Generate a list of message IDs where message.uid OR any of the referenced // target users are ones that the current user is following. - $result = db_query("SELECT m.mid AS mid - FROM {message} m - LEFT JOIN {field_data_field_target_users} tu ON m.mid=tu.entity_id + $result = db_query("SELECT m.mid AS mid + FROM {message} m + LEFT JOIN {field_data_field_target_users} tu ON m.mid=tu.entity_id WHERE tu.field_target_users_target_id IN(:uids) OR m.uid IN (:uids)", array(':uids' => array_values($followed_content['commons_follow_user']))); @@ -152,9 +92,9 @@ function commons_follow_user_commons_follow_get_following_uids(&$following_uids, $target_uids[] = $field['target_id']; } } - + $result = db_query("SELECT fc.uid FROM {flag_content} fc WHERE fc.content_type = 'user' AND fc.content_id IN(:target_uids) AND fc.fid IN (:commons_follow_flag_ids)", array(':target_uids' => array_keys($target_uids), ':commons_follow_flag_ids' => array_keys(commons_follow_get_flag_ids()))); foreach ($result as $this_result) { $following_uids[$this_result->uid] = $this_result->uid; } -} +} \ No newline at end of file diff --git a/includes/views/commons_follow.views.inc b/includes/views/commons_follow.views.inc index 698e0da..672d7f0 100644 --- a/includes/views/commons_follow.views.inc +++ b/includes/views/commons_follow.views.inc @@ -12,39 +12,4 @@ function commons_follow_views_data_alter(&$data) { 'real field' => 'mid', ), ); -} - - - -/** - * Implements hook_views_plugins(). - */ -function commons_follow_views_plugins() { - // This handler requires message_subscribe module. - return array( - 'argument default' => array( - 'commons_follow_node' => array( - 'title' => t('The node IDs the user is subscribed to'), - 'handler' => 'commons_follow_plugin_argument_default_node', - ), - ), - ); -} - -/** - * Implements hook_views_data(). - */ -function commons_follow_views_data() { - $data['node']['cf_user_follow'] = array( - 'title' => t('User Follow'), // The item it appears as on the UI, - 'help' => t('Whether the user is following this content.'), // The help that appears on the UI, - // Information for displaying a title as a field - 'filter' => array( - 'handler' => 'commons_follow_user_follow_filter', - 'label' => t('Following'), - 'type' => 'yes-no', - ), - ); - - return $data; -} +} \ No newline at end of file diff --git a/includes/views/handlers/commons_follow_plugin_argument_default_node.inc b/includes/views/handlers/commons_follow_plugin_argument_default_node.inc deleted file mode 100644 index 9f0735a..0000000 --- a/includes/views/handlers/commons_follow_plugin_argument_default_node.inc +++ /dev/null @@ -1,37 +0,0 @@ -view->argument as $argument_name => $argument) { - - if ($argument->options['default_argument_type'] == 'commons_follow_node') { - // The argument that toggles 'following' or 'not following' display. - $this->view->argument[$argument_name]->options['not'] = !$this->value; - break; - } - } - } -}