These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | *@author: Nicolaas [at] Sunny Side Up . Co . Nz |
||
4 | *@description: manual change for a buyable |
||
5 | * the buyable available quantity can be changed (manually overridden) using this class. |
||
6 | * |
||
7 | * All entries link to the BuyableStockCalculatedQuantity object. |
||
8 | * The BuyableStockCalculatedQuantity objects calculates, for each buyable, |
||
9 | * how many are available. |
||
10 | * |
||
11 | **/ |
||
12 | |||
13 | class BuyableStockManualUpdate extends DataObject |
||
14 | { |
||
15 | private static $db = array( |
||
0 ignored issues
–
show
Comprehensibility
introduced
by
Loading history...
|
|||
16 | "Quantity" => "Int", |
||
17 | "ExternalUpdate" => "Boolean" |
||
18 | ); |
||
19 | |||
20 | private static $has_one = array( |
||
0 ignored issues
–
show
|
|||
21 | "Parent" => "BuyableStockCalculatedQuantity", |
||
22 | "Member" => "Member" |
||
23 | ); |
||
24 | |||
25 | //MODEL ADMIN STUFF |
||
26 | |||
27 | private static $searchable_fields = array( |
||
0 ignored issues
–
show
|
|||
28 | "Quantity", |
||
29 | "MemberID" |
||
30 | ); |
||
31 | |||
32 | private static $field_labels = array( |
||
0 ignored issues
–
show
|
|||
33 | "Quantity", |
||
34 | "ParentID" => "Buyable", |
||
35 | "MemberID" => "Updated by ..." |
||
36 | ); |
||
37 | |||
38 | private static $summary_fields = array( |
||
0 ignored issues
–
show
|
|||
39 | "Parent.Name" => "Buyable", |
||
40 | "Member.FirstName" => "Updater", |
||
41 | "Quantity" => "Quantity" |
||
42 | ); |
||
43 | |||
44 | private static $api_access = true; |
||
0 ignored issues
–
show
|
|||
45 | |||
46 | private static $default_sort = "\"LastEdited\" DESC, \"ParentID\" ASC"; |
||
0 ignored issues
–
show
|
|||
47 | |||
48 | private static $singular_name = "Stock Manual Update Entry"; |
||
0 ignored issues
–
show
|
|||
49 | public function i18n_singular_name() |
||
50 | { |
||
51 | return _t("BuyableStockManualUpdate.STOCKUPDATEENTRY", "Stock Manual Update Entry"); |
||
52 | } |
||
53 | |||
54 | private static $plural_name = "Stock Manual Update Entries"; |
||
0 ignored issues
–
show
|
|||
55 | public function i18n_plural_name() |
||
56 | { |
||
57 | return _t("BuyableStockManualUpdate.STOCKUPDATEENTRIES", "Stock Manual Update Entries"); |
||
58 | } |
||
59 | |||
60 | public function canView($member = null) |
||
61 | { |
||
62 | return $this->canDoAnything($member); |
||
63 | } |
||
64 | |||
65 | public function canCreate($member = null) |
||
66 | { |
||
67 | return $this->canDoAnything($member); |
||
68 | } |
||
69 | |||
70 | public function canEdit($member = null) |
||
71 | { |
||
72 | return false; |
||
73 | } |
||
74 | |||
75 | public function canDelete($member = null) |
||
76 | { |
||
77 | return false; |
||
78 | } |
||
79 | |||
80 | View Code Duplication | protected function canDoAnything($member = null) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
81 | { |
||
82 | $shopAdminCode = EcommerceConfig::get("EcommerceRole", "admin_permission_code"); |
||
83 | if (!Permission::check($shopAdminCode)) { |
||
84 | Security::permissionFailure($this, _t('Security.PERMFAILURE', ' This page is secured and you need administrator rights to access it. Enter your credentials below and we will send you right along.')); |
||
85 | } |
||
86 | return true; |
||
87 | } |
||
88 | } |
||
89 |