Dotclear

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

Revision 1406, 1.9 KB checked in by JcDenis, 14 years ago (diff)

rateIt 0.9.3:

  • Fixed context errors
  • Added cut string option on widget
  • Added attribute support for rateItIf and rateItTotal
  • Removed uninstall functions
  • Removed urls edition as dcUrlHandlers work great for this
  • Changed, grouped, reordered class
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#
12# -- END LICENSE BLOCK ------------------------------------
13
14if (!defined('DC_RC_PATH')){return;}
15
16class rateItRest
17{
18     public static function vote($core,$get,$post)
19     {
20          $type = isset($post['voteType']) ? $post['voteType'] : null;
21          $id = isset($post['voteId']) ? $post['voteId'] : null;
22          $note = isset($post['voteNote']) ? $post['voteNote'] : null;
23
24          $rsp = new xmlTag();
25
26          if (!$core->blog->settings->rateit_active)
27               throw new Exception(__('Rating is disabled on this blog'));
28
29          if ($type === null || $id === null || $note === null)
30               throw new Exception(__('Rating failed because of missing informations'));
31
32          $types = new ArrayObject();
33          $types[] = 'post';
34          $types[] = 'comment';
35          $types[] = 'category';
36          $types[] = 'tag';
37          $types[] = 'gal';
38          $types[] = 'galitem';
39
40
41          # --BEHAVIOR-- addRateItType
42          $core->callBehavior('addRateItType',$types);
43
44
45          $types = (array) $types;
46
47          if (!in_array($type,$types))
48               throw new Exception(__('Rating failed because of a wrong type of entry'));
49
50          $rateIt = new rateIt($core);
51          $voted = $rateIt->voted($type,$id);
52          if ($voted)
53               throw new Exception(__('You have already voted'));
54          else
55               $rateIt->set($type,$id,$note);
56
57          $rs = $rateIt->get($type,$id);
58          $xv = new xmlTag('item');
59          $xv->type = $type;
60          $xv->id = $id;
61          $xv->ip = $rateIt->ip;
62          $xv->sum = $rs->sum;
63          $xv->max = $rs->max;
64          $xv->min = $rs->min;
65          $xv->total = $rs->total;
66          $xv->note = $rs->note;
67          $xv->quotient = $rs->quotient;
68          $rsp->insertNode($xv);
69
70          return $rsp;
71     }
72}
73?>
Note: See TracBrowser for help on using the repository browser.

Sites map