diff --git a/Config/bootstrap.php b/Config/bootstrap.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/Config/bootstrap.php @@ -0,0 +1 @@ + 'Newsletter', 'action' => 'index', 'plugin' => 'Newsletter', 'admin' => true]); +Router::connect('/admin/newsletter/ajax_sendmail', ['controller' => 'Newsletter', 'action' => 'ajax_sendmail', 'plugin' => 'Newsletter', 'admin' => true]); +Router::connect('/newsletter/ajax_updateluser', array('controller' => 'Newsletter', 'action' => 'ajax_updateluser', 'plugin' => 'Newsletter')); diff --git a/Controller/NewsletterAppController.php b/Controller/NewsletterAppController.php new file mode 100644 index 0000000..a24a291 --- /dev/null +++ b/Controller/NewsletterAppController.php @@ -0,0 +1,16 @@ +User->find('all', array('conditions' => array('User.newsletter-state' => array("true")))); + foreach($usersNLetter as $user): + sleep(0.5); + try { + $this->Util->prepareMail($user['User']['email'], $subject, $message)->sendMail(); + }catch(SocketException $e){ + continue; + } + endforeach; + } + +} diff --git a/Controller/NewsletterController.php b/Controller/NewsletterController.php new file mode 100644 index 0000000..96586c6 --- /dev/null +++ b/Controller/NewsletterController.php @@ -0,0 +1,40 @@ +layout = "admin"; + $usersNLetter = $this->User->find('all', array('conditions' => array('User.newsletter-state' => array("true")))); + $this->set(compact('usersNLetter')); + $this->set('title_for_layout', 'Newsletter | Envoie de mails'); + } + + function admin_ajax_sendmail(){ + if(!$this->isConnected || !$this->User->isAdmin()) + throw new ForbiddenException(); + if(!$this->request->is('post')) + throw new BadRequestException(); + $this->layout = null; + $this->autoRender = false; + $data = $this->request->data; + if(empty($data['subjet_msg']) && empty($data['mail_msg'])) + return $this->sendJSON(['statut' => false, 'msg' => "Vous devez remplir tout les champs"]); + $this->sendMailNewsletter($data['subjet_msg'], $data['mail_msg']); + $this->sendJSON(['statut' => true, 'msg' => "Le mail a bien été envoyé ! Veuillez patienter quelque instants le temps que le serveur envoi touts les mails"]); + } + + function ajax_updateluser(){ + if(!$this->isConnected) + throw new ForbiddenException(); + if(!$this->request->is('post')) + throw new BadRequestException(); + $this->layout = null; + $this->autoRender = false; + $data = $this->request->data; + if(empty($data)) + return $this->sendJSON(['statut' => false, 'msg' => "Vous devez remplir tout les champs"]); + if($data['newsletter-value'] != "true" && $data['newsletter-value'] != "false") + return $this->sendJSON(['statut' => false, 'msg' => "Une erreur lors du paramètrage est survenue"]); + $this->User->setKey('newsletter-state', $data['newsletter-value']); + $this->sendJSON(['statut' => true, 'msg' => "Vos paramètres ont été enregistrés avec succès !"]); + } +} diff --git a/Model/Info.php b/Model/Info.php new file mode 100644 index 0000000..942c114 --- /dev/null +++ b/Model/Info.php @@ -0,0 +1,17 @@ +find('all'); + } + + public function _delete($id){ + return $this->delete($id); + } + + public function add($pseudo, $date){ + $this->create(); + $this->set(['pseudo' => $pseudo, 'date' => $date]); + return $this->save(); + } +} \ No newline at end of file diff --git a/Model/TutorialAppModel.php b/Model/TutorialAppModel.php new file mode 100644 index 0000000..764086d --- /dev/null +++ b/Model/TutorialAppModel.php @@ -0,0 +1,4 @@ + +

NewsLetter

