Follow ReviewsForJoomla on Twitter
 
September 08, 2010, 08:39:26 PM

Login with username, password and session length

FORUM POSTING GUIDELINES - Please read and follow them.

Pages: [1]
  Print  
Author Topic: Don't Review Yourself!  (Read 126 times)
mike david
Newbie
*
Offline Offline

Posts: 9


« on: July 27, 2010, 04:48:56 PM »

Hi!

I'm using jomsocial with jreviewsEverywhere and I want to let members review any listings, even their own listings but NOT themselves(their own profile).

Is there an easy line of code I can slip in somewhere?  I'm really hoping this is an easy fix.  =\


thanks again!
mike
Logged
Alejandro
Global Moderator
Administrator
Hero Member
*
Online Online

Posts: 17021


« Reply #1 on: July 27, 2010, 07:18:03 PM »

You can do this by hacking the listing model to make JReviews believe that listings are never owned by the current user. In /jreviews/models/everywhere/everywhere_com_content, function getListingOwner. Change:

Code:
                Listing.created_by AS user_id, User.name, User.email

to:

Code:
                1 AS user_id, User.name, User.email
Logged

Leave a testimonial for JReviews
Reviews Ahoy! - Submit your jReviews site here.
mike david
Newbie
*
Offline Offline

Posts: 9


« Reply #2 on: July 28, 2010, 05:45:25 PM »

i had a feeling it was a quick one-liner!

i just tried it out and implemented it. it makes sense, but for some reason it's not working =\

Code:
    function getListingOwner($result_id)
    {
        $query = "
            SELECT
                1 AS user_id, User.name, User.email
            FROM
                #__content AS Listing
            LEFT JOIN
                #__users AS User ON Listing.created_by = User.id               
            WHERE
                Listing.id = " . (int) ($result_id);
        $this->_db->setQuery($query);
        appLogMessage($this->_db->getErrorMsg(),'owner_listing');
        return current($this->_db->loadAssocList());       
    }



in the configuration>general settings

multi user reviews per listing >Yes
disable IP address check for multiple reviews >yes
stop users from reviewing their own listings  >yes


i then cleared all the cache and registries.

i'm allowed not allowed to review myself(which is good), but then again i'm not allowed to review my own listings now either.
Logged
Alejandro
Global Moderator
Administrator
Hero Member
*
Online Online

Posts: 17021


« Reply #3 on: July 28, 2010, 08:04:27 PM »

In theory that should work Smiley Maybe try adding single quotes around the 1:

                '1' AS user_id, User.name, User.email

or if that fails change it to this:

Code:
    function getListingOwner($result_id)
    {
        return array(
           'user_id'=>1,
           'name'=>'',
           'email'=>''       
       )
    }

I am really not sure that the approach of changing this function is the best solution, but it's definitely the quickest way to do it without having to change too many things.
Logged

Leave a testimonial for JReviews
Reviews Ahoy! - Submit your jReviews site here.
mike david
Newbie
*
Offline Offline

Posts: 9


« Reply #4 on: July 28, 2010, 09:56:40 PM »

Hmm, I just tried the singlequotes and it didn't change anything.  I next tried replacing the whole function with the one you cited, and it said there was a syntax error.  I added a   ;   after the closed parenthesis and the error disappeared, however it gave the same result as the other 2 times.  -not revealing the "create review" button.

Those codes really seem logically sound to me too.  do you think the problem could be in the reviews.thtml or even listings/detail.thtml template and hiding it regardless?  

i'm sorry, i'm really not good with coding and how it all works =\
« Last Edit: July 28, 2010, 11:27:11 PM by mike david » Logged
Kristian
Global Moderator
Hero Member
*
Offline Offline

Posts: 2796



WWW
« Reply #5 on: July 29, 2010, 04:11:41 PM »

I think this doesn't work because getListingOwner() is used only when saving the review, it can't prevent the user from writing it.
A different solution is needed.
Logged
Alejandro
Global Moderator
Administrator
Hero Member
*
Online Online

Posts: 17021


« Reply #6 on: July 30, 2010, 09:27:31 PM »

Sorry, Kristian is right. You can try editing the /listings/detail.thtml file and change this line:

Code:
$userReviewSubmit = (!$editorReviewSubmitMultiple && !$editorReviewSubmitSingle) && $Access->canAddReview($listing['User']['user_id']) && (!$Access->isJReviewsEditor($User->id) || $this->Config->author_review < 2);                   

to:

Code:
$userReviewSubmit = (!$editorReviewSubmitMultiple && !$editorReviewSubmitSingle) && $Access->canAddReview() && (!$Access->isJReviewsEditor($User->id) || $this->Config->author_review < 2);                   
Logged

Leave a testimonial for JReviews
Reviews Ahoy! - Submit your jReviews site here.
mike david
Newbie
*
Offline Offline

Posts: 9


« Reply #7 on: July 31, 2010, 01:26:12 PM »

Thanks Alejandro and Kristian!!

Worked beautifully!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!