Dotclear

source: plugins/rateIt/inc/class.rateit.rest.php @ 1865

Revision 1865, 1.9 KB checked in by JcDenis, 13 years ago (diff)

rateIt 0.9.7:

  • Added entryFirstImage to wigdet
  • Fixed bug with date sorting on widget
  • Fixed bug with plugin ativityReport
  • Removed about tabs and fixed typo
Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3# This file is part of rateIt, a plugin for Dotclear 2.
4#
5# Copyright (c) 2009 JC Denis and contributors
6# jcdenis@gdwd.com
7#
8# Licensed under the GPL version 2.0 license.
9# A copy of this license is available in LICENSE file or at
10# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11# -- END LICENSE BLOCK ------------------------------------
12
13if (!defined('DC_RC_PATH')){return;}
14
15class rateItRest
16{
17     public static function vote($core,$get,$post)
18     {
19          $type = isset($post['voteType']) ? $post['voteType'] : null;
20          $id = isset($post['voteId']) ? $post['voteId'] : null;
21          $note = isset($post['voteNote']) ? $post['voteNote'] : null;
22
23          $rsp = new xmlTag();
24
25          if (!$core->blog->settings->rateit_active)
26               throw new Exception(__('Rating is disabled on this blog'));
27
28          if ($type === null || $id === null || $note === null)
29               throw new Exception(__('Rating failed because of missing informations'));
30
31          $types = new ArrayObject();
32          $types[] = 'post';
33          $types[] = 'comment';
34          $types[] = 'category';
35          $types[] = 'tag';
36          $types[] = 'gal';
37          $types[] = 'galitem';
38
39
40          # --BEHAVIOR-- addRateItType
41          $core->callBehavior('addRateItType',$types);
42
43
44          $types = (array) $types;
45
46          if (!in_array($type,$types))
47               throw new Exception(__('Rating failed because of a wrong type of entry'));
48
49          $rateIt = new rateIt($core);
50          $voted = $rateIt->voted($type,$id);
51          if ($voted)
52               throw new Exception(__('You have already voted'));
53          else
54               $rateIt->set($type,$id,$note);
55
56          $rs = $rateIt->get($type,$id);
57          $xv = new xmlTag('item');
58          $xv->type = $type;
59          $xv->id = $id;
60          $xv->ip = $rateIt->ip;
61          $xv->sum = $rs->sum;
62          $xv->max = $rs->max;
63          $xv->min = $rs->min;
64          $xv->total = $rs->total;
65          $xv->note = $rs->note;
66          $xv->quotient = $rs->quotient;
67          $rsp->insertNode($xv);
68
69          return $rsp;
70     }
71}
72?>
Note: See TracBrowser for help on using the repository browser.

Sites map