From 5de32bb047d1f9b4004d883a72eb32f1ada6ba9e Mon Sep 17 00:00:00 2001 From: nivcoo <36514752+nivcoo@users.noreply.github.com> Date: Thu, 29 Nov 2018 22:59:48 +0100 Subject: [PATCH 01/45] New design --- Controller/CategoriesController.php | 88 +++++++++++++++ Controller/ShopController.php | 102 ++++++------------ .../admin_add_category.ctp | 2 +- View/Categories/admin_index.ctp | 40 +++++++ View/Shop/admin_index.ctp | 58 +++++++--- config.json | 7 +- lang/en_US.json | 5 + lang/fr_FR.json | 6 ++ 8 files changed, 224 insertions(+), 84 deletions(-) create mode 100644 Controller/CategoriesController.php rename View/{Shop => Categories}/admin_add_category.ctp (88%) mode change 100755 => 100644 create mode 100644 View/Categories/admin_index.ctp diff --git a/Controller/CategoriesController.php b/Controller/CategoriesController.php new file mode 100644 index 0000000..8057caf --- /dev/null +++ b/Controller/CategoriesController.php @@ -0,0 +1,88 @@ +isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_ITEMS')) { + $this->set('title_for_layout', $this->Lang->get('SHOP__TITLE')); + $this->layout = 'admin'; + $this->loadModel('Shop.Category'); + $this->loadModel('Shop.Item'); + $search_categories = $this->Category->find('all'); + foreach ($search_categories as $v) { + $categories_count[$v['Category']['id']] = $this->Item->find('count', array('conditions' => array('category' => $v['Category']['id']))); + } + $this->set(compact('search_categories', 'categories_count')); + + } else { + $this->redirect('/'); + } + } + + public function admin_edit_category() + { + $this->autoRender = false; + $this->response->type('json'); + if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_CATEGORIES')) { + if ($this->request->is('post')) { + if (!empty($this->request->data['name'])) { + + $this->loadModel('Shop.Category'); + $this->Category->read(null, $this->request->data['id']); + $this->Category->set(array( + 'name' => $this->request->data['name'], + )); + $this->Category->save(); + $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('SHOP__CATEGORY_EDIT_SUCCESS')))); + } else { + $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS')))); + } + } else { + $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST')))); + } + } else { + throw new ForbiddenException(); + } + } + + /* + * ======== Ajout d'une catégorie (affichage & traitement POST) =========== + */ + + public function admin_add_category() + { + if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_ITEMS')) { + + $this->layout = 'admin'; + $this->set('title_for_layout', $this->Lang->get('SHOP__CATEGORY_ADD')); + if ($this->request->is('post')) { + if (!empty($this->request->data['name'])) { + $this->loadModel('Shop.Category'); + + $event = new CakeEvent('beforeAddCategory', $this, array('category' => $this->request->data['name'], 'user' => $this->User->getAllFromCurrentUser())); + $this->getEventManager()->dispatch($event); + if ($event->isStopped()) { + return $event->result; + } + + $this->Category->read(null, null); + $this->Category->set(array( + 'name' => $this->request->data['name'], + )); + $this->History->set('ADD_CATEGORY', 'shop'); + $this->Category->save(); + $this->Session->setFlash($this->Lang->get('SHOP__CATEGORY_ADD_SUCCESS'), 'default.success'); + $this->redirect(array('controller' => 'categories', 'action' => 'index', 'admin' => true)); + } else { + $this->Session->setFlash($this->Lang->get('ERROR__FILL_ALL_FIELDS'), 'default.error'); + } + } + } else { + $this->redirect('/'); + } + } + + +} diff --git a/Controller/ShopController.php b/Controller/ShopController.php index 78e5d7d..1fed344 100755 --- a/Controller/ShopController.php +++ b/Controller/ShopController.php @@ -523,13 +523,23 @@ public function admin_index() $this->layout = 'admin'; $this->loadModel('Shop.Item'); + $this->loadModel('Shop.Category'); + $this->loadModel('Server'); $search_items = $this->Item->find('all', array('order' => 'order')); $items = array(); foreach ($search_items as $key => $value) { + if (!$this->Category->find('first', array('conditions' => array('id' => $value['Item']['category'])))) { + $search_items_other = $this->Item->find('all', array('conditions' => array('category' => $value['Item']['category']))); + + $search_server = $this->Server->find('all', array('conditions' => array('id' => unserialize($value['Item']['servers'])))); + foreach ($search_server as $v) { + $item_server[$value['Item']['id']] .= $v['Server']['name']; + $item_server[$value['Item']['id']] .= ', '; + } + } $items[$value['Item']['id']] = $value['Item']['name']; } - $this->loadModel('Shop.Category'); $search_categories = $this->Category->find('all'); foreach ($search_categories as $v) { $categories[$v['Category']['id']]['name'] = $v['Category']['name']; @@ -539,7 +549,7 @@ public function admin_index() $findConfig = $this->ItemsConfig->find('first'); $config = (!empty($findConfig)) ? $findConfig['ItemsConfig'] : array(); - $this->set(compact('categories', 'search_categories', 'search_items', 'config', 'items')); + $this->set(compact('categories', 'search_categories', 'search_items', 'config', 'items', 'search_items_other', 'item_server')); } else { $this->redirect('/'); @@ -829,7 +839,26 @@ public function admin_edit_ajax() /* * ======== Ajout d'un article (affichage) =========== */ + + public function admin_test_item() + { + if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_ITEMS')) { + $this->set('title_for_layout', $this->Lang->get('SHOP__ITEM_ADD')); + $this->layout = 'admin'; + + $this->loadModel('Server'); + foreach ($this->request->data['server'] as $serverId) + $this->Server->commands($this->request->data['commands'], $serverId); + + $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('SHOP__ITEM_ADD_SUCCESS')))); + $this->set(compact('servers')); + + } else { + $this->redirect('/'); + } + } + public function admin_add_item() { if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_ITEMS')) { @@ -860,32 +889,7 @@ public function admin_add_item() $this->redirect('/'); } } - public function admin_edit_category() - { - $this->autoRender = false; - $this->response->type('json'); - if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_CATEGORIES')) { - if ($this->request->is('post')) { - if (!empty($this->request->data['name'])) { - - $this->loadModel('Shop.Category'); - $this->Category->read(null, $this->request->data['id']); - $this->Category->set(array( - 'name' => $this->request->data['name'], - )); - $this->Category->save(); - $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('SHOP__CATEGORY_EDIT_SUCCESS')))); - } else { - $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS')))); - } - } else { - $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST')))); - } - } else { - throw new ForbiddenException(); - } - } - + /* * ======== Ajout d'un article (Traitement AJAX) =========== */ @@ -963,44 +967,6 @@ public function admin_add_item_ajax() } } - - /* - * ======== Ajout d'une catégorie (affichage & traitement POST) =========== - */ - - public function admin_add_category() - { - if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_ITEMS')) { - - $this->layout = 'admin'; - $this->set('title_for_layout', $this->Lang->get('SHOP__CATEGORY_ADD')); - if ($this->request->is('post')) { - if (!empty($this->request->data['name'])) { - $this->loadModel('Shop.Category'); - - $event = new CakeEvent('beforeAddCategory', $this, array('category' => $this->request->data['name'], 'user' => $this->User->getAllFromCurrentUser())); - $this->getEventManager()->dispatch($event); - if ($event->isStopped()) { - return $event->result; - } - - $this->Category->read(null, null); - $this->Category->set(array( - 'name' => $this->request->data['name'], - )); - $this->History->set('ADD_CATEGORY', 'shop'); - $this->Category->save(); - $this->Session->setFlash($this->Lang->get('SHOP__CATEGORY_ADD_SUCCESS'), 'default.success'); - $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); - } else { - $this->Session->setFlash($this->Lang->get('ERROR__FILL_ALL_FIELDS'), 'default.error'); - } - } - } else { - $this->redirect('/'); - } - } - /* * ======== Suppression d'une catégorie/article/paypal/starpass (traitement) =========== */ @@ -1043,10 +1009,10 @@ public function admin_delete($type = false, $id = false) $this->Category->delete($id); $this->History->set('DELETE_CATEGORY', 'shop'); $this->Session->setFlash($this->Lang->get('SHOP__CATEGORY_DELETE_SUCCESS'), 'default.success'); - $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + $this->redirect(array('controller' => 'categories', 'action' => 'index', 'admin' => true)); } else { $this->Session->setFlash($this->Lang->get('UNKNONW_ID'), 'default.error'); - $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + $this->redirect(array('controller' => 'categories', 'action' => 'index', 'admin' => true)); } } elseif ($type == "paypal") { $this->loadModel('Shop.Paypal'); diff --git a/View/Shop/admin_add_category.ctp b/View/Categories/admin_add_category.ctp old mode 100755 new mode 100644 similarity index 88% rename from View/Shop/admin_add_category.ctp rename to View/Categories/admin_add_category.ctp index c476893..b386c75 --- a/View/Shop/admin_add_category.ctp +++ b/View/Categories/admin_add_category.ctp @@ -18,7 +18,7 @@
- get('GLOBAL__CANCEL') ?> + get('GLOBAL__CANCEL') ?>
diff --git a/View/Categories/admin_index.ctp b/View/Categories/admin_index.ctp new file mode 100644 index 0000000..0d95c96 --- /dev/null +++ b/View/Categories/admin_index.ctp @@ -0,0 +1,40 @@ +
+
+
+
+
+

get('SHOP__CATEGORIES') ?>   get('GLOBAL__ADD') ?>

+
+
+ + + + + + + + + + $v) {?> + + + + + + + +
get('GLOBAL__NAME') ?>get('SHOP__CATEGORY_NUMBER') ?>get('GLOBAL__ACTIONS') ?>
+
+ "> + "> +
+ + true)) ?>')" class="btn btn-danger">get('GLOBAL__DELETE') ?> + +
+
+
+
+
+ +
\ No newline at end of file diff --git a/View/Shop/admin_index.ctp b/View/Shop/admin_index.ctp index d506c2a..159f9e6 100755 --- a/View/Shop/admin_index.ctp +++ b/View/Shop/admin_index.ctp @@ -57,38 +57,30 @@

