Completed
Push — trunk ( d06df9...f48ee3 )
by SuperNova.WS
11:23
created

PageAjaxIgnore   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 46
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A unIgnorePlayer() 0 10 1
A loadParams() 0 2 1
A ignorePlayer() 0 10 1
1
<?php
2
/**
3
 * Created by Gorlum 14.08.2019 22:41
4
 */
5
6
namespace Pages;
7
8
use SN;
9
10
class PageAjaxIgnore extends PageAjax {
11
  /**
12
   * List of allowed actions for this page
13
   *
14
   * @var array[] $allowedActions [(string)action] => true
15
   */
16
  protected $allowedActions = [
17
    'ignorePlayer'   => true,
18
    'unIgnorePlayer' => true,
19
  ];
20
21
  protected $subjectPlayerId = 0;
22
23
  /**
24
   * Loading page data from page params
25
   */
26
  public function loadParams() {
27
    $this->subjectPlayerId = sys_get_param_id('subjectId', 0);
28
  }
29
30
  // Page Actions ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31
  public function ignorePlayer() {
32
    global $user;
33
34
    SN::$gc->ignores->ignore($user['id'], $this->subjectPlayerId);
35
36
    return [
37
      'player' => [
38
        'id' => $user['id'],
39
        'ignores' => [
40
          $this->subjectPlayerId => true,
41
        ],
42
      ],
43
    ];
44
  }
45
46
  public function unIgnorePlayer() {
47
    global $user;
48
49
    SN::$gc->ignores->unIgnore($user['id'], $this->subjectPlayerId);
50
51
    return [
52
      'player' => [
53
        'id' => $user['id'],
54
        'ignores' => [
55
          $this->subjectPlayerId => false,
56
        ],
57
      ],
58
    ];
59
  }
60
61
}
62