/** * Add new feedback * * @param int $id Violation id * @param int $user * @param int $value * * @return bool|int */ function add($id, $user, $value) { if ($this->create_simple([$id, $user, $value])) { $feedback_sum = $this->db()->qfs("SELECT SUM(`value`)\n\t\t\t\tFROM `{$this->table}`\n\t\t\t\tWHERE `id` = {$id}"); if ($feedback_sum < 0 && $feedback_sum % 5 == 0) { Violations::instance()->to_moderation($id); } return true; } return false; }
<?php /** * @package Moderation * @category modules * @author Nazar Mokrynskyi <*****@*****.**> * @copyright Copyright (c) 2014, Nazar Mokrynskyi * @license MIT License, see license.txt */ namespace cs\modules\Precincts; use cs\Config, cs\Index, cs\User; $Index = Index::instance(); if (!isset($Index->route_ids[0])) { error_code(400); return; } $module_properties = Config::instance()->module('Moderation'); $User = User::instance(); $Violations = Violations::instance(); $user_id = (int) $Index->route_ids[0]; if ($user_id == User::ROOT_ID || in_array($module_properties->moderators_group ?: User::ADMIN_GROUP_ID, $User->get_groups($user_id))) { return; } foreach ($Violations->get_new_of_user($user_id) as $violation) { $Violations->decline($violation); } unset($violation); $User->set('status', User::STATUS_INACTIVE, $user_id);
/** * @package Elections * @category modules * @author Nazar Mokrynskyi <*****@*****.**> * @copyright Copyright (c) 2014, Nazar Mokrynskyi * @license MIT License, see license.txt */ namespace cs\modules\Precincts; use h, cs\Core, cs\Index, cs\Language, cs\Page, cs\User; $Index = Index::instance(); $Index->title_auto = false; $L = Language::instance(); $Page = Page::instance(); if (isset($Index->route_path[0], $Index->route_ids[1]) && $Index->route_path[0] == 'violation') { $violation = Violations::instance()->get($Index->route_ids[1]); if ($violation['images']) { $Page->replace('/<meta content="[^"]*share.png" property="og:image">/Uims', ''); $Page->replace('/<link href="[^"]*share.png" rel="image_src">/Uims', ''); $Page->link(['rel' => 'image_src', 'href' => $violation['images'][0]]); foreach ($violation['images'] as $image) { $Page->og('image', $image); $Page->og('image:secure_url', $image); } } if ($violation['text']) { $Page->Description = description($violation['text']); } } $Page->Header .= h::{'button.cs-elections-add-violation'}(h::{'i.uk-icon-plus'}() . " {$L->add_violation}") . h::{'button.cs-elections-last-violations'}(); $Page->js("window.disqus_shortname = '" . Core::instance()->disqus_shortname . "';", 'code');