Completed
Pull Request — master (#29)
by Robbie
03:55
created
tests/UserSecurityReportTest.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -18,67 +18,67 @@
 block discarded – undo
18 18
 class UserSecurityReportTest extends SapphireTest
19 19
 {
20 20
 
21
-    protected static $fixture_file = 'UserSecurityReportTest.yml';
21
+	protected static $fixture_file = 'UserSecurityReportTest.yml';
22 22
 
23
-    protected $records;
24
-    protected $report;
23
+	protected $records;
24
+	protected $report;
25 25
 
26
-    protected static $required_extensions = [
27
-        Member::class => [
28
-            MemberReportExtension::class,
29
-        ],
30
-    ];
26
+	protected static $required_extensions = [
27
+		Member::class => [
28
+			MemberReportExtension::class,
29
+		],
30
+	];
31 31
 
32
-    protected static $illegal_extensions = [
33
-        Group::class => [
34
-            GroupSubsites::class,
35
-        ],
36
-    ];
32
+	protected static $illegal_extensions = [
33
+		Group::class => [
34
+			GroupSubsites::class,
35
+		],
36
+	];
37 37
 
38
-    /**
39
-     * Utility method for all tests to use.
40
-     *
41
-     * @return \ArrayList
42
-     * @todo pre-fill the report with fixture-defined users
43
-     */
44
-    protected function setUp()
45
-    {
46
-        parent::setUp();
47
-        $reports = Report::get_reports();
48
-        $report = $reports[UserSecurityReport::class];
49
-        $this->report = $report;
50
-        $this->records = $report->sourceRecords()->toArray();
51
-    }
38
+	/**
39
+	 * Utility method for all tests to use.
40
+	 *
41
+	 * @return \ArrayList
42
+	 * @todo pre-fill the report with fixture-defined users
43
+	 */
44
+	protected function setUp()
45
+	{
46
+		parent::setUp();
47
+		$reports = Report::get_reports();
48
+		$report = $reports[UserSecurityReport::class];
49
+		$this->report = $report;
50
+		$this->records = $report->sourceRecords()->toArray();
51
+	}
52 52
 
53
-    public function testSourceRecords()
54
-    {
55
-        $this->assertNotEmpty($this->records);
56
-    }
53
+	public function testSourceRecords()
54
+	{
55
+		$this->assertNotEmpty($this->records);
56
+	}
57 57
 
58
-    public function testGetMemberGroups()
59
-    {
60
-        //getMemberGroups(&$member) returns string
61
-        $member = $this->objFromFixture(Member::class, 'member-has-0-groups');
62
-        $groups = $member->GroupsDescription;
63
-        $this->assertEquals('Not in a Security Group', $groups);
58
+	public function testGetMemberGroups()
59
+	{
60
+		//getMemberGroups(&$member) returns string
61
+		$member = $this->objFromFixture(Member::class, 'member-has-0-groups');
62
+		$groups = $member->GroupsDescription;
63
+		$this->assertEquals('Not in a Security Group', $groups);
64 64
 
65
-        $member = $this->objFromFixture(Member::class, 'member-has-1-groups');
66
-        $groups = $member->GroupsDescription;
67
-        $this->assertEquals('Group Test 01', $groups);
68
-    }
65
+		$member = $this->objFromFixture(Member::class, 'member-has-1-groups');
66
+		$groups = $member->GroupsDescription;
67
+		$this->assertEquals('Group Test 01', $groups);
68
+	}
69 69
 
70
-    public function testGetMemberPermissions()
71
-    {
72
-        $member = $this->objFromFixture(Member::class, 'member-has-0-permissions');
73
-        $perms = $member->PermissionsDescription;
74
-        $this->assertEquals('No Permissions', $perms);
70
+	public function testGetMemberPermissions()
71
+	{
72
+		$member = $this->objFromFixture(Member::class, 'member-has-0-permissions');
73
+		$perms = $member->PermissionsDescription;
74
+		$this->assertEquals('No Permissions', $perms);
75 75
 
76
-        $member = $this->objFromFixture(Member::class, 'member-has-1-permissions');
77
-        $perms = $member->PermissionsDescription;
78
-        $this->assertEquals('Full administrative rights', $perms);
76
+		$member = $this->objFromFixture(Member::class, 'member-has-1-permissions');
77
+		$perms = $member->PermissionsDescription;
78
+		$this->assertEquals('Full administrative rights', $perms);
79 79
 
80
-        $member = $this->objFromFixture(Member::class, 'member-has-n-permissions');
81
-        $perms = $member->PermissionsDescription;
82
-        $this->assertEquals('Full administrative rights, Edit any page', $perms);
83
-    }
80
+		$member = $this->objFromFixture(Member::class, 'member-has-n-permissions');
81
+		$perms = $member->PermissionsDescription;
82
+		$this->assertEquals('Full administrative rights, Edit any page', $perms);
83
+	}
84 84
 }
Please login to merge, or discard this patch.
tests/SubsitesReportTest.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -18,66 +18,66 @@
 block discarded – undo
18 18
 class SubsitesReportTest extends SapphireTest
19 19
 {
20 20
 
21
-    protected static $fixture_file = 'SubsitesReportTest.yml';
21
+	protected static $fixture_file = 'SubsitesReportTest.yml';
22 22
 
23
-    protected $records;
23
+	protected $records;
24 24
 
25
-    protected static $required_extensions = [
26
-        Member::class => [
27
-            MemberReportExtension::class,
28
-            SubsiteMemberReportExtension::class,
29
-        ],
30
-    ];
25
+	protected static $required_extensions = [
26
+		Member::class => [
27
+			MemberReportExtension::class,
28
+			SubsiteMemberReportExtension::class,
29
+		],
30
+	];
31 31
 
32
-    protected function setUp()
33
-    {
34
-        if (!class_exists(Subsite::class)) {
35
-            // Don't break the parent:setUp() when failing to create Subsite fixtures
36
-            static::$fixture_file = null;
37
-            $this->markTestSkipped("Please install Subsites to run this test");
38
-        }
32
+	protected function setUp()
33
+	{
34
+		if (!class_exists(Subsite::class)) {
35
+			// Don't break the parent:setUp() when failing to create Subsite fixtures
36
+			static::$fixture_file = null;
37
+			$this->markTestSkipped("Please install Subsites to run this test");
38
+		}
39 39
 
40
-        parent::setUp();
40
+		parent::setUp();
41 41
 
42
-        $reports = Report::get_reports();
43
-        $report = $reports[UserSecurityReport::class];
44
-        $this->records = $report->sourceRecords()->toArray();
45
-    }
42
+		$reports = Report::get_reports();
43
+		$report = $reports[UserSecurityReport::class];
44
+		$this->records = $report->sourceRecords()->toArray();
45
+	}
46 46
 
47
-    public function testSourceRecords()
48
-    {
49
-        $this->assertNotEmpty($this->records);
50
-    }
47
+	public function testSourceRecords()
48
+	{
49
+		$this->assertNotEmpty($this->records);
50
+	}
51 51
 
52
-    public function testGetMemberGroups()
53
-    {
52
+	public function testGetMemberGroups()
53
+	{
54 54
 
55
-        // Admin
56
-        $admin = $this->objFromFixture(Member::class, 'memberadmin');
57
-        $subsites = $admin->SubsiteDescription;
58
-        $this->assertContains('TestMainSite', $subsites);
59
-        $this->assertContains('TestSubsite1', $subsites);
60
-        $this->assertContains('TestSubsite2', $subsites);
55
+		// Admin
56
+		$admin = $this->objFromFixture(Member::class, 'memberadmin');
57
+		$subsites = $admin->SubsiteDescription;
58
+		$this->assertContains('TestMainSite', $subsites);
59
+		$this->assertContains('TestSubsite1', $subsites);
60
+		$this->assertContains('TestSubsite2', $subsites);
61 61
 
62
-        // Editor
63
-        $membereditor = $this->objFromFixture(Member::class, 'membereditor');
64
-        $subsites = $membereditor->SubsiteDescription;
65
-        $this->assertContains('TestMainSite', $subsites);
66
-        $this->assertContains('TestSubsite1', $subsites);
67
-        $this->assertContains('TestSubsite2', $subsites);
62
+		// Editor
63
+		$membereditor = $this->objFromFixture(Member::class, 'membereditor');
64
+		$subsites = $membereditor->SubsiteDescription;
65
+		$this->assertContains('TestMainSite', $subsites);
66
+		$this->assertContains('TestSubsite1', $subsites);
67
+		$this->assertContains('TestSubsite2', $subsites);
68 68
 
69
-        // First User
70
-        $membersubsite1 = $this->objFromFixture(Member::class, 'membersubsite1');
71
-        $subsites = $membersubsite1->SubsiteDescription;
72
-        $this->assertNotContains('TestMainSite', $subsites);
73
-        $this->assertContains('TestSubsite1', $subsites);
74
-        $this->assertNotContains('TestSubsite2', $subsites);
69
+		// First User
70
+		$membersubsite1 = $this->objFromFixture(Member::class, 'membersubsite1');
71
+		$subsites = $membersubsite1->SubsiteDescription;
72
+		$this->assertNotContains('TestMainSite', $subsites);
73
+		$this->assertContains('TestSubsite1', $subsites);
74
+		$this->assertNotContains('TestSubsite2', $subsites);
75 75
 
76
-        // Second user
77
-        $memberallsubsites = $this->objFromFixture(Member::class, 'memberallsubsites');
78
-        $subsites = $memberallsubsites->SubsiteDescription;
79
-        $this->assertNotContains('TestMainSite', $subsites);
80
-        $this->assertContains('TestSubsite1', $subsites);
81
-        $this->assertContains('TestSubsite2', $subsites);
82
-    }
76
+		// Second user
77
+		$memberallsubsites = $this->objFromFixture(Member::class, 'memberallsubsites');
78
+		$subsites = $memberallsubsites->SubsiteDescription;
79
+		$this->assertNotContains('TestMainSite', $subsites);
80
+		$this->assertContains('TestSubsite1', $subsites);
81
+		$this->assertContains('TestSubsite2', $subsites);
82
+	}
83 83
 }
Please login to merge, or discard this patch.
src/Forms/GridFieldExportReportButton.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
      * it sources the {@link List} from $gridField->getList() instead of $gridField->getManipulatedList()
28 28
      *
29 29
      * @param GridField $gridField
30
-     * @return array
30
+     * @return string
31 31
      */
32 32
     public function generateExportFileData($gridField)
33 33
     {
Please login to merge, or discard this patch.
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -20,78 +20,78 @@
 block discarded – undo
20 20
 class GridFieldExportReportButton extends GridFieldExportButton
21 21
 {
22 22
 
23
-    /**
24
-     * Generate export fields for CSV.
25
-     *
26
-     * Replaces the definition in GridFieldExportButton, this is the same as original except
27
-     * it sources the {@link List} from $gridField->getList() instead of $gridField->getManipulatedList()
28
-     *
29
-     * @param GridField $gridField
30
-     * @return array
31
-     */
32
-    public function generateExportFileData($gridField)
33
-    {
34
-        $separator = $this->csvSeparator;
35
-        $csvColumns = ($this->exportColumns)
36
-            ? $this->exportColumns
37
-            : singleton($gridField->getModelClass())->summaryFields();
38
-        $fileData = '';
39
-        $columnData = array();
23
+	/**
24
+	 * Generate export fields for CSV.
25
+	 *
26
+	 * Replaces the definition in GridFieldExportButton, this is the same as original except
27
+	 * it sources the {@link List} from $gridField->getList() instead of $gridField->getManipulatedList()
28
+	 *
29
+	 * @param GridField $gridField
30
+	 * @return array
31
+	 */
32
+	public function generateExportFileData($gridField)
33
+	{
34
+		$separator = $this->csvSeparator;
35
+		$csvColumns = ($this->exportColumns)
36
+			? $this->exportColumns
37
+			: singleton($gridField->getModelClass())->summaryFields();
38
+		$fileData = '';
39
+		$columnData = array();
40 40
 
41
-        if ($this->csvHasHeader) {
42
-            $headers = array();
41
+		if ($this->csvHasHeader) {
42
+			$headers = array();
43 43
 
44
-            // determine the CSV headers. If a field is callable (e.g. anonymous function) then use the
45
-            // source name as the header instead
46
-            foreach ($csvColumns as $columnSource => $columnHeader) {
47
-                if (is_array($columnHeader) && array_key_exists('title', $columnHeader)) {
48
-                    $headers[] = $columnHeader['title'];
49
-                } else {
50
-                    $headers[] = (!is_string($columnHeader) && is_callable($columnHeader))
51
-                        ? $columnSource
52
-                        : $columnHeader;
53
-                }
54
-            }
44
+			// determine the CSV headers. If a field is callable (e.g. anonymous function) then use the
45
+			// source name as the header instead
46
+			foreach ($csvColumns as $columnSource => $columnHeader) {
47
+				if (is_array($columnHeader) && array_key_exists('title', $columnHeader)) {
48
+					$headers[] = $columnHeader['title'];
49
+				} else {
50
+					$headers[] = (!is_string($columnHeader) && is_callable($columnHeader))
51
+						? $columnSource
52
+						: $columnHeader;
53
+				}
54
+			}
55 55
 
56
-            $fileData .= "\"" . implode("\"{$separator}\"", array_values($headers)) . "\"";
57
-            $fileData .= "\n";
58
-        }
56
+			$fileData .= "\"" . implode("\"{$separator}\"", array_values($headers)) . "\"";
57
+			$fileData .= "\n";
58
+		}
59 59
 
60
-        // The is the only variation from the parent, using getList() instead of getManipulatedList()
61
-        $items = $gridField->getList();
60
+		// The is the only variation from the parent, using getList() instead of getManipulatedList()
61
+		$items = $gridField->getList();
62 62
 
63
-        // @todo should GridFieldComponents change behaviour based on whether others are available in the config?
64
-        foreach ($gridField->getConfig()->getComponents() as $component) {
65
-            if ($component instanceof GridFieldFilterHeader || $component instanceof GridFieldSortableHeader) {
66
-                $items = $component->getManipulatedData($gridField, $items);
67
-            }
68
-        }
63
+		// @todo should GridFieldComponents change behaviour based on whether others are available in the config?
64
+		foreach ($gridField->getConfig()->getComponents() as $component) {
65
+			if ($component instanceof GridFieldFilterHeader || $component instanceof GridFieldSortableHeader) {
66
+				$items = $component->getManipulatedData($gridField, $items);
67
+			}
68
+		}
69 69
 
70
-        foreach ($items->limit(null) as $item) {
71
-            $columnData = array();
70
+		foreach ($items->limit(null) as $item) {
71
+			$columnData = array();
72 72
 
73
-            foreach ($csvColumns as $columnSource => $columnHeader) {
74
-                if (!is_string($columnHeader) && is_callable($columnHeader)) {
75
-                    if ($item->hasMethod($columnSource)) {
76
-                        $relObj = $item->{$columnSource}();
77
-                    } else {
78
-                        $relObj = $item->relObject($columnSource);
79
-                    }
73
+			foreach ($csvColumns as $columnSource => $columnHeader) {
74
+				if (!is_string($columnHeader) && is_callable($columnHeader)) {
75
+					if ($item->hasMethod($columnSource)) {
76
+						$relObj = $item->{$columnSource}();
77
+					} else {
78
+						$relObj = $item->relObject($columnSource);
79
+					}
80 80
 
81
-                    $value = $columnHeader($relObj);
82
-                } else {
83
-                    $value = $gridField->getDataFieldValue($item, $columnSource);
84
-                }
81
+					$value = $columnHeader($relObj);
82
+				} else {
83
+					$value = $gridField->getDataFieldValue($item, $columnSource);
84
+				}
85 85
 
86
-                $value = str_replace(array("\r", "\n"), "\n", $value);
87
-                $columnData[] = '"' . str_replace('"', '\"', $value) . '"';
88
-            }
89
-            $fileData .= implode($separator, $columnData);
90
-            $fileData .= "\n";
86
+				$value = str_replace(array("\r", "\n"), "\n", $value);
87
+				$columnData[] = '"' . str_replace('"', '\"', $value) . '"';
88
+			}
89
+			$fileData .= implode($separator, $columnData);
90
+			$fileData .= "\n";
91 91
 
92
-            $item->destroy();
93
-        }
92
+			$item->destroy();
93
+		}
94 94
 
95
-        return $fileData;
96
-    }
95
+		return $fileData;
96
+	}
97 97
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
                 }
54 54
             }
55 55
 
56
-            $fileData .= "\"" . implode("\"{$separator}\"", array_values($headers)) . "\"";
56
+            $fileData .= "\"".implode("\"{$separator}\"", array_values($headers))."\"";
57 57
             $fileData .= "\n";
58 58
         }
