-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e7cb23a
Showing
13 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?php | ||
Router::connect('/admin/newsletter', ['controller' => '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')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
class NewsletterAppController extends AppController { | ||
|
||
public function sendMailNewsletter($subject, $message){ | ||
$usersNLetter = $this->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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
class NewsletterController extends NewsletterAppController{ | ||
|
||
function admin_index(){ | ||
$this->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 !"]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
class Info extends TutorialAppModel{ | ||
|
||
public function get(){ | ||
return $this->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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?php | ||
class TutorialAppModel extends AppModel{ | ||
public $tablePrefix = 'tutorial__'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<hr> | ||
<h3>NewsLetter</h3> | ||
<form method="post" data-ajax="true" data-redirect-url="?" action="<?= $this->Html->url(array('controller' => 'newsletter', 'action' => 'ajax_updateluser')) ?>"> | ||
<div class="form-group"> | ||
<label>Qu'est-ce que c'est la NewsLetter ?</label> | ||
<br> | ||
<small>La NewsLetter vous permez de rester informé des nouveautés du serveur !</small> | ||
<div class="radio"> | ||
<input type="radio" name="newsletter-value" value="true" <?= ($user['newsletter-state'] == 'true') ? 'checked=""' : '' ?>> | ||
<label><?= $Lang->get('GLOBAL__ENABLE') ?></label> | ||
</div> | ||
<div class="radio"> | ||
<input type="radio" name="newsletter-value" value="false" <?= ($user['newsletter-state'] == 'false') ? 'checked=""': '' ?>> | ||
<label><?= $Lang->get('GLOBAL__DISABLE') ?></label> | ||
</div> | ||
</div> | ||
<button type="submit" class="btn btn-primary"><?= $Lang->get('GLOBAL__SUBMIT'); ?></button> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
class NewsletterAppSchema extends CakeSchema { | ||
|
||
public $file = 'schema.php'; | ||
|
||
public function before($event = []) { | ||
return true; | ||
} | ||
|
||
public function after($event = []) {} | ||
|
||
public $users = [ | ||
'newsletter-state' => array('type' => 'string', 'null' => false, 'default' => 'true', 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1') | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<section class="content"> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="box"> | ||
<div class="box-header with-border"> | ||
<h3 class="box-title"><?= $Lang->get('NEWSLETTER__TITLE') ?></h3> | ||
</div> | ||
<div class="box-body"> | ||
Nombre d'utilisateurs ayant activé la NewsLetter: <b><?= count($usersNLetter); ?></b> | ||
<hr> | ||
<form method="post" class="form-horizontal" data-ajax="true" data-redirect-url="?" action="<?= $this->Html->url(array('controller' => 'Newsletter', 'action' => 'ajax_sendmail')) ?>"> | ||
<label>Objet du mail</label> | ||
<input type="text" class="form-control" name="subjet_msg"><br /> | ||
<label>Message du mail</label> | ||
<?= $this->Html->script('admin/tinymce/tinymce.min.js') ?> | ||
<script type="text/javascript"> | ||
tinymce.init({ | ||
selector: "textarea", | ||
height : 300, | ||
width : '100%', | ||
language : 'fr_FR', | ||
plugins: "textcolor code image link", | ||
toolbar: "fontselect fontsizeselect bold italic underline strikethrough link image forecolor backcolor alignleft aligncenter alignright alignjustify cut copy paste bullist numlist outdent indent blockquote code" | ||
}); | ||
</script> | ||
<textarea id="editor" name="mail_msg" cols="30" rows="10"></textarea> | ||
<hr> | ||
<button class="btn btn-primary"><?= $Lang->get('GLOBAL__SUBMIT'); ?></button> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"NEWSLETTER__TITLE": "Newsletter" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["QBU1F5m91hB0sRc6WyYEY1v9I3NtrK4KGos6kf/rg5AIMkVLQ23gFIsmOrHljH4FG5B9emxX5lPESDMk6eUTiRjk2MsPKTE0Op9WDNh4U7uY87GXccGy7rNZdw48j3T0utD6hId8yy6d14Bnq3q1OEOBhawxrPg977nbYoOCHaVsuazWiGBUp4rMglEO+lFLBzsjZ4j9oIFo+0ijODO46dz8+KqCn/rs4yDHHwzo/OrGyKo5YdXdrW8G/Zc/HOvDo7WPR35p0tvq+bwPylmfk2CQZ3SGmThXV8UkGWVOMMsSmlheWTw3JNJt4HXT9ONaBec1O664ViKrmV+ne/O+Og==","c1cc74a3cf217ea433bdb74d3b1d5d42dde4e2c595d7eac80bd099601d32ff64ea53c7ba9a9204511d2303f6ec4d8502bed85a58713e8d9e300e96454fc84819a8db71803d7abdee66683987d0b9b6e3fe72031a9f351edada2115866cd7a9c7878c19974635fbc363644f68ac5cc724b9df998786014aceeee3f8c8678ff7e848edf53b9c7c5b7a39d10b96008475780620c2d007a19e51dbd6cedc26b1048375ec219d3316970287b2ba403a346fcd8cc1db444c88a96ad3af13e0c1057bb278fdfa0feb07278f6e4520f5c2878294ee9f1eb19c51bcf67c2fee379f531c43fe1ea01ddf53f723f0f1660270f3b272eede05ccb7c19a499fdc7e2d7361bf47514a92249098f8eddebfdc26cafa181035b57cb3be2b1a9885607f5b712ca6725e568e009f63eb8a34397b0aff31119d40e5afc731d270631cc65dd4079cbe676c7c4beb826422f5500590a574ff7f791a60c6b8688f13d0e1e9863728511ebeb76a4811ffb6e2ad766dd37f123a999d387f54271e9491c53763c872b1576ba3c80e9372f1e62279264e35f897769aab35e0e5d53b46f12bbc7505ec83086a494e63301affc561fb68ab09260a480705caae079eef1f7f74b7f7114188edbf63e6413f7a1a808debcff21838e2fbeed7d3f331761c9cc9e2d55786592fd40b9a440b57a3f949d7bc96652e9b9df2f0352396f428de34c16e9c01aa4d7740d29ca184cd9b6a4a77bbbc0e84f0b3f4224799e25fa3035ce7e7e37f50ddda4fbcfd7df09a6bebbeade6ede63ee8ebb4afcdaa3431c997a8a984d8c142225fb66b60ce5acd57549e7285a45798bd8b74a735be13a6b7c973e86ebedf53e4e73a5e23f3938ded2eb6e73455ed200c7b5df558935947c447d318db185f9bedaf95f1b811d37019599ada80d1bacf983b97b69fa2e9da1dfaa7858d456489f3a42a4a83214020e3d99ba49d973b6e02ee9d5457b406df4c8225bad3c87a1369efa49819d5627e7e664a3bd06b7da5b8363aaccea68e0fc7e916e8e29385c8383f172583a0d728181e52b6897272f9d631b46a3e20fc591f462618da770326057bf5b96ed8b104056f2a9b103918903e9b1e1f34b6e737baa00d8097435cdcfeb61b07847e0ba6d02ea9811b4063375d7a51ed47c1489859128c870186608b141ec6d6e376848b14fa56c5a1016fdd3079930b812d8be9bd970a2d52c6e8865ff6f90a24e0cf6bb5c944dd7db3dfb7561baf0921414d7149fb64babc18e05a7b3ff9c3969ee18d1740111e0d224b68d9c428e927d322b56331886249fa0c7bdf73b29ef3"] |