Issues (88)

src/model/ContactNote.php (8 issues)

1
<?php
2
3
namespace SilverCommerce\ContactAdmin\Model;
4
5
use SilverStripe\ORM\DataObject;
6
use SilverStripe\ORM\FieldType\DBHTMLText as HTMLText;
7
use SilverStripe\Security\Member;
8
use SilverStripe\Security\Permission;
9
use SilverStripe\Forms\RequiredFields;
10
use SilverStripe\Forms\GridField\GridField;
11
use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor;
12
use SilverStripe\TagField\TagField;
13
use SilverCommerce\ContactAdmin\Model\ContactTag;
14
15
/**
16
 * Notes on a particular contact
17
 *
18
 * @property string Content
19
 * @property bool   Flag
20
 *
21
 * @method Contact Contact
22
 *
23
 * @author  ilateral
24
 * @package Contacts
25
 */
26
class ContactNote extends DataObject
27
{
28
    private static $table_name = 'ContactNote';
0 ignored issues
show
The private property $table_name is not used, and could be removed.
Loading history...
29
30
    private static $db = [
0 ignored issues
show
The private property $db is not used, and could be removed.
Loading history...
31
        "Content" => "Text",
32
        "Flag" => "Boolean"
33
    ];
34
    
35
    private static $has_one = [
0 ignored issues
show
The private property $has_one is not used, and could be removed.
Loading history...
36
        "Contact" => Contact::class
37
    ];
38
    
39
    private static $casting = [
0 ignored issues
show
The private property $casting is not used, and could be removed.
Loading history...
40
        'FlaggedNice' => 'Boolean'
41
    ];
42
    
43
    private static $summary_fields = [
0 ignored issues
show
The private property $summary_fields is not used, and could be removed.
Loading history...
44
        "FlaggedNice" => "Flagged",
45
        "Content.Summary" => "Content",
46
        "Created" => "Created"
47
    ];
48
    
49
    /**
50
     * Has this note been flagged? If so, return a HTML Object that
51
     * can be loaded into a gridfield.
52
     *
53
     * @return DBHTMLText
0 ignored issues
show
The type SilverCommerce\ContactAdmin\Model\DBHTMLText was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
54
     */
55
    public function getFlaggedNice()
56
    {
57
        $obj = HTMLText::create();
58
        $obj->setValue(($this->Flag)? '<span class="red">&#10033;</span>' : '');
59
        
60
        $this->extend("updateFlaggedNice", $obj);
61
        
62
        return $obj;
63
    }
64
65
    public function canView($member = null)
66
    {
67
        $extended = $this->extendedCan(__FUNCTION__, $member);
68
69
        if ($extended !== null) {
70
            return $extended;
71
        }
72
73
        return $this->Contact()->canView($member);
74
    }
75
76
    public function canCreate($member = null, $context = [])
77
    {
78
        $extended = $this->extendedCan(__FUNCTION__, $member, $context);
79
80
        if ($extended !== null) {
81
            return $extended;
82
        }
83
84
        if (!$member) {
85
            $member = Member::currentUser();
0 ignored issues
show
Deprecated Code introduced by
The function SilverStripe\Security\Member::currentUser() has been deprecated: 5.0.0 use Security::getCurrentUser() ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

85
            $member = /** @scrutinizer ignore-deprecated */ Member::currentUser();

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
86
        }
87
88
        if ($member && Permission::checkMember($member->ID, "CONTACTS_MANAGE")) {
89
            return true;
90
        }
91
92
        return false;
93
    }
94
95
    public function canEdit($member = null)
96
    {
97
        $extended = $this->extendedCan(__FUNCTION__, $member);
98
99
        if ($extended !== null) {
100
            return $extended;
101
        }
102
103
        return $this->Contact()->canEdit($member);
104
    }
105
106
    public function canDelete($member = null, $context = [])
0 ignored issues
show
The parameter $context is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

106
    public function canDelete($member = null, /** @scrutinizer ignore-unused */ $context = [])

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
107
    {
108
        $extended = $this->extendedCan(__FUNCTION__, $member);
109
110
        if ($extended !== null) {
111
            return $extended;
112
        }
113
114
        return $this->Contact()->canDelete($member);
115
    }
116
}
117