59 59
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                 }
85 85
 
86 86
                 $value = str_replace(array("\r", "\n"), "\n", $value);
87
-                $columnData[] = '"' . str_replace('"', '\"', $value) . '"';
87
+                $columnData[] = '"'.str_replace('"', '\"', $value).'"';
88 88
             }
89 89
             $fileData .= implode($separator, $columnData);
90 90
             $fileData .= "\n";
Please login to merge, or discard this patch.
src/Forms/GridFieldPrintReportButton.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -22,59 +22,59 @@
 block discarded – undo
22 22
 class GridFieldPrintReportButton extends GridFieldPrintButton
23 23
 {
24 24
 
25
-    /**
26
-     * Export core
27
-     *
28
-     * Replaces definition in GridFieldPrintButton
29
-     * same as original except sources data from $gridField->getList() instead of $gridField->getManipulatedList()
30
-     *
31
-     * @param GridField
32
-     * @return ArrayData
33
-     */
34
-    public function generatePrintData(GridField $gridField)
35
-    {
36
-        $printColumns = $this->getPrintColumnsForGridField($gridField);
37
-        $header = null;
25
+	/**
26
+	 * Export core
27
+	 *
28
+	 * Replaces definition in GridFieldPrintButton
29
+	 * same as original except sources data from $gridField->getList() instead of $gridField->getManipulatedList()
30
+	 *
31
+	 * @param GridField
32
+	 * @return ArrayData
33
+	 */
34
+	public function generatePrintData(GridField $gridField)
35
+	{
36
+		$printColumns = $this->getPrintColumnsForGridField($gridField);
37
+		$header = null;
38 38
 
39
-        if ($this->printHasHeader) {
40
-            $header = new ArrayList();
41
-            foreach ($printColumns as $field => $label) {
42
-                $header->push(new ArrayData(array(
43
-                    "CellString" => $label,
44
-                )));
45
-            }
46
-        }
39
+		if ($this->printHasHeader) {
40
+			$header = new ArrayList();
41
+			foreach ($printColumns as $field => $label) {
42
+				$header->push(new ArrayData(array(
43
+					"CellString" => $label,
44
+				)));
45
+			}
46
+		}
47 47
 
48
-        // The is the only variation from the parent class, using getList() instead of getManipulatedList()
49
-        $items = $gridField->getList();
48
+		// The is the only variation from the parent class, using getList() instead of getManipulatedList()
49
+		$items = $gridField->getList();
50 50
 
51
-        $itemRows = new ArrayList();
51
+		$itemRows = new ArrayList();
52 52
 
53
-        foreach ($items as $item) {
54
-            $itemRow = new ArrayList();
53
+		foreach ($items as $item) {
54
+			$itemRow = new ArrayList();
55 55
 
56
-            foreach ($printColumns as $field => $label) {
57
-                $value = $gridField->getDataFieldValue($item, $field);
58
-                $itemRow->push(new ArrayData(array(
59
-                    "CellString" => $value,
60
-                )));
61
-            }
56
+			foreach ($printColumns as $field => $label) {
57
+				$value = $gridField->getDataFieldValue($item, $field);
58
+				$itemRow->push(new ArrayData(array(
59
+					"CellString" => $value,
60
+				)));
61
+			}
62 62
 
63
-            $itemRows->push(new ArrayData(array(
64
-                "ItemRow" => $itemRow
65
-            )));
63
+			$itemRows->push(new ArrayData(array(
64
+				"ItemRow" => $itemRow
65
+			)));
66 66
 
67
-            $item->destroy();
68
-        }
67
+			$item->destroy();
68
+		}
69 69
 
70
-        $ret = new ArrayData(array(
71
-            "Title" => $this->getTitle($gridField),
72
-            "Header" => $header,
73
-            "ItemRows" => $itemRows,
74
-            "Datetime" => DBDatetime::now(),
75
-            "Member" => Security::getCurrentUser(),
76
-        ));
70
+		$ret = new ArrayData(array(
71
+			"Title" => $this->getTitle($gridField),
72
+			"Header" => $header,
73
+			"ItemRows" => $itemRows,
74
+			"Datetime" => DBDatetime::now(),
75
+			"Member" => Security::getCurrentUser(),
76
+		));
77 77
 
78
-        return $ret;
79
-    }
78
+		return $ret;
79
+	}
80 80
 }
