[TH] Extend Post Ratings [Deleted]

Error
Callback ExtendPostRating_Listener_CodeEvent::loadClass is invalid (Invalid Class).

When installing this.

I have latest 1.6.6 post ratings on xenforo 1.4.3
 
Do you think that in the future will be possible to hide who gave positive/neutral/negative rating?
 
Last edited:
Loaded all addon files, no luck.

Callback ExtendPostRating_Listener_CodeEvent::loadClass is invalid (Invalid Class).

Please verify with the attached files.

I've just installed this add-on on a blank xenforo install and have not had this issue. The error your are providing would suggest that he library/ExtendPostRating/Listener/CodeEvent.php file doesn't exist, or is corrupted. Perhaps try to delete the library/ExtendPostRating directory and re-upload it.
 
Hi first of thanks for making this, really what's missing in post ratings. Anyways It seems post posted by guests won't show up in the ratings "given page" but does get counted. is there a way to not count those ratings or include them in the "ratings given" page?
 
Bug

HTML:
Fehlermeldung des Servers
Fehlerinformation
Zend_Db_Statement_Mysqli_Exception: Mysqli prepare error: Unknown table 'user' - library/Zend/Db/Statement/Mysqli.php:77
Generiert durch: xxx, Vor einem Moment
Stapelverfolgung
#0 /www//library/Zend/Db/Statement.php(115): Zend_Db_Statement_Mysqli->_prepare('\n\t\t\tSELECT user...')
#1 /www//library/Zend/Db/Adapter/Mysqli.php(381): Zend_Db_Statement->__construct(Object(Zend_Db_Adapter_Mysqli), '\n\t\t\tSELECT user...')
#2 /www//library/Zend/Db/Adapter/Abstract.php(478): Zend_Db_Adapter_Mysqli->prepare('\n\t\t\tSELECT user...')
#3 /www//library/XenForo/Model.php(219): Zend_Db_Adapter_Abstract->query('\n\t\t\tSELECT user...', 19, 2)
#4 /www//library/ExtendPostRating/Model.php(143): XenForo_Model->fetchAllKeyed('\n\t\t\tSELECT user...', 'user_id', 19)
#5 /www//library/ExtendPostRating/ControllerPublic/PostRating.php(58): ExtendPostRating_Model->getTopRatingsForRatingId(19, 'received', 10)
#6 /www//library/ExtendPostRating/ControllerPublic/PostRating.php(17): ExtendPostRating_ControllerPublic_PostRating->_getTopUsers(19, '')
#7 /www//library/XenForo/FrontController.php(347): ExtendPostRating_ControllerPublic_PostRating->actionIndex()
#8 /www//library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#9 /www//index.php(13): XenForo_FrontController->run()
#10 {main}
Benötigter Status
array(3) {
  ["url"] => string(43) "http://post-ratings/?rating=19"
  ["_GET"] => array(1) {
    ["rating"] => string(2) "19"
  }
  ["_POST"] => array(0) {
  }
}
 
I've re-uploaded the package, but you can just replace ExtendPostRating/model.php with the following:

