5f1bcaad by Kevin Burton

Notifications System - starting of it.

1 parent a72b2dd4
Showing 46 changed files with 760 additions and 0 deletions
...@@ -47,3 +47,9 @@ ...@@ -47,3 +47,9 @@
47 margin-top: -28px; 47 margin-top: -28px;
48 } 48 }
49 #TzBrandingFooter a { color:#fff; text-decoration:none; } 49 #TzBrandingFooter a { color:#fff; text-decoration:none; }
50
51 #wpcontent {
52 /*background: #FFFFFF url(../images/backing.gif) top left repeat-y;*/
53 }
54
55 .update-nag { display:none; }
...\ No newline at end of file ...\ No newline at end of file
......
1 <?php
2 namespace Tz\WordPress\Tools\Notifications\Settings;
3 error_reporting(E_ALL^E_DEPRECATED);
4
5 use Tz\WordPress\Tools;
6 use Tz\Common;
7 use Tz\WordPress\Tools\Notifications;
8
9 const CAPABILITY = "manage_notifications";
10 const MANAGE_SYSTEM_NOTIFICATIONS = "create_system_notifications";
11
12 call_user_func(function() {
13 $role = get_role('administrator');
14 $role->add_cap(CAPABILITY);
15 $role->add_cap(MANAGE_SYSTEM_NOTIFICATIONS);
16 //$role->remove_cap(SUB_ADMIN_CAPABILITY);
17 Tools\add_actions(__NAMESPACE__ . '\Actions');
18 });
19
20 function display_page() {
21
22
23 if (isset($_GET['action']) && $_GET['action']=="edit") {
24 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'edit.php');
25
26 } else {
27
28 if (isset($_GET['action']) && $_GET['action']=="delete") {
29 wp_delete_post($_GET['page_id'],true);
30
31 } elseif (isset($_GET['action']) && $_GET['action']=="delete") {
32
33 $id = $_GET['page_id'];
34
35 $postdata = get_post_meta($id,'details',true);
36 $postdata['status'] = "archived";
37
38 update_post_meta($id,'details',$postdata);
39
40 }
41
42
43 // get all the notifications that status != "archived";
44 $notifications = array();
45 $notifications['triggered'] = array();
46 $notifications['scheduled'] = array();
47
48 $args = array(
49 'post_type' => 'notifications'
50 , 'numberposts' => -1
51 , 'orderby' => 'modified'
52 , 'order' => 'desc'
53 );
54
55
56 foreach(get_posts($args) as $entry) {
57 $id = $entry->ID;
58
59 $details = get_post_meta($id,'details',true);
60 $email = get_post_meta($id,'email',true);
61 $system = get_post_meta($id,'system',true);
62 $sms = get_post_meta($id,'sms',true);
63
64 $entry->trigger = $details['trigger'];
65 $entry->status = isset($details['status']) ? $details['status'] : "active";
66 $entry->type = $details['type'];
67 $entry->sendto = $details['sendto'];
68
69 $entry->is_email = (($email['text'] != "" || $email['html'] != "")) ? true : false;
70 $entry->is_system = ($system != "") ? true : false;
71 $entry->is_sms = ($sms != "") ? true : false;
72
73 $entry->execute_date = $details['execute_date'];
74
75 if ($entry->status != "archived") {
76 $notifications[$entry->type][] = $entry;
77 }
78
79
80 }
81
82 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin.php');
83
84
85
86 }
87
88
89
90 }
91
92 function mysqldatetime_to_timestamp($datetime = "")
93 {
94 // function is only applicable for valid MySQL DATETIME (19 characters) and DATE (10 characters)
95 $l = strlen($datetime);
96 if(!($l == 10 || $l == 19))
97 return 0;
98
99 //
100 $date = $datetime;
101 $hours = 0;
102 $minutes = 0;
103 $seconds = 0;
104
105 // DATETIME only
106 if($l == 19)
107 {
108 list($date, $time) = explode(" ", $datetime);
109 list($hours, $minutes, $seconds) = explode(":", $time);
110 }
111
112 list($year, $month, $day) = explode("-", $date);
113
114 return mktime($hours, $minutes, $seconds, $month, $day, $year);
115 }
116
117 function fixFilesArray(&$files)
118 {
119 $names = array( 'name' => 1, 'type' => 1, 'tmp_name' => 1, 'error' => 1, 'size' => 1);
120
121 foreach ($files as $key => $part) {
122 // only deal with valid keys and multiple files
123 $key = (string) $key;
124 if (isset($names[$key]) && is_array($part)) {
125 foreach ($part as $position => $value) {
126 $files[$position][$key] = $value;
127 }
128 // remove old key reference
129 unset($files[$key]);
130 }
131 }
132 }
133
134 function create_trigger_notification() {
135 print "hello";
136 }
137
138 function notification_settings() {
139 print "settings";
140 }
141
142 function create_notification() {
143
144 global $wpdb;
145
146
147 if ($_POST && isset($_POST['_POSTED_']) && $_POST['_POSTED_']=="yes") {
148
149 // ok, so now we need to create the notification.
150 class postTemplate {
151 var $post_title = '';
152 var $post_content = '';
153 var $post_status = 'publish';
154 var $post_type = 'notifications';
155 var $comment_status = 'closed';
156 }
157
158 //details
159 $type = $_POST['type'];
160 $title = $_POST['title'];
161 $sendto = $_POST['sendto'];
162 $execute_date = ($type=="scheduled") ? $_POST['execute_date'] : "0000-00-00 00:00:00";
163 $trigger = ($type=="scheduled") ? "scheduled-cron-job" : $_POST['trigger'];
164
165 // email
166 $subject = $_POST['subject'];
167 $text = $_POST['text'];
168 $html = $_POST['html'];
169 $attachments = array();
170 $upload_dir = __DIR__ . "/uploads/";
171 fixFilesArray($_FILES['attachment']);
172 foreach ($_FILES['attachment'] as $position => $file) {
173 // should output array with indices name, type, tmp_name, error, size
174 if($file['name'] != "") {
175 move_uploaded_file($file['tmp_name'],$upload_dir . $file['name']);
176 $attachments[] = $file['name'];
177 }
178 }
179
180 // system
181 $system = $_POST['system'];
182
183 // SMS
184 $sms = $_POST['sms'];
185
186
187 // make post...
188
189 $notification = new postTemplate();
190 $notification->post_title = $title;
191 $notification->post_content = "Notification created ".date('Y-m-d H:i:s')." --- to be sent on $execute_date";
192 $notification->post_date_gmt = date("Y-m-d H:i:s",time());
193
194 $id = wp_insert_post($notification);
195
196 add_post_meta($id, "details", array(
197 'type' => $type
198 , 'sendto' => $sendto
199 , 'status' => 'pending'
200 , 'trigger' => $trigger
201 , 'execute_date' => $execute_date
202 ));
203
204 add_post_meta($id, "email", array(
205 'subject' => $subject
206 , 'text' => $text
207 , 'html' => $html
208 , 'attachments' => $attachments
209 ));
210 add_post_meta($id, "system", $system);
211 add_post_meta($id, "sms", $sms);
212
213
214 $flash = "Notification Saved Successfully!";
215 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php');
216
217 } else {
218 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php');
219 }
220
221
222 }
223
224 class Actions {
225
226 public static function init() {
227 global $wpdb;
228 $wpdb->show_errors();
229
230 register_post_type( 'notifications', array(
231 'label' => __('Notifs')
232 , 'public' => true
233 , 'show_ui' => false
234 , 'hierarchical' => false
235 , 'exclude_from_search' => true
236 ));
237
238 }
239
240 public static function admin_menu() {
241 add_menu_page('Notifications','Notifications',CAPABILITY,'notifications',__NAMESPACE__ . '\display_page' );
242 add_submenu_page('notifications','New Notification', 'New Notification',CAPABILITY,'notifications-create-new',__NAMESPACE__ . '\create_notification');
243 add_submenu_page('notifications','Settings', 'Settings',CAPABILITY,'notifications-settings',__NAMESPACE__ . '\notification_settings');
244 }
245
246 public function admin_init() {
247 register_setting(Notifications\OPTION_NAME, Notifications\OPTION_NAME);
248 }
249
250 }
251
252
253 ?>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 namespace Tz\WordPress\Tools\Notifications;
3
4 use Tz\WordPress\Tools;
5 use Tz\Common;
6
7
8 const OPTION_NAME = "notif_options";
9
10 call_user_func(function() {
11 Vars::$options = new Tools\WP_Option(OPTION_NAME);
12 if (is_admin()) {
13 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'Admin.php');
14 }
15 });
16
17
18 /**
19 Send Notifications
20 @trigger = notification unique slug name
21 @user = user id (to get email and name)
22 @type = instant or cron
23 */
24 function send_notification($trigger="NO_TRIGGER",$user=0,$type="instant") {
25
26 }
27
28
29 function current_url() {
30 $pageURL = 'http';
31 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
32 $pageURL .= "://";
33 if ($_SERVER["SERVER_PORT"] != "80") {
34 $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
35 } else {
36 $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
37 }
38 return $pageURL;
39 }
40
41
42 class Vars {
43 public static $options;
44 }
45 ?>
...\ No newline at end of file ...\ No newline at end of file
No preview for this file type
No preview for this file type
No preview for this file type
1 <?php
2 use Tz\WordPress\Tools\Notifications;
3 use Tz\WordPress\Tools\Notifications\Settings;
4 use Tz\WordPress\Tools;
5
6 /*
7
8 print "<pre>";
9 print_r($notifications);
10 print "</pre>";
11
12 */
13
14 ?>
15 <link rel="stylesheet" href="<?php echo Tools\url('assets/css/notifications.css', __FILE__)?>" />
16 <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/jquery.-1.4.2.min.js', __FILE__)?>"></script>
17 <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/jquery.qtip-1.0.0-rc3.js', __FILE__)?>"></script>
18
19
20
21 <div id="" class="wrap">
22 <h2>Notifications</h2>
23 <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam iaculis convallis nisi eu dignissim. Quisque malesuada augue in mi blandit at blandit tortor sollicitudin. Cras at justo mi, vel mollis est. Donec orci erat, blandit varius vehicula vitae, volutpat at lorem. Etiam tincidunt bibendum ante, non tincidunt purus faucibus sed. Suspendisse eget facilisis tellus. Nulla imperdiet leo placerat diam sollicitudin nec mattis neque mattis. Cras id lacus tellus. Phasellus volutpat vehicula porttitor. Praesent erat felis, pharetra mollis egestas sit amet, rhoncus eget nisl. Morbi interdum sapien vitae nibh pharetra scelerisque. Mauris porta accumsan velit ac aliquam. Sed sit amet dictum felis. Fusce tempus vulputate nulla, quis tincidunt velit mattis eu.</p>
24
25 <h3 class="table-caption">Scheduled Notifications</h3>
26 <table cellspacing="0" class="widefat post fixed" style="margin-top:15px;">
27 <thead>
28 <tr>
29 <th scope="col" class="manage-column">Description</th>
30 <th scope="col" width="200" class="manage-column">Execute Date/Time</th>
31 <th scope="col" width="200" class="manage-column">Send To</th>
32 <th scope="col" width="60" class="manage-column">Email</th>
33 <th scope="col" width="60" class="manage-column">System</th>
34 <th scope="col" width="60" class="manage-column">SMS</th>
35 <th scope="col" width="200" class="manage-column">&nbsp;</th>
36 </tr>
37 </thead>
38 <tbody>
39 <?php foreach($notifications['scheduled'] as $entry):?>
40 <tr>
41 <td><?php echo $entry->post_title; ?></td>
42 <td><?php echo $entry->execute_date; ?></td>
43 <td><?php echo $entry->sendto; ?></td>
44 <td><?php if ($entry->is_email): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td>
45 <td><?php if ($entry->is_system): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td>
46 <td><?php if ($entry->is_sms): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td>
47 <td>
48
49 <?php if (Settings\mysqldatetime_to_timestamp($entry->execute_date) < time()):?>
50 <a href="/wp-admin/admin.php?page=notifications&action=archive&page_id=<?php echo $entry->ID; ?>">archive</a>
51 <?php else: ?>
52 <a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a>
53 | <a href="/wp-admin/admin.php?page=notifications&action=delete&page_id=<?php echo $entry->ID; ?>" onclick="return confirm('Are you sure?');">delete</a></td>
54 <?php endif; ?>
55 </tr>
56 <?php endforeach; ?>
57 </tbody>
58 </table>
59
60
61 <h3 class="table-caption">System Triggered Notifications</h3>
62 <table cellspacing="0" class="widefat post fixed" style="margin-top:15px;">
63 <thead>
64 <tr>
65 <th scope="col" class="manage-column">Description</th>
66 <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?>
67 <th scope="col" width="200" class="manage-column">Trigger/Slug</th>
68 <?php endif; ?>
69 <th scope="col" width="200" class="manage-column">Send To</th>
70 <th scope="col" width="60" class="manage-column">Email</th>
71 <th scope="col" width="60" class="manage-column">System</th>
72 <th scope="col" width="60" class="manage-column">SMS</th>
73 <th scope="col" width="200" class="manage-column">&nbsp;</th>
74 </tr>
75 </thead>
76 <tbody>
77 <?php foreach($notifications['triggered'] as $entry):?>
78 <tr>
79 <td><?php echo $entry->post_title; ?></td>
80 <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?>
81 <td><?php echo $entry->trigger; ?></td>
82 <?php endif; ?>
83 <td><?php echo $entry->sendto; ?></td>
84 <td><?php if ($entry->is_email): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td>
85 <td><?php if ($entry->is_system): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td>
86 <td><?php if ($entry->is_sms): ?><img src="<?php echo Tools\url('assets/images/accept.png', __FILE__)?>" /><?php endif;?></td>
87 <td><a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a>
88 <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?>
89 | <a href="/wp-admin/admin.php?page=notifications&action=delete&page_id=<?php echo $entry->ID; ?>" onclick="return confirm('Are you sure?');">delete</a>
90 <?php endif; ?>
91 </td>
92 </tr>
93 <?php endforeach; ?>
94 </tbody>
95 </table>
96
97
98 </div>
...\ No newline at end of file ...\ No newline at end of file
1 h3.table-caption { padding:0; margin:25px 0 0px 0; }
2 .wide-input-field { width:350px;resize: none}
3
4 .post-success {
5 padding:10px;
6 font-size: 12px;
7 background: #ffffcc;
8 color:#88c550;
9 }
10
11 table.expandable thead th {
12 cursor:pointer;
13 }
14
15 table.expandable tbody {
16 background-color:#fdfdee;
17 }
18
19 table.expandable thead th.toggle h6 {
20 background: transparent url(../images/open.png) left no-repeat;
21 padding:0 0 0 16px;
22
23 font-size:11px;
24 margin:0;
25 line-height:1.3em;
26
27 }
28
29 table.expandable thead.open th.toggle h6 {
30 background: transparent url(../images/close.png) left no-repeat;
31 }
32
33 #ui-timepicker-div { margin: 0px 10px; }
34 #ui-timepicker-div dl{ text-align: left; }
35 #ui-timepicker-div dl dt{ height: 25px; font-size: 11px; }
36 #ui-timepicker-div dl dd{ margin: -25px 0 10px 65px; font-size: 11px; }
...\ No newline at end of file ...\ No newline at end of file
1 /*
2 * jQuery timepicker addon
3 * By: Trent Richardson [http://trentrichardson.com]
4 * Version 0.5
5 * Last Modified: 6/16/2010
6 *
7 * Copyright 2010 Trent Richardson
8 * Dual licensed under the MIT and GPL licenses.
9 * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
10 * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
11 *
12 * HERES THE CSS:
13 * #ui-timepicker-div dl{ text-align: left; }
14 * #ui-timepicker-div dl dt{ height: 25px; }
15 * #ui-timepicker-div dl dd{ margin: -25px 0 10px 65px; }
16 */
17 (function($){function Timepicker(){}Timepicker.prototype={$input:null,$timeObj:null,inst:null,hour_slider:null,minute_slider:null,second_slider:null,hour:0,minute:0,second:0,ampm:'',formattedDate:'',formattedTime:'',formattedDateTime:'',defaults:{holdDatepickerOpen:true,showButtonPanel:true,timeOnly:false,showHour:true,showMinute:true,showSecond:false,showTime:true,stepHour:.05,stepMinute:.05,stepSecond:.05,ampm:false,hour:0,minute:0,second:0,timeFormat:'hh:mm tt',alwaysSetTime:true},addTimePicker:function(dp_inst){var tp_inst=this;var currDT=this.$input.val();var regstr=this.defaults.timeFormat.toString().replace(/h{1,2}/ig,'(\\d?\\d)').replace(/m{1,2}/ig,'(\\d?\\d)').replace(/s{1,2}/ig,'(\\d?\\d)').replace(/t{1,2}/ig,'(am|pm|a|p)?').replace(/\s/g,'\\s?')+'$';if(!this.defaults.timeOnly){regstr='\\S{'+this.defaults.timeFormat.length+',}\\s+'+regstr;}var order=this.getFormatPositions();var treg=currDT.match(new RegExp(regstr,'i'));if(treg){if(order.t!==-1)this.ampm=((treg[order.t]==undefined||treg[order.t].length==0)?'':(treg[order.t].charAt(0).toUpperCase()=='A')?'AM':'PM').toUpperCase();if(order.h!==-1){if(this.ampm=='AM'&&treg[order.h]=='12')this.hour=0;else if(this.ampm=='PM'&&treg[order.h]!='12')this.hour=(parseFloat(treg[order.h])+12).toFixed(0);else this.hour=treg[order.h];}if(order.m!==-1)this.minute=treg[order.m];if(order.s!==-1)this.second=treg[order.s];}tp_inst.timeDefined=(treg)?true:false;setTimeout(function(){tp_inst.injectTimePicker(dp_inst,tp_inst);},10);},getFormatPositions:function(){var finds=this.defaults.timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|t{1,2})/g);var orders={h:-1,m:-1,s:-1,t:-1};if(finds){for(var i=0;i<finds.length;i++){if(orders[finds[i].toString().charAt(0)]==-1)orders[finds[i].toString().charAt(0)]=i+1;}}return orders;},injectTimePicker:function(dp_inst,tp_inst){var $dp=$('#'+$.datepicker._mainDivId);var hourMax=23-(23%tp_inst.defaults.stepHour);var minMax=59-(59%tp_inst.defaults.stepMinute);var secMax=59-(59%tp_inst.defaults.stepSecond);if($dp.find("div#ui-timepicker-div").length==0){var html='<div id="ui-timepicker-div">'+'<dl>'+'<dt id="ui_tpicker_time_label"'+((tp_inst.defaults.showTime)?'':' style="display:none;"')+'>Time</dt>'+'<dd id="ui_tpicker_time"'+((tp_inst.defaults.showTime)?'':' style="display:none;"')+'></dd>'+'<dt id="ui_tpicker_hour_label"'+((tp_inst.defaults.showHour)?'':' style="display:none;"')+'>Hour</dt>'+'<dd id="ui_tpicker_hour"'+((tp_inst.defaults.showHour)?'':' style="display:none;"')+'></dd>'+'<dt id="ui_tpicker_minute_label"'+((tp_inst.defaults.showMinute)?'':' style="display:none;"')+'>Minute</dt>'+'<dd id="ui_tpicker_minute"'+((tp_inst.defaults.showMinute)?'':' style="display:none;"')+'></dd>'+'<dt id="ui_tpicker_second_label"'+((tp_inst.defaults.showSecond)?'':' style="display:none;"')+'>Second</dt>'+'<dd id="ui_tpicker_second"'+((tp_inst.defaults.showSecond)?'':' style="display:none;"')+'></dd>'+'</dl>'+'</div>';$tp=$(html);if(tp_inst.defaults.timeOnly==true){$tp.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all"><div class="ui-datepicker-title">Choose Time</div></div>');$dp.find('.ui-datepicker-header, .ui-datepicker-calendar, .ui-datepicker-current').hide();}tp_inst.hour_slider=$tp.find('#ui_tpicker_hour').slider({orientation:"horizontal",value:tp_inst.hour,min:0,max:hourMax,step:tp_inst.defaults.stepHour,slide:function(event,ui){tp_inst.hour_slider.slider("option","value",ui.value);tp_inst.onTimeChange(dp_inst,tp_inst);}});tp_inst.minute_slider=$tp.find('#ui_tpicker_minute').slider({orientation:"horizontal",value:tp_inst.minute,min:0,max:minMax,step:tp_inst.defaults.stepMinute,slide:function(event,ui){tp_inst.minute_slider.slider("option","value",ui.value);tp_inst.onTimeChange(dp_inst,tp_inst);}});tp_inst.second_slider=$tp.find('#ui_tpicker_second').slider({orientation:"horizontal",value:tp_inst.second,min:0,max:secMax,step:tp_inst.defaults.stepSecond,slide:function(event,ui){tp_inst.second_slider.slider("option","value",ui.value);tp_inst.onTimeChange(dp_inst,tp_inst);}});$dp.find('.ui-datepicker-calendar').after($tp);tp_inst.$timeObj=$('#ui_tpicker_time');if(dp_inst!=null){var timeDefined=tp_inst.timeDefined;tp_inst.onTimeChange(dp_inst,tp_inst);tp_inst.timeDefined=timeDefined;}}},onTimeChange:function(dp_inst,tp_inst){var hour=tp_inst.hour_slider.slider('value');var minute=tp_inst.minute_slider.slider('value');var second=tp_inst.second_slider.slider('value');var ampm=(tp_inst.hour<12)?'AM':'PM';var hasChanged=false;if(tp_inst.hour!=hour||tp_inst.minute!=minute||tp_inst.second!=second||(tp_inst.ampm.length>0&&tp_inst.ampm!=ampm))hasChanged=true;tp_inst.hour=parseFloat(hour).toFixed(0);tp_inst.minute=parseFloat(minute).toFixed(0);tp_inst.second=parseFloat(second).toFixed(0);tp_inst.ampm=ampm;tp_inst.formatTime(tp_inst);tp_inst.$timeObj.text(tp_inst.formattedTime);if(hasChanged){tp_inst.updateDateTime(dp_inst,tp_inst);tp_inst.timeDefined=true;}},formatTime:function(inst){var tmptime=inst.defaults.timeFormat.toString();var hour12=((inst.ampm=='AM')?(inst.hour):(inst.hour%12));hour12=(hour12==0)?12:hour12;if(inst.defaults.ampm==true){tmptime=tmptime.toString().replace(/hh/g,((hour12<10)?'0':'')+hour12).replace(/h/g,hour12).replace(/mm/g,((inst.minute<10)?'0':'')+inst.minute).replace(/m/g,inst.minute).replace(/ss/g,((inst.second<10)?'0':'')+inst.second).replace(/s/g,inst.second).replace(/TT/g,inst.ampm.toUpperCase()).replace(/tt/g,inst.ampm.toLowerCase()).replace(/T/g,inst.ampm.charAt(0).toUpperCase()).replace(/t/g,inst.ampm.charAt(0).toLowerCase());}else{tmptime=tmptime.toString().replace(/hh/g,((inst.hour<10)?'0':'')+inst.hour).replace(/h/g,inst.hour).replace(/mm/g,((inst.minute<10)?'0':'')+inst.minute).replace(/m/g,inst.minute).replace(/ss/g,((inst.second<10)?'0':'')+inst.second).replace(/s/g,inst.second);tmptime=$.trim(tmptime.replace(/t/gi,''));}inst.formattedTime=tmptime;return inst.formattedTime;},updateDateTime:function(dp_inst,tp_inst){var dt=this.$input.datepicker('getDate');if(dt==null)this.formattedDate=$.datepicker.formatDate($.datepicker._get(dp_inst,'dateFormat'),new Date(),$.datepicker._getFormatConfig(dp_inst));else this.formattedDate=$.datepicker.formatDate($.datepicker._get(dp_inst,'dateFormat'),dt,$.datepicker._getFormatConfig(dp_inst));if(this.defaults.alwaysSetTime){this.formattedDateTime=this.formattedDate+' '+this.formattedTime;}else{if(dt==null||!tp_inst.timeDefined||tp_inst.timeDefined==false){this.formattedDateTime=this.formattedDate;}else{this.formattedDateTime=this.formattedDate+' '+this.formattedTime;}}if(this.defaults.timeOnly==true)this.$input.val(this.formattedTime);else this.$input.val(this.formattedDateTime);}};jQuery.fn.datetimepicker=function(o){var tp=new Timepicker();if(o==undefined)o={};tp.defaults=$.extend({},tp.defaults,o);tp.defaults=$.extend({},tp.defaults,{beforeShow:function(input,inst){tp.hour=tp.defaults.hour;tp.minute=tp.defaults.minute;tp.second=tp.defaults.second;tp.ampm='';tp.$input=$(input);tp.inst=inst;tp.addTimePicker(inst);if($.isFunction(o['beforeShow']))o.beforeShow(input,inst);},onChangeMonthYear:function(year,month,inst){tp.updateDateTime(inst,tp);if($.isFunction(o['onChangeMonthYear']))o.onChangeMonthYear(year,month,inst);},onClose:function(dateText,inst){tp.updateDateTime(inst,tp);if($.isFunction(o['onClose']))o.onClose(dateText,inst);}});$(this).datepicker(tp.defaults);};jQuery.fn.timepicker=function(o){o=$.extend(o,{timeOnly:true});$(this).datetimepicker(o);};$.datepicker._selectDate=function(id,dateStr){var target=$(id);var inst=this._getInst(target[0]);var holdDatepickerOpen=(this._get(inst,'holdDatepickerOpen')===true)?true:false;dateStr=(dateStr!=null?dateStr:this._formatDate(inst));if(inst.input)inst.input.val(dateStr);this._updateAlternate(inst);var onSelect=this._get(inst,'onSelect');if(onSelect)onSelect.apply((inst.input?inst.input[0]:null),[dateStr,inst]);else if(inst.input)inst.input.trigger('change');if(inst.inline)this._updateDatepicker(inst);else if(holdDatepickerOpen){}else{this._hideDatepicker();this._lastInput=inst.input[0];if(typeof(inst.input[0])!='object')inst.input.focus();this._lastInput=null;}this._notifyChange(inst);};$.datepicker._base_updateDatepicker=$.datepicker._updateDatepicker;$.datepicker._updateDatepicker=function(inst){this._base_updateDatepicker(inst);this._beforeShow(inst.input,inst);};$.datepicker._beforeShow=function(input,inst){var beforeShow=this._get(inst,'beforeShow');if(beforeShow)beforeShow.apply((inst.input?inst.input[0]:null),[inst.input,inst]);};$.datepicker._doKeyPress=function(event){var inst=$.datepicker._getInst(event.target);if($.datepicker._get(inst,'constrainInput')){var dateChars=$.datepicker._possibleChars($.datepicker._get(inst,'dateFormat'));var chr=String.fromCharCode(event.charCode==undefined?event.keyCode:event.charCode);return event.ctrlKey||(chr<' '||!dateChars||dateChars.indexOf(chr)>-1||event.keyCode==58||event.keyCode==32);}};})(jQuery);
...\ No newline at end of file ...\ No newline at end of file
This diff could not be displayed because it is too large.
1 <?php
2 use Tz\WordPress\Tools\Notifications\Settings;
3 use Tz\WordPress\Tools\Notifications;
4 use Tz\WordPress\Tools;
5 ?>
6
7 <link type="text/css" href="<?php echo Tools\url('assets/css/smoothness/jquery-ui-1.8.4.custom.css', __FILE__)?>" rel="stylesheet" />
8 <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/jquery-1.4.2.min.js', __FILE__)?>"></script>
9 <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/jquery-ui-1.8.4.custom.min.js', __FILE__)?>"></script>
10 <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/datetimepicker.js', __FILE__)?>"></script>
11 <link rel="stylesheet" href="<?php echo Tools\url('assets/css/notifications.css', __FILE__)?>" />
12
13 <div id="" class="wrap">
14
15 <h2>Notifications - Create New</h2>
16 <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam iaculis convallis nisi eu dignissim. Quisque malesuada augue in mi blandit at blandit tortor sollicitudin. Cras at justo mi, vel mollis est. Donec orci erat, blandit varius vehicula vitae, volutpat at lorem. Etiam tincidunt bibendum ante, non tincidunt purus faucibus sed. Suspendisse eget facilisis tellus. Nulla imperdiet leo placerat diam sollicitudin nec mattis neque mattis. Cras id lacus tellus. Phasellus volutpat vehicula porttitor. Praesent erat felis, pharetra mollis egestas sit amet, rhoncus eget nisl. Morbi interdum sapien vitae nibh pharetra scelerisque. Mauris porta accumsan velit ac aliquam. Sed sit amet dictum felis. Fusce tempus vulputate nulla, quis tincidunt velit mattis eu.</p>
17
18 <?php if (isset($flash) && $flash !=""): ?>
19 <div class="post-success">
20 <?php echo $flash; ?>
21 </div>
22 <?php endif; ?>
23
24 <form enctype="multipart/form-data" method="post" action="/wp-admin/admin.php?page=notifications-create-new">
25
26 <input type="hidden" name="_POSTED_" value="yes" />
27
28 <table cellspacing="0" class="widefat post fixed" style="margin-top:15px;">
29 <thead>
30 <tr>
31 <th width="150">Notification Details</th>
32 <th>&nbsp;</th>
33 </tr>
34 </thead>
35 <tbody>
36 <tr>
37 <td width="150">Notification Type</td>
38 <td>
39 <select name="type" id="notif_type" class="wide-input-field" onchange="updateNotificationType();">
40 <option value="scheduled">Scheduled Notification</option>
41 <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?>
42 <option value="triggered">System Triggered Notification</option>
43 <?php endif; ?>
44 </select>
45 </td>
46 </tr>
47 <tr>
48 <td width="150">Notification Description</td>
49 <td><input type="text" name="title" class="wide-input-field" /></td>
50 </tr>
51 <tr>
52 <td>Sent To:</td>
53 <td>
54 <select name="sendto" class="wide-input-field">
55 <option value="user">Current User</option>
56 <option value="allusers">All Users</option>
57 <optgroup label="Groups:">
58 <option value="group1">Administrators</option>
59 <option value="group2">Group 2</option>
60 <option value="group3">Group 3</option>
61 </optgroup>
62 </select>
63 </td>
64 </tr>
65
66 <tr class="scheduled-extended">
67 <td>Execute Date / Time</td>
68 <td><input type="text" name="execute_date" id="execute_date" class="wide-input-field date-pick" readonly="readonly" /></td>
69 </tr>
70
71 <tr class="trigger-extended">
72 <td>Trigger</td>
73 <td><input type="text" name="trigger" id="trigger" class="wide-input-field" /></td>
74 </tr>
75
76 </tbody>
77 </table>
78
79 <table cellspacing="0" class="widefat post fixed expandable" style="margin-top:15px;">
80 <thead>
81 <tr>
82 <th width="150" class="toggle"><h6>Email</h6></th>
83 <th class="action-bar">&nbsp;</th>
84 </tr>
85 </thead>
86 <tbody>
87 <tr>
88 <td width="150">Subject Line</td>
89 <td><input type="text" name="subject" class="wide-input-field" style="width:100%;" /></td>
90 </tr>
91 <tr>
92 <td>Text Version</td>
93 <td><textarea name="text" class="wide-input-field" rows="10" style="width:100%;" ></textarea></td>
94 </tr>
95 <tr>
96 <td>HTML Version (optional)</td>
97 <td><textarea name="html" id="htmlversion" class="wide-input-field" rows="10" style="width:100%;"></textarea></td>
98 </tr>
99 <tr>
100 <td width="150">Attachments</td>
101 <td><input type="file" name="attachment[]" /></td>
102 </tr>
103 <tr>
104 <td>&nbsp;</td>
105 <td><input type="file" name="attachment[]" /></td>
106 </tr>
107 <tr>
108 <td>&nbsp;</td>
109 <td><input type="file" name="attachment[]" /></td>
110 </tr>
111 </tbody>
112 </table>
113
114 <table cellspacing="0" class="widefat post fixed expandable" style="margin-top:15px;">
115 <thead>
116 <tr>
117 <th width="150" class="toggle"><h6>System Message</h6></th>
118 <th class="action-bar">&nbsp;</th>
119 </tr>
120 </thead>
121 <tbody>
122 <tr>
123 <td>Message (Text/HTML)</td>
124 <td><textarea name="system" class="wide-input-field" rows="4" style="width:100%;" ></textarea></td>
125 </tr>
126 </tbody>
127 </table>
128
129 <table cellspacing="0" class="widefat post fixed expandable" style="margin-top:15px;">
130 <thead>
131 <tr>
132 <th width="150" class="toggle"><h6>SMS</h6></th>
133 <th class="action-bar">&nbsp;</th>
134 </tr>
135 </thead>
136 <tbody>
137 <tr>
138 <td>Text Only!</td>
139 <td><textarea name="sms" class="wide-input-field" rows="4" style="width:100%;" ></textarea></td>
140 </tr>
141 </tbody>
142 </table>
143
144
145 <p>
146 <input type="submit" value=" Save " /><input type="button" value=" Cancel " onclick="document.location.href='/wp-admin/admin.php?page=notifications';" />
147 </p>
148
149 </form>
150
151 </div>
152
153 <script type="text/javascript">
154
155
156 jQuery(document).ready(function() {
157
158 $('#execute_date').datetimepicker({
159 stepMinute: 15
160 , dateFormat: 'yy-mm-dd'
161 , timeFormat: 'hh:mm:ss'
162 });
163
164 updateNotificationType();
165
166 jQuery('table.expandable tbody').hide();
167 jQuery('table.expandable thead th').click(function() {
168 var $table = jQuery(this).parent().parent().parent();
169 if ( jQuery('tbody',$table).is(":visible") ) {
170 jQuery('thead',$table).removeClass("open");
171 jQuery('tbody',$table).fadeOut();
172 } else {
173 jQuery('thead',$table).addClass("open");
174 jQuery('tbody',$table).fadeIn();
175 }
176 });
177
178 });
179
180 function updateNotificationType() {
181 var type = jQuery('#notif_type').val();
182
183 if (type=="triggered") {
184 jQuery('.scheduled-extended').hide();
185 jQuery('.trigger-extended').show();
186 } else {
187 jQuery('.scheduled-extended').show();
188 jQuery('.trigger-extended').hide();
189 }
190
191 }
192
193
194
195 </script>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 use Tz\WordPress\Tools\Notifications;
3 use Tz\WordPress\Tools;
4 ?>
5
6 <!-- jQuery -->
7 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
8
9 <!-- required plugins -->
10 <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/date.js', __FILE__)?>"></script>
11 <!--[if IE]><script type="text/javascript" src="<?php echo Tools\url('assets/scripts/jquery.bgiframe.js', __FILE__)?>"></script><![endif]-->
12
13 <!-- jquery.datePicker.js -->
14 <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/jquery.datePicker.js', __FILE__)?>"></script>
15
16 <link rel="stylesheet" href="<?php echo Tools\url('assets/css/datePicker.css', __FILE__)?>" />
17 <link rel="stylesheet" href="<?php echo Tools\url('assets/css/notifications.css', __FILE__)?>" />
18
19 <div id="" class="wrap">
20
21 <h2>Notifications - Create New</h2>
22 <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam iaculis convallis nisi eu dignissim. Quisque malesuada augue in mi blandit at blandit tortor sollicitudin. Cras at justo mi, vel mollis est. Donec orci erat, blandit varius vehicula vitae, volutpat at lorem. Etiam tincidunt bibendum ante, non tincidunt purus faucibus sed. Suspendisse eget facilisis tellus. Nulla imperdiet leo placerat diam sollicitudin nec mattis neque mattis. Cras id lacus tellus. Phasellus volutpat vehicula porttitor. Praesent erat felis, pharetra mollis egestas sit amet, rhoncus eget nisl. Morbi interdum sapien vitae nibh pharetra scelerisque. Mauris porta accumsan velit ac aliquam. Sed sit amet dictum felis. Fusce tempus vulputate nulla, quis tincidunt velit mattis eu.</p>
23
24 <form method="post" action="/wp-admin/admin.php?page=notification&action=create">
25
26 <table cellspacing="0" class="widefat post fixed" style="margin-top:15px;">
27 <thead>
28 <tr>
29 <th width="150">Notification Details</th>
30 <th>&nbsp;</th>
31 </tr>
32 </thead>
33 <tbody>
34 <tr>
35 <td width="150">Description</td>
36 <td><input type="text" name="" class="wide-input-field" /></td>
37 </tr>
38 <tr>
39 <td>Notification Type</td>
40 <td>
41 <select name="" class="wide-input-field">
42 <option value="instant">Instant</option>
43 <option value="queued">Batch Queue</option>
44 <option value="system">System</option>
45 </select>
46 </td>
47 </tr>
48 <tr>
49 <td>Sent To:</td>
50 <td>
51 <select name="" class="wide-input-field">
52 <option value="user">Current User</option>
53 <option value="user">All Users</option>
54 <optgroup label="Groups:">
55 <option value="group1">Administrators</option>
56 <option value="group2">Group 2</option>
57 <option value="group3">Group 3</option>
58 </optgroup>
59 </select>
60 </td>
61 </tr>
62 <tr>
63 <td>Trigger/Slug</td>
64 <td><input type="text" name="" class="wide-input-field" /></td>
65 </tr>
66 <tr>
67 <td>Execute Date / Time</td>
68 <td><input type="text" name="" class="wide-input-field date-pick" /></td>
69 </tr>
70
71 </tbody>
72 </table>
73
74 <table cellspacing="0" class="widefat post fixed" style="margin-top:15px;">
75 <thead>
76 <tr>
77 <th width="150">Notification Content</th>
78 <th>&nbsp;</th>
79 </tr>
80 </thead>
81 <tbody>
82 <tr>
83 <td width="150">Subject Line</td>
84 <td><input type="text" name="" class="wide-input-field" style="width:100%;" /></td>
85 </tr>
86 <tr>
87 <td>Text Version</td>
88 <td><textarea class="wide-input-field" rows="10" style="width:100%;" ></textarea></td>
89 </tr>
90 <tr>
91 <td>HTML Version (optional)</td>
92 <td><textarea class="wide-input-field" rows="10" style="width:100%;"></textarea></td>
93 </tr>
94 </tbody>
95 </table>
96
97 <p>
98 <input type="submit" value=" Save " /><input type="button" value=" Cancel " onclick="document.location.href='/wp-admin/admin.php?page=notifications';" />
99 </p>
100
101 </form>
102
103 </div>
104
105 <script type="text/javascript">
106 $(function()
107 {
108 $('.date-pick').datePicker();
109 });
110 </script>
...\ No newline at end of file ...\ No newline at end of file