01bd83f6 by Kevin Burton

removed the CAN SPAM link in notifications - to be added in CBV Settings System

1 parent 78755781
1 <?php 1 <?php
2 namespace Tz\WordPress\Tools\Notifications\Settings; 2 namespace Tz\WordPress\Tools\Notifications\Settings;
3 error_reporting(E_ALL^E_DEPRECATED); 3 //error_reporting(E_ALL^E_DEPRECATED);
4 4
5 use Tz\WordPress\Tools; 5 use Tz\WordPress\Tools;
6 use Tz\Common; 6 use Tz\Common;
...@@ -9,13 +9,21 @@ use Tz\WordPress\Tools\Notifications\Validation; ...@@ -9,13 +9,21 @@ use Tz\WordPress\Tools\Notifications\Validation;
9 9
10 const CAPABILITY = "manage_notifications"; 10 const CAPABILITY = "manage_notifications";
11 const MANAGE_SYSTEM_NOTIFICATIONS = "create_system_notifications"; 11 const MANAGE_SYSTEM_NOTIFICATIONS = "create_system_notifications";
12 const SETTING_NS = 'canspam_settings';
13 const ADMIN_PAGE = "canspam_admin";
12 14
13 call_user_func(function() { 15 call_user_func(function() {
14 $role = get_role('administrator'); 16 $role = get_role('administrator');
15 $role->add_cap(CAPABILITY); 17 $role->add_cap(CAPABILITY);
16 $role->add_cap(MANAGE_SYSTEM_NOTIFICATIONS); 18 $role->add_cap(MANAGE_SYSTEM_NOTIFICATIONS);
17 //$role->remove_cap(SUB_ADMIN_CAPABILITY); 19 //$role->remove_cap(SUB_ADMIN_CAPABILITY);
20
21 Vars::$settings = new Tools\WP_Option(SETTING_NS);
22
18 Tools\add_actions(__NAMESPACE__ . '\Actions'); 23 Tools\add_actions(__NAMESPACE__ . '\Actions');
24
25
26
19 }); 27 });
20 28
21 function display_page() { 29 function display_page() {
...@@ -244,20 +252,7 @@ function fixFilesArray(&$files) ...@@ -244,20 +252,7 @@ function fixFilesArray(&$files)
244 252
245 function notification_settings() { 253 function notification_settings() {
246 254
247 global $wpdb; 255 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'settings.php');
248 $validation = new Notifications\Validation;
249 $validation->set_rules('company','Company','required|trim');
250 $validation->set_rules('address','Address','required|trim');
251 $validation->set_rules('city','City','required|trim');
252 $validation->set_rules('province','Province','required|trim');
253 $validation->set_rules('postal','POstal Code','required|trim');
254 $validation->set_rules('std_message','Standard Message','required|trim');
255 $validation->set_rules('opt_message','OPT-OUT Message','required|trim');
256
257 if ($validation->run() == TRUE) {
258 } else {
259 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'settings.php');
260 }
261 256
262 257
263 258
...@@ -396,14 +391,20 @@ class Actions { ...@@ -396,14 +391,20 @@ class Actions {
396 public static function admin_menu() { 391 public static function admin_menu() {
397 add_menu_page('Notifications','Notifications',CAPABILITY,'notifications',__NAMESPACE__ . '\display_page' ); 392 add_menu_page('Notifications','Notifications',CAPABILITY,'notifications',__NAMESPACE__ . '\display_page' );
398 add_submenu_page('notifications','New Notification', 'New Notification',CAPABILITY,'notifications-create-new',__NAMESPACE__ . '\create_notification'); 393 add_submenu_page('notifications','New Notification', 'New Notification',CAPABILITY,'notifications-create-new',__NAMESPACE__ . '\create_notification');
399 add_submenu_page('notifications','CAN-SPAM Settings', 'CAN-SPAM Settings',CAPABILITY,'notifications-settings',__NAMESPACE__ . '\notification_settings'); 394 //add_options_page('CAN-SPAM Settings', 'CAN-SPAM Settings', CAPABILITY, ADMIN_PAGE, __NAMESPACE__ . '\notification_settings');
395 //add_submenu_page('notifications','CAN-SPAM Settings', 'CAN-SPAM Settings',CAPABILITY,'notifications-settings',__NAMESPACE__ . '\notification_settings');
400 } 396 }
401 397
402 public function admin_init() { 398 public function admin_init() {
403 register_setting(Notifications\OPTION_NAME, Notifications\OPTION_NAME); 399 // register_setting(Notifications\OPTION_NAME, Notifications\OPTION_NAME);
400 register_setting(SETTING_NS, SETTING_NS);
404 } 401 }
405 402
406 } 403 }
407 404
405 class Vars {
406 public static $settings;
407 }
408
408 409
409 ?> 410 ?>
...\ No newline at end of file ...\ No newline at end of file
......
1 <?php 1 <?php
2 use Tz\WordPress\Tools\Notifications\Settings; 2 namespace Tz\WordPress\Tools\Notifications\Settings;
3 use Tz\WordPress\Tools\Notifications;
4 use Tz\WordPress\Tools;
5
6 ?> 3 ?>
7 4
8 <link type="text/css" href="<?php echo Tools\url('assets/css/smoothness/jquery-ui-1.8.4.custom.css', __FILE__)?>" rel="stylesheet" />
9 <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/jquery-1.4.2.min.js', __FILE__)?>"></script>
10 <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/jquery-ui-1.8.4.custom.min.js', __FILE__)?>"></script>
11 <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/datetimepicker.js', __FILE__)?>"></script>
12 <link rel="stylesheet" href="<?php echo Tools\url('assets/css/notifications.css', __FILE__)?>" />
13
14 <div id="" class="wrap"> 5 <div id="" class="wrap">
15 6
16 <h2>Notifications - Settings</h2> 7 <h2>Notifications - Settings</h2>
17 <p>In order to comply with the CAN-SPAM act, each outgoing email must include the following:</p> 8 <p>In order to comply with the CAN-SPAM act, each outgoing email must include the following:</p>
18 9
19 10
20 <form enctype="multipart/form-data" method="post" action="options.php"> 11 <form method="post" action="options.php">
21 12 <?php settings_fields(SETTING_NS); ?>
22 <input type="hidden" name="_POSTED_" value="yes" /> 13
23
24 <table cellspacing="0" class="widefat post fixed" style="margin-top:15px;"> 14 <table cellspacing="0" class="widefat post fixed" style="margin-top:15px;">
25 <thead> 15 <thead>
26 <tr> 16 <tr>
...@@ -31,20 +21,24 @@ use Tz\WordPress\Tools; ...@@ -31,20 +21,24 @@ use Tz\WordPress\Tools;
31 <tbody> 21 <tbody>
32 <tr> 22 <tr>
33 <td width="150">Company Name:</td> 23 <td width="150">Company Name:</td>
34 <td><input type="text" name="company" class="wide-input-field" /></td> 24 <?php $wp_option = SETTING_NS . '[company]'; ?>
25 <td><input type="text" id="<?php echo $wp_option; ?>" name="<?php echo $wp_option; ?>" value="<?php echo Vars::$settings['company'];?>" /></td>
35 </tr> 26 </tr>
36 <tr> 27 <tr>
37 <td width="150">Address:</td> 28 <td width="150">Address:</td>
38 <td><input type="text" name="address" class="wide-input-field" /></td> 29 <?php $wp_option = SETTING_NS . '[address]'; ?>
30 <td><input type="text" id="<?php echo $wp_option; ?>" name="<?php echo $wp_option; ?>" value="<?php echo Vars::$settings['address'];?>" /></td>
39 </tr> 31 </tr>
40 <tr> 32 <tr>
41 <td width="150">City:</td> 33 <td width="150">City:</td>
42 <td><input type="text" name="city" class="wide-input-field" /></td> 34 <?php $wp_option = SETTING_NS . '[city]'; ?>
35 <td><input type="text" id="<?php echo $wp_option; ?>" name="<?php echo $wp_option; ?>" value="<?php echo Vars::$settings['city'];?>" /></td>
43 </tr> 36 </tr>
44 <tr> 37 <tr>
45 <td width="150">Province:</td> 38 <td width="150">Province:</td>
46 <td> 39 <td>
47 <select name="province" class="wide-input-field" > 40 <?php $wp_option = SETTING_NS . '[province]'; ?>
41 <select name="<?php echo $wp_option; ?>" class="wide-input-field" >
48 <option value="Ontario">Ontario</option> 42 <option value="Ontario">Ontario</option>
49 <option value="Quebec">Quebec</option> 43 <option value="Quebec">Quebec</option>
50 <option value="Nova Scotia">Nova Scotia</option> 44 <option value="Nova Scotia">Nova Scotia</option>
...@@ -60,7 +54,8 @@ use Tz\WordPress\Tools; ...@@ -60,7 +54,8 @@ use Tz\WordPress\Tools;
60 </tr> 54 </tr>
61 <tr> 55 <tr>
62 <td width="150">Postal Code:</td> 56 <td width="150">Postal Code:</td>
63 <td><input type="text" name="postal" /></td> 57 <?php $wp_option = SETTING_NS . '[postal]'; ?>
58 <td><input type="text" id="<?php echo $wp_option; ?>" name="<?php echo $wp_option; ?>" value="<?php echo Vars::$settings['postal'];?>" /></td>
64 </tr> 59 </tr>
65 </body> 60 </body>
66 </table> 61 </table>
...@@ -74,12 +69,14 @@ use Tz\WordPress\Tools; ...@@ -74,12 +69,14 @@ use Tz\WordPress\Tools;
74 </thead> 69 </thead>
75 <tbody> 70 <tbody>
76 <tr> 71 <tr>
77 <td width="150">Standard Message:</td> 72 <td width="150">Standard Message:</td><!-- -->
78 <td><textarea name="std_message" class="wide-input-field" rows="4" style="width:100%;color:#999" onkeydown="this.style.color = '#000000';">This email was sent to ({email}) because you have agreed to receive periodic emails from us. To ensure that you continue receiving our emails, please add us to your address book or safe list.</textarea></td> 73 <?php $wp_option = SETTING_NS . '[std_message]'; ?>
74 <td><textarea id="<?php echo $wp_option; ?>" name="<?php echo $wp_option; ?>" class="wide-input-field" rows="4" style="width:100%;color:#999" onkeydown="this.style.color = '#000000';"><?php echo Vars::$settings['std_message'];?></textarea></td>
79 </tr> 75 </tr>
80 <tr> 76 <tr>
81 <td width="150">OPT-OUT Message::</td> 77 <td width="150">OPT-OUT Message:</td><!-- -->
82 <td><textarea name="opt_message" class="wide-input-field" rows="4" style="width:100%;color:#999" onkeydown="this.style.color = '#000000';" >If you do not wish to further receive emails from us, you can change your notification settings in your profile.</textarea></td> 78 <?php $wp_option = SETTING_NS . '[opt_message]'; ?>
79 <td><textarea id="<?php echo $wp_option; ?>" name="<?php echo $wp_option; ?>" class="wide-input-field" rows="4" style="width:100%;color:#999" onkeydown="this.style.color = '#000000';" ><?php echo Vars::$settings['opt_message'];?></textarea></td>
83 </tr> 80 </tr>
84 </body> 81 </body>
85 </table> 82 </table>
......