CreatorOnlyCanEditExtension::canEdit()   A
last analyzed

Complexity

Conditions 4
Paths 6

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 12
rs 9.2
cc 4
eloc 6
nc 6
nop 1
1
<?php
2
3
class CreatorOnlyCanEditExtension extends Extension
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    /*
6
    Only allow editing when the current user is the same as the creator for each of cycling route, cycling exploration and cycling short
7
    */
8
    public function canEdit($member = null)
0 ignored issues
show
Unused Code introduced by
The parameter $member is not used and could be removed.

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

Loading history...
9
    {
10
        //return in_array($this->owner->ClassName, array('RideFolder','Ride','CyclingShort','CyclingRoute','CyclingExploration'));
11
        $caneditasowner = true;
12
        if (in_array($this->owner->ClassName, array('CyclingShort', 'CyclingRoute', 'CyclingExploration'))) {
13
            if ($this->owner->CreatorID != Member::currentUserID()) {
14
                $caneditasowner = false;
15
            }
16
        }
17
18
        return (Permission::check('ADMIN')) || $caneditasowner;
19
    }
20
}
21