We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5811
    • 1,717 Posts
    Hi Marc

    I checked with firebug that the doVote function called by ajax returns a null string.

    I am a bit sceptic that this is due to the version of MySql, because all the sql statements used by this snippet are very simple and common

    So, I suggest you that under PhpMyAdmin you delete your atrating_test table and reload your page.

    If the table doesn’t exist, the table will be created first with a first row containing your AnythingRating definition.
    Try it and let me know the results
      • 17883
      • 1,039 Posts
      Hi coroico,

      I tried that several times. The table always is properly created, but rating isnt possible on that server. I also reinstalled the snippet and files several times, but no luck. On the other server it went smoothly out of the box... So I called the hoster and Im moving on a MySQL5 server this night. Will see if this does the trick.

      Okay, I just took another look and compared the two tables on server A (MySQL 4.0) and server B (MySQL 5.0):

      A:

      `modx_atRating_test` (`id`, `rating_id`, `rating`, `lastIP`, `nbIP`, `voteDate`) VALUES
      (1, 'german:all:0', 5, '@FILE:assets/snippets/anythingRating/templates/anythingRating.tpl.html', 1000000, '361231000000');


      B:

      INSERT INTO `modx_atRating_test` (`id`, `rating_id`, `rating`, `lastIP`, `nbIP`, `voteDate`) VALUES
      (1, 'german:all:0', 5, '@FILE:assets/snippets/anythingRating/templates/anythingRating.tpl.html', 1000000, '2036-12-31 00:00:00'),


      The two tables differ in the column voteDate! Obviously MySQL 4.0 isn’t capable of the Attributes you create with your snippet:

      A:

      Feld      Typ  	                Attribute  	 Null  	 Standard  	Extra  	Aktion
      voteDate  timestamp(10)  	  	          Nein  


      B:
      Feld    Typ             Attribute                   Null               Standard  	                      Extra  	Aktion
      voteDate  timestamp   ON UPDATE CURRENT_TIMESTAMP  	Nein  	CURRENT_TIMESTAMP  


      I think this could be the reason?!

      I tried to change the Attribute on A, but there is no ON UPDATE CURRENT_TIMESTAMP and setting of Standard by hand also doesn`t work....

      Thanks for your help, I will report tomorrow!
        • 17883
        • 1,039 Posts
        Moved to MySQL5 and everything works.

        In MySQL 4.1, TIMESTAMP display format changes to be the same as DATETIME, that is, as a string in ’YYYY-MM-DD HH:MM:SS’ format rather than as a number in YYYYMMDDHHMMSS format.

        Could be a reason.
          • 25551 ☆ A M B ☆
          • 1,231 Posts
          HI, I was hoping to allow a single user to vote only. Is it possible to change the canvote to user names rather than groups? I had a quick look through the documents and I see this code.

              // allowed to vote ?
              if ($this->config['canVote'] == 'all') $this->allowedToVote = true;
              else {
                  $webGroup = explode(',',$this->config['canVote']);
                  $this->allowedToVote = $modx->isMemberOfWebGroup($webGroup);
              }


          Is this what I need to change to canvote by username rather than group?

          Thanks
            Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
            AugmentBLU - MODX Partner

            BLUcart - MODX Revolution E-Commerce & Shopping Cart
            • 5811
            • 1,717 Posts
            Yes. try the following code:
                // allowed to vote ?
                if ($this->config['canVote'] == 'all') $this->allowedToVote = true;
                else {
                    $webUserName = explode(',',$this->config['canVote']);  // get the current user name
                    $this->allowedToVote = ($webUserName == $modx->getLoginUserName()); // test of user name
                }
            with &canVote=`userNameAllowedToVote`

            Not tested, but should be run.
              • 25551 ☆ A M B ☆
              • 1,231 Posts
              I tried the &canVote param with a users id, [*createdby*] and I tried the username but they didn’t work... using `all` worked for everyone though still.
                Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
                AugmentBLU - MODX Partner

                BLUcart - MODX Revolution E-Commerce & Shopping Cart
                • 23515
                • 40 Posts
                OK, trying to get it to check unique votes against webuser rather than IP, thought it was easy enough, was wrong.

                Replaced all the mentions of $_SERVER[’REMOTE_ADDR’] with $modx->getLoginUserName() in anythingRating.class.inc.php, but nothing gets written to the database in the lastIP field now.

                The field is a varchar, and the $modx->getLoginUserName() seems to print out right, so not sure what’s going wrong.

                Any ideas?
                  • 16194
                  • 103 Posts
                  Is it possible to switch from StarRating to this and put the old votes in?
                    Impossible is nothing - with ModX
                    • 23515
                    • 40 Posts
                    Still having issues with web users, it appears that the anythingRating.class.inc.php file can’t use any of the modx api functions, I don’t know enough about the modx core to know why, or if there is anyway I can turn it on, anyone know more?
                      • 25551 ☆ A M B ☆
                      • 1,231 Posts
                      Hello, I want to use this great snippet for several different features on a website but I have one question.  Can I put the ratings in to a separate database?  The reason I would like a separate database is because this could potentially make the modx database become very  large in terms of listings of tables.

                      I want to allow each user their own ratings area which works great but this is creating a whole table per user. 

                      modx_atRating_test
                      modx_atRating_test1
                      modx_atRating_test2
                      modx_atRating_test3
                      modx_atRating_test4

                      etc....

                      This will eventually make the modx database a bit annoying to scroll through so I thought that it would be good to have the ratings in a different database, on the same server.  Is this possible with little hacking?  Thanks!
                        Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
                        AugmentBLU - MODX Partner

                        BLUcart - MODX Revolution E-Commerce & Shopping Cart