-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReputation.php
More file actions
64 lines (58 loc) · 1.35 KB
/
Reputation.php
File metadata and controls
64 lines (58 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* @package framework
* @copyright Copyright (c) 2005-2020 The Regents of the University of California.
* @license http://opensource.org/licenses/MIT MIT
*/
namespace Hubzero\User;
use Hubzero\Database\Relational;
use Session;
/**
* Reputation database model
*
* @uses \Hubzero\Database\Relational
*/
class Reputation extends Relational
{
/**
* The table to which the class pertains
*
* @var string
*/
protected $table = '#__user_reputation';
/**
* Increments user spam count, both globally and in current session
*
* @return bool
*/
public function incrementSpamCount()
{
// Save global spam count
$current = $this->get('spam_count', 0);
$this->set('spam_count', ($current+1));
$this->set('user_id', \User::get('id'));
$this->save();
// Also increment session spam count
$current = Session::get('spam_count', 0);
Session::set('spam_count', ($current+1));
}
/**
* Checks to see if user is jailed
*
* @return bool
*/
public function isJailed()
{
if ($this->get('user_id', false))
{
$params = Plugin::params('system', 'spamjail');
$sessionCount = $params->get('session_count', 5);
$lifetimeCount = $params->get('user_count', 10);
if (Session::get('spam_count', 0) > $sessionCount || $this->get('spam_count', 0) > $lifetimeCount)
{
return true;
}
}
return false;
}
}