get('SHOP__ITEMS_AVAILABLE') ?>   get('GLOBAL__ADD') ?>

-
-
-

get('SHOP__CATEGORIES') ?>   get('GLOBAL__ADD') ?>

- + - $v) {?> + $v) {?> - + - $va) { $i++; - if ($categories[$va["Item"]["category"]]['name'] == $v["Category"]["name"]) { + $va) { $i++; + if ($va['Item']['category'] == $v["Category"]["id"]) { ?> -"> @@ -110,6 +102,44 @@ +
+
+
+
+

get('SHOP__ITEMS_AVAILABLE_OTHER') ?>

+
+
+ +
get('GLOBAL__NAME') ?>get('SHOP__CATEGORY') ?> get('SHOP__ITEMS_AVAILABLE') ?> get('SHOP__ITEM_PRICE') ?> get('GLOBAL__ACTIONS') ?>
-
- "> - "> +
- - true)) ?>')" class="btn btn-danger">get('GLOBAL__DELETE') ?> -
+ + + + + + + + + + $va) { + ?> + + + + + + + + +
get('SHOP__ITEMS_AVAILABLE') ?>get('SERVER__TITLE') ?>get('SHOP__ITEM_PRICE') ?>get('GLOBAL__ACTIONS') ?>
getMoneyName() ?> + true)) ?>" class="btn btn-info">get('GLOBAL__EDIT') ?> + true)) ?>')" class="btn btn-danger">get('GLOBAL__DELETE') ?> +
+
+
+
+
+ +
diff --git a/config.json b/config.json index 7bc4957..e66e45e 100755 --- a/config.json +++ b/config.json @@ -5,6 +5,11 @@ "icon": "shopping-cart", "index": "3", "menu": { + "Gérer les catégories": { + "icon": "list-alt", + "permission": "SHOP__ADMIN_MANAGE_CATEGORIES", + "route": "/admin/shop/categories" + }, "Gérer les articles": { "icon": "shopping-basket", "permission": "SHOP__ADMIN_MANAGE_ITEMS", @@ -35,7 +40,7 @@ "version":"1.2.13", "useEvents":true, "permissions" : { - "available" : ["CREDIT_ACCOUNT", "CAN_BUY", "SHOP__ADMIN_MANAGE_ITEMS", "SHOP__ADMIN_MANAGE_VOUCHERS", "SHOP__ADMIN_MANAGE_PAYMENT", "SHOP__ADMIN_GIFTALL"], + "available" : ["CREDIT_ACCOUNT", "CAN_BUY", "SHOP__ADMIN_MANAGE_ITEMS", "SHOP__ADMIN_MANAGE_CATEGORIES", "SHOP__ADMIN_MANAGE_VOUCHERS", "SHOP__ADMIN_MANAGE_PAYMENT", "SHOP__ADMIN_GIFTALL"], "default" : { "0" : ["CREDIT_ACCOUNT", "CAN_BUY"], "2" : ["CREDIT_ACCOUNT", "CAN_BUY"] diff --git a/lang/en_US.json b/lang/en_US.json index 3a8c14f..e22e4ee 100755 --- a/lang/en_US.json +++ b/lang/en_US.json @@ -156,6 +156,7 @@ "SHOP__ITEM_BUY_LIMIT_PLACEHOLDER": "Put 0 for no limit", "SHOP__ITEM_WAIT_TIME": "Time interval between purchases", "SHOP__ITEM_CANT_BUY_WAIT_TIME": "You can not buy item {ITEM_NAME} now! Every purchase must be spaced from {WAIT_TIME}.", + "SHOP__ITEMS_AVAILABLE_OTHER":"Items not listed", "SHOP__CATEGORIES": "Categories", "SHOP__CATEGORY": "Category", @@ -163,6 +164,7 @@ "SHOP__CATEGORY_ADD_SUCCESS": "Category added successfully!", "SHOP__CATEGORY_EDIT_SUCCESS": "Category successfully modified!", "SHOP__CATEGORY_DELETE_SUCCESS": "Category Successfully Deleted!", + "SHOP__CATEGORY_NUMBER": "Number of articles linked to the category", "SHOP__BUY": "Buy", "SHOP__BUY_CART": "See my cart", @@ -219,6 +221,9 @@ "PERMISSIONS__SHOP__ADMIN_MANAGE_ITEMS": "Manage articles of the shop (Add, edit, delete)", "PERMISSIONS__SHOP__ADMIN_MANAGE_VOUCHERS": "Manage the promotional codes of the shop (Add, remove)", "PERMISSIONS__SHOP__ADMIN_MANAGE_PAYMENT": "Manage the payments of the shop (Add, edit, delete, validate the PSC ...)", + "PERMISSIONS__VOTE__ADMIN_VIEW_TOP":"Go to the top vote page", + "PERMISSIONS__SHOP__ADMIN_GIFTALL":"Manage the gifts (donation of points)", + "PERMISSIONS__SHOP__ADMIN_MANAGE_CATEGORIES":"Manage store categories (Add, Edit, Delete)", "NOTIFICATION__NEW_VOUCHER": "A new promotional code is available!", "NOTIFICATION__NEW_PSC": "A new PaySafeCard must be validated!", diff --git a/lang/fr_FR.json b/lang/fr_FR.json index 65022a6..e8620d8 100755 --- a/lang/fr_FR.json +++ b/lang/fr_FR.json @@ -156,6 +156,7 @@ "SHOP__ITEM_BUY_LIMIT_PLACEHOLDER":"Mettez 0 pour aucune limite", "SHOP__ITEM_WAIT_TIME":"Intervalle de temps nécessaire entre chaque achats", "SHOP__ITEM_CANT_BUY_WAIT_TIME":"Vous ne pouvez pas acheter l'article {ITEM_NAME} maintenant ! Chaque achat doivent être espacé de {WAIT_TIME}.", + "SHOP__ITEMS_AVAILABLE_OTHER":"Articles non répertoriés", "SHOP__CATEGORIES": "Cat\u00e9gories", "SHOP__CATEGORY": "Cat\u00e9gorie", @@ -163,6 +164,7 @@ "SHOP__CATEGORY_ADD_SUCCESS": "Cat\u00e9gorie ajout\u00e9e avec succ\u00e8s !", "SHOP__CATEGORY_EDIT_SUCCESS": "Cat\u00e9gorie modifi\u00e9 avec succ\u00e8s !", "SHOP__CATEGORY_DELETE_SUCCESS": "Cat\u00e9gorie supprim\u00e9e avec succ\u00e8s !", + "SHOP__CATEGORY_NUMBER": "Nombre d'article lié à la catégorie", "SHOP__BUY": "Acheter", "SHOP__BUY_CART":"Voir mon panier", @@ -219,6 +221,10 @@ "PERMISSIONS__SHOP__ADMIN_MANAGE_ITEMS":"Gérer les articles de la boutique (Ajouter, éditer, supprimer)", "PERMISSIONS__SHOP__ADMIN_MANAGE_VOUCHERS":"Gérer les codes promotionnels de la boutique (Ajouter, supprimer)", "PERMISSIONS__SHOP__ADMIN_MANAGE_PAYMENT":"Gérer les paiements de la boutique (Ajouter, éditer, supprimer, valider les PSC...)", + "PERMISSIONS__VOTE__ADMIN_VIEW_TOP":"Accéder à la page du top vote", + "PERMISSIONS__SHOP__ADMIN_GIFTALL":"Gérer les cadeaux (don de points)", + "PERMISSIONS__SHOP__ADMIN_MANAGE_CATEGORIES":"Gérer les catégories de la boutique (Ajouter, éditer, supprimer)", + "NOTIFICATION__NEW_VOUCHER":"Un nouveau code promotionnel est disponible !", "NOTIFICATION__NEW_PSC":"Une nouvelle PaySafeCard doit être validée !", From 9fe60a37d906c5f66aa348e20997b180be86b932 Mon Sep 17 00:00:00 2001 From: nivcoo Date: Thu, 29 Nov 2018 23:41:24 +0100 Subject: [PATCH 02/45] New design --- Controller/ShopController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Controller/ShopController.php b/Controller/ShopController.php index 1fed344..0aa2ea3 100755 --- a/Controller/ShopController.php +++ b/Controller/ShopController.php @@ -527,6 +527,7 @@ public function admin_index() $this->loadModel('Server'); $search_items = $this->Item->find('all', array('order' => 'order')); $items = array(); + $item_server = array(); foreach ($search_items as $key => $value) { if (!$this->Category->find('first', array('conditions' => array('id' => $value['Item']['category'])))) { $search_items_other = $this->Item->find('all', array('conditions' => array('category' => $value['Item']['category']))); From 40b190cc1e3f73a41dc6613ffb77d69e07f34aad Mon Sep 17 00:00:00 2001 From: nivcoo <36514752+nivcoo@users.noreply.github.com> Date: Fri, 30 Nov 2018 23:03:33 +0100 Subject: [PATCH 03/45] Remove useless function --- Controller/ShopController.php | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/Controller/ShopController.php b/Controller/ShopController.php index 0aa2ea3..6f3fae0 100755 --- a/Controller/ShopController.php +++ b/Controller/ShopController.php @@ -841,25 +841,6 @@ public function admin_edit_ajax() * ======== Ajout d'un article (affichage) =========== */ - public function admin_test_item() - { - if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_ITEMS')) { - - $this->set('title_for_layout', $this->Lang->get('SHOP__ITEM_ADD')); - $this->layout = 'admin'; - - $this->loadModel('Server'); - foreach ($this->request->data['server'] as $serverId) - $this->Server->commands($this->request->data['commands'], $serverId); - - $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('SHOP__ITEM_ADD_SUCCESS')))); - $this->set(compact('servers')); - - } else { - $this->redirect('/'); - } - } - public function admin_add_item() { if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_ITEMS')) { From 9ff3e1a339722913bd22e06e224fd46644a42b40 Mon Sep 17 00:00:00 2001 From: nivcoo Date: Mon, 3 Dec 2018 18:52:57 +0100 Subject: [PATCH 04/45] Up version --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index e66e45e..eb911bd 100755 --- a/config.json +++ b/config.json @@ -37,7 +37,7 @@ "Boutique": "/shop" }, "author":"Eywek", - "version":"1.2.13", + "version":"1.2.14", "useEvents":true, "permissions" : { "available" : ["CREDIT_ACCOUNT", "CAN_BUY", "SHOP__ADMIN_MANAGE_ITEMS", "SHOP__ADMIN_MANAGE_CATEGORIES", "SHOP__ADMIN_MANAGE_VOUCHERS", "SHOP__ADMIN_MANAGE_PAYMENT", "SHOP__ADMIN_GIFTALL"], From 8ef956590ca5ca0b6cc91565e870a7f0806ed8b1 Mon Sep 17 00:00:00 2001 From: nivcoo <36514752+nivcoo@users.noreply.github.com> Date: Wed, 2 Jan 2019 22:19:22 +0100 Subject: [PATCH 05/45] Fix. Table name --- Controller/GiftallController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Controller/GiftallController.php b/Controller/GiftallController.php index 0716787..ccf08bf 100644 --- a/Controller/GiftallController.php +++ b/Controller/GiftallController.php @@ -15,7 +15,7 @@ public function admin_index() $db = ConnectionManager::getDataSource('default'); $number = $db->value($number, 'integer'); - $db->query("UPDATE Users SET money = money + $number"); + $db->query("UPDATE users SET money = money + $number"); $this->History->set("GIFTALL_$number", "shop"); @@ -31,4 +31,4 @@ public function admin_index() throw new ForbiddenException(); } } -} \ No newline at end of file +} From efd65eecb9a6a82041d44f6b45d7967b9f2fa865 Mon Sep 17 00:00:00 2001 From: Pierre LAGOUTTE Date: Sun, 23 Dec 2018 20:43:17 +0100 Subject: [PATCH 06/45] Fix decimal prices error The CMS returns an alert window containing "ERROR" if the price is decimal. --- Controller/ShopController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ShopController.php b/Controller/ShopController.php index 6f3fae0..f6a235a 100755 --- a/Controller/ShopController.php +++ b/Controller/ShopController.php @@ -166,7 +166,7 @@ function ajax_get($id) } if ($reductional_items) { - $item_price = $item_price - $reduction; + $item_price = floor($item_price - $reduction); $reduction = $reduction . ' ' . $this->Configuration->getMoneyName(); $reductional_items_list = '' . implode(', ', $reductional_items_list_display) . ''; From 5d8cfc094db9b38ccb635314a5f71356233ee1ce Mon Sep 17 00:00:00 2001 From: Valentin T Date: Sun, 3 Mar 2019 15:59:25 +0100 Subject: [PATCH 07/45] Update DiscountVoucherComponent.php --- Controller/Component/DiscountVoucherComponent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/Component/DiscountVoucherComponent.php b/Controller/Component/DiscountVoucherComponent.php index 344befe..2f791cb 100755 --- a/Controller/Component/DiscountVoucherComponent.php +++ b/Controller/Component/DiscountVoucherComponent.php @@ -1,6 +1,6 @@ Date: Sun, 3 Mar 2019 15:59:40 +0100 Subject: [PATCH 08/45] Update DiscountVoucherComponent.php --- Controller/Component/DiscountVoucherComponent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/Component/DiscountVoucherComponent.php b/Controller/Component/DiscountVoucherComponent.php index 2f791cb..8e594a6 100755 --- a/Controller/Component/DiscountVoucherComponent.php +++ b/Controller/Component/DiscountVoucherComponent.php @@ -1,5 +1,5 @@ Date: Sun, 3 Mar 2019 16:05:57 +0100 Subject: [PATCH 09/45] Update DiscountVoucherComponent.php --- Controller/Component/DiscountVoucherComponent.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Controller/Component/DiscountVoucherComponent.php b/Controller/Component/DiscountVoucherComponent.php index 8e594a6..b187ee0 100755 --- a/Controller/Component/DiscountVoucherComponent.php +++ b/Controller/Component/DiscountVoucherComponent.php @@ -1,5 +1,9 @@ Date: Sun, 3 Mar 2019 16:06:08 +0100 Subject: [PATCH 10/45] Update config.json --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index eb911bd..1ada284 100755 --- a/config.json +++ b/config.json @@ -37,7 +37,7 @@ "Boutique": "/shop" }, "author":"Eywek", - "version":"1.2.14", + "version":"1.2.15", "useEvents":true, "permissions" : { "available" : ["CREDIT_ACCOUNT", "CAN_BUY", "SHOP__ADMIN_MANAGE_ITEMS", "SHOP__ADMIN_MANAGE_CATEGORIES", "SHOP__ADMIN_MANAGE_VOUCHERS", "SHOP__ADMIN_MANAGE_PAYMENT", "SHOP__ADMIN_GIFTALL"], From 1ef8e636708f494548df9c475d712d458d87f303 Mon Sep 17 00:00:00 2001 From: Mathis Date: Tue, 9 Apr 2019 19:35:06 +0200 Subject: [PATCH 11/45] Add Event onBuyMoney (Dedipass and Paypal only) He return the credits, the price, the plateform (paypal or dedipass), and user id. --- Controller/PaymentController.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Controller/PaymentController.php b/Controller/PaymentController.php index 351cb4d..0fd5739 100755 --- a/Controller/PaymentController.php +++ b/Controller/PaymentController.php @@ -1021,6 +1021,12 @@ public function ipn() )); $this->PaypalHistory->save(); + $event = new CakeEvent('onBuyPoints', $this, array('credits' => $findOffer['Paypal']['money'], 'price' => $payment_amount, 'plateform' => 'paypal', 'user_id' => $user_id)); + $this->getEventManager()->dispatch($event); + if ($event->isStopped()) { + return $event->result; + } + $this->loadModel('Notification'); $this->Notification->setToUser($this->Lang->get('NOTIFICATION__PAYPAL_IPN_VALIDED'), $user_id); @@ -1200,6 +1206,12 @@ public function dedipass_ipn() )); $this->DedipassHistory->save(); + $event = new CakeEvent('onBuyPoints', $this, array('credits' => $virtual_currency, 'price' => $this->request->data['payout'], 'plateform' => 'dedipass', 'user_id' => $user_id)); + $this->getEventManager()->dispatch($event); + if ($event->isStopped()) { + return $event->result; + } + $this->Session->setFlash($this->Lang->get('SHOP__DEDIPASS_PAYMENT_SUCCESS', array('{MONEY}' => $virtual_currency, '{MONEY_NAME}' => $this->Configuration->getMoneyName())), 'default.success'); $this->redirect(array('controller' => 'shop', 'action' => 'index')); From 2c24c4540dc2e098b8d3419f29358c6a958d7e15 Mon Sep 17 00:00:00 2001 From: nivcoo <36514752+nivcoo@users.noreply.github.com> Date: Sat, 27 Apr 2019 12:01:17 +0200 Subject: [PATCH 12/45] feat. Best Donator --- Controller/ShopController.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Controller/ShopController.php b/Controller/ShopController.php index f6a235a..d02e015 100755 --- a/Controller/ShopController.php +++ b/Controller/ShopController.php @@ -59,6 +59,24 @@ function index($category = false) if ($vagoal != 0){ $vawidth = round((str_replace(",", '.', $vanow*100/$vagoal))); } + + $best_donator_price = array(); + + foreach($histories_dedi as $get) { + $best_donator_price[$get["DedipassHistory"]["user_id"]] += $get["DedipassHistory"]["credits_gived"]; + } + foreach($histories_paypal as $get) { + $best_donator_price[$get["PaypalHistory"]["user_id"]] += $get["PaypalHistory"]["credits_gived"]; + } + foreach($histories_pay as $get) { + $best_donator_price[$get["PaysafecardHistory"]["user_id"]] += $get["PaysafecardHistory"]["credits_gived"]; + } + foreach($histories_star as $get) { + $best_donator_price[$get["StarpassHistory"]["user_id"]] += $get["StarpassHistory"]["credits_gived"]; + } + $best_donator_id = array_search(max($best_donator_price),$best_donator_price); + $best_donator = $this->User->find('first', ['conditions' => ['id' => $best_donator_id]]); + $best_donator = $best_donator['User']; $search_categories = $this->Category->find('all'); // on cherche toutes les catégories et on envoie à la vue From 057175c824d706e52b1a8522fc65d8aff5d579da Mon Sep 17 00:00:00 2001 From: nivcoo <36514752+nivcoo@users.noreply.github.com> Date: Sun, 28 Apr 2019 17:45:41 +0200 Subject: [PATCH 13/45] feat. Best Donator --- Controller/ShopController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ShopController.php b/Controller/ShopController.php index d02e015..9f32093 100755 --- a/Controller/ShopController.php +++ b/Controller/ShopController.php @@ -112,7 +112,7 @@ function index($category = false) $singular_money = $this->Configuration->getMoneyName(false); $plural_money = $this->Configuration->getMoneyName(); - $this->set(compact('dedipass', 'vagoal', 'vawidth', 'paysafecard_enabled', 'money', 'starpass_offers', 'paypal_offers', 'search_first_category', 'search_categories', 'search_items', 'title_for_layout', 'vouchers', 'singular_money', 'plural_money')); + $this->set(compact('best_donator', 'dedipass', 'vagoal', 'vawidth', 'paysafecard_enabled', 'money', 'starpass_offers', 'paypal_offers', 'search_first_category', 'search_categories', 'search_items', 'title_for_layout', 'vouchers', 'singular_money', 'plural_money')); } /* From 613dae0a8de880d1f263c48278a8a761010182e6 Mon Sep 17 00:00:00 2001 From: Javdu10 Date: Thu, 31 Oct 2019 09:38:37 +0100 Subject: [PATCH 14/45] add Nano --- Controller/PaymentController.php | 156 +++++++++++++++++++++++++++++++ Model/Nano.php | 2 + Model/NanoHistory.php | 9 ++ SQL/schema.php | 27 ++++++ View/Payment/admin_add_nano.ctp | 42 +++++++++ View/Payment/admin_edit_nano.ctp | 42 +++++++++ View/Payment/admin_index.ctp | 90 +++++++++++++++++- lang/en_US.json | 13 ++- lang/fr_FR.json | 12 +++ 9 files changed, 390 insertions(+), 3 deletions(-) create mode 100644 Model/Nano.php create mode 100644 Model/NanoHistory.php create mode 100644 View/Payment/admin_add_nano.ctp create mode 100644 View/Payment/admin_edit_nano.ctp diff --git a/Controller/PaymentController.php b/Controller/PaymentController.php index 0fd5739..5974f23 100755 --- a/Controller/PaymentController.php +++ b/Controller/PaymentController.php @@ -41,6 +41,12 @@ public function admin_index() $offersByID['paypal'][$value['Paypal']['id']] = $value['Paypal']['name']; } + $this->loadModel('Shop.Nano'); + $offers['nano'] = $this->Nano->find('all'); + + foreach ($offers['nano'] as $key => $value) { + $offersByID['nano'][$value['Nano']['id']] = $value['Nano']['name']; + } // Les PaySafeCards c'est différents @@ -144,6 +150,34 @@ public function admin_get_paypal_histories() } } + public function admin_get_nano_histories() + { + if ($this->isConnected && $this->Permissions->can('SHOP__ADMIN_MANAGE_ITEMS')) { + $this->response->body(json_encode([])); + exit(); + $this->loadModel('Shop.Nano'); + + $this->autoRender = false; + $this->response->type('json'); + + $this->DataTable = $this->Components->load('DataTable'); + $this->modelClass = 'NanoHistory'; + $this->DataTable->initialize($this); + $this->paginate = array( + 'fields' => array('NanoHistory.block_hash', 'User.pseudo', 'Nano.name', 'NanoHistory.payment_amount', 'NanoHistory.credits_gived', 'NanoHistory.created'), + 'recursive' => 1 + ); + $this->DataTable->mDataProp = true; + + $response = $this->DataTable->getResponse(); + + $this->response->body(json_encode($response)); + + } else { + throw new ForbiddenException(); + } + } + public function admin_get_paysafecard_histories() { if ($this->isConnected && $this->Permissions->can('SHOP__ADMIN_MANAGE_ITEMS')) { @@ -666,6 +700,128 @@ public function admin_edit_paypal_ajax($id = false) } } + /* + * ======== Ajout d'une offre Nano (affichage) =========== + */ + + public function admin_add_nano() + { + if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_PAYMENT')) { + + $this->set('title_for_layout', $this->Lang->get('SHOP__NANO_OFFER_ADD')); + $this->layout = 'admin'; + } else { + $this->redirect('/'); + } + } + + /* + * ======== Ajout d'une offre Nano (Traitement AJAX) =========== + */ + + public function admin_add_nano_ajax() + { + $this->autoRender = false; + if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_PAYMENT')) { + if ($this->request->is('ajax')) { + if (!empty($this->request->data['name']) AND !empty($this->request->data['address']) AND !empty($this->request->data['price']) AND !empty($this->request->data['money'])) { + $this->request->data['price'] = number_format($this->request->data['price'], 2, '.', ''); + $this->request->data['money'] = number_format($this->request->data['money'], 2, '.', ''); + if (substr( $this->request->data['address'], 0, 4 ) === "nano") { //TODO : Validate nano_ address + $this->loadModel('Shop.Nano'); + $this->Nano->read(null, null); + $this->Nano->set($this->request->data); + $this->Nano->save(); + $this->History->set('ADD_NANO_OFFER', 'shop'); + $this->Session->setFlash($this->Lang->get('SHOP__NANO_OFFER_ADD_SUCCESS'), 'default.success'); + echo json_encode(array('statut' => true, 'msg' => $this->Lang->get('SHOP__NANO_OFFER_ADD_SUCCESS'))); + } else { + echo json_encode(array('statut' => false, 'msg' => $this->Lang->get('USER__ERROR_EMAIL_NOT_VALID'))); + } + } else { + echo json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS'))); + } + } else { + echo json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST'))); + } + } else { + throw new ForbiddenException(); + } + } + + + /* + * ======== Modification d'une offre Nano (affichage) =========== + */ + + public function admin_edit_nano($id = false) + { + if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_PAYMENT')) { + + $this->set('title_for_layout', $this->Lang->get('SHOP__NANO_OFFER_EDIT')); + $this->layout = 'admin'; + if ($id != false) { + $this->loadModel('Shop.Nano'); + $search = $this->Nano->find('all', array('conditions' => array('id' => $id))); + if (!empty($search)) { + $this->set(compact('id')); + $this->set('nano', $search[0]['Nano']); + } else { + $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + } + } else { + $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + } + } else { + $this->redirect('/'); + } + } + + + /* + * ======== Modification d'une offre Nano (traitement AJAX) =========== + */ + + public function admin_edit_nano_ajax($id = false) + { + $this->autoRender = false; + if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_PAYMENT')) { + if ($id != false) { + $this->loadModel('Shop.Nano'); + $search = $this->Nano->find('all', array('conditions' => array('id' => $id))); + if (!empty($search)) { + if ($this->request->is('ajax')) { + if (!empty($this->request->data['name']) AND !empty($this->request->data['address']) AND !empty($this->request->data['price']) AND !empty($this->request->data['money'])) { + $this->request->data['price'] = number_format($this->request->data['price'], 2, '.', ''); + $this->request->data['money'] = number_format($this->request->data['money'], 2, '.', ''); + if (substr( $this->request->data['address'], 0, 4 ) === "nano") { //TODO : Validate nano_ address + $this->loadModel('Shop.Nano'); + $this->Nano->read(null, $id); + $this->Nano->set($this->request->data); + $this->Nano->save(); + $this->History->set('EDIT_NANO_OFFER', 'shop'); + $this->Session->setFlash($this->Lang->get('SHOP__NANO_OFFER_EDIT_SUCCESS'), 'default.success'); + echo json_encode(array('statut' => true, 'msg' => $this->Lang->get('SHOP__NANO_OFFER_EDIT_SUCCESS'))); + } else { + echo json_encode(array('statut' => false, 'msg' => $this->Lang->get('USER__ERROR_EMAIL_NOT_VALID'))); + } + } else { + echo json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS'))); + } + } else { + echo json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST'))); + } + } else { + echo json_encode(array('statut' => false, 'msg' => $this->Lang->get('UNKNONW_ID'))); + } + } else { + throw new NotFoundException(); + } + } else { + throw new ForbiddenException(); + } + } + /* * ======== Ajout d'une offre StarPass (affichage) =========== diff --git a/Model/Nano.php b/Model/Nano.php new file mode 100644 index 0000000..cd50bee --- /dev/null +++ b/Model/Nano.php @@ -0,0 +1,2 @@ + array( + 'foreignKey' => 'offer_id' + ) + ); +} diff --git a/SQL/schema.php b/SQL/schema.php index 4c76505..7daf7b0 100755 --- a/SQL/schema.php +++ b/SQL/schema.php @@ -125,6 +125,33 @@ public function after($event = array()) { 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') ); + public $shop__nanos = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), + 'address' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 65, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'name' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 50, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'price' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'money' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__nano_histories = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), + 'block_hash' => array('type' => 'string', 'null' => false, 'length' => 64, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'offer_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'payment_amount' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'credits_gived' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 10, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + public $shop__paysafecard_histories = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), 'code' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), diff --git a/View/Payment/admin_add_nano.ctp b/View/Payment/admin_add_nano.ctp new file mode 100644 index 0000000..d1dd9a5 --- /dev/null +++ b/View/Payment/admin_add_nano.ctp @@ -0,0 +1,42 @@ +
+
+
+
+
+

get('SHOP__NANO_OFFER_ADD') ?>

+
+
+
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ get('GLOBAL__CANCEL') ?> + +
+
+
+
+
+
+
diff --git a/View/Payment/admin_edit_nano.ctp b/View/Payment/admin_edit_nano.ctp new file mode 100644 index 0000000..7eda328 --- /dev/null +++ b/View/Payment/admin_edit_nano.ctp @@ -0,0 +1,42 @@ +
+
+
+
+
+

get('SHOP__NANO_OFFER_EDIT') ?>

+
+
+
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ get('GLOBAL__CANCEL') ?> + +
+
+
+
+
+
+
diff --git a/View/Payment/admin_index.ctp b/View/Payment/admin_index.ctp index 4a2cf45..7a407a0 100755 --- a/View/Payment/admin_index.ctp +++ b/View/Payment/admin_index.ctp @@ -18,7 +18,8 @@ table tr td:last-child > div.btn-group {