root/trunk/actions/friends/karma.action.php

Revision 1, 2.2 KB (checked in by anonymous, 7 years ago)

initial import

Line 
1<?php
2/****************************************************** Open .node ***
3 * Description:   
4 * Status:        Stable.
5 * Author:        Alexandre Dath <alexandre@dotnode.com>
6 * $Id$
7 *
8 * Copyright (C) 2005 Alexandre Dath <alexandre@dotnode.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ******************** http://opensource.ikse.net/projects/dotnode ***/
24
25
26$id_friend = $url_id;
27
28switch($token[3])
29{
30case 'fun':
31case 'cool':
32case 'sexy':
33    if($token[4] >= -1 && $token[4]<=3)
34        $karma_value = $token[4];
35case 'fan':
36    if($token[4] == 0 || $token[4] == 1)
37                $karma_value = $token[4];
38case 'level':
39case 'type':
40    $karma_type = $token[3];
41    break;
42default:
43    error_log("Erreur de token[3]");
44    exit();
45}
46
47if($karma_type == 'level' || $karma_type == 'type')
48    $karma_value = $token[4];
49
50if(in_array($id_friend, $_SESSION['my_friends_id']))
51{
52    error_log("$karma_type, $karma_value, $id_friend");
53    $res = $db->query('UPDATE relation SET !=? WHERE id_friend=? AND id=?', array($karma_type, $karma_value, $id_friend, $_SESSION['my_id']));
54    if(DB::isError($res))
55        error_log($res->getUserInfo());
56    else
57    {
58        switch($karma_type)
59        {
60        case 'fan':
61            $karma['nb_fans'] = $db->getOne('SELECT SUM(fan) FROM relation WHERE id_friend=?', array($id_friend));
62            break;
63        case 'fun':
64        case 'cool':
65        case 'sexy':
66            $karma[$karma_type] = get_karma($id_friend, $karma_type);
67            break;
68        }
69        if($karma)
70        {
71            $kres = $db->autoExecute('cache_user', $karma, DB_AUTOQUERY_UPDATE, "id='$id_friend'");
72            if(DB::isError($kres))
73                error_log($kres->getUserInfo());
74        }
75
76    }
77
78
79}
80
81?>
Note: See TracBrowser for help on using the browser.