sunnysideup /
silverstripe-membersonlypages
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 2 | |||
| 3 | class MembersOnlyPage extends Page |
||
|
0 ignored issues
–
show
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 | private static $add_action = 'Members Only Page'; |
||
|
0 ignored issues
–
show
|
|||
| 6 | |||
| 7 | private static $icon = 'mysite/images/treeicons/MembersOnlyPage'; |
||
|
0 ignored issues
–
show
|
|||
| 8 | |||
| 9 | private static $default_parent = 'MembersOnlyPage'; |
||
|
0 ignored issues
–
show
|
|||
| 10 | |||
| 11 | private static $allowed_children = array("MembersOnlyPage"); |
||
|
0 ignored issues
–
show
|
|||
| 12 | |||
| 13 | private static $group_code = "intranet-users"; |
||
| 14 | public static function set_group_code($v) |
||
| 15 | { |
||
| 16 | self::$group_code = $v; |
||
| 17 | } |
||
| 18 | public static function get_group_code() |
||
| 19 | { |
||
| 20 | return self::$group_code; |
||
| 21 | } |
||
| 22 | |||
| 23 | private static $group_name = "intranet users"; |
||
| 24 | public static function set_group_name($v) |
||
| 25 | { |
||
| 26 | self::$group_name = $v; |
||
| 27 | } |
||
| 28 | public static function get_group_name() |
||
| 29 | { |
||
| 30 | return self::$group_name; |
||
| 31 | } |
||
| 32 | |||
| 33 | private static $permission_code = "INTRANET_USERS"; |
||
| 34 | public static function set_permission_code($v) |
||
| 35 | { |
||
| 36 | self::$permission_code = $v; |
||
| 37 | } |
||
| 38 | public static function get_permission_code() |
||
| 39 | { |
||
| 40 | return self::$permission_code; |
||
| 41 | } |
||
| 42 | |||
| 43 | private static $defaults = array( |
||
|
0 ignored issues
–
show
|
|||
| 44 | "ProvideComments" => 1, |
||
| 45 | "ShowInSearch" => 0 |
||
| 46 | ); |
||
| 47 | |||
| 48 | |||
| 49 | public function getCMSFields() |
||
|
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a Loading history...
|
|||
| 50 | { |
||
| 51 | $fields = parent::getCMSFields(); |
||
| 52 | return $fields; |
||
| 53 | } |
||
| 54 | |||
| 55 | public function canView($member = null) |
||
| 56 | { |
||
| 57 | if ($member = Member::currentUser()) { |
||
| 58 | if ($member->inGroup("ADMIN") || Permission::checkMember($member, self::$permission_code)) { |
||
| 59 | return true; |
||
| 60 | } |
||
| 61 | } |
||
| 62 | return false; |
||
| 63 | } |
||
| 64 | |||
| 65 | public function getShowInMenus() |
||
| 66 | { |
||
| 67 | return $this->canView(); |
||
| 68 | } |
||
| 69 | |||
| 70 | public function ShowInMenus() |
||
| 71 | { |
||
| 72 | return $this->canView(); |
||
| 73 | } |
||
| 74 | |||
| 75 | public function getShowInSearch() |
||
| 76 | { |
||
| 77 | return $this->canView(); |
||
| 78 | } |
||
| 79 | |||
| 80 | public function ShowInSearch() |
||
| 81 | { |
||
| 82 | return $this->canView(); |
||
| 83 | } |
||
| 84 | |||
| 85 | public function requireDefaultRecords() |
||
| 86 | { |
||
| 87 | parent::requireDefaultRecords(); |
||
| 88 | $intranetGroup = Group::get()->filter(array("Code" => $this->Config()->get("group_code")))->first(); |
||
| 89 | if ($intranetGroup && $intranetGroup->exists()) { |
||
|
0 ignored issues
–
show
This
if statement is empty and can be removed.
This check looks for the bodies of These if (rand(1, 6) > 3) {
//print "Check failed";
} else {
print "Check succeeded";
}
could be turned into if (rand(1, 6) <= 3) {
print "Check succeeded";
}
This is much more concise to read. Loading history...
|
|||
| 90 | //do nothing |
||
| 91 | } else { |
||
| 92 | $intranetGroup = new Group(); |
||
| 93 | DB::alteration_message($this->Config()->get("group_name").' group created', "created"); |
||
| 94 | } |
||
| 95 | if ($intranetGroup) { |
||
| 96 | $intranetGroup->Code = $this->Config()->get("group_code"); |
||
| 97 | $intranetGroup->Title = $this->Config()->get("group_name"); |
||
| 98 | $intranetGroup->write(); |
||
| 99 | Permission::grant($intranetGroup->ID, $this->Config()->get("permission_code")); |
||
| 100 | if (DB::query("
|
||
| 101 | SELECT * |
||
| 102 | FROM Permission |
||
| 103 | WHERE \"GroupID\" = '".$intranetGroup->ID."' |
||
| 104 | AND \"Code\" LIKE '".$this->Config()->get("permission_code")."'")->numRecords() == 0 |
||
| 105 | ) { |
||
| 106 | Permission::grant($intranetGroup->ID, $this->Config()->get("permission_code")); |
||
| 107 | DB::alteration_message($this->Config()->get("group_name").' permissions granted', "created"); |
||
| 108 | } |
||
| 109 | } |
||
| 110 | } |
||
| 111 | } |
||
| 112 | |||
| 113 | class MembersOnlyPage_Controller extends Page_Controller |
||
|
0 ignored issues
–
show
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...
|
|||
| 114 | { |
||
| 115 | public function init() |
||
| 116 | { |
||
| 117 | parent::init(); |
||
| 118 | Requirements::themedCSS("MembersOnlyPage", "membersonlypages"); |
||
| 119 | } |
||
| 120 | } |
||
| 121 |