+
+
+ +
+ La NewsLetter vous permez de rester informé des nouveautés du serveur ! +
+ > + +
+
+ > + +
+
+ +
diff --git a/SQL/schema.php b/SQL/schema.php new file mode 100644 index 0000000..050f4ca --- /dev/null +++ b/SQL/schema.php @@ -0,0 +1,15 @@ + array('type' => 'string', 'null' => false, 'default' => 'true', 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1') + ]; +} diff --git a/View/Newsletter/admin_index.ctp b/View/Newsletter/admin_index.ctp new file mode 100644 index 0000000..cc10c6a --- /dev/null +++ b/View/Newsletter/admin_index.ctp @@ -0,0 +1,34 @@ +
+
+
+
+
+

get('NEWSLETTER__TITLE') ?>

+
+
+ Nombre d'utilisateurs ayant activé la NewsLetter: +
+
+ +
+ + Html->script('admin/tinymce/tinymce.min.js') ?> + + +
+ +
+
+
+
+
+
diff --git a/config.json b/config.json new file mode 100644 index 0000000..706a33b --- /dev/null +++ b/config.json @@ -0,0 +1 @@ +{"name":"NewsLetter","admin_menus":{"GLOBAL__ADMIN_GENERAL":{"NewsLetter":{"icon":"envelope-o","route":"/admin/newsletter"}}},"author":"EmpireDev","version":"1.0.3","apiID":136,"useEvents":false,"permissions":{"available":[],"default":{"0":[],"2":[]}},"requirements":{"CMS":"^1.2.0"}} \ No newline at end of file diff --git a/lang/en_US.json b/lang/en_US.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/lang/en_US.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/lang/fr_FR.json b/lang/fr_FR.json new file mode 100644 index 0000000..8228662 --- /dev/null +++ b/lang/fr_FR.json @@ -0,0 +1,3 @@ +{ + "NEWSLETTER__TITLE": "Newsletter" +} diff --git a/secure b/secure new file mode 100644 index 0000000..b1b77a7 --- /dev/null +++ b/secure @@ -0,0 +1 @@ +["QBU1F5m91hB0sRc6WyYEY1v9I3NtrK4KGos6kf/rg5AIMkVLQ23gFIsmOrHljH4FG5B9emxX5lPESDMk6eUTiRjk2MsPKTE0Op9WDNh4U7uY87GXccGy7rNZdw48j3T0utD6hId8yy6d14Bnq3q1OEOBhawxrPg977nbYoOCHaVsuazWiGBUp4rMglEO+lFLBzsjZ4j9oIFo+0ijODO46dz8+KqCn/rs4yDHHwzo/OrGyKo5YdXdrW8G/Zc/HOvDo7WPR35p0tvq+bwPylmfk2CQZ3SGmThXV8UkGWVOMMsSmlheWTw3JNJt4HXT9ONaBec1O664ViKrmV+ne/O+Og==","c1cc74a3cf217ea433bdb74d3b1d5d42dde4e2c595d7eac80bd099601d32ff64ea53c7ba9a9204511d2303f6ec4d8502bed85a58713e8d9e300e96454fc84819a8db71803d7abdee66683987d0b9b6e3fe72031a9f351edada2115866cd7a9c7878c19974635fbc363644f68ac5cc724b9df998786014aceeee3f8c8678ff7e848edf53b9c7c5b7a39d10b96008475780620c2d007a19e51dbd6cedc26b1048375ec219d3316970287b2ba403a346fcd8cc1db444c88a96ad3af13e0c1057bb278fdfa0feb07278f6e4520f5c2878294ee9f1eb19c51bcf67c2fee379f531c43fe1ea01ddf53f723f0f1660270f3b272eede05ccb7c19a499fdc7e2d7361bf47514a92249098f8eddebfdc26cafa181035b57cb3be2b1a9885607f5b712ca6725e568e009f63eb8a34397b0aff31119d40e5afc731d270631cc65dd4079cbe676c7c4beb826422f5500590a574ff7f791a60c6b8688f13d0e1e9863728511ebeb76a4811ffb6e2ad766dd37f123a999d387f54271e9491c53763c872b1576ba3c80e9372f1e62279264e35f897769aab35e0e5d53b46f12bbc7505ec83086a494e63301affc561fb68ab09260a480705caae079eef1f7f74b7f7114188edbf63e6413f7a1a808debcff21838e2fbeed7d3f331761c9cc9e2d55786592fd40b9a440b57a3f949d7bc96652e9b9df2f0352396f428de34c16e9c01aa4d7740d29ca184cd9b6a4a77bbbc0e84f0b3f4224799e25fa3035ce7e7e37f50ddda4fbcfd7df09a6bebbeade6ede63ee8ebb4afcdaa3431c997a8a984d8c142225fb66b60ce5acd57549e7285a45798bd8b74a735be13a6b7c973e86ebedf53e4e73a5e23f3938ded2eb6e73455ed200c7b5df558935947c447d318db185f9bedaf95f1b811d37019599ada80d1bacf983b97b69fa2e9da1dfaa7858d456489f3a42a4a83214020e3d99ba49d973b6e02ee9d5457b406df4c8225bad3c87a1369efa49819d5627e7e664a3bd06b7da5b8363aaccea68e0fc7e916e8e29385c8383f172583a0d728181e52b6897272f9d631b46a3e20fc591f462618da770326057bf5b96ed8b104056f2a9b103918903e9b1e1f34b6e737baa00d8097435cdcfeb61b07847e0ba6d02ea9811b4063375d7a51ed47c1489859128c870186608b141ec6d6e376848b14fa56c5a1016fdd3079930b812d8be9bd970a2d52c6e8865ff6f90a24e0cf6bb5c944dd7db3dfb7561baf0921414d7149fb64babc18e05a7b3ff9c3969ee18d1740111e0d224b68d9c428e927d322b56331886249fa0c7bdf73b29ef3"] \ No newline at end of file