Please login to merge, or discard this patch.
src/Subsites/SubsiteSecurityReport.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@
 block discarded – undo
12 12
 class SubsiteSecurityReport extends Extension
13 13
 {
14 14
 
15
-    /**
16
-     * Columns in the report
17
-     *
18
-     * @var array
19
-     * @config
20
-     */
21
-    private static $columns = array(
22
-        'SubsiteDescription' => 'Subsites (edit permissions)',
23
-    );
15
+	/**
16
+	 * Columns in the report
17
+	 *
18
+	 * @var array
19
+	 * @config
20
+	 */
21
+	private static $columns = array(
22
+		'SubsiteDescription' => 'Subsites (edit permissions)',
23
+	);
24 24
 }
Please login to merge, or discard this patch.
src/Subsites/SubsiteMemberReportExtension.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -13,37 +13,37 @@
 block discarded – undo
13 13
 class SubsiteMemberReportExtension extends DataExtension
14 14
 {
15 15
     
16
-    /**
17
-     * Set cast of additional field
18
-     *
19
-     * @var array
20
-     * @config
21
-     */
22
-    private static $casting = array(
23
-        'SubsiteDescription' => 'Text'
24
-    );
16
+	/**
17
+	 * Set cast of additional field
18
+	 *
19
+	 * @var array
20
+	 * @config
21
+	 */
22
+	private static $casting = array(
23
+		'SubsiteDescription' => 'Text'
24
+	);
25 25
     
26
-    /**
27
-     * Default permission to filter for
28
-     *
29
-     * @var string
30
-     * @config
31
-     */
32
-    private static $subsite_description_permission = 'SITETREE_EDIT_ALL';
26
+	/**
27
+	 * Default permission to filter for
28
+	 *
29
+	 * @var string
30
+	 * @config
31
+	 */
32
+	private static $subsite_description_permission = 'SITETREE_EDIT_ALL';
33 33
     
34
-    /**
35
-     * Describes the subsites this user has SITETREE_EDIT_ALL access to
36
-     *
37
-     * @return string
38
-     */
39
-    public function getSubsiteDescription()
40
-    {
41
-        $subsites = Subsite::accessible_sites(
42
-            $this->owner->config()->get('subsite_description_permission'),
43
-            true,
44
-            "Main site",
45
-            $this->owner
46
-        );
47
-        return implode(', ', $subsites->column('Title'));
48
-    }
34
+	/**
35
+	 * Describes the subsites this user has SITETREE_EDIT_ALL access to
36
+	 *
37
+	 * @return string
38
+	 */
39
+	public function getSubsiteDescription()
40
+	{
41
+		$subsites = Subsite::accessible_sites(
42
+			$this->owner->config()->get('subsite_description_permission'),
43
+			true,
44
+			"Main site",
45
+			$this->owner
46
+		);
47
+		return implode(', ', $subsites->column('Title'));
48
+	}
49 49
 }
