--- jrating.module.old 2007-08-31 12:51:37.000000000 +0200 +++ jrating.module.new 2007-09-19 15:45:36.000000000 +0200 @@ -85,7 +85,42 @@ function jrating_settings() { '#delta' => 10, '#description' => t('Where should the rating form be positioned (heavier = lower)?') ); - + +/************************ + * Date: 09/19/2007 + * Add a feature for preventing node's owner to vote + ************************/ + + + $form['jrating_display_rating_form_for_owner'] = array( + '#type' => 'radios', + '#title' => t('Display rating form for owner'), + '#default_value' => variable_get('jrating_display_rating_form_for_owner', 0), + '#options' => array ('1' => t('Yes'), '0' => t('No')), + '#description' => t('Should a rating form be present when the node is displayed to its owner?') + ); + + $form['jrating_display_mean_rating_for_owner'] = array( + '#type' => 'radios', + '#title' => t('Display mean rating for owner'), + '#default_value' => variable_get('jrating_display_mean_rating_for_owner', 1), + '#options' => array ('1' => t('Yes'), '0' => t('No')), + '#description' => t('Should the mean rating be present when the node is displayed to its owner?') + ); + + $form['jrating_display_rating_intro_for_owner'] = array( + '#type' => 'radios', + '#title' => t('Display rating intro for owner'), + '#default_value' => variable_get('jrating_display_rating_intro_for_owner', 0), + '#options' => array ('1' => t('Yes'), '0' => t('No')), + '#description' => t('Should the rating intro be present when the node is displayed to its owner?') + ); + + +/********************* + * End of modification + *********************/ + return system_settings_form($form); } @@ -132,22 +167,50 @@ function jrating_nodeapi(&$node, $op, $t } } +/************************ + * Date: 09/19/2007 + * Add a feature for preventing node's owner to vote + ************************/ + function jrating_display_rating_form($node, $teaser){ + global $user; - if ((!$teaser || variable_get('jrating_display_form_teaser', 0)) && (user_access('rate content') || ((!$user->uid) && variable_get('jrating_display_anonymous', 1)))){ + + if ( + // display rating form for node's owner? + !( variable_get('jrating_display_rating_form_for_owner', 0) == 0 && $node->uid == $user->uid ) + && + (!$teaser || variable_get('jrating_display_form_teaser', 0)) && (user_access('rate content') || ((!$user->uid) && variable_get('jrating_display_anonymous', 1))) + ) { $rating_form = drupal_get_form('rating_form_' . $node->nid, array('nid' => $node->nid)); } - if (variable_get('jrating_display_mean', 1) && (!$teaser || variable_get('jrating_display_mean_teaser', 0))){ + if ( + // display mean rating for node's owner? + !( variable_get('jrating_display_mean_rating_for_owner', 1) == 0 && $node->uid == $user->uid ) + && + ( variable_get('jrating_display_mean', 1) && (!$teaser || variable_get('jrating_display_mean_teaser', 0)) ) + ) { $mean_rating = theme('jrating_average_rating', $node); } - $rating_intro = '
'; + if ( + // display rating intro for node's owner? + !( variable_get('jrating_display_rating_intro_for_owner', 0) == 0 && $node->uid == $user->uid ) + ) { + $rating_intro = '
'; + } return theme('jrating_rating_item', $rating_intro, $mean_rating, $rating_form); + } +/********************* + * End of modification + *********************/ + function theme_jrating_rating_item($rating_intro = NULL, $mean_rating = NULL, $rating_form = NULL){ + return '
' . $mean_rating . '
' . $rating_intro . $rating_form . '
'; }