@@ 38-72 (lines=35) @@ | ||
35 | $GLOBALS['xoopsLogger']->activated = false; |
|
36 | ||
37 | $wall = new Smallworld\WallUpdates(); |
|
38 | if ($GLOBALS['xoopsUser'] && ($GLOBALS['xoopsUser'] instanceof \XoopsUser)) { |
|
39 | if (Request::hasVar('id', 'POST')) { |
|
40 | $id = Request::getInt('id', 0, 'POST'); |
|
41 | $type = $GLOBALS['xoopsDB']->escape($_POST['type']); |
|
42 | $type2 = $GLOBALS['xoopsDB']->escape($_POST['type2']); |
|
43 | $owner = $GLOBALS['xoopsDB']->escape($_POST['owner']); |
|
44 | $userid = $GLOBALS['xoopsUser']->getVar('uid'); |
|
45 | $hasvoted = $wall->hasVoted($userid, $type, $type2, $id); |
|
46 | if ('msg' === $type) { |
|
47 | if ($hasvoted > 0) { |
|
48 | echo "<script type='text/javascript'>"; |
|
49 | echo "alert('" . _SMALLWORLD_JS_ALREADYVOTED . "');"; |
|
50 | echo '</script>'; |
|
51 | } else { |
|
52 | $sql = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('smallworld_vote') . " (vote_id,msg_id,com_id,user_id,owner,up,down) VALUES (null, '" . $id . "', '0', '" . $userid . "', '" . $owner . "', '0', '1')"; |
|
53 | $result = $GLOBALS['xoopsDB']->queryF($sql); |
|
54 | } |
|
55 | $newvote = $wall->countVotes($type, 'down', $id); |
|
56 | } |
|
57 | ||
58 | if ('com' === $type) { |
|
59 | if ($hasvoted > 0) { |
|
60 | echo "<script type='text/javascript'>alert('" . _SMALLWORLD_JS_ALREADYVOTED . "');</script>"; |
|
61 | } else { |
|
62 | $sql = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('smallworld_vote') . " (vote_id,msg_id,com_id,user_id,owner,up,down) VALUES (null, '" . $id . "', '" . $type2 . "', '" . $userid . "', '" . $owner . "', '0', '1')"; |
|
63 | $result = $GLOBALS['xoopsDB']->queryF($sql); |
|
64 | } |
|
65 | $newvote = $wall->countVotesCom($type, 'down', $type2, $id); |
|
66 | } |
|
67 | } |
|
68 | $link = '<span id ="smallworld_votenum">' . $newvote . '</span> <a href="javascript:void(0)" name="down" class="smallworld_stcomment_vote"'; |
|
69 | $link .= ' id="' . $id . '" type="' . $type . '" owner="' . $owner . '" type2="' . $type2 . '">'; |
|
70 | $link .= '<img class="smallworld_voteimg" src = "assets/images/dislike.png" ></a>'; |
|
71 | echo $link; |
|
72 | } |
|
73 |
@@ 38-73 (lines=36) @@ | ||
35 | $GLOBALS['xoopsLogger']->activated = false; |
|
36 | ||
37 | $wall = new Smallworld\WallUpdates(); |
|
38 | if ($GLOBALS['xoopsUser'] && ($GLOBALS['xoopsUser'] instanceof \XoopsUser)) { |
|
39 | if (Request::hasVar('id', 'POST')) { |
|
40 | $id = Request::getInt('id', 0, 'POST'); |
|
41 | $type = $GLOBALS['xoopsDB']->escape($_POST['type']); |
|
42 | $type2 = $GLOBALS['xoopsDB']->escape($_POST['type2']); |
|
43 | $owner = $GLOBALS['xoopsDB']->escape($_POST['owner']); |
|
44 | $userid = $GLOBALS['xoopsUser']->getVar('uid'); |
|
45 | $hasvoted = $wall->hasVoted($userid, $type, $type2, $id); |
|
46 | if ('msg' === $type) { |
|
47 | if ($hasvoted > 0) { |
|
48 | echo "<script type='text/javascript'>"; |
|
49 | echo "alert('" . _SMALLWORLD_JS_ALREADYVOTED . "');"; |
|
50 | echo '</script>'; |
|
51 | } else { |
|
52 | $sql = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('smallworld_vote') . " (vote_id,msg_id,com_id,user_id,owner,up,down) VALUES (null, '" . $id . "', '0', '" . $userid . "', '" . $owner . "', '1', '0')"; |
|
53 | $result = $GLOBALS['xoopsDB']->queryF($sql); |
|
54 | } |
|
55 | $newvote = $wall->countVotes($type, 'up', $id); |
|
56 | } |
|
57 | ||
58 | if ('com' === $type) { |
|
59 | if ($hasvoted > 0) { |
|
60 | echo "<script type='text/javascript'>alert('" . _SMALLWORLD_JS_ALREADYVOTED . "');</script>"; |
|
61 | } else { |
|
62 | $sql = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('smallworld_vote') . " (vote_id,msg_id,com_id,user_id,owner,up,down) VALUES (null, '" . $id . "', '" . $type2 . "', '" . $userid . "', '" . $owner . "', '1', '0')"; |
|
63 | $result = $GLOBALS['xoopsDB']->queryF($sql); |
|
64 | } |
|
65 | $newvote = $wall->countVotesCom($type, 'up', $type2, $id); |
|
66 | } |
|
67 | } |
|
68 | ||
69 | $link = '<span id ="smallworld_votenum">' . $newvote . '</span> <a href="javascript:void(0)" name="up" class="smallworld_stcomment_vote"'; |
|
70 | $link .= ' id="' . $id . '" type="' . $type . '" owner="' . $owner . '" type2="' . $type2 . '">'; |
|
71 | $link .= '<img class="smallworld_voteimg" src = "assets/images/like.png" ></a>'; |
|
72 | echo $link; |
|
73 | } |
|
74 |