Please login to merge, or discard this patch.
src/UserSecurityReport.php 2 patches
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -21,125 +21,125 @@
 block discarded – undo
21 21
 class UserSecurityReport extends Report
22 22
 {
23 23
 
24
-    /**
25
-     * Columns in the report
26
-     *
27
-     * @var array
28
-     * @config
29
-     */
30
-    private static $columns = array(
31
-        'ID' => 'User ID',
32
-        'FirstName' => 'First Name',
33
-        'Surname' => 'Surname',
34
-        'Email' => 'Email',
35
-        'Created' => 'Date Created',
36
-        'GroupsDescription' => 'Groups',
37
-        'PermissionsDescription' => 'Permissions',
38
-    );
24
+	/**
25
+	 * Columns in the report
26
+	 *
27
+	 * @var array
28
+	 * @config
29
+	 */
30
+	private static $columns = array(
31
+		'ID' => 'User ID',
32
+		'FirstName' => 'First Name',
33
+		'Surname' => 'Surname',
34
+		'Email' => 'Email',
35
+		'Created' => 'Date Created',
36
+		'GroupsDescription' => 'Groups',
37
+		'PermissionsDescription' => 'Permissions',
38
+	);
39 39
     
40
-    protected $dataClass = Member::class;
40
+	protected $dataClass = Member::class;
41 41
 
42
-    /**
43
-     * Returns the report title
44
-     *
45
-     * @return string
46
-     */
47
-    public function title()
48
-    {
49
-        return _t(__CLASS__ . '.REPORTTITLE', 'Users, Groups and Permissions');
50
-    }
42
+	/**
43
+	 * Returns the report title
44
+	 *
45
+	 * @return string
46
+	 */
47
+	public function title()
48
+	{
49
+		return _t(__CLASS__ . '.REPORTTITLE', 'Users, Groups and Permissions');
50
+	}
51 51
 
52
-    /**
53
-     * Builds a report description which is the current hostname with the current date and time
54
-     *
55
-     * @return string e.g. localhost/sitename - 21/12/2112
56
-     */
57
-    public function description()
58
-    {
59
-        return str_replace(
60
-            array('http', 'https', '://'),
61
-            '',
62
-            Director::protocolAndHost() . ' - ' . date('d/m/Y H:i:s')
63
-        );
64
-    }
52
+	/**
53
+	 * Builds a report description which is the current hostname with the current date and time
54
+	 *
55
+	 * @return string e.g. localhost/sitename - 21/12/2112
56
+	 */
57
+	public function description()
58
+	{
59
+		return str_replace(
60
+			array('http', 'https', '://'),
61
+			'',
62
+			Director::protocolAndHost() . ' - ' . date('d/m/Y H:i:s')
63
+		);
64
+	}
65 65
 
66
-    /**
67
-     * Returns the column names of the report
68
-     *
69
-     * @return array
70
-     */
71
-    public function columns()
72
-    {
73
-        return self::config()->columns;
74
-    }
66
+	/**
67
+	 * Returns the column names of the report
68
+	 *
69
+	 * @return array
70
+	 */
71
+	public function columns()
72
+	{
73
+		return self::config()->columns;
74
+	}
75 75
 
76
-    /**
77
-     * Alias of columns(), to support the export to csv action
78
-     * in {@link GridFieldExportButton} generateExportFileData method.
79
-     * @return array
80
-     */
81
-    public function getColumns()
82
-    {
83
-        return $this->columns();
84
-    }
76
+	/**
77
+	 * Alias of columns(), to support the export to csv action
78
+	 * in {@link GridFieldExportButton} generateExportFileData method.
79
+	 * @return array
80
+	 */
81
+	public function getColumns()
82
+	{
83
+		return $this->columns();
84
+	}
85 85
 
86
-    /**
87
-     * @return array
88
-     */
89
-    public function summaryFields()
90
-    {
91
-        return $this->columns();
92
-    }
86
+	/**
87
+	 * @return array
88
+	 */
89
+	public function summaryFields()
90
+	{
91
+		return $this->columns();
92
+	}
93 93
 
94
-    /**
95
-     * Defines the sortable columns on the report gridfield
96
-     *
97
-     * @return array
98
-     */
99
-    public function sortColumns()
100
-    {
101
-        return array_keys($this->columns());
102
-    }
94
+	/**
95
+	 * Defines the sortable columns on the report gridfield
96
+	 *
97
+	 * @return array
98
+	 */
99
+	public function sortColumns()
100
+	{
101
+		return array_keys($this->columns());
102
+	}
103 103
 
104
-    /**
105
-     * Get the source records for the report gridfield
106
-     *
107
-     * @return DataList
108
-     */
109
-    public function sourceRecords()
110
-    {
111
-        // Get members sorted by ID
112
-        return Member::get()->sort('ID');
113
-    }
104
+	/**
105
+	 * Get the source records for the report gridfield
106
+	 *
107
+	 * @return DataList
108
+	 */
109
+	public function sourceRecords()
110
+	{
111
+		// Get members sorted by ID
112
+		return Member::get()->sort('ID');
113
+	}
114 114
 
115
-    /**
116
-     * Restrict access to this report to users with security admin access
117
-     *
118
-     * @param Member $member
119
-     * @return boolean
120
-     */
121
-    public function canView($member = null)
122
-    {
123
-        return (bool)Permission::checkMember($member, "CMS_ACCESS_SecurityAdmin");
124
-    }
115
+	/**
116
+	 * Restrict access to this report to users with security admin access
117
+	 *
118
+	 * @param Member $member
119
+	 * @return boolean
120
+	 */
121
+	public function canView($member = null)
122
+	{
123
+		return (bool)Permission::checkMember($member, "CMS_ACCESS_SecurityAdmin");
124
+	}
125 125
 
126
-    /**
127
-     * Return a field, such as a {@link GridField} that is
128
-     * used to show and manipulate data relating to this report.
129
-     *
130
-     * @return FormField subclass
131
-     */
132
-    public function getReportField()
133
-    {
134
-        /** @var GridField $gridField */
135
-        $gridField = parent::getReportField();
136
-        $gridField->setModelClass(self::class);
137
-        $gridConfig = $gridField->getConfig();
138
-        $gridConfig->removeComponentsByType([GridFieldPrintButton::class, GridFieldExportButton::class]);
139
-        $gridConfig->addComponents(
140
-            new GridFieldPrintReportButton('buttons-before-left'),
141
-            new GridFieldExportReportButton('buttons-before-left')
142
-        );
143
-        return $gridField;
144
-    }
126
+	/**
127
+	 * Return a field, such as a {@link GridField} that is
128
+	 * used to show and manipulate data relating to this report.
129
+	 *
130
+	 * @return FormField subclass
131
+	 */
132
+	public function getReportField()
133
+	{
134
+		/** @var GridField $gridField */
135
+		$gridField = parent::getReportField();
136
+		$gridField->setModelClass(self::class);
137
+		$gridConfig = $gridField->getConfig();
138
+		$gridConfig->removeComponentsByType([GridFieldPrintButton::class, GridFieldExportButton::class]);
139
+		$gridConfig->addComponents(
140
+			new GridFieldPrintReportButton('buttons-before-left'),
141
+			new GridFieldExportReportButton('buttons-before-left')
142
+		);
143
+		return $gridField;
144
+	}
145 145
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function title()
48 48
     {
49
-        return _t(__CLASS__ . '.REPORTTITLE', 'Users, Groups and Permissions');
49
+        return _t(__CLASS__.'.REPORTTITLE', 'Users, Groups and Permissions');
50 50
     }
51 51
 
52 52
     /**
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         return str_replace(
60 60
             array('http', 'https', '://'),
61 61
             '',
62
-            Director::protocolAndHost() . ' - ' . date('d/m/Y H:i:s')
62
+            Director::protocolAndHost().' - '.date('d/m/Y H:i:s')
63 63
         );
64 64
     }
65 65
 
Please login to merge, or discard this patch.
src/MemberReportExtension.php 2 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -12,84 +12,84 @@
 block discarded – undo
12 12
 class MemberReportExtension extends DataExtension
13 13
 {
14 14
     
15
-    /**
16
-     * Set cast of additional fields
17
-     *
18
-     * @var array
19
-     * @config
20
-     */
21
-    private static $casting = array(
22
-        'GroupsDescription' => 'Text',
23
-        'PermissionsDescription' => 'Text'
24
-    );
15
+	/**
16
+	 * Set cast of additional fields
17
+	 *
18
+	 * @var array
19
+	 * @config
20
+	 */
21
+	private static $casting = array(
22
+		'GroupsDescription' => 'Text',
23
+		'PermissionsDescription' => 'Text'
24
+	);
25 25
 
26
-    /**
27
-     * Builds a comma separated list of member group names for a given Member.
28
-     *
29
-     * @return string
30
-     */
31
-    public function getGroupsDescription()
32
-    {
33
-        if (class_exists(Subsite::class)) {
34
-            Subsite::disable_subsite_filter(true);
35
-        }
26
+	/**
27
+	 * Builds a comma separated list of member group names for a given Member.
28
+	 *
29
+	 * @return string
30
+	 */
31
+	public function getGroupsDescription()
32
+	{
33
+		if (class_exists(Subsite::class)) {
34
+			Subsite::disable_subsite_filter(true);
35
+		}
36 36
         
37
-        // Get the member's groups, if any
38
-        $groups = $this->owner->Groups();
39
-        if ($groups->Count()) {
40
-            // Collect the group names
41
-            $groupNames = array();
42
-            foreach ($groups as $group) {
43
-                $groupNames[] = html_entity_decode($group->getTreeTitle());
44
-            }
45
-            // return a csv string of the group names, sans-markup
46
-            $result = preg_replace("#</?[^>]>#", '', implode(', ', $groupNames));
47
-        } else {
48
-            // If no groups then return a status label
49
-            $result = _t(__CLASS__ . '.NOGROUPS', 'Not in a Security Group');
50
-        }
37
+		// Get the member's groups, if any
38
+		$groups = $this->owner->Groups();
39
+		if ($groups->Count()) {
40
+			// Collect the group names
41
+			$groupNames = array();
42
+			foreach ($groups as $group) {
43
+				$groupNames[] = html_entity_decode($group->getTreeTitle());
44
+			}
45
+			// return a csv string of the group names, sans-markup
46
+			$result = preg_replace("#</?[^>]>#", '', implode(', ', $groupNames));
47
+		} else {
48
+			// If no groups then return a status label
49
+			$result = _t(__CLASS__ . '.NOGROUPS', 'Not in a Security Group');
50
+		}
51 51
         
52
-        if (class_exists(Subsite::class)) {
53
-            Subsite::disable_subsite_filter(false);
54
-        }
55
-        return $result;
56
-    }
52
+		if (class_exists(Subsite::class)) {
53
+			Subsite::disable_subsite_filter(false);
54
+		}
55
+		return $result;
56
+	}
57 57
     
58
-    /**
59
-     * Builds a comma separated list of human-readbale permissions for a given Member.
60
-     *
61
-     * @return string
62
-     */
63
-    public function getPermissionsDescription()
64
-    {
65
-        if (class_exists(Subsite::class)) {
66
-            Subsite::disable_subsite_filter(true);
67
-        }
58
+	/**
59
+	 * Builds a comma separated list of human-readbale permissions for a given Member.
60
+	 *
61
+	 * @return string
62
+	 */
63
+	public function getPermissionsDescription()
64
+	{
65
+		if (class_exists(Subsite::class)) {
66
+			Subsite::disable_subsite_filter(true);
67
+		}
68 68
         
69
-        $permissionsUsr = Permission::permissions_for_member($this->owner->ID);
70
-        $permissionsSrc = Permission::get_codes(true);
71
-        sort($permissionsUsr);
69
+		$permissionsUsr = Permission::permissions_for_member($this->owner->ID);
70
+		$permissionsSrc = Permission::get_codes(true);
71
+		sort($permissionsUsr);
72 72
         
73
-        $permissionNames = array();
74
-        foreach ($permissionsUsr as $code) {
75
-            $code = strtoupper($code);
76
-            foreach ($permissionsSrc as $k => $v) {
77
-                if (isset($v[$code])) {
78
-                    $name = empty($v[$code]['name'])
79
-                        ? _t(__CLASS__ . '.UNKNOWN', 'Unknown')
80
-                        : $v[$code]['name'];
81
-                    $permissionNames[] = $name;
82
-                }
83
-            }
84
-        }
73
+		$permissionNames = array();
74
+		foreach ($permissionsUsr as $code) {
75
+			$code = strtoupper($code);
76
+			foreach ($permissionsSrc as $k => $v) {
77
+				if (isset($v[$code])) {
78
+					$name = empty($v[$code]['name'])
79
+						? _t(__CLASS__ . '.UNKNOWN', 'Unknown')
80
+						: $v[$code]['name'];
81
+					$permissionNames[] = $name;
82
+				}
83
+			}
84
+		}
85 85
 
86
-        $result = $permissionNames
87
-            ? implode(', ', $permissionNames)
88
-            : _t(__CLASS__ . '.NOPERMISSIONS', 'No Permissions');
86
+		$result = $permissionNames
87
+			? implode(', ', $permissionNames)
88
+			: _t(__CLASS__ . '.NOPERMISSIONS', 'No Permissions');
89 89
         
90
-        if (class_exists(Subsite::class)) {
91
-            Subsite::disable_subsite_filter(false);
92
-        }
93
-        return $result;
94
-    }
90
+		if (class_exists(Subsite::class)) {
91
+			Subsite::disable_subsite_filter(false);
92
+		}
93
+		return $result;
94
+	}
95 95
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
             $result = preg_replace("#</?[^>]>#", '', implode(', ', $groupNames));
47 47
         } else {
48 48
             // If no groups then return a status label
49
-            $result = _t(__CLASS__ . '.NOGROUPS', 'Not in a Security Group');
49
+            $result = _t(__CLASS__.'.NOGROUPS', 'Not in a Security Group');
50 50
         }
51 51
         
52 52
         if (class_exists(Subsite::class)) {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             foreach ($permissionsSrc as $k => $v) {
77 77
                 if (isset($v[$code])) {
78 78
                     $name = empty($v[$code]['name'])
79
-                        ? _t(__CLASS__ . '.UNKNOWN', 'Unknown')
79
+                        ? _t(__CLASS__.'.UNKNOWN', 'Unknown')
80 80
                         : $v[$code]['name'];
81 81
                     $permissionNames[] = $name;
82 82
                 }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
         $result = $permissionNames
87 87
             ? implode(', ', $permissionNames)
88
-            : _t(__CLASS__ . '.NOPERMISSIONS', 'No Permissions');
88
+            : _t(__CLASS__.'.NOPERMISSIONS', 'No Permissions');
89 89
         
90 90
         if (class_exists(Subsite::class)) {
91 91
             Subsite::disable_subsite_filter(false);
Please login to merge, or discard this patch.