Code:
<?php
class ExtendPostRating_Model extends XFCP_ExtendPostRating_Model
{
    public function countRatingsByContentUserAndRatingId($userId, $ratingId)
    {
        $xenOptions = XenForo_Application::get('options')->getOptions();

        if ($ratingId == $xenOptions['dark_postrating_like_id'])
        {
            return $this->_getDb()->fetchOne('
                SELECT COUNT(*)
                FROM xf_liked_content
                WHERE like_user_id = ?
                ', $userId);
        }
        else
        {
            return $this->_getDb()->fetchOne('
                select COUNT(*)
                FROM dark_postrating
                WHERE user_id = ? and rating = ?
                ', array($userId, $ratingId));
        }
    }

    public function countRatingsForContentUserAndRatingId($userId, $ratingId)
    {
        $xenOptions = XenForo_Application::get('options')->getOptions();

        if ($ratingId == $xenOptions['dark_postrating_like_id'])
        {
            return $this->_getDb()->fetchOne('
                SELECT COUNT(*)
                FROM xf_liked_content
                WHERE content_user_id = ?
                ', $userId);
        }
        else
        {
            return $this->_getDb()->fetchOne('
                select COUNT(*)
                FROM dark_postrating
                WHERE rated_user_id = ? and rating = ?
                ', array($userId, $ratingId));
        }
    }

    public function getRatingsByContentUserAndRatingId($userId, array $fetchOptions = array(), $ratingId)
    {
        $xenOptions = XenForo_Application::get('options')->getOptions();
        $limitOptions = $this->prepareLimitFetchOptions($fetchOptions);

        if ($ratingId == $xenOptions['dark_postrating_like_id'])
        {
            return $this->fetchAllKeyed($this->limitQueryResults('
                SELECT liked_content.like_id as id, liked_content.content_id as post_id, liked_content.like_user_id as user_id, liked_content.content_user_id as rated_user_id, ? as rating, liked_content.like_date as date,
                    user.*, liked_content.like_user_id as user_id, liked_content.content_type, liked_content.content_id, liked_content.like_user_id as rating_user_id
                FROM xf_liked_content AS liked_content
                INNER JOIN xf_user AS user ON (user.user_id = liked_content.content_user_id)
                WHERE 1 = ? and liked_content.like_user_id = ? and liked_content.content_type = \'post\'
                ORDER BY liked_content.like_date DESC
            ', $limitOptions['limit'], $limitOptions['offset']
            ), 'id', array($xenOptions['dark_postrating_like_id'], $xenOptions['dark_postrating_like_id'] > 0 ? 1 : 0, $userId));
        }
        else
        {
            return $this->fetchAllKeyed($this->limitQueryResults('
                SELECT pr.*, user.*, pr.user_id as user_id, "post" as content_type, pr.post_id as content_id, pr.user_id as rating_user_id
                FROM dark_postrating pr
                INNER JOIN xf_user AS user ON (user.user_id = pr.rated_user_id)
                WHERE pr.user_id=? and pr.rating = ?
                ORDER BY pr.date DESC
            ', $limitOptions['limit'], $limitOptions['offset']
            ), 'id', array($userId, $ratingId));
        }
    }

    public function getRatingsForContentUserAndRatingId($userId, array $fetchOptions = array(), $ratingId)
    {
        $xenOptions = XenForo_Application::get('options')->getOptions();
        $limitOptions = $this->prepareLimitFetchOptions($fetchOptions);

        if ($ratingId == $xenOptions['dark_postrating_like_id'])
        {
            return $this->fetchAllKeyed($this->limitQueryResults('
                SELECT liked_content.like_id as id, liked_content.content_id as post_id, liked_content.like_user_id as user_id, liked_content.content_user_id as rated_user_id, ? as rating, liked_content.like_date as date,
                    user.*, liked_content.like_user_id as user_id, liked_content.content_type, liked_content.content_id, liked_content.like_user_id as rating_user_id
                FROM xf_liked_content AS liked_content
                INNER JOIN xf_user AS user ON (user.user_id = liked_content.like_user_id)
                WHERE 1 = ? and liked_content.content_user_id = ? and liked_content.content_type = \'post\'
                ORDER BY liked_content.like_date DESC
            ', $limitOptions['limit'], $limitOptions['offset']
            ), 'id', array($xenOptions['dark_postrating_like_id'], $xenOptions['dark_postrating_like_id'] > 0 ? 1 : 0, $userId));
        }
        else
        {
            return $this->fetchAllKeyed($this->limitQueryResults('
                SELECT pr.*, user.*, pr.user_id as user_id, "post" as content_type, pr.post_id as content_id, pr.user_id as rating_user_id
                FROM dark_postrating pr
                INNER JOIN xf_user AS user ON (user.user_id = pr.user_id)
                WHERE pr.rated_user_id=? and pr.rating = ?
                ORDER BY pr.date DESC
            ', $limitOptions['limit'], $limitOptions['offset']
            ), 'id', array($userId, $ratingId));
        }
    }

    public function getTopRatingsForRatingId($ratingId, $type='received', $limit=10)
    {
        $xenOption = XenForo_Application::getOptions();
        if ($xenOption->dark_postrating_like_id > 0 && $xenOption->dark_postrating_like_show && $ratingId == $xenOption->dark_postrating_like_id)
        {
            if ($type == 'received')
            {
                $orderField = 'like_count';
            }
            else
            {
                $orderField = 'epr_like_given';
            }

            return $this->fetchAllKeyed('
                SELECT *
                FROM xf_user
                ORDER BY '.$orderField.' DESC
                LIMIT '.$limit
                , 'user_id');
        }
        if ($type == 'received')
        {
            $orderField = 'count_received';
        }
        else
        {
            $orderField = 'count_given';
        }
        return $this->fetchAllKeyed('
            SELECT user.*, rating.'.$orderField.', rating.rating
            FROM xf_user AS user
            LEFT JOIN dark_postrating_count AS rating ON(rating.user_id = user.user_id AND rating.rating=?)
            ORDER BY '.$orderField.' DESC
            LIMIT '.$limit
            , 'user_id', $ratingId);
    }
}

had the 'FROM xf_user AS user' as 'FROM xf_user AS USER' accidentally, which apparently worked on MySQL for Windows.
 
Getting this when trying to update:

Code:
Error Info
Zend_Db_Statement_Mysqli_Exception: Mysqli statement execute error : Duplicate column name 'epr_like_given' - library/Zend/Db/Statement/Mysqli.php:214
Generated By: The Sandman, A moment ago
Stack Trace
#0 /srv/www/theadminzone.com/public_html/library/Zend/Db/Statement.php(297): Zend_Db_Statement_Mysqli->_execute(Array)
#1 /srv/www/theadminzone.com/public_html/library/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#2 /srv/www/theadminzone.com/public_html/library/ExtendPostRating/Listener/Install.php(9): Zend_Db_Adapter_Abstract->query('ALTER TABLE xf_...')
#3 [internal function]: ExtendPostRating_Listener_Install::install(Array, Array, Object(SimpleXMLElement))
#4 /srv/www/theadminzone.com/public_html/library/XenForo/Model/AddOn.php(215): call_user_func(Array, Array, Array, Object(SimpleXMLElement))
#5 /srv/www/theadminzone.com/public_html/library/Waindigo/InstallUpgrade/Extend/XenForo/Model/AddOn.php(88): XenForo_Model_AddOn->installAddOnXml(Object(SimpleXMLElement), 'epr')
#6 /srv/www/theadminzone.com/public_html/library/ConvEss/Model/AddOn.php(24): Waindigo_InstallUpgrade_Extend_XenForo_Model_AddOn->installAddOnXml(Object(SimpleXMLElement), 'epr')
#7 /srv/www/theadminzone.com/public_html/library/XenForo/Model/AddOn.php(169): ConvEss_Model_AddOn->installAddOnXml(Object(SimpleXMLElement), 'epr')
#8 /srv/www/theadminzone.com/public_html/library/Waindigo/InstallUpgrade/Extend/XenForo/Model/AddOn.php(64): XenForo_Model_AddOn->installAddOnXmlFromFile('install/data/ad...', 'epr')
#9 /srv/www/theadminzone.com/public_html/library/XenForo/ControllerAdmin/AddOn.php(236): Waindigo_InstallUpgrade_Extend_XenForo_Model_AddOn->installAddOnXmlFromFile('/srv/www/theadm...', 'epr')
#10 /srv/www/theadminzone.com/public_html/library/Waindigo/InstallUpgrade/Extend/XenForo/ControllerAdmin/AddOn.php(165): XenForo_ControllerAdmin_AddOn->actionUpgrade()
#11 /srv/www/theadminzone.com/public_html/library/XenForo/FrontController.php(347): Waindigo_InstallUpgrade_Extend_XenForo_ControllerAdmin_AddOn->actionUpgrade()
#12 /srv/www/theadminzone.com/public_html/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#13 /srv/www/theadminzone.com/public_html/admin.php(13): XenForo_FrontController->run()
#14 {main}
Request State
array(3) {
  ["url"] => string(54) "https://theadminzone.com/admin.php?add-ons/epr/upgrade"
  ["_GET"] => array(1) {
    ["add-ons/epr/upgrade"] => string(0) ""
  }
  ["_POST"] => array(3) {
    ["server_file"] => string(65) "https://xenforo.com/community/resources/extend-post-ratings.3817/"
    ["_xfConfirm"] => string(1) "1"
    ["_xfToken"] => string(8) "********"
  }
}
 
A small suggestion...

Somehow have the li class have a name... say, whatever the actual rating is:

Screenshot_6.webp

The other suggestion, you are already aware of.
 
A small suggestion...

Somehow have the li class have a name... say, whatever the actual rating is:

View attachment 94467

The other suggestion, you are already aware of.

Yeah, I can add this in for the next release.

Getting this when trying to update:

Code:
Error Info
Zend_Db_Statement_Mysqli_Exception: Mysqli statement execute error : Duplicate column name 'epr_like_given' - library/Zend/Db/Statement/Mysqli.php:214
Generated By: The Sandman, A moment ago
Stack Trace
#0 /srv/www/theadminzone.com/public_html/library/Zend/Db/Statement.php(297): Zend_Db_Statement_Mysqli->_execute(Array)
#1 /srv/www/theadminzone.com/public_html/library/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#2 /srv/www/theadminzone.com/public_html/library/ExtendPostRating/Listener/Install.php(9): Zend_Db_Adapter_Abstract->query('ALTER TABLE xf_...')
#3 [internal function]: ExtendPostRating_Listener_Install::install(Array, Array, Object(SimpleXMLElement))
#4 /srv/www/theadminzone.com/public_html/library/XenForo/Model/AddOn.php(215): call_user_func(Array, Array, Array, Object(SimpleXMLElement))
#5 /srv/www/theadminzone.com/public_html/library/Waindigo/InstallUpgrade/Extend/XenForo/Model/AddOn.php(88): XenForo_Model_AddOn->installAddOnXml(Object(SimpleXMLElement), 'epr')
#6 /srv/www/theadminzone.com/public_html/library/ConvEss/Model/AddOn.php(24): Waindigo_InstallUpgrade_Extend_XenForo_Model_AddOn->installAddOnXml(Object(SimpleXMLElement), 'epr')
#7 /srv/www/theadminzone.com/public_html/library/XenForo/Model/AddOn.php(169): ConvEss_Model_AddOn->installAddOnXml(Object(SimpleXMLElement), 'epr')
#8 /srv/www/theadminzone.com/public_html/library/Waindigo/InstallUpgrade/Extend/XenForo/Model/AddOn.php(64): XenForo_Model_AddOn->installAddOnXmlFromFile('install/data/ad...', 'epr')
#9 /srv/www/theadminzone.com/public_html/library/XenForo/ControllerAdmin/AddOn.php(236): Waindigo_InstallUpgrade_Extend_XenForo_Model_AddOn->installAddOnXmlFromFile('/srv/www/theadm...', 'epr')
#10 /srv/www/theadminzone.com/public_html/library/Waindigo/InstallUpgrade/Extend/XenForo/ControllerAdmin/AddOn.php(165): XenForo_ControllerAdmin_AddOn->actionUpgrade()
#11 /srv/www/theadminzone.com/public_html/library/XenForo/FrontController.php(347): Waindigo_InstallUpgrade_Extend_XenForo_ControllerAdmin_AddOn->actionUpgrade()
#12 /srv/www/theadminzone.com/public_html/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#13 /srv/www/theadminzone.com/public_html/admin.php(13): XenForo_FrontController->run()
#14 {main}
Request State
array(3) {
  ["url"] => string(54) "https://theadminzone.com/admin.php?add-ons/epr/upgrade"
  ["_GET"] => array(1) {
    ["add-ons/epr/upgrade"] => string(0) ""
  }
  ["_POST"] => array(3) {
    ["server_file"] => string(65) "https://xenforo.com/community/resources/extend-post-ratings.3817/"
    ["_xfConfirm"] => string(1) "1"
    ["_xfToken"] => string(8) "********"
  }
}

I think you and Lisa were trying to install it at the same time, I was just trying to help her fix this issue. Upload and install the add-on from the attached package. It has the install function commented out so it won't try to add that table.
 

Attachments

Top Bottom