sunnysideup /
silverstripe-wishlist
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 |
||
| 2 | |||
| 3 | /** |
||
| 4 | *@author nicolaas[at]sunnysideup.co.nz |
||
| 5 | * |
||
| 6 | * |
||
| 7 | * |
||
| 8 | **/ |
||
| 9 | |||
| 10 | class WishListPage extends Page |
||
|
0 ignored issues
–
show
|
|||
| 11 | { |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Icon to use for this page type. |
||
| 15 | */ |
||
| 16 | public static $icon = "wishlist/images/treeicons/WishListPage"; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Additional page database fields. |
||
| 20 | */ |
||
| 21 | public static $db = array( |
||
| 22 | "AddedToListText" => "Varchar(255)", |
||
| 23 | "AddedToListTextError" => "Varchar(255)", |
||
| 24 | "RemovedFromListConfirmation" => "Varchar(255)", |
||
| 25 | "RetrieveListConfirmation" => "Varchar(255)", |
||
| 26 | "ClearListConfirmation" => "Varchar(255)", |
||
| 27 | "RemovedFromListText" => "Varchar(255)", |
||
| 28 | "RemovedFromListTextError" => "Varchar(255)", |
||
| 29 | "ClearWishList" => "Varchar(255)", |
||
| 30 | "SavedWishListText" => "Varchar(255)", |
||
| 31 | "SavedWishListTextError" => "Varchar(255)", |
||
| 32 | "RetrievedWishListText" => "Varchar(255)", |
||
| 33 | "RetrievedWishListTextError" => "Varchar(255)" |
||
| 34 | ); |
||
| 35 | |||
| 36 | |||
| 37 | /** |
||
| 38 | * Add page CMS fields. |
||
| 39 | * @return FieldSet |
||
| 40 | */ |
||
| 41 | public function getCMSFields() |
||
| 42 | { |
||
| 43 | $fields = parent::getCMSFields(); |
||
| 44 | $fields->addFieldToTab("Root.Content.SaveAndRemoveMessages", new TextField($name = "AddedToListText", $title = "added to list")); |
||
| 45 | $fields->addFieldToTab("Root.Content.SaveAndRemoveMessages", new TextField($name = "AddedToListTextError", $title = "could not add to list")); |
||
| 46 | $fields->addFieldToTab("Root.Content.SaveAndRemoveMessages", new TextField($name = "RemovedFromListText", $title = "removed from list")); |
||
| 47 | $fields->addFieldToTab("Root.Content.SaveAndRemoveMessages", new TextField($name = "RemovedFromListTextError", $title = "could not remove from list")); |
||
| 48 | $fields->addFieldToTab("Root.Content.WholeListMessages", new TextField($name = "ClearWishList", $title = "cleared list")); |
||
| 49 | $fields->addFieldToTab("Root.Content.WholeListMessages", new TextField($name = "SavedWishListText", $title = "saved list")); |
||
| 50 | $fields->addFieldToTab("Root.Content.WholeListMessages", new TextField($name = "SavedWishListTextError", $title = "could not save list")); |
||
| 51 | $fields->addFieldToTab("Root.Content.WholeListMessages", new TextField($name = "RetrievedWishListText", $title = "retrieved list")); |
||
| 52 | $fields->addFieldToTab("Root.Content.WholeListMessages", new TextField($name = "RetrievedWishListTextError", $title = "could not retrieve list")); |
||
| 53 | $fields->addFieldToTab("Root.Content.DoubleChecksQuestions", new TextField($name = "RemovedFromListConfirmation", $title = "Are you sure you want to remove this item? Pop-up double-check question...")); |
||
| 54 | $fields->addFieldToTab("Root.Content.DoubleChecksQuestions", new TextField($name = "RetrieveListConfirmation", $title = "Are you sure you want to retrieve your saved list? Pop-up double-check question... We ask them because they will loose their currently shown list.")); |
||
| 55 | $fields->addFieldToTab("Root.Content.DoubleChecksQuestions", new TextField($name = "ClearListConfirmation", $title = "Are you sure you want to clear your saved list? Pop-up double-check question...")); |
||
| 56 | return $fields; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Add default records to database. |
||
| 61 | * Make sure you call parent::requireDefaultRecords(). |
||
| 62 | */ |
||
| 63 | public function requireDefaultRecords() |
||
| 64 | { |
||
| 65 | parent::requireDefaultRecords(); |
||
| 66 | $update = array(); |
||
| 67 | $page = DataObject::get_one("WishListPage"); |
||
| 68 | if (!$page) { |
||
| 69 | $page = new WishListPage(); |
||
| 70 | $page->Title = "Wish List"; |
||
| 71 | $page->MetaTitle = "Wish List"; |
||
| 72 | $page->URLSegment = "wish-list"; |
||
| 73 | $page->MenuTitle = "wish list"; |
||
| 74 | } |
||
| 75 | if ($page) { |
||
| 76 | if (!$page->AddedToListText) { |
||
| 77 | $page->AddedToListText = "added to wish list"; |
||
| 78 | $update[] ="updated AddedToListText"; |
||
| 79 | } |
||
| 80 | if (!$page->AddedToListTextError) { |
||
| 81 | $page->AddedToListTextError = "could not add to wish list"; |
||
| 82 | $update[] ="updated AddedToListTextError"; |
||
| 83 | } |
||
| 84 | if (!$page->RemovedFromListConfirmation) { |
||
| 85 | $page->RemovedFromListConfirmation = "are you sure you want to remove it from your wish list?"; |
||
| 86 | $update[] ="updated RemovedFromListConfirmation"; |
||
| 87 | } |
||
| 88 | if (!$page->RetrieveListConfirmation) { |
||
| 89 | $page->RetrieveListConfirmation = "Are you sure you would like to retrieve your saved list? It will replace your current list. Do you want to go ahead?"; |
||
| 90 | $update[] ="updated RetrieveListConfirmation"; |
||
| 91 | } |
||
| 92 | if (!$page->ClearListConfirmation) { |
||
| 93 | $page->ClearListConfirmation = "Are you sure you would like to clear your saved list? "; |
||
| 94 | $update[] ="updated ClearListConfirmation"; |
||
| 95 | } |
||
| 96 | if (!$page->RemovedFromListText) { |
||
| 97 | $page->RemovedFromListText = "removed from wish list"; |
||
| 98 | $update[] ="updated RemovedFromListText"; |
||
| 99 | } |
||
| 100 | if (!$page->RemovedFromListTextError) { |
||
| 101 | $page->RemovedFromListTextError = "could not be removed from wish list"; |
||
| 102 | $update[] ="updated RemovedFromListTextError"; |
||
| 103 | } |
||
| 104 | if (!$page->ClearWishList) { |
||
| 105 | $page->ClearWishList = "cleared wish list"; |
||
| 106 | $update[] ="updated ClearWishList"; |
||
| 107 | } |
||
| 108 | if (!$page->SavedWishListText) { |
||
| 109 | $page->SavedWishListText = "saved wish list"; |
||
| 110 | $update[] ="updated SavedWishListText"; |
||
| 111 | } |
||
| 112 | if (!$page->SavedWishListTextError) { |
||
| 113 | $page->SavedWishListTextError = "could not save wish list"; |
||
| 114 | $update[] ="updated SavedWishListTextError"; |
||
| 115 | } |
||
| 116 | if (!$page->RetrievedWishListText) { |
||
| 117 | $page->RetrievedWishListText = "retrieved wish list"; |
||
| 118 | $update[] ="updated RetrievedWishListText"; |
||
| 119 | } |
||
| 120 | if (!$page->RetrievedWishListTextError) { |
||
| 121 | $page->RetrievedWishListTextError = "could not retrieve wish list"; |
||
| 122 | $update[] ="updated RetrievedWishListTextError"; |
||
| 123 | } |
||
| 124 | if (count($update)) { |
||
| 125 | $page->writeToStage('Stage'); |
||
| 126 | $page->publish('Stage', 'Live'); |
||
| 127 | DB::alteration_message($page->ClassName." created/updated: <ul><li>".implode("</li><li>", $update)."</li></ul>", 'created'); |
||
| 128 | } |
||
| 129 | } |
||
| 130 | } |
||
| 131 | } |
||
| 132 | |||
| 133 | class WishListPage_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...
|
|||
| 134 | { |
||
| 135 | |||
| 136 | /** |
||
| 137 | * Initialisation function that is run before any action on the controller is called. |
||
| 138 | */ |
||
| 139 | public function init() |
||
| 140 | { |
||
| 141 | parent::init(); |
||
| 142 | WishListDecorator_Controller::set_inline_requirements(); |
||
| 143 | } |
||
| 144 | |||
| 145 | /** |
||
| 146 | * Return whether there are wish list items to be saved. |
||
| 147 | * @return boolean |
||
| 148 | */ |
||
| 149 | public function CanSaveWishList() |
||
| 150 | { |
||
| 151 | return $this->CanRetrieveWishList(); |
||
| 152 | } |
||
| 153 | |||
| 154 | /** |
||
| 155 | * Return whether there are wish list items to be retrieved (that haven't already been retrieved). |
||
| 156 | * @return boolean |
||
| 157 | */ |
||
| 158 | public function CanRetrieveWishList() |
||
| 159 | { |
||
| 160 | if ($array = WishListDecorator_Controller::get_wish_list_from_member_array()) { |
||
| 161 | if (is_array($array)) { |
||
| 162 | if (count($array)) { |
||
| 163 | return true; |
||
| 164 | } |
||
| 165 | } |
||
| 166 | } |
||
| 167 | return false; |
||
| 168 | } |
||
| 169 | |||
| 170 | /** |
||
| 171 | * Return whether the member wish list is non-empty and hence can be cleared. |
||
| 172 | * @return boolean |
||
| 173 | */ |
||
| 174 | public function CanClearWishList() |
||
| 175 | { |
||
| 176 | return $this->CanRetrieveWishList(); |
||
| 177 | } |
||
| 178 | } |
||
| 179 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.