glFusion Wiki

Site Tools


glfusion:development:api:rating:api

RATING_ratingBar

(glFusion v1.1.7)

string RATING_ratingBar( string $type, string $id, int $total_votes, int $total_value, [ int $voted, int $units, int $static, string $size ] )

This function will return the HTML code for the rating block.

Parameters

string $type Plugin name or rating type (i.e.; article)
string $id Item ID of the item to be rated
int $total_votes The total number of votes already cast for this item
int $total_value The total rating value for the item
int $voted True if user has already voted, otherwise false
int $units Size of the rating bar (defaults to 5 stars)
int $static True if rating bar should not allow votes, false allows voting
string $size 'sm' = small rating bar, otherwise use large stars

Return

Returns the HTML for the rating bar.

Notes

It is up to the plugin to define the necessary styles for the rating bar. Each class used will be preceded by the $type name. For example:

<div class="filemgmt-ratingbar">
  <div id="unit_long332">
    <ul id="unit_ul332" class="filemgmt-small-rating-unit" style="width:75px;">
      <li class="current-rating" style="width:60px;">Currently 4.00/5</li>
    </ul>
    <span class="static">Rating: <strong> 4.0</strong>/5 (1 vote cast)</span>
  </div>
</div>

Notice the filemgmt-ratingbar class name and the filemgmt-small-rating-unit class name. This allows the plugin more control over how the rating bar is displayed.

The programmer should reference the standard glFusion style.css file for a template of the rating styles.

RATING_getVoteData

(glFusion v1.1.7)

array RATING_getVoteData( string $type, [ string $item_id, string $sort, string $sortdir, array $filterArray ] )

Returns an array of all voting records for either a $type or an $item_id.

Parameters

string $type Plugin name or rating type (i.e.; article)
string $item_id item id (optional)
string $sort column to sort data by
string $sortdir Sort direction: asc or desc
array $filterArray An array of fields ⇒ values for where clause

Return

An array of all voting records that match the search criteria

RATING_getRating

(glFusion v1.1.7)

array RATING_getRating( string $type, string $item_id )

Returns an array consisting of the rating_id, votes and rating of a specific item.

Parameters

string $type Plugin name or rating type (i.e.; article)
string $item_id Item ID of the item to be returned

Return

An array of rating_id, rating, votes

RATING_hasVoted

(glFusion v1.1.7)

bool RATING_hasVoted( string $type, string $item_id, int $uid, string $ip )

Determines if user or IP has already rated the item.

Parameters

string $type Plugin name or rating type (i.e.; article)
string $item_id Item ID of the item to be returned
int $uid User id of user to check
string $ip IP Address of user to check

Return

true if user or ip has already rated, false if not

RATING_resetRating

(glFusion v1.1.7)

void RATING_resetRating( string $type, string $item_id )

Removes all rating data for an item

Parameters

string $type Plugin name or rating type (i.e.; article)
string $item_id Item ID of the item to be reset

Return

none

See Also

PLG_itemRated()

RATING_deleteVote

(glFusion v1.1.7)

bool RATING_deleteVote( string $vote_id )

Deletes a specific rating entry and recalculates the new rating

Parameters

string $vote_id The ID of the rating_votes record

Return

true if successful otherwise false

See Also

PLG_itemRated()

RATING_addVote

(glFusion v1.1.7)

array RATING_addVote( string $type, string $item_id, int $rating, int $uid, string $ip )

Adds a new rating for an item. This will calculate the new overall rating, update the vote table with the user / ip info and ask the plugin to update its records.

Parameters

string $type Plugin name or rating type (i.e.; article)
string $item_id Item ID of the item to be rated
int $rating Rating sent by user
int $uid User id of rater
string $ip IP address of rater

Return

An array with the new overall rating and total number of votes.

See Also

PLG_itemRated()

RATING_getRatedIds

(glFusion v1.1.7)

array RATING_getRatedIds( string $type )

This function will return an array of all the items the user has rated for the specific type.

Parameters

string $type Plugin name or rating type (i.e.; article)

Return

An array of item ids

glfusion/development/api/rating/api.txt · Last modified: 2017/04/12 21:15 (external edit)

Page Tools